diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 3a43923a5..21da39d50 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -121,6 +121,8 @@ 7B81682828B310D50069F315 /* _007_HomeQueryOptimisationIndexes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B81682728B310D50069F315 /* _007_HomeQueryOptimisationIndexes.swift */; }; 7B81682A28B6F1420069F315 /* ReactionResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B81682928B6F1420069F315 /* ReactionResponse.swift */; }; 7B81682C28B72F480069F315 /* PendingChange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B81682B28B72F480069F315 /* PendingChange.swift */; }; + 7B87EF422A8D9840002A0E8F /* DisplayNameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */; }; + 7B87EF442A8DA720002A0E8F /* SessionTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */; }; 7B8914772A7CAAE200A4C627 /* SessionHostingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */; }; 7B8C44C528B49DDA00FBE25F /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */; }; 7B8D5FC428332600008324D9 /* VisibleMessage+Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */; }; @@ -1235,6 +1237,8 @@ 7B81682728B310D50069F315 /* _007_HomeQueryOptimisationIndexes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _007_HomeQueryOptimisationIndexes.swift; sourceTree = ""; }; 7B81682928B6F1420069F315 /* ReactionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionResponse.swift; sourceTree = ""; }; 7B81682B28B72F480069F315 /* PendingChange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PendingChange.swift; sourceTree = ""; }; + 7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameView.swift; sourceTree = ""; }; + 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTextField.swift; sourceTree = ""; }; 7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionHostingViewController.swift; sourceTree = ""; }; 7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = ""; }; 7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisibleMessage+Reaction.swift"; sourceTree = ""; }; @@ -2949,6 +2953,7 @@ FD71165A28E6DDBC00B47552 /* StyledNavigationController.swift */, FD0B77AF29B69A65009169BA /* TopBannerController.swift */, 7BDE2A992A8C59CF00AE4393 /* AttributedText.swift */, + 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */, ); path = Components; sourceTree = ""; @@ -2999,6 +3004,7 @@ B85357C223A1BD1200AAF6CD /* SeedVC.swift */, B8D0A26825E4A2C200C1835E /* Onboarding.swift */, 7BDE2A972A8B122900AE4393 /* LandingView.swift */, + 7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */, ); path = Onboarding; sourceTree = ""; @@ -5495,6 +5501,7 @@ FD37E9CF28A1EB1B003AE748 /* Theme.swift in Sources */, C331FFB92558FA8D00070591 /* UIView+Constraints.swift in Sources */, 7BDE2A9A2A8C59CF00AE4393 /* AttributedText.swift in Sources */, + 7B87EF442A8DA720002A0E8F /* SessionTextField.swift in Sources */, FD0B77B029B69A65009169BA /* TopBannerController.swift in Sources */, FD37E9F628A5F106003AE748 /* Configuration.swift in Sources */, 7BF8D1FB2A70AF57005F1D6E /* SwiftUI+Theme.swift in Sources */, @@ -6071,6 +6078,7 @@ B82B408E239DC00D00A248E7 /* DisplayNameVC.swift in Sources */, B835246E25C38ABF0089A44F /* ConversationVC.swift in Sources */, 7B7037432834B81F000DCF35 /* ReactionContainerView.swift in Sources */, + 7B87EF422A8D9840002A0E8F /* DisplayNameView.swift in Sources */, 7BBBDC462875600700747E59 /* DocumentTitleViewController.swift in Sources */, FD71163F28E2C82C00B47552 /* SessionHeaderView.swift in Sources */, 7B8914772A7CAAE200A4C627 /* SessionHostingViewController.swift in Sources */, diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 2000a74c9..374a6a558 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -611,7 +611,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD case .missingName: DispatchQueue.main.async { - let viewController: DisplayNameVC = DisplayNameVC(flow: .register) + let viewController = SessionHostingViewController(rootView: DisplayNameView(flow: .register)) + viewController.setUpNavBarSessionIcon() populateHomeScreenTimer.invalidate() rootViewControllerSetupComplete(viewController) } diff --git a/Session/Meta/Translations/de.lproj/Localizable.strings b/Session/Meta/Translations/de.lproj/Localizable.strings index 67d906f4d..ab1c3e18c 100644 --- a/Session/Meta/Translations/de.lproj/Localizable.strings +++ b/Session/Meta/Translations/de.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index a5fadd666..eb9dce0fd 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/es.lproj/Localizable.strings b/Session/Meta/Translations/es.lproj/Localizable.strings index 024e2bb0f..e9b2957cb 100644 --- a/Session/Meta/Translations/es.lproj/Localizable.strings +++ b/Session/Meta/Translations/es.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/fa.lproj/Localizable.strings b/Session/Meta/Translations/fa.lproj/Localizable.strings index c1b458aa9..f2cacd937 100644 --- a/Session/Meta/Translations/fa.lproj/Localizable.strings +++ b/Session/Meta/Translations/fa.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/fi.lproj/Localizable.strings b/Session/Meta/Translations/fi.lproj/Localizable.strings index bc712f34e..28447fc30 100644 --- a/Session/Meta/Translations/fi.lproj/Localizable.strings +++ b/Session/Meta/Translations/fi.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/fr.lproj/Localizable.strings b/Session/Meta/Translations/fr.lproj/Localizable.strings index 2a5a00f1b..122cfd5b2 100644 --- a/Session/Meta/Translations/fr.lproj/Localizable.strings +++ b/Session/Meta/Translations/fr.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/hi.lproj/Localizable.strings b/Session/Meta/Translations/hi.lproj/Localizable.strings index 2605a045f..7c872b637 100644 --- a/Session/Meta/Translations/hi.lproj/Localizable.strings +++ b/Session/Meta/Translations/hi.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/hr.lproj/Localizable.strings b/Session/Meta/Translations/hr.lproj/Localizable.strings index e2bd15c9c..81ebd3c8f 100644 --- a/Session/Meta/Translations/hr.lproj/Localizable.strings +++ b/Session/Meta/Translations/hr.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/id-ID.lproj/Localizable.strings b/Session/Meta/Translations/id-ID.lproj/Localizable.strings index 919365412..6378d0daf 100644 --- a/Session/Meta/Translations/id-ID.lproj/Localizable.strings +++ b/Session/Meta/Translations/id-ID.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/it.lproj/Localizable.strings b/Session/Meta/Translations/it.lproj/Localizable.strings index e77b1ed97..d453194ac 100644 --- a/Session/Meta/Translations/it.lproj/Localizable.strings +++ b/Session/Meta/Translations/it.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/ja.lproj/Localizable.strings b/Session/Meta/Translations/ja.lproj/Localizable.strings index c927b609c..b5307190f 100644 --- a/Session/Meta/Translations/ja.lproj/Localizable.strings +++ b/Session/Meta/Translations/ja.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/nl.lproj/Localizable.strings b/Session/Meta/Translations/nl.lproj/Localizable.strings index 167e06f8c..987bfcfbb 100644 --- a/Session/Meta/Translations/nl.lproj/Localizable.strings +++ b/Session/Meta/Translations/nl.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/pl.lproj/Localizable.strings b/Session/Meta/Translations/pl.lproj/Localizable.strings index 8b43ff475..1bc94d386 100644 --- a/Session/Meta/Translations/pl.lproj/Localizable.strings +++ b/Session/Meta/Translations/pl.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings index 278344991..ed669ec6f 100644 --- a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings +++ b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/ru.lproj/Localizable.strings b/Session/Meta/Translations/ru.lproj/Localizable.strings index c63944321..9bf7f0688 100644 --- a/Session/Meta/Translations/ru.lproj/Localizable.strings +++ b/Session/Meta/Translations/ru.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/si.lproj/Localizable.strings b/Session/Meta/Translations/si.lproj/Localizable.strings index 965014681..afdba54d5 100644 --- a/Session/Meta/Translations/si.lproj/Localizable.strings +++ b/Session/Meta/Translations/si.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/sk.lproj/Localizable.strings b/Session/Meta/Translations/sk.lproj/Localizable.strings index 22d3972a5..71383bb13 100644 --- a/Session/Meta/Translations/sk.lproj/Localizable.strings +++ b/Session/Meta/Translations/sk.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/sv.lproj/Localizable.strings b/Session/Meta/Translations/sv.lproj/Localizable.strings index 8e37b756e..8f314922c 100644 --- a/Session/Meta/Translations/sv.lproj/Localizable.strings +++ b/Session/Meta/Translations/sv.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/th.lproj/Localizable.strings b/Session/Meta/Translations/th.lproj/Localizable.strings index 4a3c4da37..13f5d9bf5 100644 --- a/Session/Meta/Translations/th.lproj/Localizable.strings +++ b/Session/Meta/Translations/th.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings index 7474fac4c..076f9889e 100644 --- a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings +++ b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings index 1d73613f0..c428df7ba 100644 --- a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings index 4b5aac0b2..e8785a9ce 100644 --- a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings @@ -664,3 +664,5 @@ "onboarding_T&C" = "By using this service, you agree to our %@ and %@"; "terms_of_service" = "Terms of Service"; "privacy_policy" = "Privacy Policy"; +"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time."; +"onboarding_display_name_hint" = "Enter your display name"; diff --git a/Session/Onboarding/DisplayNameView.swift b/Session/Onboarding/DisplayNameView.swift index 8c8a2e799..8b9a11b0d 100644 --- a/Session/Onboarding/DisplayNameView.swift +++ b/Session/Onboarding/DisplayNameView.swift @@ -1,15 +1,85 @@ // Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. import SwiftUI +import SessionUIKit struct DisplayNameView: View { + @Environment(\.viewController) private var viewControllerHolder: UIViewController? + + @State private var displayName: String = "" + + private let flow: Onboarding.Flow + + public init(flow: Onboarding.Flow) { + self.flow = flow + } + var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + NavigationView { + ZStack(alignment: .center) { + if #available(iOS 14.0, *) { + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea() + } else { + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary) + } + + VStack( + alignment: .leading, + spacing: Values.mediumSpacing + ) { + Spacer() + + Text("vc_display_name_title_2".localized()) + .bold() + .font(.system(size: Values.veryLargeFontSize)) + .foregroundColor(themeColor: .textPrimary) + .padding(.vertical, Values.mediumSpacing) + + Text("onboarding_display_name_explanation".localized()) + .font(.system(size: Values.smallFontSize)) + .foregroundColor(themeColor: .textPrimary) + .padding(.vertical, Values.mediumSpacing) + + SessionTextField( + $displayName, + placeholder: "onboarding_display_name_hint".localized() + ) + + Spacer() + } + .padding(.horizontal, Values.veryLargeSpacing) + .padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight) + + VStack() { + Spacer() + + Button { + + } label: { + Text("continue_2".localized()) + .bold() + .font(.system(size: Values.smallFontSize)) + .foregroundColor(themeColor: .sessionButton_text) + .frame( + maxWidth: .infinity, + maxHeight: Values.largeButtonHeight, + alignment: .center + ) + .overlay( + Capsule() + .stroke(themeColor: .sessionButton_border) + ) + } + .padding(.horizontal, Values.massiveSpacing) + } + .padding(.vertical, Values.mediumSpacing) + } + } } } struct DisplayNameView_Previews: PreviewProvider { static var previews: some View { - DisplayNameView() + DisplayNameView(flow: .register) } } diff --git a/SessionUIKit/Components/SessionTextField.swift b/SessionUIKit/Components/SessionTextField.swift index 346868edc..35d7602e7 100644 --- a/SessionUIKit/Components/SessionTextField.swift +++ b/SessionUIKit/Components/SessionTextField.swift @@ -2,14 +2,53 @@ import SwiftUI -struct SessionTextField: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) +public struct SessionTextField: View { + @Binding var text: String + let placeholder: String + + static let height: CGFloat = isIPhone5OrSmaller ? CGFloat(48) : CGFloat(80) + static let cornerRadius: CGFloat = 13 + + public init(_ text: Binding, placeholder: String) { + self._text = text + self.placeholder = placeholder + } + + public var body: some View { + ZStack(alignment: .topLeading) { + if text.isEmpty { + Text(placeholder) + .font(.system(size: Values.mediumFontSize)) + .foregroundColor(themeColor: .textSecondary) + } + + SwiftUI.TextField( + "", + text: $text + ) + .font(.system(size: Values.mediumFontSize)) + .foregroundColor(themeColor: .textPrimary) + } + .padding(.horizontal, Values.largeSpacing) + .frame( + maxWidth: .infinity, + maxHeight: Self.height + ) + .overlay( + RoundedRectangle( + cornerSize: CGSize( + width: Self.cornerRadius, + height: Self.cornerRadius + ) + ) + .stroke(themeColor: .borderSeparator) + ) } } struct SessionTextField_Previews: PreviewProvider { + @State static var text: String = "" static var previews: some View { - SessionTextField() + SessionTextField($text, placeholder: "Placeholder") } }