Files
jrshikoku/targets/widget/SharedData.swift
harukin-expo-dev-env d4ad8c005e feat(widget): add Shortcut, Delay Info, and Felica Balance widgets
- Implemented ShortcutWidget for quick access to app features with customizable shortcuts.
- Added DelayInfoWidget to display train delay information fetched from a remote endpoint.
- Created FelicaBalanceWidget to show the balance of Felica-compatible IC cards.
- Introduced OperationInfoWidget for displaying train operation status.
- Set up shared data handling for Felica snapshots between the main app and widget.
- Configured widget assets and entitlements for proper functionality.
- Updated Info.plist and expo-target.config.js for widget deployment.
2026-03-22 11:45:58 +00:00

24 lines
625 B
Swift

import WidgetKit
import SwiftUI
/// App Group ID shared between the main app and widget extension.
let appGroupID = "group.jrshikokuinfo.xprocess.hrkn"
// MARK: - Shared data helpers
struct FelicaSnapshot: Codable {
let balance: Int
let idm: String
let systemCode: String?
let scannedAt: String
}
func sharedDefaults() -> UserDefaults {
UserDefaults(suiteName: appGroupID) ?? .standard
}
func loadFelicaSnapshot() -> FelicaSnapshot? {
guard let data = sharedDefaults().data(forKey: "felicaLastSnapshot") else { return nil }
return try? JSONDecoder().decode(FelicaSnapshot.self, from: data)
}