iOS 0.4.1: clearing tiles, deleting presets and slot-editor imports work on iOS 15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-16 09:40:32 +01:00
co-authored by Claude Opus 5.5
parent 962cfd1e2b
commit 42f66534bf
4 changed files with 32 additions and 25 deletions
+8
View File
@@ -3,6 +3,14 @@
Sizzle for iOS/iPadOS (`cc.tiredsysadmin.ios.sizzle`). One entry per version in
`../versions.properties` (`ios.versionName` / `ios.versionCode`).
## 0.4.1 (build 9)
- Fix: clearing a Toolbox tile, deleting a preset, and importing a WAV, SF2/XI
or preset in the slot editor did nothing. On iOS 15, SwiftUI resets an
alert's (or file picker's) presentation state before running the button's
action, and the action read that state. The tile / preset / kind of import is
now handed over in a way that survives that.
## 0.4.0 (build 8)
- Sizzle itself on iOS: the Tracker, Mix, Toolbox and Setup tabs, ported from
+14 -13
View File
@@ -21,7 +21,10 @@ struct SlotEditor: View {
@StateObject private var model: DeviceModel
@ObservedObject private var watch = MixSongWatch.shared
@State private var pad = 0
/// What the file picker is for; kept after it closes, because SwiftUI resets
/// the presentation binding before calling the completion handler.
@State private var importing: ImportKind?
@State private var pickerShown = false
@State private var importError: String?
enum ImportKind: Identifiable {
@@ -61,11 +64,8 @@ struct SlotEditor: View {
}
}
.background(Theme.background.opacity(0.96))
.fileImporter(isPresented: Binding(get: { importing != nil }, set: { if !$0 { importing = nil } }),
allowedContentTypes: importTypes, allowsMultipleSelection: false) { result in
let kind = importing
importing = nil
if case .success(let urls) = result, let url = urls.first, let kind = kind { load(url, kind) }
.fileImporter(isPresented: $pickerShown, allowedContentTypes: importTypes, allowsMultipleSelection: false) { result in
if case .success(let urls) = result, let url = urls.first, let kind = importing { load(url, kind) }
}
.alert("Import failed", isPresented: Binding(get: { importError != nil }, set: { if !$0 { importError = nil } }),
actions: { Button("OK") { importError = nil } }, message: { Text(importError ?? "") })
@@ -88,10 +88,10 @@ struct SlotEditor: View {
Text("CLOSE ✕").font(Theme.mono(13)).foregroundColor(Theme.dim)
.contentShape(Rectangle()).onTapGesture(perform: onClose)
}
PresetBar(slot: slot, type: type, model: model, onImport: { importing = .preset })
PresetBar(slot: slot, type: type, model: model, onImport: { importing = .preset; pickerShown = true })
switch type {
case "SAMPLER": SamplerDetail(slot: slot, pad: pad, onSelectPad: { pad = $0 }, onImport: { importing = .padSample })
case "SOUNDFONT": SoundFontDetail(slot: slot, onImport: { importing = .soundFont })
case "SAMPLER": SamplerDetail(slot: slot, pad: pad, onSelectPad: { pad = $0 }, onImport: { importing = .padSample; pickerShown = true })
case "SOUNDFONT": SoundFontDetail(slot: slot, onImport: { importing = .soundFont; pickerShown = true })
default: EmptyView()
}
// The card editor brings its own padding and header row; with no name and
@@ -232,15 +232,16 @@ private struct PresetBar: View {
}
}
.sheet(isPresented: $saving) { saveSheet }
.alert("Delete preset", isPresented: Binding(get: { confirmDelete != nil }, set: { if !$0 { confirmDelete = nil } }), actions: {
// `presenting:`: the binding (and confirmDelete) is reset before the action runs.
.alert("Delete preset", isPresented: Binding(get: { confirmDelete != nil }, set: { if !$0 { confirmDelete = nil } }),
presenting: confirmDelete, actions: { n in
Button("Delete", role: .destructive) {
if let n = confirmDelete { _ = session.deletePreset(n, type: type) }
_ = session.deletePreset(n, type: type)
selected = nil
confirmDelete = nil
names = session.libraryPresets(forType: type)
}
Button("Cancel", role: .cancel) { confirmDelete = nil }
}, message: { Text("Delete \"\(confirmDelete ?? "")\"? This cannot be undone.") })
Button("Cancel", role: .cancel) {}
}, message: { n in Text("Delete \"\(n)\"? This cannot be undone.") })
}
private var saveSheet: some View {
@@ -70,16 +70,14 @@ private struct ToolboxBody: View {
}
}
.background(Theme.background)
.alert("Clear tile", isPresented: Binding(get: { clearing != nil }, set: { if !$0 { clearing = nil } }), actions: {
Button("Clear", role: .destructive) {
if let i = clearing { session.clearSlot(i) }
clearing = nil
}
Button("Cancel", role: .cancel) { clearing = nil }
}, message: {
if let i = clearing {
Text("Remove \"\(tileLabel(i))\" from tile \(i + 1)? This clears the device and its settings and can't be undone.")
}
// `presenting:` hands the tile to the buttons: SwiftUI resets the binding
// (and so `clearing`) before a button's action runs.
.alert("Clear tile", isPresented: Binding(get: { clearing != nil }, set: { if !$0 { clearing = nil } }),
presenting: clearing, actions: { i in
Button("Clear", role: .destructive) { session.clearSlot(i) }
Button("Cancel", role: .cancel) {}
}, message: { i in
Text("Remove \"\(tileLabel(i))\" from tile \(i + 1)? This clears the device and its settings and can't be undone.")
})
}