From ad2a933ef6203597f389fca715a28b8527f8c80b Mon Sep 17 00:00:00 2001 From: astar76 Date: Tue, 27 Oct 2026 23:02:25 -0500 Subject: [PATCH] 1.0.5: chip row margin fix, FlacBox-style widgets with 10-second skips Co-Authored-By: Claude Opus 5.5 --- App/MulberryApp.swift | 2 + App/UI/LibraryView.swift | 3 +- App/UI/PlaylistsView.swift | 1 + Shared/WidgetShared.swift | 18 +++++- VERSION | 2 +- Widget/MulberryWidgets.swift | 113 +++++++++++++++++++---------------- docs/releases/1.0.5.md | 10 ++++ tools/gen-appintents.py | 2 + 8 files changed, 96 insertions(+), 55 deletions(-) create mode 100644 docs/releases/1.0.5.md diff --git a/App/MulberryApp.swift b/App/MulberryApp.swift index 25d4a64..60a127d 100644 --- a/App/MulberryApp.swift +++ b/App/MulberryApp.swift @@ -19,6 +19,8 @@ struct MulberryApp: App { case .shuffle: p.setShuffle(!Prefs.shared.shuffle) case .repeatMode: p.cycleRepeat() case .favourite: if let s = p.current { PlayStats.shared.setFav(s, !PlayStats.shared.fav(s)) } + case .back10: p.seek(max(0, p.position - 10)) + case .forward10: p.seek(p.position + 10) } } IntentRouter.listen() diff --git a/App/UI/LibraryView.swift b/App/UI/LibraryView.swift index 57b3e26..b24f387 100644 --- a/App/UI/LibraryView.swift +++ b/App/UI/LibraryView.swift @@ -29,7 +29,8 @@ struct LibraryView: View { .padding(.horizontal, 16) .padding(.vertical, 10) } - .fixedSize(horizontal: false, vertical: true) // a horizontal ScrollView otherwise grabs spare height + .contentMargins(.bottom, 0, for: .scrollContent) // the root's bottom margin is for vertical lists only + .fixedSize(horizontal: false, vertical: true) content } .surface(p) diff --git a/App/UI/PlaylistsView.swift b/App/UI/PlaylistsView.swift index d705816..1d989f1 100644 --- a/App/UI/PlaylistsView.swift +++ b/App/UI/PlaylistsView.swift @@ -52,6 +52,7 @@ struct PlaylistsView: View { } .padding(.horizontal, 16).padding(.vertical, 12) } + .contentMargins(.bottom, 0, for: .scrollContent) SectionLabel(text: "Smart playlists") ForEach(Self.smart, id: \.key) { sm in NavigationLink(value: LibraryRoute.smart(sm.key)) { diff --git a/Shared/WidgetShared.swift b/Shared/WidgetShared.swift index 7fc63fa..fc516c0 100644 --- a/Shared/WidgetShared.swift +++ b/Shared/WidgetShared.swift @@ -67,7 +67,7 @@ struct NowSnapshot: Codable, Equatable { // build.sh generates Metadata.appintents for these (tools/gen-appintents.py); without it iOS drops the widget. enum MulberryCommand: String { - case toggle, next, previous, shuffle, repeatMode, favourite + case toggle, next, previous, shuffle, repeatMode, favourite, back10, forward10 } /// The app installs a handler at launch; inside the widget extension it stays nil. @@ -113,7 +113,7 @@ enum IntentRouter { /// App side: act on commands posted by the widget extension. @MainActor static func listen() { let center = CFNotificationCenterGetDarwinNotifyCenter() - for c in [MulberryCommand.toggle, .next, .previous, .shuffle, .repeatMode, .favourite] { + for c in [MulberryCommand.toggle, .next, .previous, .shuffle, .repeatMode, .favourite, .back10, .forward10] { CFNotificationCenterAddObserver(center, nil, { _, _, name, _, _ in guard let raw = name?.rawValue as String?, let cmd = MulberryCommand(rawValue: String(raw.dropFirst("com.mulberry.player.cmd.".count))) else { return } @@ -158,6 +158,20 @@ struct RepeatIntent: AudioPlaybackIntent { func perform() async throws -> some IntentResult { await IntentRouter.run(.repeatMode); return .result() } } +@available(iOS 17.0, *) +struct SkipBackIntent: AudioPlaybackIntent { + static var title: LocalizedStringResource = "Back 10 seconds" + init() {} + func perform() async throws -> some IntentResult { await IntentRouter.run(.back10); return .result() } +} + +@available(iOS 17.0, *) +struct SkipForwardIntent: AudioPlaybackIntent { + static var title: LocalizedStringResource = "Forward 10 seconds" + init() {} + func perform() async throws -> some IntentResult { await IntentRouter.run(.forward10); return .result() } +} + @available(iOS 17.0, *) struct FavouriteIntent: AudioPlaybackIntent { static var title: LocalizedStringResource = "Favourite" diff --git a/VERSION b/VERSION index ee90284..90a27f9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.4 +1.0.5 diff --git a/Widget/MulberryWidgets.swift b/Widget/MulberryWidgets.swift index cd15dc1..6ca20f7 100644 --- a/Widget/MulberryWidgets.swift +++ b/Widget/MulberryWidgets.swift @@ -95,34 +95,37 @@ struct CoverCookie: View { } } -struct CtlButton: View { +/// Plain glyph button like FlacBox's widget (no capsule). +struct GlyphButton: View { let intent: I let icon: String let size: CGFloat - let fg: Color - let bg: Color - var wide = false + let color: Color var body: some View { Button(intent: intent) { Image(systemName: icon) - .font(.system(size: size * 0.4, weight: .bold)) - .foregroundColor(fg) - .frame(width: wide ? size * 1.5 : size, height: size) - .background(Capsule().fill(bg)) + .font(.system(size: size, weight: .semibold)) + .foregroundColor(color) + .frame(maxWidth: .infinity, minHeight: size * 1.6) + .contentShape(Rectangle()) } .buttonStyle(.plain) } } +/// Previous / (−10) / Play / (+10) / Next row. struct Controls: View { let s: NowSnapshot let col: WColors - var size: CGFloat = 34 + var size: CGFloat = 26 + var skips = true var body: some View { - HStack(spacing: 10) { - CtlButton(intent: PreviousTrackIntent(), icon: "backward.end.fill", size: size, fg: col.onSecondaryC, bg: col.secondaryC) - CtlButton(intent: PlayPauseIntent(), icon: s.playing ? "pause.fill" : "play.fill", size: size, fg: col.onPrimary, bg: col.primary, wide: true) - CtlButton(intent: NextTrackIntent(), icon: "forward.end.fill", size: size, fg: col.onSecondaryC, bg: col.secondaryC) + HStack(spacing: 0) { + GlyphButton(intent: PreviousTrackIntent(), icon: "backward.fill", size: size, color: col.onSurface) + if skips { GlyphButton(intent: SkipBackIntent(), icon: "gobackward.10", size: size * 0.9, color: col.onSurface) } + GlyphButton(intent: PlayPauseIntent(), icon: s.playing ? "pause.fill" : "play.fill", size: size * 1.2, color: col.primary) + if skips { GlyphButton(intent: SkipForwardIntent(), icon: "goforward.10", size: size * 0.9, color: col.onSurface) } + GlyphButton(intent: NextTrackIntent(), icon: "forward.fill", size: size, color: col.onSurface) } } } @@ -157,6 +160,7 @@ struct LiveProgress: View { } } +/// Now Playing widget, laid out like FlacBox's (no progress bar or timer), in Mulberry's colours. struct PlayerWidgetView: View { let e: NowEntry @Environment(\.widgetFamily) var family @@ -164,70 +168,77 @@ struct PlayerWidgetView: View { var body: some View { let s = e.snap, col = WColors(s) Group { - if s.title.isEmpty { - VStack(spacing: 8) { - Image(systemName: "music.note").font(.title).foregroundColor(col.primary) - Text("Nothing playing").font(.headline).foregroundColor(col.onSurface) - Text("Tap to open Mulberry").font(.caption).foregroundColor(col.onSurfaceVar) - } - } else { - switch family { - case .systemSmall: small(s, col) - case .systemLarge: large(s, col) - default: medium(s, col) - } + switch family { + case .systemSmall: small(s, col) + case .systemLarge: large(s, col) + default: medium(s, col) } } .widgetURL(URL(string: "mulberry://nowplaying")) .containerBackground(for: .widget) { - LinearGradient(colors: [Color(rgb: Palette.mix(s.palette.count == 10 ? s.palette[2] : 0x553355, s.palette.count == 10 ? s.palette[7] : 0x222222, 0.35)), + LinearGradient(colors: [Color(rgb: Palette.mix(s.palette.count == 10 ? s.palette[2] : 0x553355, + s.palette.count == 10 ? s.palette[7] : 0x222222, 0.45)), col.surfaceHigh], startPoint: .topLeading, endPoint: .bottomTrailing) } } - private func titles(_ s: NowSnapshot, _ col: WColors, big: Bool = false) -> some View { - VStack(alignment: .leading, spacing: 1) { - Text(s.title).font(.system(size: big ? 19 : 16, weight: .bold)).foregroundColor(col.onSurface).lineLimit(1) - Text(s.artist).font(.system(size: big ? 15 : 13)).foregroundColor(col.onSurface.opacity(0.85)).lineLimit(1) - if !s.album.isEmpty { Text(s.album).font(.system(size: big ? 14 : 12, weight: .semibold)).foregroundColor(col.primary).lineLimit(1) } + private func title(_ s: NowSnapshot) -> String { s.title.isEmpty ? "Not playing" : s.title } + + private func subtitle(_ s: NowSnapshot) -> String { + if s.title.isEmpty { return "Mulberry" } + return [s.artist, s.album].filter { !$0.isEmpty }.joined(separator: " • ") + } + + private func heart(_ s: NowSnapshot, _ col: WColors) -> some View { + Button(intent: FavouriteIntent()) { + Image(systemName: s.favourite ? "heart.fill" : "heart") + .font(.system(size: 22, weight: .regular)) + .foregroundColor(s.favourite ? col.primary : col.onSurface) + .frame(width: 34, height: 34) } + .buttonStyle(.plain) } private func small(_ s: NowSnapshot, _ col: WColors) -> some View { - VStack(alignment: .leading, spacing: 6) { - HStack(alignment: .top) { - CoverCookie(art: e.art, colors: col).frame(width: 64, height: 64) - Spacer() - CtlButton(intent: PlayPauseIntent(), icon: s.playing ? "pause.fill" : "play.fill", size: 40, fg: col.onPrimary, bg: col.primary) - } - Spacer(minLength: 0) - titles(s, col) - LiveProgress(s: s, col: col, date: e.date, showTimes: false) + VStack(alignment: .leading, spacing: 4) { + CoverCookie(art: e.art, colors: col).frame(width: 54, height: 54) + Spacer(minLength: 2) + Text(title(s)).font(.system(size: 14, weight: .bold)).foregroundColor(col.onSurface).lineLimit(1) + Text(s.artist).font(.system(size: 12)).foregroundColor(col.onSurfaceVar).lineLimit(1) + Controls(s: s, col: col, size: 18, skips: false) } } private func medium(_ s: NowSnapshot, _ col: WColors) -> some View { VStack(spacing: 6) { - HStack(spacing: 12) { - CoverCookie(art: e.art, colors: col).frame(width: 62, height: 62) - titles(s, col) + HStack(alignment: .top, spacing: 12) { + CoverCookie(art: e.art, colors: col).frame(width: 64, height: 64) + VStack(alignment: .leading, spacing: 2) { + Text(title(s)).font(.system(size: 18, weight: .bold)).foregroundColor(col.onSurface).lineLimit(1) + Text(subtitle(s)).font(.system(size: 14)).foregroundColor(col.onSurfaceVar).lineLimit(1) + } Spacer(minLength: 0) + heart(s, col) } - LiveProgress(s: s, col: col, date: e.date) - Controls(s: s, col: col, size: 34) + Spacer(minLength: 0) + Controls(s: s, col: col, size: 24) } } private func large(_ s: NowSnapshot, _ col: WColors) -> some View { VStack(spacing: 10) { - HStack(spacing: 14) { - CoverCookie(art: e.art, colors: col).frame(width: 84, height: 84) - titles(s, col, big: true) + HStack(alignment: .top) { + CoverCookie(art: e.art, colors: col).frame(width: 150, height: 150) Spacer(minLength: 0) + heart(s, col) } - LiveProgress(s: s, col: col, date: e.date) - Controls(s: s, col: col, size: 40) - LyricsCard(e: e, col: col, lines: 3) + VStack(alignment: .leading, spacing: 3) { + Text(title(s)).font(.system(size: 22, weight: .bold)).foregroundColor(col.onSurface).lineLimit(2) + Text(subtitle(s)).font(.system(size: 16)).foregroundColor(col.onSurfaceVar).lineLimit(1) + } + .frame(maxWidth: .infinity, alignment: .leading) + Spacer(minLength: 0) + Controls(s: s, col: col, size: 30) } } } diff --git a/docs/releases/1.0.5.md b/docs/releases/1.0.5.md new file mode 100644 index 0000000..2c21717 --- /dev/null +++ b/docs/releases/1.0.5.md @@ -0,0 +1,10 @@ +# Mulberry for iOS 1.0.5 + +## Fixes +- Library: the blank, sideways-swipeable area under the chip row is gone (the list bottom margin was being applied to the horizontal chip row too). + +## Widgets +- Redesigned like FlacBox, in Mulberry colours, without a progress bar or timer: + - Small: cover, title, artist, previous / play / next. + - Medium: cover, title, artist • album, favourite, previous / back 10 / play / forward 10 / next. + - Large: the same with a bigger cover. diff --git a/tools/gen-appintents.py b/tools/gen-appintents.py index 8a71074..7b41a67 100644 --- a/tools/gen-appintents.py +++ b/tools/gen-appintents.py @@ -16,6 +16,8 @@ INTENTS = [ ("ShuffleIntent", "Shuffle"), ("RepeatIntent", "Repeat"), ("FavouriteIntent", "Favourite"), + ("SkipBackIntent", "Back 10 seconds"), + ("SkipForwardIntent", "Forward 10 seconds"), ]