Compare commits

...
Author SHA1 Message Date
rootandClaude Opus 5.5 42f5eddb36 Stem playlists: sorting, rename/cover/mix/copy to Plex in long-press menu (build 63)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 11:34:51 -08:00
3 changed files with 55 additions and 24 deletions

No files matched your search

+22 -15
View File
@@ -129,23 +129,30 @@ struct MediaMenu {
{ pl.tracks }, confirm: false)
if pl.items.isEmpty { a = [] }
let lists = g.stemPlaylists
a.append(SheetAction("Rename…", icon: "pencil") {
overlays.prompt("Rename Stem Playlist", nil, initial: pl.title, "Save") { lists.rename(pl.id, $0) }
})
a.append(SheetAction("Change Cover…", icon: "photo") {
var seen = Set<String>()
var acts: [SheetAction] = [
SheetAction("Choose from Photos…", icon: "photo.on.rectangle") {
overlays.pickPhoto { data in
if !lists.setPhotoArt(pl.id, data) { overlays.hud("Couldn't use that photo", "exclamationmark.triangle") }
}
},
SheetAction("Automatic", icon: "wand.and.stars") { lists.setArt(pl.id, nil) },
]
for t in pl.tracks {
guard let th = t.thumb, seen.insert(th).inserted, seen.count <= 20 else { continue }
acts.append(SheetAction(t.album, icon: th == pl.artThumb ? "checkmark" : "photo") { lists.setArt(pl.id, th) })
}
overlays.actions("Choose a Cover", acts)
})
if !pl.items.isEmpty {
a.append(SheetAction("Change Cover…", icon: "photo") {
var seen = Set<String>()
var acts: [SheetAction] = [
SheetAction("Choose from Photos…", icon: "photo.on.rectangle") {
overlays.pickPhoto { data in
if !lists.setPhotoArt(pl.id, data) { overlays.hud("Couldn't use that photo", "exclamationmark.triangle") }
}
},
SheetAction("Automatic", icon: "wand.and.stars") { lists.setArt(pl.id, nil) },
]
for t in pl.tracks {
guard let th = t.thumb, seen.insert(th).inserted, seen.count <= 20 else { continue }
acts.append(SheetAction(t.album, icon: th == pl.artThumb ? "checkmark" : "photo") { lists.setArt(pl.id, th) })
}
overlays.actions("Choose a Cover", acts)
a.append(SheetAction("Set Mix for All Songs…", icon: "slider.horizontal.3") {
chooseMix(pl.tracks) { m in lists.setItems(pl.id, pl.items.map { var it = $0; it.mix = MixPresets.normalized(m); return it }) }
})
a.append(SheetAction("Copy to Plex Playlist…", icon: "doc.on.doc") { newPlaylist(pl.tracks) { ui.playlistEdits += 1 } })
}
a.append(SheetAction("Delete Stem Playlist", icon: "trash", destructive: true) {
overlays.confirm("Delete “\(pl.title)”?", "Stem playlists are only on this device.", "Delete") { lists.delete(pl.id); if onPage { ui.pop() } }
+32 -8
View File
@@ -10,6 +10,8 @@ struct PlaylistsScreen: View {
@State private var reload = 0
@AppStorage("playlistKind") private var kind = PlaylistKind.Plex
private let sort = SortState("playlists", PLAYLIST_SORTS)
private let stemSort = SortState("stemPlaylists", STEM_PLAYLIST_SORTS)
@State private var shuffleSeed = 0
private var g: AppGraph { .shared }
var body: some View {
@@ -31,7 +33,7 @@ struct PlaylistsScreen: View {
}
}
} else {
let stems = g.stemPlaylists.lists
let stems = g.stemPlaylists.lists.sorted(stemSort, seed: shuffleSeed)
if stems.isEmpty {
EmptyState(icon: "slider.horizontal.3", title: "No Stem Playlists",
message: "Each song plays with its own mix, like an instrumental or a cappella. Hold any song and choose “Add to Stem Playlist”, or copy a Plex playlist with +.")
@@ -42,11 +44,12 @@ struct PlaylistsScreen: View {
}
}
.toolbar {
if kind == .Plex { ToolbarItem(placement: .topBarTrailing) { SortMenu(sort: sort) } }
ToolbarItem(placement: .topBarTrailing) { SortMenu(sort: kind == .Plex ? sort : stemSort) }
ToolbarItem(placement: .topBarTrailing) {
Button { kind == .Plex ? newPlaylist() : newStemPlaylist() } label: { Image(systemName: "plus") }
}
}
.onChange(of: stemSort.token) { shuffleSeed += 1 }
.task(id: "\(g.settings.libraryKey)|\(sort.token)|\(reload)|\(ui.playlistEdits)") {
// /playlists may not take sort=random, so Random shuffles here.
let random = sort.option.random
@@ -180,15 +183,36 @@ struct StemPlaylistScreen: View {
}
private func moreItems(_ pl: StemPlaylist) -> [SheetAction] {
let lists = g.stemPlaylists
let edit = pl.items.isEmpty ? [] : [SheetAction("Edit Songs", icon: "list.bullet") { items = pl.items; editing = true }]
let rename = SheetAction("Rename…", icon: "pencil") {
ui.overlays.prompt("Rename Stem Playlist", nil, initial: pl.title, "Save") { lists.rename(pl.id, $0) }
return ui.menu.stemPlaylist(pl, extra: edit, onPage: true)
}
}
/// Stem playlists live on the device, so they sort here.
let STEM_PLAYLIST_SORTS = [
SortOption(title: "Title", key: "title", up: "A to Z", down: "Z to A"),
SortOption(title: "Date Added", key: "created", desc: true, up: "Oldest First", down: "Newest First"),
SortOption(title: "Last Updated", key: "updated", desc: true, up: "Oldest First", down: "Newest First"),
SortOption(title: "Songs", key: "count", desc: true, up: "Fewest First", down: "Most First"),
SortOption(title: "Duration", key: "duration", desc: true, up: "Shortest First", down: "Longest First"),
SortOption(title: "Random", key: "random", up: "Shuffled", down: "Shuffled"),
]
extension [StemPlaylist] {
func sorted(_ sort: SortState, seed: Int) -> [StemPlaylist] {
let o = sort.option
if o.random {
return map { ($0, ($0.id + "\(seed)").hashValue) }.sorted { $0.1 < $1.1 }.map(\.0)
}
let mixAll = SheetAction("Set Mix for All Songs…", icon: "slider.horizontal.3") {
ui.menu.chooseMix(pl.tracks) { m in lists.setItems(pl.id, pl.items.map { var it = $0; it.mix = MixPresets.normalized(m); return it }) }
let asc: [StemPlaylist]
switch o.key {
case "created": asc = sorted { $0.created < $1.created }
case "updated": asc = sorted { $0.updated < $1.updated }
case "count": asc = sorted { $0.items.count < $1.items.count }
case "duration": asc = sorted { $0.durationMs < $1.durationMs }
default: asc = sorted { $0.title.localizedStandardCompare($1.title) == .orderedAscending }
}
return ui.menu.stemPlaylist(pl, extra: edit + (pl.items.isEmpty ? [rename] : [rename, mixAll]), onPage: true)
return sort.descending ? asc.reversed() : asc
}
}
+1 -1
View File
@@ -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.10.1"
VERSION_LABEL: "0.10.1"
CURRENT_PROJECT_VERSION: "62"
CURRENT_PROJECT_VERSION: "63"
# Dev builds override these (build-ipa.sh dev) so they install next to the release app.
APP_ID: org.cdnutter.stemify
APP_NAME: Stemify