-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add live activities for download progress #1058
Conversation
Fixes kiwix#1037 Add Live Activities support for displaying download progress on the lock screen and in the Dynamic Island. * Import `ActivityKit` and create a new `DownloadActivityAttributes` struct in `App/App_iOS.swift`. * Update `Model/DownloadService.swift` to manage Live Activities during download progress changes. * Modify `Views/BuildingBlocks/DownloadTaskCell.swift` to include Live Activities updates. * Update `Views/Library/ZimFileDetail.swift` to handle Live Activities for download details. * Add Live Activities updates in `Views/Library/ZimFilesDownloads.swift`. * Add a new setting to enable or disable Live Activities in `Views/Settings/Settings.swift`. * Handle alerts for Live Activities in `Views/ViewModifiers/AlertHandler.swift`. * Add `Model/DownloadActivityAttributes.swift` to define the attributes for Live Activities. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/kiwix/kiwix-apple/issues/1037?shareId=XXXX-XXXX-XXXX-XXXX).
@plyght Thank you for your PR, we will review it, but might take a while considering we are now mostly in the Christmas break. |
@kelson42 All good! Have a wonderful Christmas! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plyght thank you for your PR.
- Please don't remove file headers.
- Doesn't compile on my machine
- Doesn't compile on CI
- There are a couple of codefactor issues that can be addressed once the code actually runs.
Thank you for your PR @plyght . By the first glance, it needs more work.
|
@@ -337,6 +346,11 @@ final class DownloadService: NSObject, URLSessionDelegate, URLSessionTaskDelegat | |||
progress.updateFor(uuid: zimFileID, | |||
downloaded: totalBytesWritten, | |||
total: totalBytesExpectedToWrite) | |||
// Update Live Activity | |||
let progressPercentage = Double(totalBytesWritten) / Double(totalBytesExpectedToWrite) | |||
let speed = Double(bytesWritten) / 1024.0 / 1024.0 // Convert to MB/s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be incorrect.
It has no notion of time, therefore it cannot represent speed, which is per second.
@@ -265,6 +252,7 @@ struct Settings: View { | |||
SelectedLanaguageLabel() | |||
}.disabled(library.state != .complete) | |||
Toggle("library_settings.toggle.cellular".localized, isOn: $downloadUsingCellular) | |||
Toggle("library_settings.toggle.live_activities".localized, isOn: $enableLiveActivities) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a nice addition, but the value of it isn't read anywhere, so it's not turning anything on / off atm.
@@ -139,4 +130,14 @@ private struct RootView: UIViewControllerRepresentable { | |||
func updateUIViewController(_ controller: SplitViewController, context: Context) { | |||
} | |||
} | |||
|
|||
struct DownloadActivityAttributes: ActivityAttributes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct is a duplicate.
Closing this PR for now, it requires more work, and a more throughout approach to handle cross platform, and iOS 16.1 availability. |
Fixes #1037
Add Live Activities support for displaying download progress on the lock screen and in the Dynamic Island.
ActivityKit
and create a newDownloadActivityAttributes
struct inApp/App_iOS.swift
.Model/DownloadService.swift
to manage Live Activities during download progress changes.Views/BuildingBlocks/DownloadTaskCell.swift
to include Live Activities updates.Views/Library/ZimFileDetail.swift
to handle Live Activities for download details.Views/Library/ZimFilesDownloads.swift
.Views/Settings/Settings.swift
.Views/ViewModifiers/AlertHandler.swift
.Model/DownloadActivityAttributes.swift
to define the attributes for Live Activities.For more details, open the Copilot Workspace session.