display name screen

This commit is contained in:
Ryan Zhao 2023-08-17 14:14:29 +10:00
parent 6cd8326904
commit a495b9eb63
26 changed files with 169 additions and 7 deletions

View File

@ -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 = "<group>"; };
7B81682928B6F1420069F315 /* ReactionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionResponse.swift; sourceTree = "<group>"; };
7B81682B28B72F480069F315 /* PendingChange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PendingChange.swift; sourceTree = "<group>"; };
7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameView.swift; sourceTree = "<group>"; };
7B87EF432A8DA720002A0E8F /* SessionTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTextField.swift; sourceTree = "<group>"; };
7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionHostingViewController.swift; sourceTree = "<group>"; };
7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = "<group>"; };
7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisibleMessage+Reaction.swift"; sourceTree = "<group>"; };
@ -2949,6 +2953,7 @@
FD71165A28E6DDBC00B47552 /* StyledNavigationController.swift */,
FD0B77AF29B69A65009169BA /* TopBannerController.swift */,
7BDE2A992A8C59CF00AE4393 /* AttributedText.swift */,
7B87EF432A8DA720002A0E8F /* SessionTextField.swift */,
);
path = Components;
sourceTree = "<group>";
@ -2999,6 +3004,7 @@
B85357C223A1BD1200AAF6CD /* SeedVC.swift */,
B8D0A26825E4A2C200C1835E /* Onboarding.swift */,
7BDE2A972A8B122900AE4393 /* LandingView.swift */,
7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */,
);
path = Onboarding;
sourceTree = "<group>";
@ -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 */,

View File

@ -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)
}

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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)
}
}

View File

@ -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<String>, 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")
}
}