Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Prompt | Confirmation Alert Missing Before Deleting Section-Level Downloaded Videos #456 #463

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add same string for uk.lproj/Localizable.strings file.

Copy link
Contributor Author

@forgotvas forgotvas Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, please check again


"COURSE_CONTAINER.HOME" = "Home";
"COURSE_CONTAINER.VIDEOS" = "Videos";
Expand Down
Loading