mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +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:
+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