ui: status view fixes for smaller screen devices
Changelog-Added: Tap to dismiss keyboard on user status view Closes: https://github.com/damus-io/damus/pull/1652 Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
7710839261
commit
ec604664d8
@@ -46,7 +46,7 @@ enum StatusDuration: CustomStringConvertible, CaseIterable {
|
||||
}
|
||||
|
||||
let formatter = DateComponentsFormatter()
|
||||
formatter.unitsStyle = .abbreviated
|
||||
formatter.unitsStyle = .full
|
||||
formatter.allowedUnits = [.minute, .hour, .day, .weekOfMonth]
|
||||
return formatter.string(from: timeInterval) ?? "\(timeInterval) seconds"
|
||||
}
|
||||
@@ -65,9 +65,8 @@ struct UserStatusSheet: View {
|
||||
@State var duration: StatusDuration = .never
|
||||
@State var show_link: Bool = false
|
||||
|
||||
@FocusState var focusedTextField : Fields?
|
||||
|
||||
@ObservedObject var status: UserStatusModel
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var status_binding: Binding<String> {
|
||||
@@ -95,6 +94,8 @@ struct UserStatusSheet: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
// This is needed to prevent the view from being moved when the keyboard is shown
|
||||
GeometryReader { geometry in
|
||||
VStack {
|
||||
HStack {
|
||||
Button(action: {
|
||||
@@ -123,38 +124,35 @@ struct UserStatusSheet: View {
|
||||
})
|
||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||
}
|
||||
.padding()
|
||||
.padding(5)
|
||||
|
||||
Divider()
|
||||
|
||||
ZStack {
|
||||
ZStack(alignment: .top) {
|
||||
ProfilePicView(pubkey: keypair.pubkey, size: 120.0, highlight: .custom(DamusColors.white, 3.0), profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
|
||||
.padding(.top, 130)
|
||||
.padding(.top, 30)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
HStack {
|
||||
TextField(NSLocalizedString("Staying humble...", comment: "Placeholder as an example of what the user could set as their profile status."), text: status_binding, axis: .vertical)
|
||||
.focused($focusedTextField, equals: Fields.status)
|
||||
.task {
|
||||
self.focusedTextField = .status
|
||||
}
|
||||
.autocorrectionDisabled(true)
|
||||
.textInputAutocapitalization(.never)
|
||||
.lineLimit(3)
|
||||
.frame(width: 175)
|
||||
|
||||
}
|
||||
.padding(10)
|
||||
.background(DamusColors.adaptableWhite)
|
||||
.background(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||
.cornerRadius(15)
|
||||
.shadow(color: DamusColors.neutral3, radius: 15)
|
||||
.shadow(color: colorScheme == .light ? DamusColors.neutral3 : .clear, radius: 15)
|
||||
|
||||
Circle()
|
||||
.fill(DamusColors.adaptableWhite)
|
||||
.fill(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||
.frame(width: 12, height: 12)
|
||||
.padding(.trailing, 140)
|
||||
|
||||
Circle()
|
||||
.fill(DamusColors.adaptableWhite)
|
||||
.fill(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||
.frame(width: 7, height: 7)
|
||||
.padding(.trailing, 120)
|
||||
|
||||
@@ -170,7 +168,7 @@ struct UserStatusSheet: View {
|
||||
TextField(text: url_binding, label: {
|
||||
Text("Add an external link", comment: "Placeholder as an example of what the user could set so that the link is opened when the status is tapped.")
|
||||
})
|
||||
.focused($focusedTextField, equals: Fields.link)
|
||||
.autocorrectionDisabled(true)
|
||||
}
|
||||
.padding(10)
|
||||
.cornerRadius(12)
|
||||
@@ -198,13 +196,17 @@ struct UserStatusSheet: View {
|
||||
.tag(d)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
}
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
|
||||
}
|
||||
.padding(.top)
|
||||
.background(DamusColors.adaptableWhite.edgesIgnoringSafeArea(.all))
|
||||
}
|
||||
.dismissKeyboardOnTap()
|
||||
.ignoresSafeArea(.keyboard, edges: .bottom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user