Repository navigation
Add push notification onboarding preview #10161
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2670e4f
Add push notification onboarding preview
azooz2003-bit 8d249c6
Localize onboarding preview clock
azooz2003-bit 381be00
Name onboarding push preview test
azooz2003-bit 1c8aad7
Add separate system push onboarding page
azooz2003-bit 79139f8
Use cmux system push notification preview
azooz2003-bit 105900b
Use real grouped notifications in onboarding
azooz2003-bit df03af9
Merge remote-tracking branch 'origin/main' into feat-ios-push-onboard…
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ges/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/OnboardingPushNotificationsView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #if os(iOS) | ||
| import CmuxMobileSupport | ||
| import SwiftUI | ||
| import UIKit | ||
|
|
||
| /// Sets context for the system notification prompt with an expanded group of | ||
| /// notifications captured from iOS instead of approximating Apple's effects. | ||
| struct OnboardingPushNotificationsView: View { | ||
| var body: some View { | ||
| ZStack { | ||
| Color.clear | ||
| .frame(width: 1, height: 1) | ||
| .accessibilityElement(children: .ignore) | ||
| .accessibilityLabel(title) | ||
| .accessibilityIdentifier("MobileOnboardingPushNotificationsScene") | ||
|
|
||
| OnboardingSceneContent( | ||
| title: title, | ||
| message: L10n.string( | ||
| "mobile.onboarding.pushNotifications.body", | ||
| defaultValue: "Get a push when work finishes or needs your input. Tap to open the right workspace." | ||
| ), | ||
| visual: OnboardingSystemNotificationPreview() | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private var title: String { | ||
| L10n.string( | ||
| "mobile.onboarding.pushNotifications.title", | ||
| defaultValue: "Know when your agent needs you" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| private struct OnboardingSystemNotificationPreview: View { | ||
| @Environment(\.locale) private var locale | ||
|
|
||
| var body: some View { | ||
| Group { | ||
| if let image { | ||
| Image(uiImage: image) | ||
| .resizable() | ||
| .scaledToFit() | ||
| // 1,200 pixels is the native width of the @3x system capture. | ||
| // Capping at its point width prevents iOS typography from scaling up. | ||
| .frame(maxWidth: 400) | ||
| } | ||
| } | ||
| .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| .accessibilityElement(children: .ignore) | ||
| .accessibilityLabel(L10n.string( | ||
| "mobile.onboarding.pushPreview.accessibilityLabel", | ||
| defaultValue: "Three cmux notifications for completed work, failed checks, and requested input." | ||
| )) | ||
| .accessibilityIdentifier("MobileOnboardingPushPreview") | ||
| } | ||
|
|
||
| private var resourceName: String { | ||
| let language = OnboardingScreenshotLanguage.resolve(locale: locale) | ||
| return "Onboarding-push-\(language.rawValue)" | ||
| } | ||
|
|
||
| private var image: UIImage? { | ||
| guard let url = Bundle.module.url( | ||
| forResource: resourceName, | ||
| withExtension: "png" | ||
| ) else { return nil } | ||
| return UIImage(contentsOfFile: url.path) | ||
| } | ||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+795 KB
...ources/CmuxMobileShellUI/Resources/OnboardingScreenshots/Onboarding-push-en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+776 KB
...ources/CmuxMobileShellUI/Resources/OnboardingScreenshots/Onboarding-push-ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
Cache the loaded preview image instead of reloading it on every render.
resourceNameandimageare computed properties. SwiftUI re-evaluates them each timebodyruns. The onboarding page transition re-renders this view during swipe animation. Each re-render triggers aBundle.module.urllookup and a synchronousUIImage(contentsOfFile:)disk read. Repeated disk reads during animation frames can cause hitches.Load the image once and store it in state.
♻️ Proposed fix to load the image once
private struct OnboardingSystemNotificationPreview: View { `@Environment`(\.locale) private var locale + `@State` private var cachedImage: UIImage? var body: some View { Group { - if let image { + if let image = cachedImage { Image(uiImage: image) .resizable() .scaledToFit() // 1,105 pixels is the native width of the `@3x` system capture. // Capping at its point width prevents iOS typography from scaling up. .frame(maxWidth: 368.33) } } .frame(maxWidth: .infinity, maxHeight: .infinity) .accessibilityElement(children: .ignore) .accessibilityLabel(L10n.string( "mobile.onboarding.pushPreview.accessibilityLabel", defaultValue: "cmux notification: Agent needs your input." )) .accessibilityIdentifier("MobileOnboardingPushPreview") + .task(id: locale) { + cachedImage = loadImage() + } } private var resourceName: String { let language = OnboardingScreenshotLanguage.resolve(locale: locale) return "Onboarding-push-\(language.rawValue)" } - private var image: UIImage? { + private func loadImage() -> UIImage? { guard let url = Bundle.module.url( forResource: resourceName, withExtension: "png" ) else { return nil } return UIImage(contentsOfFile: url.path) } }📝 Committable suggestion
🤖 Prompt for AI Agents