mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
More tweaks for User Status. (#6051)
* Make sure user profiles are up to date when mentioning. * Automatically focus the custom status text field. * Make sure to clear the previous custom status text before input. * Attempt to fix the user status sheet sometimes disappearing.
This commit is contained in:
@@ -46,6 +46,13 @@ struct SettingsScreen: View {
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbarVisibility(context.viewState.navigationBarVisibility, for: .navigationBar)
|
||||
.toolbar { toolbar }
|
||||
.sheet(isPresented: $context.isPresentingStatusPicker) {
|
||||
SettingsScreenUserStatusPickerView { action in
|
||||
context.send(viewAction: .userStatus(action))
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
.presentationBackground(.compound.bgCanvasDefault)
|
||||
}
|
||||
}
|
||||
|
||||
private var userSection: some View {
|
||||
@@ -94,13 +101,6 @@ struct SettingsScreen: View {
|
||||
SettingsScreenUserStatusRow(mode: context.viewState.userStatusRowMode) { action in
|
||||
context.send(viewAction: .userStatus(action))
|
||||
}
|
||||
.sheet(isPresented: $context.isPresentingStatusPicker) {
|
||||
SettingsScreenUserStatusPickerView { action in
|
||||
context.send(viewAction: .userStatus(action))
|
||||
}
|
||||
.presentationDetents([.medium]) // Stop using a List and calculate the exact height?
|
||||
.presentationBackground(.compound.bgCanvasDefault)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-1
@@ -9,13 +9,33 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsScreenUserStatusRow: View {
|
||||
enum Mode: Equatable { case pickStatusButton, customStatusInput(emoji: Character), showingStatus(UserStatus.Displayed) }
|
||||
enum Mode: Equatable {
|
||||
case pickStatusButton, customStatusInput(emoji: Character), showingStatus(UserStatus.Displayed)
|
||||
|
||||
var isCustomStatusInput: Bool {
|
||||
switch self {
|
||||
case .customStatusInput: true
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mode: Mode
|
||||
let action: (SettingsScreenViewAction.UserStatusAction) -> Void
|
||||
|
||||
@State private var customText = ""
|
||||
@FocusState private var isCustomFieldFocused: Bool
|
||||
|
||||
var body: some View {
|
||||
rowContent
|
||||
.onChange(of: mode.isCustomStatusInput) { _, newValue in
|
||||
guard newValue else { return }
|
||||
customText = ""
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var rowContent: some View {
|
||||
switch mode {
|
||||
case .pickStatusButton:
|
||||
ListRow(label: .default(title: L10n.screenSettingsUserStatusPlaceholder, icon: \.reaction),
|
||||
@@ -34,6 +54,8 @@ struct SettingsScreenUserStatusRow: View {
|
||||
|
||||
TextField(L10n.screenSettingsUserStatusCustomHint, text: $customText)
|
||||
.textFieldStyle(.compound(.raised))
|
||||
.focused($isCustomFieldFocused)
|
||||
.onAppear { isCustomFieldFocused = true }
|
||||
.accessibilityLabel(L10n.screenSettingsUserStatusCustomHint)
|
||||
.padding(.vertical, 3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user