Skip to content

Commit

Permalink
chore: add alert when disable downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
eyatsenkoperpetio committed Jan 31, 2024
1 parent 81a4512 commit 22fa31f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,38 @@ final class CourseVideoDownloadBarViewModel: ObservableObject {
self?.courseViewModel.router.dismiss(animated: true)
},
okTapped: { [weak self] in
guard let self else { return }
Task {
await self?.downloadAll(
isOn: false
)
await self.downloadAll(isOn: false)
}
self?.courseViewModel.router.dismiss(animated: true)
self.courseViewModel.router.dismiss(animated: true)
},
type: .default(positiveAction: CoreLocalization.Alert.delete, image: CoreAssets.bgDelete.swiftUIImage)
)
return
}
await downloadAll(
isOn: isOn ? false : true
)

if isOn {
courseViewModel.router.presentAlert(
alertTitle: "Warning",
alertMessage: "\(CourseLocalization.Alert.stopDownloading) \"\(courseStructure.displayName)\"?",
positiveAction: CoreLocalization.Alert.accept,
onCloseTapped: { [weak self] in
self?.courseViewModel.router.dismiss(animated: true)
},
okTapped: { [weak self] in
guard let self else { return }
Task {
await self.downloadAll(isOn: false)
}
self.courseViewModel.router.dismiss(animated: true)
},
type: .default(positiveAction: CoreLocalization.Alert.accept, image: nil)
)
return
}

await downloadAll(isOn: true)
}

@MainActor
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 @@ -27,6 +27,8 @@ public enum CourseLocalization {
public static let deleteVideos = CourseLocalization.tr("Localizable", "ALERT.DELETE_VIDEOS", fallback: "Are you sure you want to delete video(s) for")
/// Rotate your device to view this video in full screen.
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")
}
public enum Courseware {
/// Back to outline
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 @@ -33,6 +33,7 @@
"ALERT.ACCEPT" = "Accept";
"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";

"COURSE_CONTAINER.COURSE" = "Course";
"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 @@ -32,6 +32,7 @@
"ALERT.ACCEPT" = "Accept";
"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";

"COURSE_CONTAINER.COURSE" = "Курс";
"COURSE_CONTAINER.VIDEOS" = "Всі відео";
Expand Down

0 comments on commit 22fa31f

Please sign in to comment.