iOS dev 31: folded left-align art setting, folded Duo locked upright, tab bar order stable across fold/unfold
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
150e47a305
commit
1072dde293
7 files changed
+96
-27
No files matched your search
@@ -20,12 +20,31 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
return UISceneConfiguration(name: "Phone", sessionRole: session.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
|
||||
Orientation.mask
|
||||
}
|
||||
|
||||
/// Siri: "Play <album> on Stemify".
|
||||
func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any? {
|
||||
intent is INPlayMediaIntent ? PlayMediaHandler() : nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Folded on the iPhone Duo the app stays upright; everywhere else it turns as usual.
|
||||
enum Orientation {
|
||||
nonisolated(unsafe) static var mask: UIInterfaceOrientationMask = .allButUpsideDown
|
||||
|
||||
@MainActor static func lock(_ upright: Bool) {
|
||||
let m: UIInterfaceOrientationMask = upright ? .portrait : .allButUpsideDown
|
||||
guard m != mask else { return }
|
||||
mask = m
|
||||
for case let scene as UIWindowScene in UIApplication.shared.connectedScenes {
|
||||
scene.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
|
||||
if upright { scene.requestGeometryUpdate(.iOS(interfaceOrientations: .portrait)) { _ in } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
struct StemifyApp: App {
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) private var delegate
|
||||
|
||||
@@ -109,7 +109,7 @@ final class Settings: @unchecked Sendable {
|
||||
"servers", "plexUrl", "plexToken", "plexUser", "plexMachineId", "musicSection", "musicSectionTitle",
|
||||
"stemUrl", "stemToken", "plexAccountToken", "stemRoots", "theme", "accent", "albumColorNowPlaying", "highRefreshRate",
|
||||
"stemQuality", "cacheLimitGb", "downloadsWifiOnly", "downloadSort", "keepStemMix", "masterVolume", "tabLayout",
|
||||
"karaokeVocals", "karaokeSoftDb", "playbackSpeed", "stemsOnly", "noStems", "precacheCount", "hiddenNowPlaying", "presets", "presetOrder", "hiddenPresets", "lockedPreset", "webStations", "lockScreenMix", "swipeUpQueue", "acapella", "crossfadeSec", "sweetFades",
|
||||
"karaokeVocals", "karaokeSoftDb", "playbackSpeed", "stemsOnly", "noStems", "precacheCount", "hiddenNowPlaying", "presets", "presetOrder", "hiddenPresets", "lockedPreset", "webStations", "lockScreenMix", "swipeUpQueue", "acapella", "crossfadeSec", "sweetFades", "foldedArtLeft",
|
||||
]
|
||||
|
||||
private func read<T>(_ kp: KeyPath<Settings, T>, _ key: String, _ def: T) -> T {
|
||||
@@ -220,6 +220,8 @@ final class Settings: @unchecked Sendable {
|
||||
var swipeUpQueue: Bool { get { read(\.swipeUpQueue, "swipeUpQueue", true) } set { write(\.swipeUpQueue, "swipeUpQueue", newValue, true) } }
|
||||
var lockScreenMix: Bool { get { read(\.lockScreenMix, "lockScreenMix", false) } set { write(\.lockScreenMix, "lockScreenMix", newValue, false) } }
|
||||
var albumColorNowPlaying: Bool { get { read(\.albumColorNowPlaying, "albumColorNowPlaying", false) } set { write(\.albumColorNowPlaying, "albumColorNowPlaying", newValue, false) } }
|
||||
/// Folded iPhone Duo: Now Playing's art sits at the left instead of centred.
|
||||
var foldedArtLeft: Bool { get { read(\.foldedArtLeft, "foldedArtLeft", false) } set { write(\.foldedArtLeft, "foldedArtLeft", newValue, false) } }
|
||||
var highRefreshRate: Bool { get { read(\.highRefreshRate, "highRefreshRate", true) } set { write(\.highRefreshRate, "highRefreshRate", newValue, true) } }
|
||||
|
||||
var stemQuality: StemQuality { get { readEnum(\.stemQuality, "stemQuality", .High) } set { writeEnum(\.stemQuality, "stemQuality", newValue, .High) } }
|
||||
|
||||
@@ -120,9 +120,24 @@ final class Ui {
|
||||
/// Split only: brings the stems and queue (or the lyrics) back beside Now Playing.
|
||||
func showDeck(_ page: DeckPage? = nil) { deck = true; if let page { deckPage = page } }
|
||||
|
||||
/// This phone has shown the Duo's folded status column at least once (saved).
|
||||
private var duo = UserDefaults.standard.bool(forKey: "duoSeen")
|
||||
/// Folded iPhone Duo: the outer display, kept upright.
|
||||
var folded: Bool { duo && !split }
|
||||
|
||||
/// Called with the window's side insets. Upright, only the folded Duo has a trailing one.
|
||||
func sawInsets(trailing: CGFloat, upright: Bool) {
|
||||
if !duo && upright && !split && trailing > 20 {
|
||||
duo = true
|
||||
UserDefaults.standard.set(true, forKey: "duoSeen")
|
||||
}
|
||||
Orientation.lock(folded)
|
||||
}
|
||||
|
||||
func setSplit(_ on: Bool) {
|
||||
guard on != split else { return }
|
||||
split = on
|
||||
Orientation.lock(folded)
|
||||
if on {
|
||||
nowPlayingOpen = false
|
||||
}
|
||||
|
||||
@@ -11,28 +11,10 @@ struct RootView: View {
|
||||
var body: some View {
|
||||
let s = g.settings
|
||||
let p = Palette.of(s.theme, s.accent)
|
||||
TabView(selection: Binding(get: { ui.showsDeck ? BarItem.deck : .tab(ui.tab) },
|
||||
set: { if case .tab(let t) = $0 { ui.selectTab(t) } else { ui.showDeck() } })) {
|
||||
// Unfolded with something playing, Now Playing leads the bar: the deck (stems, lyrics,
|
||||
// queue, EQ) on this side of the hinge, the player docked on the other.
|
||||
if ui.hasDeckTab {
|
||||
DuoPane { NowPlayingDeck() }
|
||||
.tabItem { Label("Now Playing", systemImage: "waveform") }
|
||||
.tag(BarItem.deck)
|
||||
}
|
||||
ForEach(ui.tabs, id: \.self) { t in
|
||||
DuoPane {
|
||||
NavigationStack(path: ui.path(t)) {
|
||||
root(t).miniPlayerRoom()
|
||||
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
|
||||
}
|
||||
.modifier(FloatingMiniPlayer())
|
||||
}
|
||||
.tabItem { Label(t.rawValue, systemImage: t.icon) }
|
||||
.tag(BarItem.tab(t))
|
||||
}
|
||||
}
|
||||
bar
|
||||
.modifier(GlassMiniPlayerHost())
|
||||
// Folded on the Duo the app stays upright (the window's trailing inset gives the Duo away).
|
||||
.onGeometryChange(for: CGFloat.self) { $0.safeAreaInsets.trailing } action: { ui.sawInsets(trailing: $0, upright: vSize == .regular) }
|
||||
.background(p.bg.ignoresSafeArea())
|
||||
.onChange(of: ui.tabs) { _, _ in ui.ensureValidTab() }
|
||||
.fullScreenCover(isPresented: Binding(get: { ui.nowPlayingOpen }, set: { ui.nowPlayingOpen = $0 })) {
|
||||
@@ -53,8 +35,53 @@ struct RootView: View {
|
||||
.tint(p.accent)
|
||||
}
|
||||
|
||||
@Environment(\.verticalSizeClass) private var vSize
|
||||
|
||||
private enum BarItem: Hashable { case deck, tab(Tab) }
|
||||
|
||||
private var selection: Binding<BarItem> {
|
||||
Binding(get: { ui.showsDeck ? BarItem.deck : .tab(ui.tab) },
|
||||
set: { if case .tab(let t) = $0 { ui.selectTab(t) } else { ui.showDeck() } })
|
||||
}
|
||||
|
||||
/// Unfolded with something playing, Now Playing leads the bar: the deck (stems, lyrics, queue,
|
||||
/// EQ) on this side of the hinge, the player docked on the other. On iOS 18 every item stays in
|
||||
/// the bar and only hides, so folding and unfolding can't shuffle the order.
|
||||
@ViewBuilder private var bar: some View {
|
||||
if #available(iOS 18, *) {
|
||||
let shown = ui.tabs
|
||||
TabView(selection: selection) {
|
||||
SwiftUI.Tab("Now Playing", systemImage: "waveform", value: BarItem.deck) { DuoPane { NowPlayingDeck() } }
|
||||
.hidden(!ui.hasDeckTab)
|
||||
ForEach(Tab.layout(g.settings.tabLayout), id: \.self) { t in
|
||||
SwiftUI.Tab(t.rawValue, systemImage: t.icon, value: BarItem.tab(t)) { page(t) }
|
||||
.hidden(!shown.contains(t))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TabView(selection: selection) {
|
||||
if ui.hasDeckTab {
|
||||
DuoPane { NowPlayingDeck() }
|
||||
.tabItem { Label("Now Playing", systemImage: "waveform") }
|
||||
.tag(BarItem.deck)
|
||||
}
|
||||
ForEach(ui.tabs, id: \.self) { t in
|
||||
page(t).tabItem { Label(t.rawValue, systemImage: t.icon) }.tag(BarItem.tab(t))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func page(_ t: Tab) -> some View {
|
||||
DuoPane {
|
||||
NavigationStack(path: ui.path(t)) {
|
||||
root(t).miniPlayerRoom()
|
||||
.navigationDestination(for: Route.self) { destination($0).miniPlayerRoom() }
|
||||
}
|
||||
.modifier(FloatingMiniPlayer())
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private func root(_ t: Tab) -> some View {
|
||||
switch t {
|
||||
case .Library: LibraryHome()
|
||||
|
||||
@@ -201,7 +201,8 @@ struct NowPlayingScreen: View {
|
||||
@ViewBuilder
|
||||
private func panelView(_ track: Track, header: Bool) -> some View {
|
||||
switch panel {
|
||||
case .Art: ArtPanel(thumb: track.thumb, playing: g.playback.playWhenReady, inset: header || !tight ? artInset : 12).contentShape(Rectangle())
|
||||
case .Art: ArtPanel(thumb: track.thumb, playing: g.playback.playWhenReady, inset: header || !tight ? artInset : 12,
|
||||
leading: folded && g.settings.foldedArtLeft).contentShape(Rectangle())
|
||||
case .Mixer: VStack(spacing: 0) { if header { mini(track) }; MixerPanel(spread: folded) }
|
||||
case .Queue: VStack(spacing: 0) { if header { mini(track) }; QueuePanel(close: { show(.Queue) }) }
|
||||
case .Lyrics: VStack(spacing: 0) { if header { mini(track) }; LyricsPanel(track: track) }
|
||||
@@ -493,14 +494,16 @@ private struct ArtPanel: View {
|
||||
let thumb: String?
|
||||
let playing: Bool
|
||||
var inset: CGFloat = 28
|
||||
/// Settings > Appearance, folded Duo only: art against the left edge.
|
||||
var leading = false
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
let side = max(min(geo.size.width, geo.size.height), 1)
|
||||
Artwork(thumb: thumb, size: side, corner: 12)
|
||||
.shadow(color: .black.opacity(playing ? 0.35 : 0.15), radius: playing ? 24 : 10, y: 10)
|
||||
.scaleEffect(playing ? 1 : 0.82)
|
||||
.scaleEffect(playing ? 1 : 0.82, anchor: leading ? .leading : .center)
|
||||
.animation(.spring(response: 0.45, dampingFraction: 0.62), value: playing)
|
||||
.frame(width: geo.size.width, height: geo.size.height)
|
||||
.frame(width: geo.size.width, height: geo.size.height, alignment: leading ? .leading : .center)
|
||||
}
|
||||
.padding(.horizontal, inset).padding(.vertical, 8)
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,10 @@ struct AppearanceScreen: View {
|
||||
Toggle(isOn: $s.albumColorNowPlaying) { Text("Album Colour Background").foregroundStyle(c.label) }
|
||||
.tint(Color(hex: 0x34C759))
|
||||
.themedRow()
|
||||
} header: { Header(text: "Now Playing") } footer: { Footer(text: "Paints the Now Playing screen in one solid colour taken from the album art.") }
|
||||
Toggle(isOn: $s.foldedArtLeft) { Text("Left-Align Art When Folded").foregroundStyle(c.label) }
|
||||
.tint(Color(hex: 0x34C759))
|
||||
.themedRow()
|
||||
} header: { Header(text: "Now Playing") } footer: { Footer(text: "Album Colour paints the Now Playing screen in one solid colour taken from the album art. Left-Align moves the art to the left edge on the folded iPhone Duo.") }
|
||||
Section {
|
||||
Toggle(isOn: $s.acapella) { Text("Spell It “Acapella”").foregroundStyle(c.label) }
|
||||
.tint(Color(hex: 0x34C759))
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ settings:
|
||||
# iOS needs a plain number for the bundle version; the label is what the app and releases show.
|
||||
MARKETING_VERSION: "0.9.0"
|
||||
VERSION_LABEL: "0.9.0"
|
||||
CURRENT_PROJECT_VERSION: "30"
|
||||
CURRENT_PROJECT_VERSION: "31"
|
||||
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
|
||||
APP_ID: org.cdnutter.stemify
|
||||
APP_NAME: Stemify
|
||||
|
||||
Reference in new issue
Block a user