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 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"; 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" = "Всі відео";