2022-09-27 07:17:22 +00:00
|
|
|
//
|
2022-03-07 16:30:26 +00:00
|
|
|
// Copyright 2021 New Vector Ltd
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
// MARK: View model
|
|
|
|
|
|
|
|
enum OnboardingDisplayNameViewModelResult {
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The user would like to save the entered display name.
|
2022-03-15 16:00:06 +00:00
|
|
|
case save(String)
|
2022-03-21 11:42:58 +00:00
|
|
|
/// Move on to the next screen in the flow without setting a display name.
|
2022-03-15 16:00:06 +00:00
|
|
|
case skip
|
2022-03-07 16:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: View
|
|
|
|
|
|
|
|
struct OnboardingDisplayNameViewState: BindableState {
|
|
|
|
var bindings: OnboardingDisplayNameBindings
|
2022-03-21 11:42:58 +00:00
|
|
|
/// Any error that occurred during display name validation otherwise `nil`.
|
2022-03-15 16:00:06 +00:00
|
|
|
var validationErrorMessage: String?
|
|
|
|
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The string to be displayed in the text field's footer.
|
2022-03-15 16:00:06 +00:00
|
|
|
var textFieldFooterMessage: String {
|
|
|
|
validationErrorMessage ?? VectorL10n.onboardingDisplayNameHint
|
|
|
|
}
|
2022-03-07 16:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct OnboardingDisplayNameBindings {
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The display name string entered by the user.
|
2022-03-07 16:30:26 +00:00
|
|
|
var displayName: String
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The currently displayed alert's info value otherwise `nil`.
|
2022-03-07 16:30:26 +00:00
|
|
|
var alertInfo: AlertInfo<Int>?
|
|
|
|
}
|
|
|
|
|
|
|
|
enum OnboardingDisplayNameViewAction {
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The display name needs validation.
|
2022-03-15 16:00:06 +00:00
|
|
|
case validateDisplayName
|
2022-03-21 11:42:58 +00:00
|
|
|
/// The user would like to save the entered display name.
|
2022-03-07 16:30:26 +00:00
|
|
|
case save
|
2022-03-21 11:42:58 +00:00
|
|
|
/// Move on to the next screen in the flow without setting a display name.
|
2022-03-07 16:30:26 +00:00
|
|
|
case skip
|
|
|
|
}
|