Skip to content

Astro plugin star map#5528

Open
vitaliy-sova-ios wants to merge 19 commits into
masterfrom
astro_plugin_star_map
Open

Astro plugin star map#5528
vitaliy-sova-ios wants to merge 19 commits into
masterfrom
astro_plugin_star_map

Conversation

@vitaliy-sova-ios

Copy link
Copy Markdown
Contributor

No description provided.

colorIndex: int(item[keyColorIndex], fallback: nextColor % DirectionColor.allCases.count))
},
celestialPaths: parseItems(json?[keyCelestialPaths]) { CelestialPathConfig(id: $0) })
celestialPaths: parseItems(json?[keyCelestialPaths]) { CelestialPathConfig(id: $0) },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason we're manually parsing [String: Any] instead of using Decodable?

private static let keyId = "id"
private static let keyColorIndex = "colorIndex"

private static let keySavedMapPosition = "savedMapPosition"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

private enum Keys {}

private func commonInit() {
isUserInteractionEnabled = false
backgroundColor = .mapNightFilter
layer.compositingFilter = "multiplyBlendMode"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Contributor Author

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.

Comment on lines +44 to +55
func setOnDateTimeChangeListener(_ listener: @escaping (Date) -> Void) {
onDateTimeChangeListener = listener
}

func setDateTime(_ date: Date) {
currentDate = date
updateDisplay()
}

func getDateTime() -> Date {
currentDate
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Java code style

}

func setArDirectionEnabled(_ enabled: Bool) {
arDirectionEnabled = enabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we avoid calling updateArrowIcon() when the value hasn't changed?

} else {
color = StarMapControlTheme.foreground(active: active, nightMode: nightMode)
}
print(color, active, isHighlighted)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

resetButton.updateTheme(nightmod: nightMode, active: active)

if pressed {
let pressedColorDay = UIColor(rgb: color_on_map_icon_background_color_tap_light).withAlphaComponent(StarMapControlTheme.defaultBackgroundAlpha)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

asset color?


if pressed {
let pressedColorDay = UIColor(rgb: color_on_map_icon_background_color_tap_light).withAlphaComponent(StarMapControlTheme.defaultBackgroundAlpha)
let pressedColorNight = UIColor(rgb: color_on_map_icon_background_color_tap_dark).withAlphaComponent(StarMapControlTheme.defaultBackgroundAlpha)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

up

override func layoutSubviews() {
super.layoutSubviews()
guard bounds.width > 0, bounds.height > 0 else { return }
if #available(iOS 26.0, *) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

up

layer.shadowOpacity = 0.35
layer.shadowRadius = 5
layer.shadowOffset = CGSize(width: 0, height: 2)
layer.borderColor = UIColor(rgb: color_on_map_icon_border_color).cgColor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

up

- Add mapButtonBorderColor asset and migrate color constants to asset-based system
- Make AstronomyPluginSettings and nested types Codable for simplified JSON serialization
- Refactor DateTimeSelectionView to use properties instead of setter methods
- Update UI components to use typed icon assets instead of string-based icon names
- Simplify glass background management with weak view references
- Standardize control card theme methods (add border and pressed background)
- Remove redundant manual JSON parsing/serialization code
return
}
UserDefaults.standard.set(string, forKey: Self.storageKey)
UserDefaults.standard.set(object: settings, forKey: storageKey)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This setting should be shared across platforms. Follow the Android implementation


private func getMyDataInsertionOrderMap(_ quickPresetType: StarMapSearchQuickPresetType) -> [String: Int] {
let config = parentStarMapController?.searchStarMapConfig() ?? AstronomyPluginSettings.load().starMap
let config = parentStarMapController?.searchStarMapConfig() ?? plugin.astroSettings.getStarMapConfig()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't use get

.makeProfile()
.makeShared()

private let recentPref: OACommonString = OAAppSettings.sharedManager()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this also configured as .makeGlobal().makeShared() on Android?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does the logic differ from Android?

let dataProvider: AstroDataDbProvider
@objc final class AstronomyPlugin: OAPlugin {
private enum PreferenceId {
static let settings = "astronomy_settings"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Handle Android legacy star_watcher_settings too. Android migrates it to astronomy_settings, and this key may exist in backup/cloud exports. Since this setting is now cross-platform, iOS should register star_watcher_settings as profile/shared and migrate its value to astronomy_settings when the new pref is empty.

…on iOS

Register the legacy profile/shared preference so cloud and file backups can
apply it, then copy into astronomy_settings only when the new pref is empty
(after plugin init and profile import/sync).
Comment thread Sources/Backup/BackupUtils.swift Outdated
let hasProfileItems = items.contains { $0 is OAProfileSettingsItem }
if hasProfileItems,
let plugin = OAPluginsHelper.getPlugin(AstronomyPlugin.self) as? AstronomyPlugin {
plugin.migrateLegacyStarWatcherSettingsIfNeeded()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is migration needed here?

.makeProfile()
.makeShared()

private let recentPref: OACommonString = OAAppSettings.sharedManager()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does the logic differ from Android?

override init() {
super.init()
recentSearchChips = astronomySettingsStorage.getRecentChips()
migrateLegacyStarWatcherSettingsIfNeeded()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You are already performing the migration at startup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed from AstronomyPlugin.init

private let legacySettingsPref: OACommonString = OAAppSettings.sharedManager()
.registerStringPreference(PreferenceId.legacySettings, defValue: "")
.makeProfile()
.makeShared()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will this setting be included in the imported file? If so, .makeShared() should be removed


private let recentPref: OACommonString = OAAppSettings.sharedManager()
.registerStringPreference(PreferenceId.recent, defValue: "")
.makeGlobal()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.makeGlobal() ?

applyPillAppearance()
}

func setValue(_ text: String) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SwiftLint order

layer.borderWidth = nightMode ? 2 : 0
}

override func layoutSubviews() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SwiftLint

nav.navigationBar.prefersLargeTitles = true
searchNavigationController = nav

if UIDevice.current.userInterfaceIdiom == .pad {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OAUtilities.isIPad

let cameraSliderTopConstraint = sliderContainer.topAnchor.constraint(equalTo: cameraButton.bottomAnchor, constant: Layout.contentPadding)
cameraSliderTopConstraint.priority = .defaultHigh
addRoundButton(zoomOutButton,
iconName: "ic_custom_map_zoom_out",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not pass the icon from the asset catalog directly?

setNeedsDisplay()
}

func getAltitude() -> Double {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't use get

return value
}

private func commonInit() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SwiftLint order


@objc func showSearchDialog() {
@objc private func showSearchDialog() {
if UIDevice.current.userInterfaceIdiom == .pad, searchViewController != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants