parent
b073e55104
commit
d2f1b036aa
@ -0,0 +1,34 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||||||
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="22A400" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="YES" userDefinedModelVersionIdentifier=""> |
||||||
|
<entity name="AbstractSoundTimer" representedClassName="AbstractSoundTimer" isAbstract="YES" parentEntity="AbstractTimer" syncable="YES"> |
||||||
|
<attribute name="playlistList" optional="YES" attributeType="String"/> |
||||||
|
<attribute name="repeatCount" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/> |
||||||
|
<attribute name="soundList" optional="YES" attributeType="String"/> |
||||||
|
</entity> |
||||||
|
<entity name="AbstractTimer" representedClassName="AbstractTimer" isAbstract="YES" syncable="YES"> |
||||||
|
<attribute name="image" optional="YES" attributeType="String"/> |
||||||
|
<attribute name="order" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/> |
||||||
|
<relationship name="activity" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Activity" inverseName="timers" inverseEntity="Activity"/> |
||||||
|
</entity> |
||||||
|
<entity name="Activity" representedClassName="Activity" syncable="YES"> |
||||||
|
<attribute name="name" attributeType="String" defaultValueString=""/> |
||||||
|
<relationship name="records" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Record" inverseName="activity" inverseEntity="Record"/> |
||||||
|
<relationship name="timers" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="AbstractTimer" inverseName="activity" inverseEntity="AbstractTimer"/> |
||||||
|
</entity> |
||||||
|
<entity name="Alarm" representedClassName="Alarm" parentEntity="AbstractSoundTimer" syncable="YES"> |
||||||
|
<attribute name="fireDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/> |
||||||
|
</entity> |
||||||
|
<entity name="Countdown" representedClassName="Countdown" parentEntity="AbstractSoundTimer" syncable="YES"> |
||||||
|
<attribute name="duration" attributeType="Double" defaultValueString="0" usesScalarValueType="YES"/> |
||||||
|
</entity> |
||||||
|
<entity name="Record" representedClassName="Record" syncable="YES"> |
||||||
|
<attribute name="end" attributeType="Date" defaultDateTimeInterval="696425400" usesScalarValueType="NO"/> |
||||||
|
<attribute name="start" attributeType="Date" defaultDateTimeInterval="696425400" usesScalarValueType="NO"/> |
||||||
|
<relationship name="activity" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Activity" inverseName="records" inverseEntity="Activity"/> |
||||||
|
</entity> |
||||||
|
<entity name="Stopwatch" representedClassName="Stopwatch" parentEntity="AbstractTimer" syncable="YES"> |
||||||
|
<attribute name="end" optional="YES" attributeType="Date" usesScalarValueType="NO"/> |
||||||
|
<attribute name="sound" optional="YES" attributeType="Integer 16" usesScalarValueType="YES"/> |
||||||
|
<attribute name="start" optional="YES" attributeType="Date" usesScalarValueType="NO"/> |
||||||
|
</entity> |
||||||
|
</model> |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
// |
||||||
|
// SoundSelectionView.swift |
||||||
|
// LeCountdown |
||||||
|
// |
||||||
|
// Created by Laurent Morvillier on 08/02/2023. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
struct SoundRow: View { |
||||||
|
var sound: Sound |
||||||
|
@State var selected: Bool |
||||||
|
var handleSelection: (Bool) -> () |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
Toggle(sound.localizedString, isOn: $selected) |
||||||
|
.onChange(of: selected, perform: handleSelection) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
struct SoundSelectionView: View { |
||||||
|
|
||||||
|
@Binding var playlistBinding: [PlaylistSelection] |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
|
||||||
|
Form { |
||||||
|
|
||||||
|
ForEach($playlistBinding, id: \.id) { $ps in |
||||||
|
|
||||||
|
List(selection: <#T##Binding<_?>?#>) { |
||||||
|
<#code#> |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
Section { |
||||||
|
ForEach(ps.playlist.sounds) { sound in |
||||||
|
|
||||||
|
SoundRow(sound: sound, selected: ps.sounds.contains(sound)) { selected in |
||||||
|
if selected { |
||||||
|
ps.sounds.append(sound) |
||||||
|
} else { |
||||||
|
ps.sounds.removeAll(where: { $0 == sound }) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} header: { |
||||||
|
Toggle(ps.playlist.localizedString, isOn: $ps.selected) |
||||||
|
} |
||||||
|
}.navigationTitle("Sounds") |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
struct SoundSelectionView_Previews: PreviewProvider { |
||||||
|
static var previews: some View { |
||||||
|
SoundSelectionView( |
||||||
|
playlistBinding: .constant([])) |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue