-
Notifications
You must be signed in to change notification settings - Fork 117
Astro plugin star map #5528
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
Astro plugin star map #5528
Changes from all commits
4cbf29d
c12fa80
33044d8
c792bb0
48653f1
8892c6a
8099f44
4250a13
e5426e3
90d5a26
08ace4e
9b2abf7
9a75cc1
abfdcc5
bade85b
af03df6
b871e21
37a369e
c02d9e7
2f925d0
0fa2a7f
81d52a5
a64f8d4
f4cbf71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "colors" : [ | ||
| { | ||
| "color" : { | ||
| "color-space" : "srgb", | ||
| "components" : { | ||
| "alpha" : "1.000", | ||
| "blue" : "0x4D", | ||
| "green" : "0x4D", | ||
| "red" : "0x4D" | ||
| } | ||
| }, | ||
| "idiom" : "universal" | ||
| }, | ||
| { | ||
| "appearances" : [ | ||
| { | ||
| "appearance" : "luminosity", | ||
| "value" : "dark" | ||
| } | ||
| ], | ||
| "color" : { | ||
| "color-space" : "srgb", | ||
| "components" : { | ||
| "alpha" : "1.000", | ||
| "blue" : "0x4D", | ||
| "green" : "0x4D", | ||
| "red" : "0x4D" | ||
| } | ||
| }, | ||
| "idiom" : "universal" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "ic_navbar_close@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "ic_navbar_close@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| }, | ||
| "properties" : { | ||
| "template-rendering-intent" : "template" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,50 @@ | |
|
|
||
| import UIKit | ||
|
|
||
| @objc(AstronomyPlugin) | ||
| final class AstronomyPlugin: OAPlugin { | ||
| let dataProvider: AstroDataDbProvider | ||
| @objc final class AstronomyPlugin: OAPlugin { | ||
| private enum PreferenceId { | ||
| static let settings = "astronomy_settings" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle Android legacy |
||
| static let legacySettings = "star_watcher_settings" | ||
| static let recent = "astronomy_recently_viewed" | ||
| } | ||
|
|
||
| let dataProvider = AstroDataDbProvider() | ||
|
|
||
| var astroSettings: AstronomyPluginSettings { astronomySettingsStorage } | ||
| var recentSearchChips: [StarMapRecentChip] = [] | ||
|
|
||
| private let settingsPref: OACommonString = OAAppSettings.sharedManager() | ||
| .registerStringPreference(PreferenceId.settings, defValue: "") | ||
| .makeProfile() | ||
| .makeShared() | ||
|
|
||
| private let legacySettingsPref: OACommonString = OAAppSettings.sharedManager() | ||
| .registerStringPreference(PreferenceId.legacySettings, defValue: "") | ||
| .makeProfile() | ||
|
|
||
| private let recentPref: OACommonString = OAAppSettings.sharedManager() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this also configured as .makeGlobal().makeShared() on Android?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Android, they are stored only in RAM, for a single session. On iOS, they need to be saved across sessions and shared among all profiles.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does the logic differ from Android? |
||
| .registerStringPreference(PreferenceId.recent, defValue: "") | ||
| .makeGlobal() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .makeGlobal() ? |
||
|
|
||
| private lazy var astronomySettingsStorage = AstronomyPluginSettings(settingsPref: settingsPref, recentPref: recentPref) | ||
|
|
||
| override init() { | ||
| dataProvider = AstroDataDbProvider() | ||
| super.init() | ||
| recentSearchChips = astronomySettingsStorage.recentChips() | ||
| } | ||
|
|
||
| func saveRecentSearchChips() { | ||
| astronomySettingsStorage.setRecentChips(recentSearchChips) | ||
| } | ||
|
|
||
| func migrateLegacyStarWatcherSettingsIfNeeded() { | ||
| for appMode in OAApplicationMode.allPossibleValues() { | ||
| guard legacySettingsPref.isSet(for: appMode), !settingsPref.isSet(for: appMode) else { | ||
| continue | ||
| } | ||
| settingsPref.set(legacySettingsPref.get(appMode), mode: appMode) | ||
| } | ||
| astronomySettingsStorage.reloadFromPreference() | ||
| } | ||
|
|
||
| override func getId() -> String? { | ||
|
|
||
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.
?
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 approximately matches the astronomical red filter on Android. On Android, the effect is implemented using ColorMatrixColorFilter, which maps luminance to the red channel. UIKit does not provide a public equivalent of a color matrix filter for arbitrary UIView content, so on iOS we approximate the effect by applying a red overlay with the multiplyBlendMode compositing filter.