generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # ElementX.xcodeproj/project.pbxproj # ElementX/Sources/Services/AppLock/AppLockService.swift
- Loading branch information
Showing
36 changed files
with
776 additions
and
78 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...entX/Sources/Screens/AppLock/AppLockSettingsScreen/AppLockSettingsScreenCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// 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 | ||
|
||
struct AppLockSettingsScreenCoordinatorParameters { | ||
let appLockService: AppLockServiceProtocol | ||
} | ||
|
||
enum AppLockSettingsScreenCoordinatorAction { | ||
case done | ||
} | ||
|
||
final class AppLockSettingsScreenCoordinator: CoordinatorProtocol { | ||
private let parameters: AppLockSettingsScreenCoordinatorParameters | ||
private var viewModel: AppLockSettingsScreenViewModelProtocol | ||
private let actionsSubject: PassthroughSubject<AppLockSettingsScreenCoordinatorAction, Never> = .init() | ||
private var cancellables = Set<AnyCancellable>() | ||
|
||
var actions: AnyPublisher<AppLockSettingsScreenCoordinatorAction, Never> { | ||
actionsSubject.eraseToAnyPublisher() | ||
} | ||
|
||
init(parameters: AppLockSettingsScreenCoordinatorParameters) { | ||
self.parameters = parameters | ||
|
||
viewModel = AppLockSettingsScreenViewModel(appLockService: parameters.appLockService) | ||
} | ||
|
||
func start() { | ||
viewModel.actions.sink { [weak self] action in | ||
MXLog.info("Coordinator: received view model action: \(action)") | ||
|
||
guard let self else { return } | ||
switch action { | ||
case .changePINCode: | ||
break | ||
case .done: | ||
self.actionsSubject.send(.done) | ||
} | ||
} | ||
.store(in: &cancellables) | ||
} | ||
|
||
func toPresentable() -> AnyView { | ||
AnyView(AppLockSettingsScreen(context: viewModel.context)) | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
ElementX/Sources/Screens/AppLock/AppLockSettingsScreen/AppLockSettingsScreenModels.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// 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 | ||
import LocalAuthentication | ||
|
||
enum AppLockSettingsScreenViewModelAction { | ||
/// The user would like to enter new PIN code. | ||
case changePINCode | ||
case done | ||
} | ||
|
||
struct AppLockSettingsScreenViewState: BindableState { | ||
let biometryType: LABiometryType | ||
var bindings: AppLockSettingsScreenViewStateBindings | ||
|
||
var supportsBiometry: Bool { biometryType != .none } | ||
var enableBiometryTitle: String { | ||
switch biometryType { | ||
case .none: | ||
L10n.commonError | ||
case .touchID: | ||
UntranslatedL10n.screenAppLockSettingsEnableTouchIdIos | ||
case .faceID: | ||
UntranslatedL10n.screenAppLockSettingsEnableFaceIdIos | ||
case .opticID: | ||
UntranslatedL10n.screenAppLockSettingsEnableOpticIdIos | ||
@unknown default: | ||
UntranslatedL10n.screenAppLockSettingsEnableBiometricUnlock | ||
} | ||
} | ||
} | ||
|
||
struct AppLockSettingsScreenViewStateBindings { | ||
var enableBiometrics: Bool | ||
var alertInfo: AlertInfo<AppLockSettingsScreenAlertType>? | ||
} | ||
|
||
enum AppLockSettingsScreenAlertType { | ||
/// The alert shown to confirm the user would like to remove their PIN. | ||
case confirmRemovePINCode | ||
} | ||
|
||
enum AppLockSettingsScreenViewAction { | ||
/// The user would like to enter a new PIN code. | ||
case changePINCode | ||
/// The user would like to disable the App Lock feature. | ||
case disable | ||
/// The user has toggled the biometrics setting. | ||
case enableBiometricsChanged | ||
case done | ||
} |
Oops, something went wrong.