Skip to content

Commit

Permalink
chore: Remove header and add cancel button
Browse files Browse the repository at this point in the history
  • Loading branch information
charlella committed Apr 11, 2024
1 parent f94b310 commit 05bc0a7
Showing 1 changed file with 29 additions and 38 deletions.
67 changes: 29 additions & 38 deletions Mail/Views/Bottom sheets/RestoreEmailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,40 @@ struct RestoreEmailsView: View {

var body: some View {
VStack(alignment: .leading, spacing: 0) {
if !isCompactWindow {
HeaderCloseButtonView(title: MailResourcesStrings.Localizable.restoreEmailsTitle) {
dismiss()
Text(MailResourcesStrings.Localizable.restoreEmailsTitle)
.textStyle(.bodyMedium)
.padding(.bottom, value: .regular)

Text(MailResourcesStrings.Localizable.restoreEmailsText)
.textStyle(.bodySecondary)
.padding(.bottom, value: .small)

LargePicker(title: MailResourcesStrings.Localizable.restoreEmailsBackupDate,
noSelectionText: pickerNoSelectionText,
selection: $selectedDate,
items: availableDates.map(mapDates))
.padding(.bottom, value: .medium)
.onChange(of: selectedDate) { _ in
matomo.track(eventWithCategory: .restoreEmailsBottomSheet, action: .input, name: "selectDate")
}
} else {
Text(MailResourcesStrings.Localizable.restoreEmailsTitle)
.textStyle(.bodyMedium)
.padding(.bottom, 16)
.padding(.horizontal, UIPadding.bottomSheetHorizontal)
}

VStack(alignment: .leading, spacing: 0) {
Text(MailResourcesStrings.Localizable.restoreEmailsText)
.textStyle(.bodySecondary)
.padding(.bottom, 10)

LargePicker(title: MailResourcesStrings.Localizable.restoreEmailsBackupDate,
noSelectionText: pickerNoSelectionText,
selection: $selectedDate,
items: availableDates.map(mapDates))
.padding(.bottom, 24)
.onChange(of: selectedDate) { _ in
matomo.track(eventWithCategory: .restoreEmailsBottomSheet, action: .input, name: "selectDate")
}

ModalButtonsView(primaryButtonTitle: MailResourcesStrings.Localizable.buttonConfirmRestoreEmails,
secondaryButtonTitle: nil,
primaryButtonEnabled: !availableDates.isEmpty,
primaryButtonAction: restoreEmails)
}
.padding(.horizontal, isCompactWindow ? UIPadding.bottomSheetHorizontal : 0)
.task {
await tryOrDisplayError {
let backupsList = try await mailboxManager.apiFetcher.listBackups(mailbox: mailboxManager.mailbox).backups
withAnimation {
availableDates = backupsList
selectedDate = backupsList.last ?? ""
pickerNoSelectionText = MailResourcesStrings.Localizable.pickerNoSelection
}
ModalButtonsView(primaryButtonTitle: MailResourcesStrings.Localizable.buttonConfirmRestoreEmails,
primaryButtonEnabled: !availableDates.isEmpty,
primaryButtonAction: restoreEmails,
secondaryButtonAction: dismiss.callAsFunction)
}
.padding(.horizontal, isCompactWindow ? UIPadding.bottomSheetHorizontal : 0)
.task {
await tryOrDisplayError {
let backupsList = try await mailboxManager.apiFetcher.listBackups(mailbox: mailboxManager.mailbox).backups
withAnimation {
availableDates = backupsList
selectedDate = backupsList.last ?? ""
pickerNoSelectionText = MailResourcesStrings.Localizable.pickerNoSelection
}
}
.matomoView(view: [MatomoUtils.View.bottomSheet.displayName, "RestoreEmailsView"])
}
.matomoView(view: [MatomoUtils.View.bottomSheet.displayName, "RestoreEmailsView"])
}

private func restoreEmails() async {
Expand Down

0 comments on commit 05bc0a7

Please sign in to comment.