Skip to content

Commit

Permalink
Merge pull request #1752 from planetary-social/fix-keyboard
Browse files Browse the repository at this point in the history
fix the keyboard in onboarding screens
  • Loading branch information
bryanmontz authored Feb 1, 2025
2 parents 5d0ca91 + 880f83d commit f1441e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a crash when processing a malformed delete (kind 5) event. [#170](https://github.com/verse-pbc/issues/issues/170)
- Fixed: tapping a user on a list causes a crash. [#172](https://github.com/verse-pbc/issues/issues/172)
- Removed link to Listr.lol when list is empty. [#176](https://github.com/verse-pbc/issues/issues/176)
- Fixed: text fields sometimes don't work on onboarding screens. [#178](https://github.com/verse-pbc/issues/issues/178)

### Internal Changes
- Added function for creating a new list and a test verifying list editing. [#112](https://github.com/verse-pbc/issues/issues/112)
Expand Down
10 changes: 9 additions & 1 deletion Nos/Views/Onboarding/DisplayNameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct DisplayNameView: View {
@Environment(OnboardingState.self) private var state
@Environment(CurrentUser.self) private var currentUser
@Environment(\.managedObjectContext) private var viewContext
@FocusState private var isTextFieldFocused: Bool

@Dependency(\.crashReporting) private var crashReporting

Expand All @@ -16,7 +17,7 @@ struct DisplayNameView: View {
ZStack {
Color.appBg
.ignoresSafeArea()
ViewThatFits(in: .vertical) {
ViewThatFits {
displayNameStack

ScrollView {
Expand All @@ -25,6 +26,11 @@ struct DisplayNameView: View {
}
}
.navigationBarHidden(true)
.onAppear {
isTextFieldFocused = true
}
.ignoresSafeArea(.keyboard)
.interactiveDismissDisabled()
.alert("", isPresented: $showError) {
Button {
nextStep()
Expand Down Expand Up @@ -55,6 +61,7 @@ struct DisplayNameView: View {
.foregroundStyle(Color.primaryTxt)
.fontWeight(.bold)
.autocorrectionDisabled()
.focused($isTextFieldFocused)
.padding()
.withStyledBorder()
Spacer()
Expand All @@ -65,6 +72,7 @@ struct DisplayNameView: View {
}
.padding(40)
.readabilityPadding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
}

func nextStep() {
Expand Down
18 changes: 13 additions & 5 deletions Nos/Views/Onboarding/UsernameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct UsernameView: View {
@Environment(OnboardingState.self) private var state
@Environment(CurrentUser.self) private var currentUser
@Environment(\.managedObjectContext) private var viewContext
@FocusState private var isTextFieldFocused: Bool

@Dependency(\.crashReporting) private var crashReporting
@Dependency(\.namesAPI) private var namesAPI
Expand Down Expand Up @@ -47,15 +48,20 @@ struct UsernameView: View {
ZStack {
Color.appBg
.ignoresSafeArea()
ViewThatFits(in: .vertical) {
displayNameStack

ViewThatFits {
usernameStack
ScrollView {
displayNameStack
usernameStack
}
}
}
.navigationBarHidden(true)
.onAppear {
isTextFieldFocused = true
}
.ignoresSafeArea(.keyboard)
.interactiveDismissDisabled()
.alert("", isPresented: showAlert) {
Button {
nextStep()
Expand All @@ -67,7 +73,7 @@ struct UsernameView: View {
}
}

var displayNameStack: some View {
var usernameStack: some View {
VStack(alignment: .leading, spacing: 20) {
LargeNumberView(4)
HStack(alignment: .firstTextBaseline) {
Expand All @@ -92,6 +98,7 @@ struct UsernameView: View {
.foregroundStyle(Color.primaryTxt)
.fontWeight(.bold)
.autocorrectionDisabled()
.focused($isTextFieldFocused)
.padding()
.withStyledBorder()

Expand All @@ -110,6 +117,7 @@ struct UsernameView: View {
}
.padding(40)
.readabilityPadding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
}

var usernameAlreadyClaimedText: some View {
Expand Down

0 comments on commit f1441e6

Please sign in to comment.