164 lines
5.2 KiB
Swift
164 lines
5.2 KiB
Swift
//
|
|
// GenericResiliationScreen.swift
|
|
// AlloVoisinsSwiftUI
|
|
//
|
|
// Created by Victor on 14/10/2024.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
protocol ResiliationContentView: View {
|
|
var screenType: ResiliationScreenType { get }
|
|
}
|
|
|
|
enum ResiliationScreenType {
|
|
case alloVoisinReputation
|
|
case askIfWillComeBack
|
|
case continueAsParticular
|
|
case getMoreRatings
|
|
case moreTime
|
|
case onlyProRequests
|
|
case personalizedSupport
|
|
case profileCompletion
|
|
case resizePerimeter
|
|
case softwarePresentation
|
|
case statusChange
|
|
case webinaire
|
|
|
|
var title: String {
|
|
switch self {
|
|
case .statusChange: return "Changer de statut"
|
|
default: return "Ne partez pas !"
|
|
}
|
|
}
|
|
|
|
var mainColor: Color {
|
|
switch self {
|
|
case .alloVoisinReputation, .moreTime: return Color.sqBlue(10)
|
|
case .continueAsParticular, .resizePerimeter, .statusChange: return Color.sqOrange(10)
|
|
case .getMoreRatings: return Color.sqGold(10)
|
|
case .onlyProRequests, .personalizedSupport, .webinaire: return Color.sqGrape(10)
|
|
case .profileCompletion: return Color.sqNeutral(10)
|
|
case .softwarePresentation: return Color.white
|
|
default: return Color.white
|
|
}
|
|
}
|
|
|
|
var buttonColor: Color {
|
|
switch self {
|
|
case .alloVoisinReputation, .continueAsParticular, .profileCompletion, .softwarePresentation:
|
|
return Color.sqNeutral(100)
|
|
case .getMoreRatings: return Color.sqGold(50)
|
|
case .moreTime: return Color.sqBlue(50)
|
|
case .onlyProRequests, .personalizedSupport, .webinaire: return Color.sqGrape(80)
|
|
case .resizePerimeter, .statusChange: return Color.sqOrange(50)
|
|
default: return Color.sqNeutral(100)
|
|
}
|
|
}
|
|
|
|
var buttonTitle: String {
|
|
switch self {
|
|
case .alloVoisinReputation: return "Conserver mon abonnement"
|
|
case .continueAsParticular: return "Changer de statut"
|
|
case .getMoreRatings: return "Recueillir des avis"
|
|
case .moreTime: return "Je prolonge ma période d'essai"
|
|
case .onlyProRequests: return "Voir les demandes"
|
|
case .personalizedSupport: return "Je souhaite être appelé"
|
|
case .profileCompletion: return "Je complète mon profil"
|
|
case .resizePerimeter: return "Modifier mon périmètre"
|
|
case .softwarePresentation: return "Découvrir le logiciel"
|
|
case .statusChange: return "Résilier et changer de statut"
|
|
case .webinaire: return "Je m'inscris"
|
|
default: return "Continuer"
|
|
}
|
|
}
|
|
|
|
var cancelButtonTitle: String {
|
|
switch self {
|
|
case .moreTime, .personalizedSupport, .webinaire:
|
|
return "Non merci, je souhaite résilier"
|
|
default:
|
|
return "J'ai compris, mais je souhaite résilier"
|
|
}
|
|
}
|
|
}
|
|
|
|
struct GenericResiliationScreen<Content: ResiliationContentView>: View {
|
|
@ObservedObject var viewModel: PromotionalScreenViewModel
|
|
@State private var navigateToNext = false
|
|
let content: Content
|
|
let buttonAction: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 16) {
|
|
VStack(spacing: 32) {
|
|
content
|
|
.padding(16)
|
|
.background(content.screenType.mainColor)
|
|
.cornerRadius(8)
|
|
|
|
SQButton(content.screenType.buttonTitle, color: content.screenType.buttonColor, textColor: .white, action: buttonAction)
|
|
}
|
|
|
|
if content.screenType != .statusChange {
|
|
SQButton(content.screenType.cancelButtonTitle, color: .white, textSize: 13) {
|
|
navigateToNext = true
|
|
}
|
|
}
|
|
}
|
|
.navigationDestination(isPresented: $navigateToNext) {
|
|
if let screen = viewModel.nextPromotionalScreen {
|
|
viewModel.getPromotionalScreenNew(for: screen)
|
|
} else {
|
|
ResiliationConfirmationScreen()
|
|
}
|
|
}
|
|
.sqNavigationBar(title: content.screenType.title)
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// GenericResiliationScreen(viewModel: ResiliationViewModel(resiliationType: .apProWithTrial), content: ResiliationContentView) {
|
|
//
|
|
// }
|
|
//}
|
|
struct AlloVoisinReputationScreens: View {
|
|
@ObservedObject var viewModel: PromotionalScreenViewModel
|
|
|
|
var body: some View {
|
|
GenericResiliationScreen(
|
|
viewModel: viewModel,
|
|
content: AlloVoisinReputationContent(),
|
|
buttonAction: {
|
|
// Handle button action
|
|
}
|
|
)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
AlloVoisinReputationScreens(viewModel: PromotionalScreenViewModel())
|
|
}
|
|
|
|
struct AlloVoisinReputationContent: ResiliationContentView {
|
|
let screenType: ResiliationScreenType = .alloVoisinReputation
|
|
|
|
var body: some View {
|
|
VStack(spacing: 32) {
|
|
VStack {
|
|
SQText("Le saviez-vous ?", size: 20, font: .bold)
|
|
SQText("AlloVoisins en France, c'est :", size: 20, font: .bold)
|
|
}
|
|
VStack {
|
|
SQText("4,5 millions", size: 32, font: .bold)
|
|
SQText("de membres, partout en France")
|
|
}
|
|
.padding(16)
|
|
.background(Color.white)
|
|
.cornerRadius(8)
|
|
// ... Rest of the content
|
|
}
|
|
}
|
|
}
|