mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
- Add personal pins (My sessions), global/project pin separation, H5 running/pending and active/idle buckets, and collapsible project groups with counts and selected-row expansion. - Add local personal pin storage and list-specific display metrics. - Add Settings > Appearance list text size (80-130%) and CLI/code font size (9-17 pt), with Dynamic Type still applied. - Keep search flat and filters force groups open; shared/archived/status detail/preview-fold remain out of scope. - Bump the local build to 14. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
55 lines
2.1 KiB
Swift
55 lines
2.1 KiB
Swift
import Foundation
|
|
import Observation
|
|
|
|
/// User-adjustable display sizes, independent of Dynamic Type.
|
|
///
|
|
/// The web sidebar exposes a global font scale and a terminal font size. iOS
|
|
/// keeps the scales app-local and applies the list scale only to the session
|
|
/// list; the code scale applies to terminal-styled output and code blocks.
|
|
@MainActor @Observable
|
|
public final class DisplayPrefs {
|
|
public static let listFontScaleKey = "settings.sessionListFontScale"
|
|
public static let codeFontSizeKey = "settings.codeFontSize"
|
|
|
|
public static let listFontScales: [Double] = [0.8, 0.9, 1.0, 1.1, 1.2, 1.3]
|
|
public static let codeFontSizes: [Double] = [9, 11, 13, 15, 17]
|
|
|
|
public static let defaultListFontScale = 1.0
|
|
public static let defaultCodeFontSize = 13.0
|
|
|
|
public private(set) var listFontScale: Double
|
|
public private(set) var codeFontSize: Double
|
|
|
|
private let defaults: UserDefaults
|
|
|
|
public init(defaults: UserDefaults = .standard) {
|
|
self.defaults = defaults
|
|
let storedScale = defaults.object(forKey: Self.listFontScaleKey) as? Double
|
|
self.listFontScale = Self.validScale(storedScale) ?? Self.defaultListFontScale
|
|
let storedCode = defaults.object(forKey: Self.codeFontSizeKey) as? Double
|
|
self.codeFontSize = Self.validCodeSize(storedCode) ?? Self.defaultCodeFontSize
|
|
}
|
|
|
|
public func setListFontScale(_ value: Double) {
|
|
guard let value = Self.validScale(value) else { return }
|
|
listFontScale = value
|
|
defaults.set(value, forKey: Self.listFontScaleKey)
|
|
}
|
|
|
|
public func setCodeFontSize(_ value: Double) {
|
|
guard let value = Self.validCodeSize(value) else { return }
|
|
codeFontSize = value
|
|
defaults.set(value, forKey: Self.codeFontSizeKey)
|
|
}
|
|
|
|
private static func validScale(_ value: Double?) -> Double? {
|
|
guard let value, listFontScales.contains(value) else { return nil }
|
|
return value
|
|
}
|
|
|
|
private static func validCodeSize(_ value: Double?) -> Double? {
|
|
guard let value, codeFontSizes.contains(value) else { return nil }
|
|
return value
|
|
}
|
|
}
|