mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Hook up the emoji picker to the custom status row. (#5902)
* Refactor EmojiPickerScreen to take a continuation instead of a timeline/itemID. * Hook up the emoji picker to the custom status row.
This commit is contained in:
+6
-7
@@ -9,11 +9,10 @@ import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsScreenUserStatusRow: View {
|
||||
enum Mode: Equatable { case pick, custom, show(UserStatus.Raw) }
|
||||
enum Mode: Equatable { case pick, custom(emoji: Character), show(UserStatus.Raw) }
|
||||
let mode: Mode
|
||||
let action: (SettingsScreenViewAction.UserStatusAction) -> Void
|
||||
|
||||
@State private var customEmoji = "😄"
|
||||
@State private var customText = ""
|
||||
|
||||
var body: some View {
|
||||
@@ -21,15 +20,15 @@ struct SettingsScreenUserStatusRow: View {
|
||||
case .pick:
|
||||
ListRow(label: .default(title: L10n.screenSettingsUserStatusPlaceholder, icon: \.reaction),
|
||||
kind: .button { action(.pickStatus) })
|
||||
case .custom:
|
||||
case .custom(let emoji):
|
||||
ListRow(kind: .custom {
|
||||
HStack(spacing: ListRowPadding.labelIconSpacing) {
|
||||
Button { action(.pickCustomEmoji) } label: {
|
||||
Text(customEmoji)
|
||||
Text(String(emoji))
|
||||
.font(.compound.headingSM)
|
||||
.foregroundStyle(.compound.textPrimary)
|
||||
.accessibilityLabel(L10n.a11yCustomEmoji)
|
||||
.accessibilityValue(customEmoji)
|
||||
.accessibilityValue(String(emoji))
|
||||
}
|
||||
.buttonStyle(EditEmojiButtonStyle())
|
||||
|
||||
@@ -81,7 +80,7 @@ struct SettingsScreenUserStatusRow: View {
|
||||
}
|
||||
|
||||
private func saveCustomStatus() {
|
||||
guard let emoji = customEmoji.first else { return }
|
||||
guard case let .custom(emoji) = mode else { return }
|
||||
action(.set(.init(text: customText, emoji: emoji)))
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ struct SettingsScreenUserStatusRow_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
Section {
|
||||
SettingsScreenUserStatusRow(mode: .custom) { _ in }
|
||||
SettingsScreenUserStatusRow(mode: .custom(emoji: "😄")) { _ in }
|
||||
}
|
||||
|
||||
Section {
|
||||
|
||||
Reference in New Issue
Block a user