Files
bundesmessenger-ios/bwi/WelcomeExperience/WelcomeExperienceView.swift
T
2022-11-28 11:28:58 +01:00

76 lines
3.3 KiB
Swift

import SwiftUI
/// Helper class for making our SwiftUI view available to ObjectiveC
@objcMembers class WelcomeExperienceViewController: NSObject {
class func makeViewController(session: MXSession) -> UIViewController {
return UIHostingController(rootView: WelcomeExperienceView())
}
}
struct WelcomeExperienceView: View {
var body: some View {
TabView {
Page(image: "welcome_experience_1", title: NSLocalizedString("welcome_experience_title1", comment: ""), description: NSLocalizedString("welcome_experience_title1", comment: ""))
Page(image: "welcome_experience_2", title: NSLocalizedString("welcome_experience_title2", comment: ""), description: NSLocalizedString("welcome_experience_title2", comment: ""))
Page(image: "welcome_experience_3", title: NSLocalizedString("welcome_experience_title3", comment: ""), description: NSLocalizedString("welcome_experience_title3", comment: ""))
Page(image: "welcome_experience_4", title: NSLocalizedString("welcome_experience_title4", comment: ""), description: NSLocalizedString("welcome_experience_title4", comment: ""))
Page(image: "welcome_experience_5", title: NSLocalizedString("welcome_experience_title5", comment: ""), description: NSLocalizedString("welcome_experience_title5", comment: ""))
Page(image: "welcome_experience_2", title: NSLocalizedString("welcome_experience_title2", comment: ""), description: NSLocalizedString("welcome_experience_title2", comment: ""), doneButton: NSLocalizedString("welcome_experience_start", comment: ""))
}
.tabViewStyle(.page)
.indexViewStyle(.page(backgroundDisplayMode: .always))
.background(Color.white)
}
}
fileprivate struct Page: View {
var image: String
var title: String
var description: String
var doneButton: String?
var body: some View {
GeometryReader { geometry in
VStack(alignment: .center, spacing: 50) {
Image(image)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geometry.size.height * 0.3)
Text(title)
.foregroundColor(.black)
.font(.largeTitle.weight(.bold))
.multilineTextAlignment(.center)
Text(description)
.foregroundColor(.black)
.font(.body)
.multilineTextAlignment(.center)
Spacer()
if let doneButton = doneButton {
Button(action: {}) {
Text(doneButton)
.foregroundColor(.white)
.padding(.vertical, 10)
.padding(.horizontal, 50)
.background(Color(ThemeService.shared().theme.tintColor))
.clipShape(RoundedRectangle(cornerRadius: 10))
}
.padding(.bottom, 100)
}
}
.padding(.top, 100)
.padding(.horizontal, 20)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
}
struct WelcomeExperienceView_Previews: PreviewProvider {
static var previews: some View {
WelcomeExperienceView()
}
}