From 86297e2f4f65f79cf466ef3626730f56bb44c0f1 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Thu, 13 Jun 2024 19:14:47 +0300 Subject: [PATCH 1/3] fix: confirmation alert --- .../Subviews/CustomDisclosureGroup.swift | 23 ++++++++++++++++++- Course/Course/SwiftGen/Strings.swift | 2 ++ Course/Course/en.lproj/Localizable.strings | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift b/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift index 75186dd91..10ab50625 100644 --- a/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift +++ b/Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift @@ -50,7 +50,24 @@ struct CustomDisclosureGroup: View { let state = downloadAllButtonState(for: chapter) { Button( action: { - downloadAllSubsections(in: chapter, state: state) + switch state { + case .finished: + viewModel.router.presentAlert( + alertTitle: CourseLocalization.Alert.warning, + alertMessage: deleteMessage(for: chapter), + positiveAction: CoreLocalization.Alert.delete, + onCloseTapped: { + viewModel.router.dismiss(animated: true) + }, + okTapped: { + downloadAllSubsections(in: chapter, state: state) + viewModel.router.dismiss(animated: true) + }, + type: .deleteVideo + ) + default: + downloadAllSubsections(in: chapter, state: state) + } }, label: { switch state { case .available: @@ -175,6 +192,10 @@ struct CustomDisclosureGroup: View { } } + private func deleteMessage(for chapter: CourseChapter) -> String { + "\(CourseLocalization.Alert.deleteVideos) \"\(chapter.displayName)\"?" + } + func getAssignmentStatus(for date: Date) -> String { let calendar = Calendar.current let today = Date() diff --git a/Course/Course/SwiftGen/Strings.swift b/Course/Course/SwiftGen/Strings.swift index 1cada7b12..91e479f03 100644 --- a/Course/Course/SwiftGen/Strings.swift +++ b/Course/Course/SwiftGen/Strings.swift @@ -37,6 +37,8 @@ public enum CourseLocalization { public static let rotateDevice = CourseLocalization.tr("Localizable", "ALERT.ROTATE_DEVICE", fallback: "Rotate your device to view this video in full screen.") /// Turning off the switch will stop downloading and delete all downloaded videos for public static let stopDownloading = CourseLocalization.tr("Localizable", "ALERT.STOP_DOWNLOADING", fallback: "Turning off the switch will stop downloading and delete all downloaded videos for") + /// Warning + public static let warning = CourseLocalization.tr("Localizable", "ALERT.WARNING", fallback: "Warning") } public enum Course { /// Due Today diff --git a/Course/Course/en.lproj/Localizable.strings b/Course/Course/en.lproj/Localizable.strings index 40a4d8157..f4a37b8a4 100644 --- a/Course/Course/en.lproj/Localizable.strings +++ b/Course/Course/en.lproj/Localizable.strings @@ -34,6 +34,7 @@ "ALERT.DELETE_ALL_VIDEOS" = "Are you sure you want to delete all video(s) for"; "ALERT.DELETE_VIDEOS" = "Are you sure you want to delete video(s) for"; "ALERT.STOP_DOWNLOADING" = "Turning off the switch will stop downloading and delete all downloaded videos for"; +"ALERT.WARNING" = "Warning"; "COURSE_CONTAINER.HOME" = "Home"; "COURSE_CONTAINER.VIDEOS" = "Videos"; From 9a6ce33eff9db4b035a18e630902380c7900dca4 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Thu, 13 Jun 2024 20:42:50 +0300 Subject: [PATCH 2/3] chore: changed string to localization --- .../CourseVideoDownloadBarViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarViewModel.swift b/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarViewModel.swift index 5caa8ece4..841c49c1f 100644 --- a/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarViewModel.swift +++ b/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarViewModel.swift @@ -124,7 +124,7 @@ final class CourseVideoDownloadBarViewModel: ObservableObject { func onToggle() async { if allVideosDownloaded { courseViewModel.router.presentAlert( - alertTitle: "Warning", + alertTitle: CourseLocalization.Alert.warning, alertMessage: "\(CourseLocalization.Alert.deleteAllVideos) \"\(courseStructure.displayName)\"?", positiveAction: CoreLocalization.Alert.delete, onCloseTapped: { [weak self] in @@ -145,7 +145,7 @@ final class CourseVideoDownloadBarViewModel: ObservableObject { if isOn { courseViewModel.router.presentAlert( - alertTitle: "Warning", + alertTitle: CourseLocalization.Alert.warning, alertMessage: "\(CourseLocalization.Alert.stopDownloading) \"\(courseStructure.displayName)\"", positiveAction: CoreLocalization.Alert.accept, onCloseTapped: { [weak self] in From c1bb3123fd8781d2a6af8185bfe1aa367e960a50 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Mon, 17 Jun 2024 11:36:22 +0300 Subject: [PATCH 3/3] chore: review required changes --- Course/Course/uk.lproj/Localizable.strings | 1 + 1 file changed, 1 insertion(+) diff --git a/Course/Course/uk.lproj/Localizable.strings b/Course/Course/uk.lproj/Localizable.strings index abb9dc970..b5a3746f6 100644 --- a/Course/Course/uk.lproj/Localizable.strings +++ b/Course/Course/uk.lproj/Localizable.strings @@ -33,6 +33,7 @@ "ALERT.DELETE_ALL_VIDEOS" = "Are you sure you want to delete all video(s) for"; "ALERT.DELETE_VIDEOS" = "Are you sure you want to delete video(s) for"; "ALERT.STOP_DOWNLOADING" = "Turning off the switch will stop downloading and delete all downloaded videos for"; +"ALERT.WARNING" = "Warning"; "COURSE_CONTAINER.COURSE" = "Курс"; "COURSE_CONTAINER.VIDEOS" = "Всі відео";