Cover cropper with zoom and output size for both playlist types, lyrics Vocals/Softness turn karaoke on (build 65)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b10528d69c
commit
ac363ea0f7
6 files changed
+182
-12
No files matched your search
@@ -33,6 +33,9 @@ final class Overlays {
|
||||
/// Set while the Photos picker is up; gets the picked image's data.
|
||||
var photoPick: ((Data) -> Void)?
|
||||
var photoShown = false
|
||||
/// A picked cover waiting in the cropper.
|
||||
var crop: Crop?
|
||||
struct Crop: Identifiable { let id = UUID(); var image: UIImage; var run: (Data) -> Void }
|
||||
/// 1 while the Now Playing sheet is up, so its host shows overlays instead of the root's.
|
||||
var level = 0
|
||||
|
||||
@@ -95,7 +98,7 @@ struct OverlayHost: ViewModifier {
|
||||
private var mine: Bool { overlays.level == level }
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
content.modifier(CropHost(overlays: overlays, mine: mine))
|
||||
.overlay {
|
||||
if mine, let h = overlays.hud {
|
||||
HudView(hud: h).transition(.opacity.combined(with: .scale(scale: 0.9))).allowsHitTesting(false)
|
||||
@@ -132,8 +135,9 @@ struct OverlayHost: ViewModifier {
|
||||
photo = nil
|
||||
overlays.photoPick = nil
|
||||
Task { @MainActor in
|
||||
if let data = try? await item.loadTransferable(type: Data.self) { run(data) }
|
||||
else { overlays.hud("Couldn't load that photo", "exclamationmark.triangle") }
|
||||
if let data = try? await item.loadTransferable(type: Data.self), let img = UIImage(data: data) {
|
||||
overlays.crop = Overlays.Crop(image: img, run: run)
|
||||
} else { overlays.hud("Couldn't load that photo", "exclamationmark.triangle") }
|
||||
}
|
||||
}
|
||||
.sheet(item: Binding(get: { mine ? overlays.addToPlaylist : nil }, set: { overlays.addToPlaylist = $0 })) { r in
|
||||
@@ -146,6 +150,20 @@ struct OverlayHost: ViewModifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// The cover cropper, split out to keep OverlayHost's chain small enough to type-check.
|
||||
private struct CropHost: ViewModifier {
|
||||
let overlays: Overlays
|
||||
let mine: Bool
|
||||
func body(content: Content) -> some View {
|
||||
content.fullScreenCover(item: Binding(get: { mine ? overlays.crop : nil }, set: { overlays.crop = $0 })) { c in
|
||||
CoverCropper(image: c.image) { data in
|
||||
overlays.crop = nil
|
||||
if let data { c.run(data) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct HudView: View {
|
||||
let hud: Overlays.Hud
|
||||
var body: some View {
|
||||
|
||||
Reference in new issue
Block a user