mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Onboarding flow coordinator and FTUE changes (#2578)
Fixes #2595, fixes #2594, fixes #2593, fixes #2592, fixes #2591
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
//
|
||||
// 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 SwiftUI
|
||||
|
||||
/// Represents the position of a checkmark item in a list.
|
||||
enum ListPosition {
|
||||
case top, middle, bottom
|
||||
|
||||
/// The corners that should be rounded for this position.
|
||||
var roundedCorners: UIRectCorner {
|
||||
switch self {
|
||||
case .top:
|
||||
return [.topLeft, .topRight]
|
||||
case .middle:
|
||||
return []
|
||||
case .bottom:
|
||||
return [.bottomLeft, .bottomRight]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RoundedLabelItem<Icon: View>: View {
|
||||
@Environment(\.backgroundStyle) private var backgroundStyle
|
||||
|
||||
let title: String
|
||||
let listPosition: ListPosition
|
||||
let iconContent: () -> Icon
|
||||
|
||||
private var backgroundColor: AnyShapeStyle {
|
||||
backgroundStyle ?? AnyShapeStyle(.compound.bgSubtleSecondary)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Label { Text(title) } icon: {
|
||||
iconContent()
|
||||
}
|
||||
.labelStyle(CheckmarkLabelStyle())
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 12)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(backgroundColor, in: RoundedCornerShape(radius: 16, corners: listPosition.roundedCorners))
|
||||
}
|
||||
}
|
||||
|
||||
private struct CheckmarkLabelStyle: LabelStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 16) {
|
||||
configuration.icon
|
||||
.font(.compound.bodyLGSemibold)
|
||||
configuration.title
|
||||
.font(.compound.bodyMDSemibold)
|
||||
}
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct AnalyticsPromptScreenCheckmarkItem_Previews: PreviewProvider, TestablePreview {
|
||||
static let strings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsConfiguration.termsURL)
|
||||
|
||||
@ViewBuilder
|
||||
static var testImage1: some View {
|
||||
Image(systemName: "circle")
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
static var testImage2: some View {
|
||||
Image(systemName: "square")
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
RoundedLabelItem(title: strings.point1, listPosition: .top) {
|
||||
testImage1
|
||||
}
|
||||
RoundedLabelItem(title: strings.point2, listPosition: .middle) {
|
||||
testImage2
|
||||
}
|
||||
RoundedLabelItem(title: "This is a short string.", listPosition: .middle) {
|
||||
testImage1
|
||||
}
|
||||
RoundedLabelItem(title: "This is a very long string that will be used to test the layout over multiple lines of text to ensure everything is correct.",
|
||||
listPosition: .bottom) {
|
||||
testImage2
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ final class LoginScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private static let loadingIndicatorIdentifier = "LoginCoordinatorLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(LoginScreenCoordinatorAction.self)-Loading"
|
||||
|
||||
private func startLoading(isInteractionBlocking: Bool) {
|
||||
if isInteractionBlocking {
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ final class SoftLogoutScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private static let loadingIndicatorIdentifier = "SoftLogoutLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(SoftLogoutScreenCoordinator.self)-Loading"
|
||||
|
||||
/// Show an activity indicator whilst loading.
|
||||
@MainActor private func startLoading() {
|
||||
|
||||
@@ -82,7 +82,7 @@ class BlockedUsersScreenViewModel: BlockedUsersScreenViewModelType, BlockedUsers
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let loadingIndicatorIdentifier = "BlockedUsersLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(BlockedUsersScreenViewModel.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
|
||||
@@ -90,7 +90,7 @@ final class BugReportScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private static let loadingIndicatorIdentifier = "BugReportLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(BugReportScreenCoordinator.self)-Loading"
|
||||
|
||||
private func startLoading(label: String = L10n.commonLoading, progressPublisher: CurrentValuePublisher<Double, Never>) {
|
||||
parameters.userIndicatorController?.submitIndicator(
|
||||
|
||||
@@ -171,7 +171,7 @@ class CreateRoomViewModel: CreateRoomViewModelType, CreateRoomViewModelProtocol
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let loadingIndicatorIdentifier = "CreateRoomLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(CreateRoomViewModel.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
|
||||
@@ -31,7 +31,6 @@ enum HomeScreenCoordinatorAction {
|
||||
case roomLeft(roomIdentifier: String)
|
||||
case presentSettingsScreen
|
||||
case presentFeedbackScreen
|
||||
case presentSessionVerificationScreen
|
||||
case presentSecureBackupSettings
|
||||
case presentStartChatScreen
|
||||
case presentInvitesScreen
|
||||
@@ -74,8 +73,6 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.presentFeedbackScreen)
|
||||
case .presentSettingsScreen:
|
||||
actionsSubject.send(.presentSettingsScreen)
|
||||
case .presentSessionVerificationScreen:
|
||||
actionsSubject.send(.presentSessionVerificationScreen)
|
||||
case .presentSecureBackupSettings:
|
||||
actionsSubject.send(.presentSecureBackupSettings)
|
||||
case .logout:
|
||||
|
||||
@@ -22,7 +22,6 @@ enum HomeScreenViewModelAction {
|
||||
case presentRoom(roomIdentifier: String)
|
||||
case presentRoomDetails(roomIdentifier: String)
|
||||
case roomLeft(roomIdentifier: String)
|
||||
case presentSessionVerificationScreen
|
||||
case presentSecureBackupSettings
|
||||
case presentSettingsScreen
|
||||
case presentFeedbackScreen
|
||||
@@ -39,9 +38,7 @@ enum HomeScreenViewAction {
|
||||
case confirmLeaveRoom(roomIdentifier: String)
|
||||
case showSettings
|
||||
case startChat
|
||||
case verifySession
|
||||
case confirmRecoveryKey
|
||||
case skipSessionVerification
|
||||
case skipRecoveryKeyConfirmation
|
||||
case updateVisibleItemRange(range: Range<Int>, isScrolling: Bool)
|
||||
case selectInvites
|
||||
@@ -74,7 +71,6 @@ enum HomeScreenRoomListMode: CustomStringConvertible {
|
||||
enum SecurityBannerMode {
|
||||
case none
|
||||
case dismissed
|
||||
case sessionVerification
|
||||
case recoveryKeyConfirmation
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +70,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
guard let self else { return }
|
||||
|
||||
switch (securityState.verificationState, securityState.recoveryState) {
|
||||
case (.unverified, _):
|
||||
state.requiresExtraAccountSetup = true
|
||||
if state.securityBannerMode != .dismissed {
|
||||
state.securityBannerMode = .sessionVerification
|
||||
}
|
||||
case (.verified, .disabled):
|
||||
state.requiresExtraAccountSetup = true
|
||||
state.securityBannerMode = .none
|
||||
@@ -134,12 +129,8 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
leaveRoom(roomId: roomIdentifier)
|
||||
case .showSettings:
|
||||
actionsSubject.send(.presentSettingsScreen)
|
||||
case .verifySession:
|
||||
actionsSubject.send(.presentSessionVerificationScreen)
|
||||
case .confirmRecoveryKey:
|
||||
actionsSubject.send(.presentSecureBackupSettings)
|
||||
case .skipSessionVerification:
|
||||
state.securityBannerMode = .dismissed
|
||||
case .skipRecoveryKeyConfirmation:
|
||||
state.securityBannerMode = .dismissed
|
||||
case .updateVisibleItemRange(let range, let isScrolling):
|
||||
|
||||
@@ -103,16 +103,13 @@ struct HomeScreenContent: View {
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
/// The session verification banner and invites button if either are needed.
|
||||
private var topSection: some View {
|
||||
VStack(spacing: 0) {
|
||||
if !context.isSearchFieldFocused {
|
||||
RoomListFiltersView(state: $context.filtersState)
|
||||
}
|
||||
|
||||
if context.viewState.securityBannerMode == .sessionVerification {
|
||||
HomeScreenSessionVerificationBanner(context: context)
|
||||
} else if context.viewState.securityBannerMode == .recoveryKeyConfirmation {
|
||||
if context.viewState.securityBannerMode == .recoveryKeyConfirmation {
|
||||
HomeScreenRecoveryKeyConfirmationBanner(context: context)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
//
|
||||
// Copyright 2023 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 Combine
|
||||
import SwiftUI
|
||||
|
||||
struct HomeScreenSessionVerificationBanner: View {
|
||||
@ObservedObject var context: HomeScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 16) {
|
||||
Text(L10n.sessionVerificationBannerTitle)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
context.send(viewAction: .skipSessionVerification)
|
||||
} label: {
|
||||
Image(systemName: "xmark")
|
||||
.foregroundColor(.compound.iconSecondary)
|
||||
.frame(width: 12, height: 12)
|
||||
}
|
||||
}
|
||||
Text(L10n.sessionVerificationBannerMessage)
|
||||
.font(.compound.bodyMD)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
|
||||
Button(L10n.actionContinue) {
|
||||
context.send(viewAction: .verifySession)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.buttonStyle(.compound(.primary, size: .medium))
|
||||
.accessibilityIdentifier(A11yIdentifiers.homeScreen.verificationBannerContinue)
|
||||
}
|
||||
.padding(16)
|
||||
.background(Color.compound.bgSubtleSecondary)
|
||||
.cornerRadius(14)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
}
|
||||
|
||||
struct HomeScreenSessionVerificationBanner_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = buildViewModel()
|
||||
|
||||
static var previews: some View {
|
||||
HomeScreenSessionVerificationBanner(context: viewModel.context)
|
||||
}
|
||||
|
||||
static func buildViewModel() -> HomeScreenViewModel {
|
||||
let clientProxy = ClientProxyMock(.init(userID: "@alice:example.com",
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loading))))
|
||||
|
||||
let userSession = MockUserSession(clientProxy: clientProxy,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ struct CameraPicker: UIViewControllerRepresentable {
|
||||
self.cameraPicker = cameraPicker
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "CameraPickerLoadingIndicator"
|
||||
private static let loadingIndicatorIdentifier = "\(CameraPicker.self)-Loading"
|
||||
|
||||
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
|
||||
picker.delegate = nil
|
||||
|
||||
@@ -62,7 +62,7 @@ struct DocumentPicker: UIViewControllerRepresentable {
|
||||
documentPicker.callback(.cancel)
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "DocumentPickerLoadingIndicator"
|
||||
private static let loadingIndicatorIdentifier = "\(DocumentPicker.self)-Loading"
|
||||
|
||||
func documentPicker(_ picker: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
|
||||
guard let url = urls.first else {
|
||||
|
||||
@@ -62,7 +62,7 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
|
||||
// MARK: PHPickerViewControllerDelegate
|
||||
|
||||
private static let loadingIndicatorIdentifier = "PhotoLibraryPickerLoadingIndicator"
|
||||
private static let loadingIndicatorIdentifier = "\(PhotoLibraryPicker.self)-Loading"
|
||||
|
||||
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
||||
guard let provider = results.first?.itemProvider,
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
|
||||
}
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "MediaUploadPreviewLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(MediaUploadPreviewScreenViewModel.self)-Loading"
|
||||
|
||||
private func startLoading(progressPublisher: CurrentValuePublisher<Double, Never>) {
|
||||
userIndicatorController.submitIndicator(
|
||||
|
||||
+5
-7
@@ -21,7 +21,7 @@ struct AnalyticsPromptScreen: View {
|
||||
@ObservedObject var context: AnalyticsPromptScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: UIConstants.startScreenBreakerScreenTopPadding) {
|
||||
FullscreenDialog(topPadding: UIConstants.startScreenBreakerScreenTopPadding, showBackgroundGradient: true) {
|
||||
mainContent
|
||||
} bottomContent: {
|
||||
buttons
|
||||
@@ -30,6 +30,7 @@ struct AnalyticsPromptScreen: View {
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
/// The main content of the screen that is shown inside the scroll view.
|
||||
@@ -88,12 +89,9 @@ struct AnalyticsPromptScreen: View {
|
||||
/// The stack of enable/disable buttons.
|
||||
private var buttons: some View {
|
||||
VStack(spacing: 16) {
|
||||
Button { context.send(viewAction: .enable) } label: {
|
||||
Text(L10n.actionOk)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.accessibilityIdentifier(A11yIdentifiers.analyticsPromptScreen.enable)
|
||||
Button(L10n.actionOk) { context.send(viewAction: .enable) }
|
||||
.buttonStyle(.compound(.primary))
|
||||
.accessibilityIdentifier(A11yIdentifiers.analyticsPromptScreen.enable)
|
||||
|
||||
Button { context.send(viewAction: .disable) } label: {
|
||||
Text(L10n.actionNotNow)
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Copyright 2022 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.
|
||||
//
|
||||
|
||||
// periphery:ignore:all - this is just a identityConfirmation remove this comment once generating the final file
|
||||
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct IdentityConfirmationScreenCoordinatorParameters {
|
||||
let userSession: UserSessionProtocol
|
||||
let appSettings: AppSettings
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
}
|
||||
|
||||
enum IdentityConfirmationScreenCoordinatorAction {
|
||||
case otherDevice
|
||||
case recoveryKey
|
||||
}
|
||||
|
||||
final class IdentityConfirmationScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: IdentityConfirmationScreenCoordinatorParameters
|
||||
private let viewModel: IdentityConfirmationScreenViewModelProtocol
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private let actionsSubject: PassthroughSubject<IdentityConfirmationScreenCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmationScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(parameters: IdentityConfirmationScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = IdentityConfirmationScreenViewModel(userSession: parameters.userSession,
|
||||
appSettings: parameters.appSettings,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
viewModel.actionsPublisher.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
MXLog.info("Coordinator: received view model action: \(action)")
|
||||
switch action {
|
||||
case .otherDevice:
|
||||
actionsSubject.send(.otherDevice)
|
||||
case .recoveryKey:
|
||||
actionsSubject.send(.recoveryKey)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(IdentityConfirmationScreen(context: viewModel.context))
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright 2022 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
|
||||
|
||||
enum IdentityConfirmationScreenViewModelAction {
|
||||
case otherDevice
|
||||
case recoveryKey
|
||||
}
|
||||
|
||||
struct IdentityConfirmationScreenViewState: BindableState {
|
||||
enum Mode {
|
||||
case recoveryOnly
|
||||
case recoveryAndVerification
|
||||
}
|
||||
|
||||
var mode = Mode.recoveryOnly
|
||||
let learnMoreURL: URL
|
||||
}
|
||||
|
||||
enum IdentityConfirmationScreenViewAction {
|
||||
case otherDevice
|
||||
case recoveryKey
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// Copyright 2022 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 Combine
|
||||
import SwiftUI
|
||||
|
||||
typealias IdentityConfirmationScreenViewModelType = StateStoreViewModel<IdentityConfirmationScreenViewState, IdentityConfirmationScreenViewAction>
|
||||
|
||||
class IdentityConfirmationScreenViewModel: IdentityConfirmationScreenViewModelType, IdentityConfirmationScreenViewModelProtocol {
|
||||
private let userSession: UserSessionProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<IdentityConfirmationScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmationScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(userSession: UserSessionProtocol, appSettings: AppSettings, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userSession = userSession
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
super.init(initialViewState: IdentityConfirmationScreenViewState(learnMoreURL: appSettings.encryptionURL))
|
||||
|
||||
userSession.sessionSecurityStatePublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] state in
|
||||
Task {
|
||||
await self?.updateWithSessionSecurityState(state)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
await updateWithSessionSecurityState(userSession.sessionSecurityStatePublisher.value)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: IdentityConfirmationScreenViewAction) {
|
||||
MXLog.info("View model: received view action: \(viewAction)")
|
||||
switch viewAction {
|
||||
case .otherDevice:
|
||||
actionsSubject.send(.otherDevice)
|
||||
case .recoveryKey:
|
||||
actionsSubject.send(.recoveryKey)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func updateWithSessionSecurityState(_ sessionSecurityState: SessionSecurityState) async {
|
||||
if sessionSecurityState.verificationState == .unknown {
|
||||
showLoadingIndicator()
|
||||
} else {
|
||||
hideLoadingIndicator()
|
||||
}
|
||||
|
||||
guard sessionSecurityState.verificationState == .unverified else {
|
||||
return
|
||||
}
|
||||
|
||||
guard case let .success(isOnlyDeviceLeft) = await userSession.clientProxy.isOnlyDeviceLeft() else {
|
||||
return
|
||||
}
|
||||
|
||||
state.mode = isOnlyDeviceLeft ? .recoveryOnly : .recoveryAndVerification
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "\(IdentityConfirmationScreenViewModel.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
type: .modal,
|
||||
title: L10n.commonLoading,
|
||||
persistent: true))
|
||||
}
|
||||
|
||||
private func hideLoadingIndicator() {
|
||||
userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2022 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 Combine
|
||||
|
||||
@MainActor
|
||||
protocol IdentityConfirmationScreenViewModelProtocol {
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmationScreenViewModelAction, Never> { get }
|
||||
var context: IdentityConfirmationScreenViewModelType.Context { get }
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Copyright 2022 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 Compound
|
||||
import SwiftUI
|
||||
|
||||
struct IdentityConfirmationScreen: View {
|
||||
@ObservedObject var context: IdentityConfirmationScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: UIConstants.startScreenBreakerScreenTopPadding) {
|
||||
screenHeader
|
||||
} bottomContent: {
|
||||
actionButtons
|
||||
}
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@ViewBuilder
|
||||
private var screenHeader: some View {
|
||||
VStack(spacing: 0) {
|
||||
HeroImage(icon: \.lockSolid)
|
||||
.padding(.bottom, 16)
|
||||
|
||||
Text(L10n.screenIdentityConfirmationTitle)
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.padding(.bottom, 8)
|
||||
|
||||
Text(L10n.screenIdentityConfirmationSubtitle)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
|
||||
Button(L10n.actionLearnMore) {
|
||||
UIApplication.shared.open(context.viewState.learnMoreURL)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
.padding(.top, 16)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var actionButtons: some View {
|
||||
VStack(spacing: 32) {
|
||||
switch context.viewState.mode {
|
||||
case .recoveryOnly:
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
case .recoveryAndVerification:
|
||||
Button(L10n.actionStartVerification) {
|
||||
context.send(viewAction: .otherDevice)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
IdentityConfirmationScreen(context: viewModel.context)
|
||||
}
|
||||
}
|
||||
|
||||
private static var viewModel: IdentityConfirmationScreenViewModel {
|
||||
let userSession = MockUserSession(clientProxy: ClientProxyMock(.init(userID: "@user:example.com",
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([]))))),
|
||||
mediaProvider: MockMediaProvider(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock())
|
||||
|
||||
return IdentityConfirmationScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright 2022 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.
|
||||
//
|
||||
|
||||
// periphery:ignore:all - this is just a identityConfirmed remove this comment once generating the final file
|
||||
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct IdentityConfirmedScreenCoordinatorParameters { }
|
||||
|
||||
enum IdentityConfirmedScreenCoordinatorAction {
|
||||
case done
|
||||
}
|
||||
|
||||
final class IdentityConfirmedScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: IdentityConfirmedScreenCoordinatorParameters
|
||||
private let viewModel: IdentityConfirmedScreenViewModelProtocol
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private let actionsSubject: PassthroughSubject<IdentityConfirmedScreenCoordinatorAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmedScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(parameters: IdentityConfirmedScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = IdentityConfirmedScreenViewModel()
|
||||
}
|
||||
|
||||
func start() {
|
||||
viewModel.actionsPublisher.sink { [weak self] action in
|
||||
MXLog.info("Coordinator: received view model action: \(action)")
|
||||
|
||||
guard let self else { return }
|
||||
switch action {
|
||||
case .done:
|
||||
self.actionsSubject.send(.done)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(IdentityConfirmedScreen(context: viewModel.context))
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Copyright 2022 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
|
||||
|
||||
enum IdentityConfirmedScreenViewModelAction {
|
||||
case done
|
||||
}
|
||||
|
||||
struct IdentityConfirmedScreenViewState: BindableState { }
|
||||
|
||||
enum IdentityConfirmedScreenViewAction {
|
||||
case done
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright 2022 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 Combine
|
||||
import SwiftUI
|
||||
|
||||
typealias IdentityConfirmedScreenViewModelType = StateStoreViewModel<IdentityConfirmedScreenViewState, IdentityConfirmedScreenViewAction>
|
||||
|
||||
class IdentityConfirmedScreenViewModel: IdentityConfirmedScreenViewModelType, IdentityConfirmedScreenViewModelProtocol {
|
||||
private let actionsSubject: PassthroughSubject<IdentityConfirmedScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmedScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(initialViewState: .init())
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: IdentityConfirmedScreenViewAction) {
|
||||
MXLog.info("View model: received view action: \(viewAction)")
|
||||
|
||||
switch viewAction {
|
||||
case .done:
|
||||
actionsSubject.send(.done)
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright 2022 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 Combine
|
||||
|
||||
@MainActor
|
||||
protocol IdentityConfirmedScreenViewModelProtocol {
|
||||
var actionsPublisher: AnyPublisher<IdentityConfirmedScreenViewModelAction, Never> { get }
|
||||
var context: IdentityConfirmedScreenViewModelType.Context { get }
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Copyright 2022 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 Compound
|
||||
import SwiftUI
|
||||
|
||||
struct IdentityConfirmedScreen: View {
|
||||
@ObservedObject var context: IdentityConfirmedScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: UIConstants.startScreenBreakerScreenTopPadding) {
|
||||
screenHeader
|
||||
} bottomContent: {
|
||||
actionButtons
|
||||
}
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@ViewBuilder
|
||||
private var screenHeader: some View {
|
||||
VStack(spacing: 0) {
|
||||
HeroImage(icon: \.checkCircle, style: .positive)
|
||||
.padding(.bottom, 16)
|
||||
|
||||
Text(L10n.screenIdentityConfirmedTitle)
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.padding(.bottom, 8)
|
||||
|
||||
Text(L10n.screenIdentityConfirmedSubtitle)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var actionButtons: some View {
|
||||
Button(L10n.actionContinue) {
|
||||
context.send(viewAction: .done)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct IdentityConfirmedScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = IdentityConfirmedScreenViewModel()
|
||||
static var previews: some View {
|
||||
NavigationStack {
|
||||
IdentityConfirmedScreen(context: viewModel.context)
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// 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 Combine
|
||||
import SwiftUI
|
||||
|
||||
struct NotificationPermissionsScreenCoordinatorParameters {
|
||||
let notificationManager: NotificationManagerProtocol
|
||||
}
|
||||
|
||||
enum NotificationPermissionsScreenCoordinatorAction {
|
||||
case done
|
||||
}
|
||||
|
||||
final class NotificationPermissionsScreenCoordinator: CoordinatorProtocol {
|
||||
private var viewModel: NotificationPermissionsScreenViewModelProtocol
|
||||
private let actionsSubject: PassthroughSubject<NotificationPermissionsScreenCoordinatorAction, Never> = .init()
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
var actions: AnyPublisher<NotificationPermissionsScreenCoordinatorAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(parameters: NotificationPermissionsScreenCoordinatorParameters) {
|
||||
viewModel = NotificationPermissionsScreenViewModel(notificationManager: parameters.notificationManager)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func start() {
|
||||
viewModel.actionsPublisher
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
switch action {
|
||||
case .done:
|
||||
actionsSubject.send(.done)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(NotificationPermissionsScreen(context: viewModel.context))
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// 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
|
||||
|
||||
enum NotificationPermissionsScreenViewAction {
|
||||
case enable
|
||||
case notNow
|
||||
}
|
||||
|
||||
enum NotificationPermissionsScreenViewModelAction {
|
||||
case done
|
||||
}
|
||||
|
||||
struct NotificationPermissionsScreenViewState: BindableState { }
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// 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 Combine
|
||||
import SwiftUI
|
||||
|
||||
typealias NotificationPermissionsScreenViewModelType = StateStoreViewModel<NotificationPermissionsScreenViewState, NotificationPermissionsScreenViewAction>
|
||||
|
||||
class NotificationPermissionsScreenViewModel: NotificationPermissionsScreenViewModelType, NotificationPermissionsScreenViewModelProtocol {
|
||||
private let notificationManager: NotificationManagerProtocol
|
||||
|
||||
private var actionsSubject: PassthroughSubject<NotificationPermissionsScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<NotificationPermissionsScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(notificationManager: NotificationManagerProtocol) {
|
||||
self.notificationManager = notificationManager
|
||||
|
||||
super.init(initialViewState: .init())
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: NotificationPermissionsScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .enable:
|
||||
notificationManager.requestAuthorization()
|
||||
|
||||
actionsSubject.send(.done)
|
||||
case .notNow:
|
||||
actionsSubject.send(.done)
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// 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 Combine
|
||||
|
||||
@MainActor
|
||||
protocol NotificationPermissionsScreenViewModelProtocol {
|
||||
var actionsPublisher: AnyPublisher<NotificationPermissionsScreenViewModelAction, Never> { get }
|
||||
var context: NotificationPermissionsScreenViewModelType.Context { get }
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// 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 SwiftUI
|
||||
|
||||
/// A prompt that asks the user whether they would like to enable Analytics or not.
|
||||
struct NotificationPermissionsScreen: View {
|
||||
@ObservedObject var context: NotificationPermissionsScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
FullscreenDialog(topPadding: UIConstants.startScreenBreakerScreenTopPadding, showBackgroundGradient: true) {
|
||||
mainContent
|
||||
} bottomContent: {
|
||||
buttons
|
||||
}
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.navigationBarHidden(true)
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
/// The main content of the screen that is shown inside the scroll view.
|
||||
private var mainContent: some View {
|
||||
VStack(spacing: 8) {
|
||||
HeroImage(icon: \.notificationsSolid)
|
||||
.padding(.bottom, 8)
|
||||
|
||||
Text(L10n.screenNotificationOptinTitle)
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
|
||||
Text(L10n.screenNotificationOptinSubtitle)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
|
||||
Asset.Images.notificationsPromptGraphic.swiftUIImage.resizable().aspectRatio(contentMode: .fit)
|
||||
}
|
||||
}
|
||||
|
||||
private var buttons: some View {
|
||||
VStack(spacing: 16) {
|
||||
Button(L10n.actionOk) { context.send(viewAction: .enable) }
|
||||
.buttonStyle(.compound(.primary))
|
||||
|
||||
Button { context.send(viewAction: .notNow) } label: {
|
||||
Text(L10n.actionNotNow)
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.padding(14)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct NotificationPermissionsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = NotificationPermissionsScreenViewModel(notificationManager: NotificationManagerMock())
|
||||
static var previews: some View {
|
||||
NotificationPermissionsScreen(context: viewModel.context)
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -18,13 +18,11 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
enum SessionVerificationScreenCoordinatorAction {
|
||||
case recoveryKey
|
||||
case done
|
||||
}
|
||||
|
||||
struct SessionVerificationScreenCoordinatorParameters {
|
||||
let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol
|
||||
let recoveryState: SecureBackupRecoveryState
|
||||
}
|
||||
|
||||
final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
@@ -38,8 +36,7 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
init(parameters: SessionVerificationScreenCoordinatorParameters) {
|
||||
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy,
|
||||
recoveryState: parameters.recoveryState)
|
||||
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -50,8 +47,6 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
guard let self else { return }
|
||||
|
||||
switch action {
|
||||
case .recoveryKey:
|
||||
actionsSubject.send(.recoveryKey)
|
||||
case .finished:
|
||||
actionsSubject.send(.done)
|
||||
}
|
||||
@@ -59,6 +54,10 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func stop() {
|
||||
viewModel.stop()
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(SessionVerificationScreen(context: viewModel.context))
|
||||
}
|
||||
-5
@@ -17,13 +17,10 @@
|
||||
import Foundation
|
||||
|
||||
enum SessionVerificationScreenViewModelAction {
|
||||
case recoveryKey
|
||||
case finished
|
||||
}
|
||||
|
||||
struct SessionVerificationScreenViewState: BindableState {
|
||||
let showRecoveryOption: Bool
|
||||
|
||||
var verificationState: SessionVerificationScreenStateMachine.State = .initial
|
||||
|
||||
var title: String? {
|
||||
@@ -86,11 +83,9 @@ struct SessionVerificationScreenViewState: BindableState {
|
||||
}
|
||||
|
||||
enum SessionVerificationScreenViewAction {
|
||||
case recoveryKey
|
||||
case requestVerification
|
||||
case startSasVerification
|
||||
case restart
|
||||
case accept
|
||||
case decline
|
||||
case close
|
||||
}
|
||||
+10
-18
@@ -31,13 +31,12 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
}
|
||||
|
||||
init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol,
|
||||
recoveryState: SecureBackupRecoveryState,
|
||||
verificationState: SessionVerificationScreenStateMachine.State = .initial) {
|
||||
self.sessionVerificationControllerProxy = sessionVerificationControllerProxy
|
||||
|
||||
stateMachine = SessionVerificationScreenStateMachine()
|
||||
|
||||
super.init(initialViewState: .init(showRecoveryOption: recoveryState == .incomplete, verificationState: verificationState))
|
||||
super.init(initialViewState: .init(verificationState: verificationState))
|
||||
|
||||
setupStateMachine()
|
||||
|
||||
@@ -71,23 +70,12 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
|
||||
override func process(viewAction: SessionVerificationScreenViewAction) {
|
||||
switch viewAction {
|
||||
case .recoveryKey:
|
||||
actionsSubject.send(.recoveryKey)
|
||||
case .requestVerification:
|
||||
stateMachine.processEvent(.requestVerification)
|
||||
case .startSasVerification:
|
||||
stateMachine.processEvent(.startSasVerification)
|
||||
case .restart:
|
||||
stateMachine.processEvent(.restart)
|
||||
case .close:
|
||||
guard stateMachine.state == .initial ||
|
||||
stateMachine.state == .verified ||
|
||||
stateMachine.state == .cancelled else {
|
||||
stateMachine.processEvent(.cancel)
|
||||
return
|
||||
}
|
||||
|
||||
actionsSubject.send(.finished)
|
||||
case .accept:
|
||||
stateMachine.processEvent(.acceptChallenge)
|
||||
case .decline:
|
||||
@@ -95,6 +83,14 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
}
|
||||
}
|
||||
|
||||
func stop() {
|
||||
let uncancellableStates: [SessionVerificationScreenStateMachine.State] = [.initial, .verified, .cancelled]
|
||||
|
||||
if !uncancellableStates.contains(stateMachine.state) {
|
||||
stateMachine.processEvent(.cancel)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func setupStateMachine() {
|
||||
@@ -115,11 +111,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
|
||||
case (_, .cancel, .cancelling):
|
||||
cancelVerification()
|
||||
case (_, _, .verified):
|
||||
// Dismiss the success screen automatically.
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(2))
|
||||
self.actionsSubject.send(.finished)
|
||||
}
|
||||
actionsSubject.send(.finished)
|
||||
default:
|
||||
break
|
||||
}
|
||||
+2
@@ -20,4 +20,6 @@ import Combine
|
||||
protocol SessionVerificationScreenViewModelProtocol {
|
||||
var actions: AnyPublisher<SessionVerificationScreenViewModelAction, Never> { get }
|
||||
var context: SessionVerificationViewModelType.Context { get }
|
||||
|
||||
func stop()
|
||||
}
|
||||
+26
-45
@@ -20,23 +20,18 @@ struct SessionVerificationScreen: View {
|
||||
@ObservedObject var context: SessionVerificationScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(spacing: 32) {
|
||||
screenHeader
|
||||
Spacer()
|
||||
mainContent
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.top, 24)
|
||||
.frame(maxWidth: .infinity)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { toolbarContent }
|
||||
FullscreenDialog {
|
||||
VStack(spacing: 32) {
|
||||
screenHeader
|
||||
Spacer()
|
||||
mainContent
|
||||
}
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.safeAreaInset(edge: .bottom) { actionButtons.padding() }
|
||||
} bottomContent: {
|
||||
actionButtons
|
||||
}
|
||||
.interactiveDismissDisabled() // Make sure dismissal goes through the state machine(s).
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.interactiveDismissDisabled()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -44,7 +39,7 @@ struct SessionVerificationScreen: View {
|
||||
private var headerImageName: String {
|
||||
switch context.viewState.verificationState {
|
||||
case .initial:
|
||||
return "macbook.and.iphone"
|
||||
return "lock"
|
||||
case .cancelled:
|
||||
return "exclamationmark.shield"
|
||||
case .requestingVerification:
|
||||
@@ -71,19 +66,24 @@ struct SessionVerificationScreen: View {
|
||||
@ViewBuilder
|
||||
private var screenHeader: some View {
|
||||
VStack(spacing: 0) {
|
||||
Image(systemName: headerImageName)
|
||||
.heroImage()
|
||||
.padding(.bottom, 16)
|
||||
if context.viewState.verificationState == .initial {
|
||||
HeroImage(icon: \.lockSolid)
|
||||
.padding(.bottom, 16)
|
||||
} else {
|
||||
Image(systemName: headerImageName)
|
||||
.heroImage()
|
||||
.padding(.bottom, 16)
|
||||
}
|
||||
|
||||
Text(context.viewState.title ?? "")
|
||||
.font(.title2.bold())
|
||||
.font(.compound.headingMDBold)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
.padding(.bottom, 8)
|
||||
.accessibilityIdentifier(context.viewState.titleAccessibilityIdentifier)
|
||||
|
||||
Text(context.viewState.message)
|
||||
.font(.subheadline)
|
||||
.font(.compound.bodyMD)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
@@ -134,14 +134,6 @@ struct SessionVerificationScreen: View {
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.requestVerification)
|
||||
|
||||
if context.viewState.showRecoveryOption {
|
||||
Button(L10n.screenSessionVerificationEnterRecoveryKey) {
|
||||
context.send(viewAction: .recoveryKey)
|
||||
}
|
||||
.buttonStyle(.compound(.plain))
|
||||
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.enterRecoveryKey)
|
||||
}
|
||||
}
|
||||
case .cancelled:
|
||||
Button(L10n.actionRetry) {
|
||||
@@ -157,9 +149,9 @@ struct SessionVerificationScreen: View {
|
||||
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.startSasVerification)
|
||||
|
||||
case .showingChallenge:
|
||||
VStack(spacing: 30) {
|
||||
Button { context.send(viewAction: .accept) } label: {
|
||||
Label(L10n.screenSessionVerificationTheyMatch, systemImage: "checkmark")
|
||||
VStack(spacing: 32) {
|
||||
Button(L10n.screenSessionVerificationTheyMatch) {
|
||||
context.send(viewAction: .accept)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.acceptChallenge)
|
||||
@@ -172,12 +164,12 @@ struct SessionVerificationScreen: View {
|
||||
}
|
||||
|
||||
case .acceptingChallenge:
|
||||
VStack(spacing: 30) {
|
||||
VStack(spacing: 32) {
|
||||
Button { context.send(viewAction: .accept) } label: {
|
||||
HStack(spacing: 16) {
|
||||
ProgressView()
|
||||
.tint(.compound.textOnSolidPrimary)
|
||||
Label(L10n.screenSessionVerificationTheyMatch, systemImage: "checkmark")
|
||||
Text(L10n.screenSessionVerificationTheyMatch)
|
||||
}
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
@@ -197,16 +189,6 @@ struct SessionVerificationScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ToolbarContentBuilder
|
||||
private var toolbarContent: some ToolbarContent {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .close)
|
||||
}
|
||||
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.close)
|
||||
}
|
||||
}
|
||||
|
||||
struct EmojiView: View {
|
||||
let emoji: SessionVerificationEmoji
|
||||
|
||||
@@ -244,7 +226,6 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
static func sessionVerificationScreen(state: SessionVerificationScreenStateMachine.State) -> some View {
|
||||
let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(),
|
||||
recoveryState: .incomplete,
|
||||
verificationState: state)
|
||||
|
||||
return SessionVerificationScreen(context: viewModel.context)
|
||||
@@ -82,7 +82,7 @@ final class ReportContentScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private static let loadingIndicatorIdentifier = "ReportContentLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(ReportContentScreenCoordinator.self)-Loading"
|
||||
|
||||
private func startLoading() {
|
||||
parameters.userIndicatorController.submitIndicator(
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let loadingIndicatorIdentifier = "RoomMemberLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(RoomMemberDetailsScreenViewModel.self)-Loading"
|
||||
|
||||
private func showMemberLoadingIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
|
||||
@@ -97,9 +97,8 @@ struct TimelineItemPlainStylerView<Content: View>: View {
|
||||
HStack(spacing: 8) {
|
||||
TimelineSenderAvatarView(timelineItem: timelineItem)
|
||||
Text(timelineItem.sender.displayName ?? timelineItem.sender.id)
|
||||
.font(.subheadline)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundColor(.compound.decorativeColor(for: timelineItem.sender.id).text)
|
||||
.fontWeight(.semibold)
|
||||
.lineLimit(1)
|
||||
}
|
||||
.onTapGesture {
|
||||
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
//
|
||||
// Copyright 2023 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 Compound
|
||||
import SwiftUI
|
||||
|
||||
/// The item shown when all previous items are un-decryptable due to
|
||||
/// key backup not yet being supported in the app.
|
||||
struct EncryptedHistoryRoomTimelineView: View {
|
||||
let timelineItem: EncryptedHistoryRoomTimelineItem
|
||||
|
||||
var body: some View {
|
||||
Label {
|
||||
Text(title)
|
||||
.font(.compound.bodyMDSemibold)
|
||||
.foregroundColor(.compound.textInfoPrimary)
|
||||
} icon: {
|
||||
CompoundIcon(\.infoSolid, size: .small, relativeTo: .compound.bodyMDSemibold)
|
||||
.foregroundColor(.compound.iconInfoPrimary)
|
||||
}
|
||||
.labelStyle(EncryptedHistoryLabelStyle())
|
||||
.padding(16)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(Color.compound.bgInfoSubtle)
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(Color.compound.borderInfoSubtle)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 16)
|
||||
}
|
||||
|
||||
private var title: String {
|
||||
timelineItem.isSessionVerified ? L10n.screenRoomEncryptedHistoryBanner : L10n.screenRoomEncryptedHistoryBannerUnverified
|
||||
}
|
||||
}
|
||||
|
||||
private struct EncryptedHistoryLabelStyle: LabelStyle {
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
HStack(alignment: .top, spacing: 16) {
|
||||
configuration.icon
|
||||
configuration.title
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EncryptedHistoryRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
VStack(spacing: 8) {
|
||||
EncryptedHistoryRoomTimelineView(timelineItem: .init(id: .random, isSessionVerified: true))
|
||||
EncryptedHistoryRoomTimelineView(timelineItem: .init(id: .random, isSessionVerified: false))
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -86,7 +86,7 @@ class SecureBackupKeyBackupScreenViewModel: SecureBackupKeyBackupScreenViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private static let loadingIndicatorIdentifier = "SecureBackupKeyBackupScreenLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(SecureBackupKeyBackupScreenViewModel.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController?.submitIndicator(.init(id: Self.loadingIndicatorIdentifier, type: .modal, title: L10n.commonLoading, persistent: true))
|
||||
|
||||
+15
-15
@@ -22,12 +22,21 @@ struct SecureBackupKeyBackupScreen: View {
|
||||
@ObservedObject var context: SecureBackupKeyBackupScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
mainContent
|
||||
.padding()
|
||||
.interactiveDismissDisabled()
|
||||
.toolbar { toolbar }
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.alert(item: $context.alertInfo)
|
||||
FullscreenDialog {
|
||||
mainContent
|
||||
} bottomContent: {
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .toggleBackup)
|
||||
} label: {
|
||||
Text(L10n.screenChatBackupKeyBackupActionDisable)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.interactiveDismissDisabled()
|
||||
.toolbar { toolbar }
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -71,15 +80,6 @@ struct SecureBackupKeyBackupScreen: View {
|
||||
.foregroundColor(.compound.iconCriticalPrimary)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .toggleBackup)
|
||||
} label: {
|
||||
Text(L10n.screenChatBackupKeyBackupActionDisable)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-30
@@ -22,26 +22,21 @@ struct SecureBackupLogoutConfirmationScreen: View {
|
||||
@ObservedObject var context: SecureBackupLogoutConfirmationScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
VStack(spacing: 16) {
|
||||
header
|
||||
content
|
||||
}
|
||||
.padding()
|
||||
FullscreenDialog {
|
||||
VStack(spacing: 16) {
|
||||
HeroImage(icon: \.keyOffSolid)
|
||||
content
|
||||
}
|
||||
.toolbar { toolbar }
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.safeAreaInset(edge: .bottom) { footer.padding() }
|
||||
.alert(item: $context.alertInfo)
|
||||
.padding()
|
||||
} bottomContent: {
|
||||
footer.padding()
|
||||
}
|
||||
.toolbar { toolbar }
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var header: some View {
|
||||
HeroImage(icon: \.keyOffSolid)
|
||||
}
|
||||
|
||||
|
||||
@ViewBuilder
|
||||
private var content: some View {
|
||||
Text(title)
|
||||
@@ -62,21 +57,23 @@ struct SecureBackupLogoutConfirmationScreen: View {
|
||||
|
||||
@ViewBuilder
|
||||
private var footer: some View {
|
||||
if context.viewState.mode == .saveRecoveryKey {
|
||||
Button {
|
||||
context.send(viewAction: .settings)
|
||||
VStack(spacing: 16.0) {
|
||||
if context.viewState.mode == .saveRecoveryKey {
|
||||
Button {
|
||||
context.send(viewAction: .settings)
|
||||
} label: {
|
||||
Text(L10n.commonSettings)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .logout)
|
||||
} label: {
|
||||
Text(L10n.commonSettings)
|
||||
Text(L10n.actionSignout)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
|
||||
Button(role: .destructive) {
|
||||
context.send(viewAction: .logout)
|
||||
} label: {
|
||||
Text(L10n.actionSignout)
|
||||
}
|
||||
.buttonStyle(.compound(.primary))
|
||||
}
|
||||
|
||||
@ToolbarContentBuilder
|
||||
@@ -88,7 +85,7 @@ struct SecureBackupLogoutConfirmationScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
var title: String {
|
||||
private var title: String {
|
||||
switch context.viewState.mode {
|
||||
case .saveRecoveryKey:
|
||||
return L10n.screenSignoutSaveRecoveryKeyTitle
|
||||
@@ -99,7 +96,7 @@ struct SecureBackupLogoutConfirmationScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
var subtitle: String {
|
||||
private var subtitle: String {
|
||||
switch context.viewState.mode {
|
||||
case .saveRecoveryKey:
|
||||
return L10n.screenSignoutSaveRecoveryKeySubtitle
|
||||
|
||||
+3
-1
@@ -20,6 +20,7 @@ import SwiftUI
|
||||
struct SecureBackupRecoveryKeyScreenCoordinatorParameters {
|
||||
let secureBackupController: SecureBackupControllerProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
let isModallyPresented: Bool
|
||||
}
|
||||
|
||||
enum SecureBackupRecoveryKeyScreenCoordinatorAction {
|
||||
@@ -40,7 +41,8 @@ final class SecureBackupRecoveryKeyScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: SecureBackupRecoveryKeyScreenCoordinatorParameters) {
|
||||
viewModel = SecureBackupRecoveryKeyScreenViewModel(secureBackupController: parameters.secureBackupController,
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
||||
+3
@@ -28,6 +28,9 @@ enum SecureBackupRecoveryKeyScreenViewMode {
|
||||
}
|
||||
|
||||
struct SecureBackupRecoveryKeyScreenViewState: BindableState {
|
||||
/// Whether the screen is presented modally or within a navigation stack.
|
||||
var isModallyPresented: Bool
|
||||
|
||||
let mode: SecureBackupRecoveryKeyScreenViewMode
|
||||
|
||||
var recoveryKey: String?
|
||||
|
||||
+6
-2
@@ -28,11 +28,15 @@ class SecureBackupRecoveryKeyScreenViewModel: SecureBackupRecoveryKeyScreenViewM
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(secureBackupController: SecureBackupControllerProtocol, userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
init(secureBackupController: SecureBackupControllerProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
isModallyPresented: Bool) {
|
||||
self.secureBackupController = secureBackupController
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
super.init(initialViewState: .init(mode: secureBackupController.recoveryState.value.viewMode, bindings: .init()))
|
||||
super.init(initialViewState: .init(isModallyPresented: isModallyPresented,
|
||||
mode: secureBackupController.recoveryState.value.viewMode,
|
||||
bindings: .init()))
|
||||
|
||||
secureBackupController.recoveryState
|
||||
.receive(on: DispatchQueue.main)
|
||||
|
||||
+9
-10
@@ -24,7 +24,7 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
private let textFieldIdentifier = "textFieldIdentifier"
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
FullscreenDialog {
|
||||
ScrollViewReader { reader in
|
||||
mainContent
|
||||
.padding(16)
|
||||
@@ -33,17 +33,14 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
reader.scrollTo(textFieldIdentifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
.safeAreaInset(edge: .bottom) {
|
||||
} bottomContent: {
|
||||
footer
|
||||
.padding([.horizontal, .bottom], 16)
|
||||
.padding(.top, 8)
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
}
|
||||
.interactiveDismissDisabled()
|
||||
.toolbar { toolbar }
|
||||
.toolbar(.visible, for: .navigationBar)
|
||||
.background(Color.compound.bgCanvasDefault.ignoresSafeArea())
|
||||
.background()
|
||||
.environment(\.backgroundStyle, AnyShapeStyle(Color.compound.bgCanvasDefault))
|
||||
.interactiveDismissDisabled()
|
||||
.alert(item: $context.alertInfo)
|
||||
}
|
||||
|
||||
@@ -101,7 +98,7 @@ struct SecureBackupRecoveryKeyScreen: View {
|
||||
|
||||
@ToolbarContentBuilder
|
||||
private var toolbar: some ToolbarContent {
|
||||
if context.viewState.recoveryKey == nil {
|
||||
if context.viewState.isModallyPresented == true, context.viewState.recoveryKey == nil {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .cancel)
|
||||
@@ -235,6 +232,8 @@ struct SecureBackupRecoveryKeyScreen_Previews: PreviewProvider, TestablePreview
|
||||
let backupController = SecureBackupControllerMock()
|
||||
backupController.underlyingRecoveryState = CurrentValueSubject<SecureBackupRecoveryState, Never>(recoveryState).asCurrentValuePublisher()
|
||||
|
||||
return SecureBackupRecoveryKeyScreenViewModel(secureBackupController: backupController, userIndicatorController: UserIndicatorControllerMock())
|
||||
return SecureBackupRecoveryKeyScreenViewModel(secureBackupController: backupController,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
isModallyPresented: true)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ final class SecureBackupScreenCoordinator: CoordinatorProtocol {
|
||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||
|
||||
let recoveryKeyCoordinator = SecureBackupRecoveryKeyScreenCoordinator(parameters: .init(secureBackupController: parameters.secureBackupController,
|
||||
userIndicatorController: parameters.userIndicatorController))
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
isModallyPresented: true))
|
||||
|
||||
recoveryKeyCoordinator.actions.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
||||
@@ -33,7 +33,6 @@ enum SettingsScreenCoordinatorAction {
|
||||
case bugReport
|
||||
case about
|
||||
case blockedUsers
|
||||
case sessionVerification
|
||||
case accountSessions
|
||||
case notifications
|
||||
case advancedSettings
|
||||
@@ -77,8 +76,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||
actionsSubject.send(.about)
|
||||
case .blockedUsers:
|
||||
actionsSubject.send(.blockedUsers)
|
||||
case .sessionVerification:
|
||||
actionsSubject.send(.sessionVerification)
|
||||
case .secureBackup:
|
||||
actionsSubject.send(.secureBackup)
|
||||
case .accountSessionsList:
|
||||
|
||||
@@ -26,7 +26,6 @@ enum SettingsScreenViewModelAction {
|
||||
case reportBug
|
||||
case about
|
||||
case blockedUsers
|
||||
case sessionVerification
|
||||
case secureBackup
|
||||
case accountSessionsList
|
||||
case notifications
|
||||
@@ -37,7 +36,6 @@ enum SettingsScreenViewModelAction {
|
||||
|
||||
enum SettingsScreenSecuritySectionMode {
|
||||
case none
|
||||
case sessionVerification
|
||||
case secureBackup
|
||||
}
|
||||
|
||||
@@ -65,7 +63,6 @@ enum SettingsScreenViewAction {
|
||||
case reportBug
|
||||
case about
|
||||
case blockedUsers
|
||||
case sessionVerification
|
||||
case secureBackup
|
||||
case accountSessionsList
|
||||
case notifications
|
||||
|
||||
@@ -50,9 +50,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
guard let self else { return }
|
||||
|
||||
switch (securityState.verificationState, securityState.recoveryState) {
|
||||
case (.unverified, _):
|
||||
state.showSecuritySectionBadge = true
|
||||
state.securitySectionMode = .sessionVerification
|
||||
case (.verified, .disabled):
|
||||
state.showSecuritySectionBadge = true
|
||||
state.securitySectionMode = .secureBackup
|
||||
@@ -107,8 +104,6 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
actionsSubject.send(.blockedUsers)
|
||||
case .logout:
|
||||
actionsSubject.send(.logout)
|
||||
case .sessionVerification:
|
||||
actionsSubject.send(.sessionVerification)
|
||||
case .secureBackup:
|
||||
actionsSubject.send(.secureBackup)
|
||||
case .notifications:
|
||||
|
||||
@@ -81,11 +81,6 @@ struct SettingsScreen: View {
|
||||
private var accountSecuritySection: some View {
|
||||
Section {
|
||||
switch context.viewState.securitySectionMode {
|
||||
case .sessionVerification:
|
||||
ListRow(label: .default(title: L10n.actionCompleteVerification,
|
||||
icon: \.checkCircle),
|
||||
details: context.viewState.showSecuritySectionBadge ? .icon(securitySectionBadge) : nil,
|
||||
kind: .button { context.send(viewAction: .sessionVerification) })
|
||||
case .secureBackup:
|
||||
ListRow(label: .default(title: L10n.commonChatBackup,
|
||||
icon: \.key),
|
||||
|
||||
@@ -190,7 +190,7 @@ final class StartChatScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let loadingIndicatorIdentifier = "StartChatCoordinatorLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(StartChatScreenCoordinator.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
parameters.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
|
||||
@@ -145,7 +145,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let loadingIndicatorIdentifier = "StartChatLoading"
|
||||
private static let loadingIndicatorIdentifier = "\(StartChatScreenViewModel.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
|
||||
Reference in New Issue
Block a user