Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac0e962105 | ||
|
|
e02428ab70 | ||
|
|
9f68aa588b | ||
|
|
406895a3f0 | ||
|
|
02539d72b1 | ||
|
|
71134ff322 | ||
|
|
d248abf143 | ||
|
|
2dca5467db |
No files matched your search
@@ -1,4 +1,9 @@
|
|||||||
### ⚠️ THIS PROJECT WAS ENTIRELY VIBECODED AND IS SLOP. DO NOT PROCEED IF YOU DO NOT ALIGN WITH THESE VALUES. DO NOT COMPLAIN ABOUT IT IN PULL RELEASES, ISSUES, ETC. UNLESS THERE ARE SEVERE SECURITY RISKS. THEY WILL BE REMOVED. PROCEED AT YOUR OWN RISK! ⚠️
|
> [!CAUTION]
|
||||||
|
> This project heavily used agentic coding practices. It is not recommended to use this for production and should be heavily monitored prior to any implementation. If you do not align with agentic-coding values, do not use this application.
|
||||||
|
|
||||||
|
> The model(s) used: **Claude Opus 5.5, Claude Sonnet 5.5**
|
||||||
|
|
||||||
|
> AI contribution: **99%**, Human contribution: **1%**
|
||||||
|
|
||||||
# Stemify
|
# Stemify
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ final class AppGraph {
|
|||||||
mediaSession = URLSession(configuration: m)
|
mediaSession = URLSession(configuration: m)
|
||||||
|
|
||||||
plex = PlexClient(http: apiHttp, settings: settings)
|
plex = PlexClient(http: apiHttp, settings: settings)
|
||||||
|
let plex = plex
|
||||||
|
// Left home or joined Wi-Fi: the saved Plex address may be dead now. Give the new link a moment first.
|
||||||
|
net.onChange {
|
||||||
|
Task.detached {
|
||||||
|
try? await Task.sleep(nanoseconds: 1_500_000_000)
|
||||||
|
await plex.reroute("network changed")
|
||||||
|
}
|
||||||
|
}
|
||||||
reach = HomeReach(settings: settings, net: net)
|
reach = HomeReach(settings: settings, net: net)
|
||||||
let reach = reach
|
let reach = reach
|
||||||
carHttp.forceCache = { !reach.lastKnown }
|
carHttp.forceCache = { !reach.lastKnown }
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
|
|||||||
enum Orientation {
|
enum Orientation {
|
||||||
nonisolated(unsafe) static var mask: UIInterfaceOrientationMask = .allButUpsideDown
|
nonisolated(unsafe) static var mask: UIInterfaceOrientationMask = .allButUpsideDown
|
||||||
|
|
||||||
@MainActor static func lock(_ upright: Bool) {
|
/// Folded Duo: portrait only. Unfolded Duo: landscape only. Anything else turns freely.
|
||||||
let m: UIInterfaceOrientationMask = upright ? .portrait : .allButUpsideDown
|
@MainActor static func lock(_ m: UIInterfaceOrientationMask) {
|
||||||
guard m != mask else { return }
|
guard m != mask else { return }
|
||||||
mask = m
|
mask = m
|
||||||
for case let scene as UIWindowScene in UIApplication.shared.connectedScenes {
|
for case let scene as UIWindowScene in UIApplication.shared.connectedScenes {
|
||||||
scene.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
|
scene.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
|
||||||
if upright { scene.requestGeometryUpdate(.iOS(interfaceOrientations: .portrait)) { _ in } }
|
if m != .allButUpsideDown { scene.requestGeometryUpdate(.iOS(interfaceOrientations: m)) { _ in } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,7 @@ struct StemifyApp: App {
|
|||||||
AppActivity.setPhone(p != .background)
|
AppActivity.setPhone(p != .background)
|
||||||
guard p == .active else { return }
|
guard p == .active else { return }
|
||||||
AppGraph.shared.eq.refreshRoute()
|
AppGraph.shared.eq.refreshRoute()
|
||||||
|
Task.detached { await AppGraph.shared.plex.reroute("foreground") }
|
||||||
// Keep downloaded playlists in step with the server, like Plexamp.
|
// Keep downloaded playlists in step with the server, like Plexamp.
|
||||||
Task { await AppGraph.shared.downloads.refresh() }
|
Task { await AppGraph.shared.downloads.refresh() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,9 +722,19 @@ final class PlaybackManager: StemEngineListener, @unchecked Sendable {
|
|||||||
|
|
||||||
private func openDetached(_ track: Track, _ startMs: Int64) async throws -> (TrackSession, StemEntry?) {
|
private func openDetached(_ track: Track, _ startMs: Int64) async throws -> (TrackSession, StemEntry?) {
|
||||||
// Plain Plex files need a playback session first, or a Remote Access upload limit fails them.
|
// Plain Plex files need a playback session first, or a Remote Access upload limit fails them.
|
||||||
var stream: URL?
|
let plain = stems.find(track) == nil && !cache.isComplete(Self.plexKey(track))
|
||||||
if stems.find(track) == nil, !cache.isComplete(Self.plexKey(track)) { stream = await plex.streamUrl(track) }
|
let stream = plain ? await plex.streamUrl(track) : nil
|
||||||
return try await withCheckedThrowingContinuation { [stream] cont in
|
do {
|
||||||
|
return try await openOn(track, startMs, stream)
|
||||||
|
} catch {
|
||||||
|
// A dead saved address (left home, network changed): pick a working one and try once more.
|
||||||
|
guard plain, !Task.isCancelled, await plex.reroute("stream failed") else { throw error }
|
||||||
|
return try await openOn(track, startMs, await plex.streamUrl(track))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func openOn(_ track: Track, _ startMs: Int64, _ stream: URL?) async throws -> (TrackSession, StemEntry?) {
|
||||||
|
try await withCheckedThrowingContinuation { cont in
|
||||||
DispatchQueue.global(qos: .userInitiated).async { [self] in
|
DispatchQueue.global(qos: .userInitiated).async { [self] in
|
||||||
cont.resume(with: Result { try open(track, startMs, stream: stream) })
|
cont.resume(with: Result { try open(track, startMs, stream: stream) })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ struct MediaServer: Codable, Hashable, Identifiable {
|
|||||||
var machineId = ""
|
var machineId = ""
|
||||||
var sections: [String] = []
|
var sections: [String] = []
|
||||||
var sectionTitles = ""
|
var sectionTitles = ""
|
||||||
|
/// Every address plex.tv lists for this server, best first (local, remote, relay).
|
||||||
|
/// Optional so servers saved before it still decode.
|
||||||
|
var connections: [String]? = nil
|
||||||
|
|
||||||
var signedIn: Bool { !token.isEmpty }
|
var signedIn: Bool { !token.isEmpty }
|
||||||
var ready: Bool { signedIn && !sections.isEmpty }
|
var ready: Bool { signedIn && !sections.isEmpty }
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ final class PlexClient: @unchecked Sendable {
|
|||||||
private let lock = NSLock()
|
private let lock = NSLock()
|
||||||
private var builtFrom = "\u{0}"
|
private var builtFrom = "\u{0}"
|
||||||
private var built: [MediaSource] = []
|
private var built: [MediaSource] = []
|
||||||
|
private var rerouting = false
|
||||||
|
|
||||||
init(http: Http, settings: Settings) {
|
init(http: Http, settings: Settings) {
|
||||||
self.http = http
|
self.http = http
|
||||||
@@ -285,6 +286,45 @@ final class PlexClient: @unchecked Sendable {
|
|||||||
return box.url
|
return box.url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- address re-picking ------------------------------------------------------------
|
||||||
|
|
||||||
|
/// Re-picks each Plex server's address. Sign-in picks one (a LAN address at home) and it
|
||||||
|
/// used to stick forever, so away from home every stream hit a dead LAN address (TLS error)
|
||||||
|
/// or a relay (503). Probes every known address and keeps the best one that answers;
|
||||||
|
/// when none answer, asks plex.tv for the current list. Returns true if any address changed.
|
||||||
|
@discardableResult
|
||||||
|
func reroute(_ why: String) async -> Bool {
|
||||||
|
lock.lock()
|
||||||
|
if rerouting { lock.unlock(); return false }
|
||||||
|
rerouting = true
|
||||||
|
lock.unlock()
|
||||||
|
defer { lock.lock(); rerouting = false; lock.unlock() }
|
||||||
|
|
||||||
|
let tv = plexTv()
|
||||||
|
var changed = false
|
||||||
|
for srv in settings.servers where srv.kind == .plex && srv.signedIn {
|
||||||
|
var uris = srv.connections ?? []
|
||||||
|
if !uris.contains(srv.base) { uris.append(srv.base) }
|
||||||
|
var best = await tv.firstAlive(uris, machineId: srv.machineId, token: srv.token)
|
||||||
|
var fresh: [String]?
|
||||||
|
if best == nil || srv.connections == nil, !srv.machineId.isEmpty,
|
||||||
|
let r = (try? await tv.resources(token: srv.token))?.first(where: { $0.clientIdentifier == srv.machineId }) {
|
||||||
|
fresh = PlexServer.ranked(r)
|
||||||
|
if best == nil, let f = fresh { best = await tv.firstAlive(f, machineId: srv.machineId, token: srv.token) }
|
||||||
|
}
|
||||||
|
var s = srv
|
||||||
|
if let fresh { s.connections = fresh }
|
||||||
|
if let best { s.url = best }
|
||||||
|
guard s != srv else { continue }
|
||||||
|
if s.url != srv.url {
|
||||||
|
changed = true
|
||||||
|
Log.shared.info("plex", "\(srv.label) (\(why)): \(srv.base) -> \(s.base)")
|
||||||
|
}
|
||||||
|
settings.save(s)
|
||||||
|
}
|
||||||
|
return changed
|
||||||
|
}
|
||||||
|
|
||||||
// ---- sign-in helpers --------------------------------------------------------------
|
// ---- sign-in helpers --------------------------------------------------------------
|
||||||
|
|
||||||
/// A Plex client for plex.tv calls and for a server that isn't saved yet.
|
/// A Plex client for plex.tv calls and for a server that isn't saved yet.
|
||||||
@@ -323,6 +363,7 @@ final class PlexClient: @unchecked Sendable {
|
|||||||
?? settings.servers.first { $0.kind == .plex && $0.machineId.isEmpty && $0.base == h.url.trimmingCharacters(in: CharacterSet(charactersIn: "/")) }
|
?? settings.servers.first { $0.kind == .plex && $0.machineId.isEmpty && $0.base == h.url.trimmingCharacters(in: CharacterSet(charactersIn: "/")) }
|
||||||
var srv = known ?? MediaServer(id: settings.nextServerId(), kind: .plex)
|
var srv = known ?? MediaServer(id: settings.nextServerId(), kind: .plex)
|
||||||
srv.url = h.url
|
srv.url = h.url
|
||||||
|
srv.connections = PlexServer.ranked(h.res)
|
||||||
srv.token = h.res.accessToken.isEmpty ? token : h.res.accessToken
|
srv.token = h.res.accessToken.isEmpty ? token : h.res.accessToken
|
||||||
srv.machineId = h.res.clientIdentifier
|
srv.machineId = h.res.clientIdentifier
|
||||||
srv.user = user
|
srv.user = user
|
||||||
|
|||||||
@@ -375,21 +375,41 @@ final class PlexServer: MediaSource, @unchecked Sendable {
|
|||||||
/// The first address that answers /identity as the expected server, local ones first, relay last.
|
/// The first address that answers /identity as the expected server, local ones first, relay last.
|
||||||
func reach(_ r: PlexResource, userToken: String) async -> String? {
|
func reach(_ r: PlexResource, userToken: String) async -> String? {
|
||||||
let tok = r.accessToken.isEmpty ? userToken : r.accessToken
|
let tok = r.accessToken.isEmpty ? userToken : r.accessToken
|
||||||
let ordered = r.connections.filter { !$0.uri.isEmpty }.sorted { rank($0) < rank($1) }
|
return await firstAlive(Self.ranked(r), machineId: r.clientIdentifier, token: tok)
|
||||||
for c in ordered {
|
|
||||||
let base = c.uri.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
|
|
||||||
guard let u = URL(string: base + "/identity") else { continue }
|
|
||||||
var req = request(u, withToken: false)
|
|
||||||
req.setValue(tok, forHTTPHeaderField: "X-Plex-Token")
|
|
||||||
req.timeoutInterval = 3.5
|
|
||||||
guard let body = try? await http.data(req),
|
|
||||||
let id = try? decode(body).machineIdentifier, id == r.clientIdentifier || r.clientIdentifier.isEmpty else { continue }
|
|
||||||
return base
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func rank(_ c: PlexResource.Connection) -> Int { c.relay ? 2 : (c.local ? 0 : 1) }
|
/// A resource's addresses, local first, then remote, relay last.
|
||||||
|
static func ranked(_ r: PlexResource) -> [String] {
|
||||||
|
r.connections.filter { !$0.uri.isEmpty }
|
||||||
|
.sorted { ($0.relay ? 2 : ($0.local ? 0 : 1)) < ($1.relay ? 2 : ($1.local ? 0 : 1)) }
|
||||||
|
.map { $0.uri.trimmingCharacters(in: CharacterSet(charactersIn: "/")) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Probes every address's /identity at once, straight to the network (the offline cache
|
||||||
|
/// would make a dead LAN address look alive), and returns the earliest one in [uris] that
|
||||||
|
/// answers as [machineId].
|
||||||
|
func firstAlive(_ uris: [String], machineId: String, token: String, timeout: TimeInterval = 4) async -> String? {
|
||||||
|
let bases = uris.map { $0.trimmingCharacters(in: CharacterSet(charactersIn: "/")) }
|
||||||
|
let alive: [Int] = await withTaskGroup(of: Int?.self) { group in
|
||||||
|
for (i, b) in bases.enumerated() {
|
||||||
|
group.addTask { [self] in
|
||||||
|
guard let u = URL(string: b + "/identity") else { return nil }
|
||||||
|
var req = request(u, withToken: false)
|
||||||
|
req.setValue(token, forHTTPHeaderField: "X-Plex-Token")
|
||||||
|
req.timeoutInterval = timeout
|
||||||
|
guard let (body, resp) = try? await http.session.data(for: req),
|
||||||
|
(resp as? HTTPURLResponse)?.statusCode == 200,
|
||||||
|
let id = try? decode(body).machineIdentifier,
|
||||||
|
machineId.isEmpty || id == machineId else { return nil }
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var out: [Int] = []
|
||||||
|
for await i in group { if let i { out.append(i) } }
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
return alive.min().map { bases[$0] }
|
||||||
|
}
|
||||||
|
|
||||||
func checkPin(_ id: Int64) async throws -> PlexPin {
|
func checkPin(_ id: Int64) async throws -> PlexPin {
|
||||||
let req = request(URL(string: "https://plex.tv/api/v2/pins/\(id)")!, withToken: false)
|
let req = request(URL(string: "https://plex.tv/api/v2/pins/\(id)")!, withToken: false)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 246 KiB |
@@ -131,13 +131,24 @@ final class Ui {
|
|||||||
duo = true
|
duo = true
|
||||||
UserDefaults.standard.set(true, forKey: "duoSeen")
|
UserDefaults.standard.set(true, forKey: "duoSeen")
|
||||||
}
|
}
|
||||||
Orientation.lock(folded)
|
lockOrientation()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Split (unfolded) goes landscape at once. Portrait waits a moment and checks again, so a
|
||||||
|
/// frame without a hinge reading mid-rotation can't throw an unfolded phone back upright.
|
||||||
|
private func lockOrientation() {
|
||||||
|
if split { Orientation.lock(.landscape); return }
|
||||||
|
guard folded else { Orientation.lock(.allButUpsideDown); return }
|
||||||
|
Task { @MainActor in
|
||||||
|
try? await Task.sleep(for: .milliseconds(400))
|
||||||
|
if self.folded { Orientation.lock(.portrait) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSplit(_ on: Bool) {
|
func setSplit(_ on: Bool) {
|
||||||
guard on != split else { return }
|
guard on != split else { return }
|
||||||
split = on
|
split = on
|
||||||
Orientation.lock(folded)
|
lockOrientation()
|
||||||
if on {
|
if on {
|
||||||
nowPlayingOpen = false
|
nowPlayingOpen = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,32 +44,32 @@ struct RootView: View {
|
|||||||
set: { if case .tab(let t) = $0 { ui.selectTab(t) } else { ui.showDeck() } })
|
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,
|
/// The bar always holds the same slots. Unfolded with something playing, Now Playing takes
|
||||||
/// EQ) on this side of the hinge, the player docked on the other. On iOS 18 every item stays in
|
/// the place of the last tab before Settings (iOS folds a sixth item into "More"), so folding
|
||||||
/// the bar and only hides, so folding and unfolding can't shuffle the order.
|
/// and unfolding swaps one item in place and nothing else moves.
|
||||||
@ViewBuilder private var bar: some View {
|
private var slots: [BarItem] {
|
||||||
if #available(iOS 18, *) {
|
let all = Tab.layout(g.settings.tabLayout)
|
||||||
let shown = ui.tabs
|
var items = all.map { BarItem.tab($0) }
|
||||||
TabView(selection: selection) {
|
guard ui.hasDeckTab else { return items }
|
||||||
SwiftUI.Tab("Now Playing", systemImage: "waveform", value: BarItem.deck) { DuoPane { NowPlayingDeck() } }
|
if all.count >= Tab.maxVisible, let i = all.lastIndex(where: { $0 != .Settings }) { items[i] = .deck }
|
||||||
.hidden(!ui.hasDeckTab)
|
else { items.insert(.deck, at: all.lastIndex(of: .Settings) ?? items.count) }
|
||||||
ForEach(Tab.layout(g.settings.tabLayout), id: \.self) { t in
|
return items
|
||||||
SwiftUI.Tab(t.rawValue, systemImage: t.icon, value: BarItem.tab(t)) { page(t) }
|
}
|
||||||
.hidden(!shown.contains(t))
|
|
||||||
}
|
private var bar: some View {
|
||||||
}
|
TabView(selection: selection) {
|
||||||
} else {
|
ForEach(Array(slots.enumerated()), id: \.offset) { _, item in
|
||||||
TabView(selection: selection) {
|
switch item {
|
||||||
if ui.hasDeckTab {
|
case .deck:
|
||||||
DuoPane { NowPlayingDeck() }
|
DuoPane { NowPlayingDeck() }
|
||||||
.tabItem { Label("Now Playing", systemImage: "waveform") }
|
.tabItem { Label("Now Playing", systemImage: "waveform") }
|
||||||
.tag(BarItem.deck)
|
.tag(item)
|
||||||
}
|
case .tab(let t):
|
||||||
ForEach(ui.tabs, id: \.self) { t in
|
page(t).tabItem { Label(t.rawValue, systemImage: t.icon) }.tag(item)
|
||||||
page(t).tabItem { Label(t.rawValue, systemImage: t.icon) }.tag(BarItem.tab(t))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.transaction { $0.animation = nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
private func page(_ t: Tab) -> some View {
|
private func page(_ t: Tab) -> some View {
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ struct NowPlayingScreen: View {
|
|||||||
private func panelView(_ track: Track, header: Bool) -> some View {
|
private func panelView(_ track: Track, header: Bool) -> some View {
|
||||||
switch panel {
|
switch panel {
|
||||||
case .Art: ArtPanel(thumb: track.thumb, playing: g.playback.playWhenReady, inset: header || !tight ? artInset : 12,
|
case .Art: ArtPanel(thumb: track.thumb, playing: g.playback.playWhenReady, inset: header || !tight ? artInset : 12,
|
||||||
leading: folded && g.settings.foldedArtLeft).contentShape(Rectangle())
|
leading: folded && !docked && !ui.split && g.settings.foldedArtLeft).contentShape(Rectangle())
|
||||||
case .Mixer: VStack(spacing: 0) { if header { mini(track) }; MixerPanel(spread: folded) }
|
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 .Queue: VStack(spacing: 0) { if header { mini(track) }; QueuePanel(close: { show(.Queue) }) }
|
||||||
case .Lyrics: VStack(spacing: 0) { if header { mini(track) }; LyricsPanel(track: track) }
|
case .Lyrics: VStack(spacing: 0) { if header { mini(track) }; LyricsPanel(track: track) }
|
||||||
@@ -215,8 +215,8 @@ struct NowPlayingScreen: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func controls(_ track: Track, wide: Bool, width: CGFloat) -> some View {
|
private func controls(_ track: Track, wide: Bool, width: CGFloat) -> some View {
|
||||||
// Folded with a panel open, the controls give the panel some of their spacing.
|
// Folded, the controls keep the tight stems-panel spacing on every panel, so the art gets the room.
|
||||||
let snug = folded && panel != .Art
|
let snug = folded
|
||||||
let pm = g.playback
|
let pm = g.playback
|
||||||
let c = tint.map { base.tinted($0) } ?? base
|
let c = tint.map { base.tinted($0) } ?? base
|
||||||
let pad: CGFloat = wide && tight ? 14 : hPad
|
let pad: CGFloat = wide && tight ? 14 : hPad
|
||||||
@@ -235,7 +235,7 @@ struct NowPlayingScreen: View {
|
|||||||
Spacer(minLength: 8)
|
Spacer(minLength: 8)
|
||||||
EllipsisButton(items: ui.menu.track(track))
|
EllipsisButton(items: ui.menu.track(track))
|
||||||
}
|
}
|
||||||
.padding(.top, tight ? 8 : 14)
|
.padding(.top, tight || snug ? 8 : 14)
|
||||||
.transition(.opacity.combined(with: .move(edge: .top)))
|
.transition(.opacity.combined(with: .move(edge: .top)))
|
||||||
}
|
}
|
||||||
ProgressVolumeBar(played: c.label, unplayed: c.label3, centerLabel: badge(track))
|
ProgressVolumeBar(played: c.label, unplayed: c.label3, centerLabel: badge(track))
|
||||||
@@ -742,7 +742,8 @@ private struct MixerPanel: View {
|
|||||||
// Spread spare height across the stem rows instead of leaving it all at the bottom.
|
// Spread spare height across the stem rows instead of leaving it all at the bottom.
|
||||||
let count = CGFloat(max(names.count, 1))
|
let count = CGFloat(max(names.count, 1))
|
||||||
// Rows shrink to fit every stem before anything has to scroll (the folded outer display is short).
|
// Rows shrink to fit every stem before anything has to scroll (the folded outer display is short).
|
||||||
let rowH = roomy ? min(80, max(Self.roomyMin, (geo.size.height - Self.roomyChrome) / count))
|
// Roomy (the unfolded deck), the rows share every point under the chips down to the bottom.
|
||||||
|
let rowH = roomy ? max(Self.roomyMin, (geo.size.height - chipsH - 8) / count)
|
||||||
: min(62, max(spread ? Self.foldedMin : Self.compactMin, (geo.size.height - chipsH - 8) / count))
|
: min(62, max(spread ? Self.foldedMin : Self.compactMin, (geo.size.height - chipsH - 8) / count))
|
||||||
// Gap above the rows that centres them on the whole panel, not just the space under the chips.
|
// Gap above the rows that centres them on the whole panel, not just the space under the chips.
|
||||||
let lead = max(0, (geo.size.height - rowH * count) / 2 - chipsH)
|
let lead = max(0, (geo.size.height - rowH * count) / 2 - chipsH)
|
||||||
@@ -760,7 +761,7 @@ private struct MixerPanel: View {
|
|||||||
HStack(spacing: 8) { saveChips(pm); presetChips(pm, names) }.padding(.horizontal, 24)
|
HStack(spacing: 8) { saveChips(pm); presetChips(pm, names) }.padding(.horizontal, 24)
|
||||||
}
|
}
|
||||||
.scrollIndicators(.hidden)
|
.scrollIndicators(.hidden)
|
||||||
.padding(.horizontal, -24)
|
.padding(.leading, -24).padding(.trailing, roomy ? -6 : -24)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.onGeometryChange(for: CGFloat.self) { $0.size.height } action: { chipsH = $0 }
|
.onGeometryChange(for: CGFloat.self) { $0.size.height } action: { chipsH = $0 }
|
||||||
}
|
}
|
||||||
@@ -774,13 +775,11 @@ private struct MixerPanel: View {
|
|||||||
StemFader(name: name, setting: pm.mix[name] ?? StemSetting(), level: i < levels.count ? levels[i] : 0, enabled: stems, height: rowH, roomy: roomy)
|
StemFader(name: name, setting: pm.mix[name] ?? StemSetting(), level: i < levels.count ? levels[i] : 0, enabled: stems, height: rowH, roomy: roomy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Wide panes keep the faders a sensible length, centred across the panel.
|
|
||||||
.frame(maxWidth: roomy ? 560 : .infinity)
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
}
|
}
|
||||||
Spacer(minLength: 8)
|
Spacer(minLength: 8)
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 24)
|
// Roomy, the faders run right up to the hinge.
|
||||||
|
.padding(.leading, 24).padding(.trailing, roomy ? 6 : 24)
|
||||||
.frame(minHeight: geo.size.height)
|
.frame(minHeight: geo.size.height)
|
||||||
}
|
}
|
||||||
.scrollIndicators(.hidden)
|
.scrollIndicators(.hidden)
|
||||||
@@ -845,7 +844,7 @@ extension MixerPanel {
|
|||||||
|
|
||||||
static let roomyRow: CGFloat = 66
|
static let roomyRow: CGFloat = 66
|
||||||
/// Shortest stacked row: name line, fader and the gap under it.
|
/// Shortest stacked row: name line, fader and the gap under it.
|
||||||
static let roomyMin: CGFloat = 60
|
static let roomyMin: CGFloat = 68
|
||||||
/// Shortest side-by-side row, the fader's own height.
|
/// Shortest side-by-side row, the fader's own height.
|
||||||
static let compactMin: CGFloat = 30
|
static let compactMin: CGFloat = 30
|
||||||
static let foldedMin: CGFloat = 40
|
static let foldedMin: CGFloat = 40
|
||||||
@@ -921,7 +920,7 @@ struct FaderRow<Fader: View, Trailing: View>: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
if stacked {
|
if stacked {
|
||||||
// Bottom-aligned with a gap under, so each name sits clear of the meter above it.
|
// Bottom-aligned with a gap under, so each name sits clear of the meter above it.
|
||||||
VStack(alignment: .leading, spacing: 2) {
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
if let dot { Circle().fill(dot).frame(width: 8, height: 8) }
|
if let dot { Circle().fill(dot).frame(width: 8, height: 8) }
|
||||||
Text(label).font(.subheadline.weight(.semibold)).foregroundStyle(dim ? p.label2 : p.label).lineLimit(1)
|
Text(label).font(.subheadline.weight(.semibold)).foregroundStyle(dim ? p.label2 : p.label).lineLimit(1)
|
||||||
@@ -931,8 +930,8 @@ struct FaderRow<Fader: View, Trailing: View>: View {
|
|||||||
.frame(height: 18)
|
.frame(height: 18)
|
||||||
HStack(spacing: 8) { fader; trailing }
|
HStack(spacing: 8) { fader; trailing }
|
||||||
}
|
}
|
||||||
.padding(.bottom, 4)
|
// Centred in its slot, so tall rows keep even gaps above and below.
|
||||||
.frame(height: height, alignment: .bottom)
|
.frame(height: height)
|
||||||
} else {
|
} else {
|
||||||
row
|
row
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ settings:
|
|||||||
# iOS needs a plain number for the bundle version; the label is what the app and releases show.
|
# iOS needs a plain number for the bundle version; the label is what the app and releases show.
|
||||||
MARKETING_VERSION: "0.9.0"
|
MARKETING_VERSION: "0.9.0"
|
||||||
VERSION_LABEL: "0.9.0"
|
VERSION_LABEL: "0.9.0"
|
||||||
CURRENT_PROJECT_VERSION: "31"
|
CURRENT_PROJECT_VERSION: "37"
|
||||||
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
|
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
|
||||||
APP_ID: org.cdnutter.stemify
|
APP_ID: org.cdnutter.stemify
|
||||||
APP_NAME: Stemify
|
APP_NAME: Stemify
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
"""Run from a venv with resvg-py and pillow: python make-icon.py OUTDIR
|
||||||
|
Stemify app icon: six stem-colored capsules (the app's stem palette) glowing on a deep night background.
|
||||||
|
Usage: make.py OUTDIR -> icon.png, icon-dev.png, icon-dev-dark.png, icon-dev-tinted.png"""
|
||||||
|
import io, sys
|
||||||
|
import resvg_py
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
S = 1024
|
||||||
|
# vocals, drums, bass, guitar, piano, other (PlaybackManager stem colors)
|
||||||
|
STEMS = [0xFF7AB6, 0xFFB547, 0x7C8CFF, 0xFF8A5C, 0xB48CFF, 0x4CD07D]
|
||||||
|
HEIGHTS = [300, 510, 390, 620, 455, 330]
|
||||||
|
W, GAP = 78, 30
|
||||||
|
|
||||||
|
|
||||||
|
def hx(c): return f"#{c:06X}"
|
||||||
|
def mix(c, t, k):
|
||||||
|
a = [(c >> s) & 255 for s in (16, 8, 0)]; b = [(t >> s) & 255 for s in (16, 8, 0)]
|
||||||
|
return "#" + "".join(f"{round(x + (y - x) * k):02X}" for x, y in zip(a, b))
|
||||||
|
|
||||||
|
|
||||||
|
def svg(mode="color", sash=False):
|
||||||
|
tint = mode == "tinted"
|
||||||
|
total = len(STEMS) * W + (len(STEMS) - 1) * GAP
|
||||||
|
x0 = (S - total) / 2
|
||||||
|
cy = S / 2 + 6
|
||||||
|
defs, glow, bars, shine = [], [], [], []
|
||||||
|
for i, (c, h) in enumerate(zip(STEMS, HEIGHTS)):
|
||||||
|
if tint: c = 0xFFFFFF
|
||||||
|
x, y = x0 + i * (W + GAP), cy - h / 2
|
||||||
|
defs.append(f'<linearGradient id="g{i}" x1="0" y1="0" x2="0" y2="1">'
|
||||||
|
f'<stop offset="0" stop-color="{mix(c, 0xFFFFFF, 0.38)}"/>'
|
||||||
|
f'<stop offset="0.55" stop-color="{hx(c)}"/>'
|
||||||
|
f'<stop offset="1" stop-color="{mix(c, 0x000000, 0.18 if not tint else 0.45)}"/></linearGradient>')
|
||||||
|
r = W / 2
|
||||||
|
glow.append(f'<rect x="{x}" y="{y}" width="{W}" height="{h}" rx="{r}" fill="{hx(c)}"/>')
|
||||||
|
bars.append(f'<rect x="{x}" y="{y}" width="{W}" height="{h}" rx="{r}" fill="url(#g{i})"/>')
|
||||||
|
# glassy highlight down the left edge
|
||||||
|
shine.append(f'<rect x="{x + W * 0.2}" y="{y + W * 0.32}" width="{W * 0.17}" height="{max(h * 0.42, 40)}" '
|
||||||
|
f'rx="{W * 0.085}" fill="#FFFFFF" opacity="0.22"/>')
|
||||||
|
|
||||||
|
if tint:
|
||||||
|
bg = '<rect width="1024" height="1024" fill="#000"/>'
|
||||||
|
aura = ""
|
||||||
|
else:
|
||||||
|
bg = ('<radialGradient id="bg" cx="0.5" cy="0.42" r="0.78">'
|
||||||
|
'<stop offset="0" stop-color="#211A3A"/><stop offset="0.55" stop-color="#110E1F"/>'
|
||||||
|
'<stop offset="1" stop-color="#05040A"/></radialGradient>'
|
||||||
|
'<rect width="1024" height="1024" fill="url(#bg)"/>')
|
||||||
|
# soft colored light pooling behind the bars
|
||||||
|
aura = ('<g filter="url(#aura)" opacity="0.55">'
|
||||||
|
f'<circle cx="330" cy="420" r="190" fill="{hx(STEMS[0])}"/>'
|
||||||
|
f'<circle cx="690" cy="400" r="200" fill="{hx(STEMS[4])}"/>'
|
||||||
|
f'<circle cx="520" cy="660" r="210" fill="{hx(STEMS[2])}"/>'
|
||||||
|
f'<circle cx="760" cy="640" r="150" fill="{hx(STEMS[5])}"/>'
|
||||||
|
f'<circle cx="290" cy="650" r="150" fill="{hx(STEMS[1])}"/></g>'
|
||||||
|
'<rect width="1024" height="1024" fill="#05040A" opacity="0.45"/>')
|
||||||
|
|
||||||
|
vignette = ('<radialGradient id="vig" cx="0.5" cy="0.5" r="0.72"><stop offset="0.6" stop-color="#000" stop-opacity="0"/>'
|
||||||
|
'<stop offset="1" stop-color="#000" stop-opacity="0.55"/></radialGradient>'
|
||||||
|
'<rect width="1024" height="1024" fill="url(#vig)"/>') if not tint else ""
|
||||||
|
|
||||||
|
sash_svg = ""
|
||||||
|
if sash:
|
||||||
|
sash_svg = ('<linearGradient id="sash" x1="0" y1="1" x2="1" y2="0">'
|
||||||
|
'<stop offset="0" stop-color="#FF9BD0"/><stop offset="1" stop-color="#C9A8FF"/></linearGradient>'
|
||||||
|
'<g transform="translate(222,222) rotate(-45)">'
|
||||||
|
'<rect x="-420" y="-58" width="840" height="116" fill="url(#sash)"/>'
|
||||||
|
'<line x1="-420" y1="-44" x2="420" y2="-44" stroke="#FFF" stroke-opacity="0.75" stroke-width="5" stroke-dasharray="18 14"/>'
|
||||||
|
'<line x1="-420" y1="44" x2="420" y2="44" stroke="#FFF" stroke-opacity="0.75" stroke-width="5" stroke-dasharray="18 14"/>'
|
||||||
|
'<text x="-30" y="30" text-anchor="middle" font-family="DejaVu Sans" font-weight="bold" font-size="88" '
|
||||||
|
'fill="#3A1F4D" opacity="0.45" transform="translate(4,5)">dev</text>'
|
||||||
|
'<text x="-30" y="30" text-anchor="middle" font-family="DejaVu Sans" font-weight="bold" font-size="88" fill="#FFF">dev</text>'
|
||||||
|
'<path transform="translate(118,-4) scale(2.6)" fill="#FFF" '
|
||||||
|
'd="M0 9 C-9 3 -12 -3 -8 -8 C-5 -11 -1 -10 0 -6 C1 -10 5 -11 8 -8 C12 -3 9 3 0 9 Z"/></g>')
|
||||||
|
|
||||||
|
return f'''<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
|
<defs>{"".join(defs)}
|
||||||
|
<filter id="aura" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="110"/></filter>
|
||||||
|
<filter id="glow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="26"/></filter>
|
||||||
|
<filter id="drop" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="10"/></filter>
|
||||||
|
</defs>
|
||||||
|
{bg}{aura}
|
||||||
|
<g filter="url(#glow)" opacity="{0.25 if tint else 0.7}">{"".join(glow)}</g>
|
||||||
|
<g filter="url(#drop)" opacity="0.5" transform="translate(0,14)">{"".join(g.replace('fill="#', 'fill="#000" data-c="') for g in glow)}</g>
|
||||||
|
<g>{"".join(bars)}</g>
|
||||||
|
<g>{"".join(shine)}</g>
|
||||||
|
{vignette}{sash_svg}
|
||||||
|
</svg>'''
|
||||||
|
|
||||||
|
|
||||||
|
def png(s, path, gray=False):
|
||||||
|
im = Image.open(io.BytesIO(bytes(resvg_py.svg_to_bytes(svg_string=s)))).convert("RGB")
|
||||||
|
(im.convert("L") if gray else im).save(path, optimize=True)
|
||||||
|
|
||||||
|
|
||||||
|
out = sys.argv[1]
|
||||||
|
png(svg(), f"{out}/icon.png")
|
||||||
|
png(svg(sash=True), f"{out}/icon-dev.png")
|
||||||
|
png(svg(sash=True), f"{out}/icon-dev-dark.png")
|
||||||
|
png(svg("tinted", sash=True), f"{out}/icon-dev-tinted.png", gray=True)
|
||||||
|
open(f"{out}/icon.svg", "w").write(svg())
|
||||||