mirror of
git://jb55.com/damus
synced 2024-09-18 19:23:49 +00:00
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:
parent
7710839261
commit
ec604664d8
@ -46,7 +46,7 @@ enum StatusDuration: CustomStringConvertible, CaseIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let formatter = DateComponentsFormatter()
|
let formatter = DateComponentsFormatter()
|
||||||
formatter.unitsStyle = .abbreviated
|
formatter.unitsStyle = .full
|
||||||
formatter.allowedUnits = [.minute, .hour, .day, .weekOfMonth]
|
formatter.allowedUnits = [.minute, .hour, .day, .weekOfMonth]
|
||||||
return formatter.string(from: timeInterval) ?? "\(timeInterval) seconds"
|
return formatter.string(from: timeInterval) ?? "\(timeInterval) seconds"
|
||||||
}
|
}
|
||||||
@ -64,10 +64,9 @@ struct UserStatusSheet: View {
|
|||||||
|
|
||||||
@State var duration: StatusDuration = .never
|
@State var duration: StatusDuration = .never
|
||||||
@State var show_link: Bool = false
|
@State var show_link: Bool = false
|
||||||
|
|
||||||
@FocusState var focusedTextField : Fields?
|
|
||||||
|
|
||||||
@ObservedObject var status: UserStatusModel
|
@ObservedObject var status: UserStatusModel
|
||||||
|
@Environment(\.colorScheme) var colorScheme
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
var status_binding: Binding<String> {
|
var status_binding: Binding<String> {
|
||||||
@ -95,116 +94,119 @@ struct UserStatusSheet: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
// This is needed to prevent the view from being moved when the keyboard is shown
|
||||||
HStack {
|
GeometryReader { geometry in
|
||||||
Button(action: {
|
|
||||||
dismiss()
|
|
||||||
}, label: {
|
|
||||||
Text("Cancel", comment: "Cancel button text for dismissing profile status settings view.")
|
|
||||||
.padding(10)
|
|
||||||
})
|
|
||||||
.buttonStyle(NeutralButtonStyle())
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
Button(action: {
|
|
||||||
guard let status = self.status.general,
|
|
||||||
let kp = keypair.to_full(),
|
|
||||||
let ev = make_user_status_note(status: status, keypair: kp, expiry: duration.expiration)
|
|
||||||
else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
postbox.send(ev)
|
|
||||||
|
|
||||||
dismiss()
|
|
||||||
}, label: {
|
|
||||||
Text("Share", comment: "Save button text for saving profile status settings.")
|
|
||||||
})
|
|
||||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
|
|
||||||
Divider()
|
|
||||||
|
|
||||||
ZStack {
|
|
||||||
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)
|
|
||||||
|
|
||||||
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)
|
|
||||||
.cornerRadius(15)
|
|
||||||
.shadow(color: DamusColors.neutral3, radius: 15)
|
|
||||||
|
|
||||||
Circle()
|
|
||||||
.fill(DamusColors.adaptableWhite)
|
|
||||||
.frame(width: 12, height: 12)
|
|
||||||
.padding(.trailing, 140)
|
|
||||||
|
|
||||||
Circle()
|
|
||||||
.fill(DamusColors.adaptableWhite)
|
|
||||||
.frame(width: 7, height: 7)
|
|
||||||
.padding(.trailing, 120)
|
|
||||||
|
|
||||||
}
|
|
||||||
.padding(.leading, 60)
|
|
||||||
}
|
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Image("link")
|
Button(action: {
|
||||||
.foregroundColor(DamusColors.neutral3)
|
dismiss()
|
||||||
|
}, label: {
|
||||||
TextField(text: url_binding, label: {
|
Text("Cancel", comment: "Cancel button text for dismissing profile status settings view.")
|
||||||
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.")
|
.padding(10)
|
||||||
})
|
})
|
||||||
.focused($focusedTextField, equals: Fields.link)
|
.buttonStyle(NeutralButtonStyle())
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
guard let status = self.status.general,
|
||||||
|
let kp = keypair.to_full(),
|
||||||
|
let ev = make_user_status_note(status: status, keypair: kp, expiry: duration.expiration)
|
||||||
|
else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
postbox.send(ev)
|
||||||
|
|
||||||
|
dismiss()
|
||||||
|
}, label: {
|
||||||
|
Text("Share", comment: "Save button text for saving profile status settings.")
|
||||||
|
})
|
||||||
|
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||||
}
|
}
|
||||||
.padding(10)
|
.padding(5)
|
||||||
.cornerRadius(12)
|
|
||||||
.overlay(
|
Divider()
|
||||||
RoundedRectangle(cornerRadius: 12)
|
|
||||||
.stroke(DamusColors.neutral3, lineWidth: 1)
|
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, 30)
|
||||||
.padding()
|
|
||||||
|
VStack(spacing: 0) {
|
||||||
Toggle(isOn: $status.playing_enabled, label: {
|
HStack {
|
||||||
Text("Broadcast music playing on Apple Music", comment: "Toggle to enable or disable broadcasting what music is being played on Apple Music in their profile status.")
|
TextField(NSLocalizedString("Staying humble...", comment: "Placeholder as an example of what the user could set as their profile status."), text: status_binding, axis: .vertical)
|
||||||
})
|
.autocorrectionDisabled(true)
|
||||||
.tint(DamusColors.purple)
|
.textInputAutocapitalization(.never)
|
||||||
.padding(.horizontal)
|
.lineLimit(3)
|
||||||
|
.frame(width: 175)
|
||||||
HStack {
|
|
||||||
Text("Clear status", comment: "Label to prompt user to select an expiration time for the profile status to clear.")
|
}
|
||||||
|
.padding(10)
|
||||||
Spacer()
|
.background(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||||
|
.cornerRadius(15)
|
||||||
Picker(NSLocalizedString("Duration", comment: "Label for profile status expiration duration picker."), selection: $duration) {
|
.shadow(color: colorScheme == .light ? DamusColors.neutral3 : .clear, radius: 15)
|
||||||
ForEach(StatusDuration.allCases, id: \.self) { d in
|
|
||||||
Text(verbatim: d.description)
|
Circle()
|
||||||
.tag(d)
|
.fill(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||||
|
.frame(width: 12, height: 12)
|
||||||
|
.padding(.trailing, 140)
|
||||||
|
|
||||||
|
Circle()
|
||||||
|
.fill(colorScheme == .light ? .white : DamusColors.neutral3)
|
||||||
|
.frame(width: 7, height: 7)
|
||||||
|
.padding(.trailing, 120)
|
||||||
|
|
||||||
|
}
|
||||||
|
.padding(.leading, 60)
|
||||||
|
}
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
HStack {
|
||||||
|
Image("link")
|
||||||
|
.foregroundColor(DamusColors.neutral3)
|
||||||
|
|
||||||
|
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.")
|
||||||
|
})
|
||||||
|
.autocorrectionDisabled(true)
|
||||||
|
}
|
||||||
|
.padding(10)
|
||||||
|
.cornerRadius(12)
|
||||||
|
.overlay(
|
||||||
|
RoundedRectangle(cornerRadius: 12)
|
||||||
|
.stroke(DamusColors.neutral3, lineWidth: 1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
|
||||||
|
Toggle(isOn: $status.playing_enabled, label: {
|
||||||
|
Text("Broadcast music playing on Apple Music", comment: "Toggle to enable or disable broadcasting what music is being played on Apple Music in their profile status.")
|
||||||
|
})
|
||||||
|
.tint(DamusColors.purple)
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("Clear status", comment: "Label to prompt user to select an expiration time for the profile status to clear.")
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Picker(NSLocalizedString("Duration", comment: "Label for profile status expiration duration picker."), selection: $duration) {
|
||||||
|
ForEach(StatusDuration.allCases, id: \.self) { d in
|
||||||
|
Text(verbatim: d.description)
|
||||||
|
.tag(d)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.pickerStyle(.segmented)
|
.padding()
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
}
|
}
|
||||||
.padding()
|
.padding(.top)
|
||||||
|
.background(DamusColors.adaptableWhite.edgesIgnoringSafeArea(.all))
|
||||||
Spacer()
|
|
||||||
}
|
}
|
||||||
.padding(.top)
|
.dismissKeyboardOnTap()
|
||||||
|
.ignoresSafeArea(.keyboard, edges: .bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user