Skip to content

Commit

Permalink
[iOS] Prompt | Confirmation Alert Missing Before Deleting Section-Lev…
Browse files Browse the repository at this point in the history
…el Downloaded Videos #456 (#463)

* fix: confirmation alert

* chore: changed string to localization

* chore: review required changes
  • Loading branch information
forgotvas authored Jun 20, 2024
1 parent 34cee0d commit 5498a1c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 22 additions & 1 deletion Course/Course/Presentation/Subviews/CustomDisclosureGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions Course/Course/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Course/Course/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions Course/Course/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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" = "Всі відео";
Expand Down

0 comments on commit 5498a1c

Please sign in to comment.