33 lines
1.0 KiB
Swift
33 lines
1.0 KiB
Swift
//
|
|
// Copyright 2021-2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// Renders the keywords input, driven by 'NotificationSettingsViewModel'.
|
|
struct NotificationSettingsKeywords: View {
|
|
@ObservedObject var viewModel: NotificationSettingsViewModel
|
|
var body: some View {
|
|
ChipsInput(
|
|
titles: viewModel.viewState.keywords,
|
|
didAddChip: viewModel.add(keyword:),
|
|
didDeleteChip: viewModel.remove(keyword:),
|
|
placeholder: VectorL10n.settingsNewKeyword
|
|
)
|
|
.disabled(!(viewModel.viewState.selectionState[.keywords] ?? false))
|
|
}
|
|
}
|
|
|
|
struct Keywords_Previews: PreviewProvider {
|
|
static let viewModel = NotificationSettingsViewModel(
|
|
notificationSettingsService: MockNotificationSettingsService.example,
|
|
ruleIds: NotificationSettingsScreen.mentionsAndKeywords.pushRules
|
|
)
|
|
static var previews: some View {
|
|
NotificationSettingsKeywords(viewModel: viewModel)
|
|
}
|
|
}
|