Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ui-fixes for app backup feature #5315

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ class RestoreCloudViewController: ThemeViewController {
extension RestoreCloudViewController: SectionsDataSource {

func buildSections() -> [SectionProtocol] {
guard !walletViewItem.isEmpty else {
guard !walletViewItem.isEmpty || !fullBackupViewItem.isEmpty else {
return []
}

var sections = [
descriptionSection,
]
var sections = [ descriptionSection ]

if !walletViewItem.notImported.isEmpty {
sections.append(
section(id: "not_imported", headerTitle: "restore.cloud.wallets".localized, viewItems: viewModel.walletViewItem.notImported)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class RestoreFileConfigurationModule {
let viewModel = RestoreFileConfigurationViewModel(
cloudBackupManager: App.shared.cloudBackupManager,
appBackupProvider: App.shared.appBackupProvider,
contactBookManager: App.shared.contactManager,
rawBackup: rawBackup
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class RestoreFileConfigurationViewController: KeyboardAwareViewController {
restoreButton.addTarget(self, action: #selector(onTapRestore), for: .touchUpInside)
restoreButton.set(style: .yellow)

viewModel.showMergeAlertPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] in
self?.showMergeAlert()
}
.store(in: &cancellables)

viewModel.finishedPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] success in
Expand All @@ -75,6 +82,10 @@ class RestoreFileConfigurationViewController: KeyboardAwareViewController {
}

@objc private func onTapRestore() {
viewModel.onTapRestore()
}

private func showMergeAlert() {
let viewController = BottomSheetModule.viewController(
image: .local(image: UIImage(named: "warning_2_24")?.withTintColor(.themeJacob)),
title: "alert.notice".localized,
Expand All @@ -83,7 +94,7 @@ class RestoreFileConfigurationViewController: KeyboardAwareViewController {
],
buttons: [
.init(style: .red, title: "backup_app.restore.notice.merge".localized, actionType: .afterClose) { [weak self] in
self?.viewModel.onTapRestore()
self?.viewModel.restore()
},
.init(style: .transparent, title: "button.cancel".localized, actionType: .afterClose),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import Combine
class RestoreFileConfigurationViewModel {
private let cloudBackupManager: CloudBackupManager
private let appBackupProvider: AppBackupProvider
private let contactBookManager: ContactBookManager
private let rawBackup: RawFullBackup

private let showMergeAlertSubject = PassthroughSubject<Void, Never>()
private let finishedSubject = PassthroughSubject<Bool, Never>()

init(cloudBackupManager: CloudBackupManager, appBackupProvider: AppBackupProvider, rawBackup: RawFullBackup) {
init(cloudBackupManager: CloudBackupManager, appBackupProvider: AppBackupProvider, contactBookManager: ContactBookManager, rawBackup: RawFullBackup) {
self.cloudBackupManager = cloudBackupManager
self.appBackupProvider = appBackupProvider
self.contactBookManager = contactBookManager
self.rawBackup = rawBackup
}

Expand Down Expand Up @@ -61,10 +64,22 @@ extension RestoreFileConfigurationViewModel {
}

func onTapRestore() {
if contactBookManager.state.data?.contacts.isEmpty ?? true {
restore()
} else {
showMergeAlertSubject.send()
}
}

func restore() {
appBackupProvider.restore(raw: rawBackup)
finishedSubject.send(true)
}

var showMergeAlertPublisher: AnyPublisher<Void, Never> {
showMergeAlertSubject.eraseToAnyPublisher()
}

var finishedPublisher: AnyPublisher<Bool, Never> {
finishedSubject.eraseToAnyPublisher()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct BackupDisclaimerView: View {
@ObservedObject var viewModel: BackupAppViewModel
var onDismiss: (() -> Void)?

@State var isOn: Bool = true
@State var isOn: Bool = false

var body: some View {
let backupDisclaimer = (viewModel.destination ?? .local).backupDisclaimer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@ struct BackupListView: View {
ThemeView {
BottomGradientWrapper {
VStack(spacing: .margin24) {
VStack(spacing: 0) {
ListSectionHeader(text: "backup_app.backup_list.header.wallets".localized)
if !viewModel.accountItems.isEmpty {
VStack(spacing: 0) {
ListSectionHeader(text: "backup_app.backup_list.header.wallets".localized)

ListSection {
ForEach(viewModel.accountItems, id: \.accountId) { (item: BackupAppModule.AccountItem) in
if viewModel.selected[item.id] != nil {
let selected = binding(for: item.accountId)
ListSection {
ForEach(viewModel.accountItems, id: \.accountId) { (item: BackupAppModule.AccountItem) in
if viewModel.selected[item.id] != nil {
let selected = binding(for: item.accountId)

ClickableRow(action: {
viewModel.toggle(item: item)
}) {
HStack {
AccountView(item: item)
ClickableRow(action: {
viewModel.toggle(item: item)
}) {
HStack {
AccountView(item: item)

Toggle(isOn: selected) {}
.labelsHidden()
.toggleStyle(CheckboxStyle())
Toggle(isOn: selected) {}
.labelsHidden()
.toggleStyle(CheckboxStyle())
}
}
} else {
ListRow {
AccountView(item: item)
}
}
} else {
ListRow {
AccountView(item: item)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Go to Settings - > %@ and allow access to the camera.";
"backup.cloud.password.confirm.placeholder" = "Confirm";
"backup.cloud.password.save" = "Save and Backup";

"backup.cloud.password.error.empty_passphrase" = "Passphrase cannot be empty";
"backup.cloud.password.error.empty_passphrase" = "Password cannot be empty";
"backup.cloud.password.error.forbidden_symbols" = "Please use only supported symbols: A-Z a-z 0-9 ' \" ` & / ? ! : ; . , ~ * $ = + - [ ] ( ) { } < > \\ _ # @ | %";
"backup.cloud.password.error.minimum_requirement" = "At least 8 characters, including one uppercase letter, one lowercase letter, one number, and one symbol";
"backup.cloud.password.error.invalid_password" = "Incorrect Password";
Expand Down