Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b10528d69c | ||
|
|
42f5eddb36 |
No files matched your search
@@ -315,11 +315,14 @@ struct HingeEdge: ViewModifier {
|
||||
struct Page<Content: View>: View {
|
||||
let title: String
|
||||
var large = true
|
||||
/// Moves the content up into an empty nav bar.
|
||||
var pullUp: CGFloat = 0
|
||||
@ViewBuilder let content: () -> Content
|
||||
@Environment(\.palette) private var p
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 0) { content() }
|
||||
.padding(.top, -pullUp)
|
||||
.padding(.bottom, 24)
|
||||
}
|
||||
.modifier(HingeEdge())
|
||||
|
||||
@@ -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() } }
|
||||
|
||||
@@ -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
|
||||
@@ -140,7 +143,7 @@ struct StemPlaylistScreen: View {
|
||||
.navigationTitle(pl.title)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
} else {
|
||||
Page(title: pl.title, large: false) {
|
||||
Page(title: pl.title, large: false, pullUp: BAR_PULL) {
|
||||
header(pl)
|
||||
if pl.items.isEmpty {
|
||||
EmptyState(icon: "slider.horizontal.3", title: "No Songs",
|
||||
@@ -161,7 +164,7 @@ struct StemPlaylistScreen: View {
|
||||
else { MoreMenu(items: moreItems(pl)) }
|
||||
}
|
||||
}
|
||||
.modifier(SplitHidesTitle())
|
||||
.modifier(SplitHidesTitle(bare: !editing))
|
||||
}
|
||||
|
||||
private func header(_ pl: StemPlaylist) -> some View {
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +279,7 @@ struct PlaylistScreen: View {
|
||||
.navigationTitle(title)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
} else {
|
||||
Page(title: title, large: false) {
|
||||
Page(title: title, large: false, pullUp: BAR_PULL) {
|
||||
header(list)
|
||||
Loaded(state: tracks, retry: { reload += 1 }) { list in
|
||||
ForEach(Array(list.enumerated()), id: \.element.id) { i, t in
|
||||
@@ -273,7 +297,7 @@ struct PlaylistScreen: View {
|
||||
else { MoreMenu(items: moreItems(list)) }
|
||||
}
|
||||
}
|
||||
.modifier(SplitHidesTitle())
|
||||
.modifier(SplitHidesTitle(bare: !editing))
|
||||
.task(id: reload) {
|
||||
await LoadState.load($tracks) { try await g.plex.playlistTracks(playlist.ratingKey) }
|
||||
}
|
||||
@@ -402,11 +426,16 @@ struct SearchScreen: View {
|
||||
}
|
||||
|
||||
/// Split at the Duo's hinge the pane's own header already names the playlist, so the bar drops the title.
|
||||
/// How far a playlist page's header rides up into the empty nav bar, between back and •••.
|
||||
private let BAR_PULL: CGFloat = 40
|
||||
|
||||
/// Hides the bar title in split view, and while [bare] (the header already shows it).
|
||||
private struct SplitHidesTitle: ViewModifier {
|
||||
var bare = false
|
||||
@Environment(Ui.self) private var ui
|
||||
func body(content: Content) -> some View {
|
||||
content.toolbar {
|
||||
if ui.split { ToolbarItem(placement: .principal) { Color.clear.frame(width: 1, height: 1) } }
|
||||
if ui.split || bare { ToolbarItem(placement: .principal) { Color.clear.frame(width: 1, height: 1) } }
|
||||
}
|
||||
}
|
||||
}
|
||||
+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.10.1"
|
||||
VERSION_LABEL: "0.10.1"
|
||||
CURRENT_PROJECT_VERSION: "62"
|
||||
CURRENT_PROJECT_VERSION: "64"
|
||||
# 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