mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
a0ec5ed9dd
* Show the user's own Status emoji on the SettingsScreen. * Add the UI for setting your own status. * Add placeholder action for selecting a custom emoji and fix some accessibility issues.
79 lines
2.5 KiB
Swift
79 lines
2.5 KiB
Swift
//
|
|
// Copyright 2026 Element Creations Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Compound
|
|
import SwiftUI
|
|
|
|
struct SettingsScreenUserStatusPickerView: View {
|
|
let action: (SettingsScreenViewAction.UserStatusAction) -> Void
|
|
|
|
@State private var selection: UserStatusPreset?
|
|
|
|
var body: some View {
|
|
ElementNavigationStack {
|
|
list
|
|
.navigationTitle(L10n.screenSettingsUserStatusPlaceholder)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar { toolbar }
|
|
}
|
|
}
|
|
|
|
var list: some View {
|
|
List {
|
|
ListRow(label: .plain(title: ""),
|
|
kind: .inlinePicker(selection: $selection,
|
|
items: UserStatusPreset.allCases.map { (title: "\($0.rawStatus.emoji) \($0.rawStatus.text)", tag: $0) }))
|
|
|
|
ListRow(label: .plain(title: "✍️ \(L10n.screenSettingsUserStatusCustom)"),
|
|
kind: .button { action(.customStatus) })
|
|
}
|
|
.compoundList(.plain)
|
|
}
|
|
|
|
@ToolbarContentBuilder
|
|
var toolbar: some ToolbarContent {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
ToolbarButton(role: .cancel) { action(.cancel) }
|
|
}
|
|
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
ToolbarButton(role: .save) {
|
|
if let selection {
|
|
action(.set(selection.rawStatus))
|
|
}
|
|
}
|
|
.disabled(selection == nil)
|
|
}
|
|
}
|
|
}
|
|
|
|
private enum UserStatusPreset: CaseIterable {
|
|
case inAMeeting
|
|
case focusTime
|
|
case onTheRoad
|
|
case beRightBack
|
|
case away
|
|
|
|
var rawStatus: UserStatus.Raw {
|
|
switch self {
|
|
case .inAMeeting: .init(text: L10n.screenSettingsUserStatusInAMeeting, emoji: "💬")
|
|
case .focusTime: .init(text: L10n.screenSettingsUserStatusFocusTime, emoji: "💡")
|
|
case .onTheRoad: .init(text: L10n.screenSettingsUserStatusOnTheRoad, emoji: "🚙")
|
|
case .beRightBack: .init(text: L10n.screenSettingsUserStatusBeRightBack, emoji: "☕️")
|
|
case .away: .init(text: L10n.screenSettingsUserStatusAway, emoji: "🌴")
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: - Previews
|
|
|
|
struct SettingsScreenUserStatusPickerView_Previews: PreviewProvider, TestablePreview {
|
|
static var previews: some View {
|
|
SettingsScreenUserStatusPickerView { _ in }
|
|
}
|
|
}
|