Sound selection update, does not work

release
Laurent 3 years ago
parent b073e55104
commit d2f1b036aa
  1. 8
      LeCountdown.xcodeproj/project.pbxproj
  2. 22
      LeCountdown/LeCountdownApp.swift
  3. 3
      LeCountdown/Model/Generation/AbstractSoundTimer+CoreDataProperties.swift
  4. 2
      LeCountdown/Model/LeCountdown.xcdatamodeld/.xccurrentversion
  5. 34
      LeCountdown/Model/LeCountdown.xcdatamodeld/LeCountdown.0.5.xcdatamodel/contents
  6. 51
      LeCountdown/Model/Model+Extensions.swift
  7. 82
      LeCountdown/Sound/Sound.swift
  8. 19
      LeCountdown/Views/Alarm/AlarmFormView.swift
  9. 26
      LeCountdown/Views/Alarm/NewAlarmView.swift
  10. 51
      LeCountdown/Views/Components/SoundImageFormView.swift
  11. 63
      LeCountdown/Views/Components/SoundSelectionView.swift
  12. 6
      LeCountdown/Views/Countdown/CountdownFormView.swift
  13. 18
      LeCountdown/Views/Countdown/NewCountdownView.swift
  14. 2
      LeCountdown/Views/DialView.swift
  15. 21
      LeCountdown/Views/Stopwatch/NewStopwatchView.swift
  16. 8
      LeCountdown/Views/Stopwatch/StopwatchFormView.swift

@ -68,6 +68,7 @@
C498E5A3298D720600E90DE0 /* TestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C498E5A2298D720600E90DE0 /* TestView.swift */; };
C498E5A5299152B400E90DE0 /* GreenCheckmarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C498E5A4299152B400E90DE0 /* GreenCheckmarkView.swift */; };
C498E5A6299152C600E90DE0 /* GreenCheckmarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C498E5A4299152B400E90DE0 /* GreenCheckmarkView.swift */; };
C4BA2AD62993F62700CB4FBA /* SoundSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2AD52993F62700CB4FBA /* SoundSelectionView.swift */; };
C4F8B1532987FE6F005C86A5 /* LaunchWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C438C7D72981216200BF3EF9 /* LaunchWidgetLiveActivity.swift */; };
C4F8B15729891271005C86A5 /* Conductor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F8B15629891271005C86A5 /* Conductor.swift */; };
C4F8B15929891528005C86A5 /* forest_stream.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C4F8B15829891528005C86A5 /* forest_stream.mp3 */; };
@ -232,6 +233,8 @@
C498E5A0298D543900E90DE0 /* LiveTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveTimer.swift; sourceTree = "<group>"; };
C498E5A2298D720600E90DE0 /* TestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestView.swift; sourceTree = "<group>"; };
C498E5A4299152B400E90DE0 /* GreenCheckmarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreenCheckmarkView.swift; sourceTree = "<group>"; };
C4BA2AD52993F62700CB4FBA /* SoundSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoundSelectionView.swift; sourceTree = "<group>"; };
C4BA2AD72993F7D200CB4FBA /* LeCountdown.0.5.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = LeCountdown.0.5.xcdatamodel; sourceTree = "<group>"; };
C4F8B15629891271005C86A5 /* Conductor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Conductor.swift; sourceTree = "<group>"; };
C4F8B15829891528005C86A5 /* forest_stream.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = forest_stream.mp3; sourceTree = "<group>"; };
C4F8B15E298961A7005C86A5 /* ReorderableForEach.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReorderableForEach.swift; sourceTree = "<group>"; };
@ -538,6 +541,7 @@
C498E5A4299152B400E90DE0 /* GreenCheckmarkView.swift */,
C4F8B1D1298BF646005C86A5 /* PermissionAlertView.swift */,
C4F8B165298A9ABB005C86A5 /* SoundImageFormView.swift */,
C4BA2AD52993F62700CB4FBA /* SoundSelectionView.swift */,
);
path = Components;
sourceTree = "<group>";
@ -752,6 +756,7 @@
C438C807298195E600BF3EF9 /* Model+Extensions.swift in Sources */,
C438C7FF2981300500BF3EF9 /* IntentDataProvider.swift in Sources */,
C4F8B183298AC234005C86A5 /* Stopwatch+CoreDataProperties.swift in Sources */,
C4BA2AD62993F62700CB4FBA /* SoundSelectionView.swift in Sources */,
C4F8B1A8298AC2FC005C86A5 /* AbstractSoundTimer+CoreDataProperties.swift in Sources */,
C498E5A5299152B400E90DE0 /* GreenCheckmarkView.swift in Sources */,
C4F8B1B8298AC81D005C86A5 /* CountdownDialView.swift in Sources */,
@ -1328,13 +1333,14 @@
C4060DCA297AE73D003FAB80 /* LeCountdown.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
C4BA2AD72993F7D200CB4FBA /* LeCountdown.0.5.xcdatamodel */,
C40FDB672993D5E80042A390 /* LeCountdown.0.4.xcdatamodel */,
C4F8B160298A90E8005C86A5 /* LeCountdown.0.3.xcdatamodel */,
C445FA902987C0CF0054D761 /* LeCountdown.0.2.xcdatamodel */,
C418A14F298428CB00C22230 /* LeCountdown.0.1.xcdatamodel */,
C4060DCB297AE73D003FAB80 /* LeCountdown.xcdatamodel */,
);
currentVersion = C40FDB672993D5E80042A390 /* LeCountdown.0.4.xcdatamodel */;
currentVersion = C4BA2AD72993F7D200CB4FBA /* LeCountdown.0.5.xcdatamodel */;
path = LeCountdown.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;

@ -71,17 +71,17 @@ struct LeCountdownApp: App {
fileprivate func _onAppear() {
self._registerBackgroundRefreshes()
let voices = AVSpeechSynthesisVoice.speechVoices()
let grouped = Dictionary(grouping: voices, by: { $0.language })
for language in grouped.keys {
if let lvoices = grouped[language] {
print("language = \(language)")
for voice in lvoices {
print("name = \(voice.name), gender = \(voice.gender)")
}
print("========")
}
}
// let voices = AVSpeechSynthesisVoice.speechVoices()
// let grouped = Dictionary(grouping: voices, by: { $0.language })
// for language in grouped.keys {
// if let lvoices = grouped[language] {
// print("language = \(language)")
// for voice in lvoices {
// print("name = \(voice.name), gender = \(voice.gender)")
// }
// print("========")
// }
// }
}

@ -17,6 +17,7 @@ extension AbstractSoundTimer {
}
@NSManaged public var repeatCount: Int16
@NSManaged public var sound: Int16
@NSManaged public var playlistList: String?
@NSManaged public var soundList: String?
}

@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>LeCountdown.0.4.xcdatamodel</string>
<string>LeCountdown.0.5.xcdatamodel</string>
</dict>
</plist>

@ -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>

@ -46,8 +46,33 @@ extension AbstractTimer {
extension AbstractSoundTimer {
var sounds: [Sound] {
if let soundList {
return soundList.enumItems()
}
return []
}
var playlists: [Playlist] {
if let playlistList {
return playlistList.enumItems()
}
return []
}
func setSounds(_ sounds: [Sound]) {
self.soundList = sounds.stringRepresentation
}
func setPlaylists(_ playlists: [Playlist]) {
self.playlistList = playlists.stringRepresentation
}
var coolSound: Sound {
return Sound(rawValue: Int(self.sound)) ?? Sound.allCases[0]
var allSounds: [Sound] = []
allSounds.append(contentsOf: self.sounds)
allSounds.append(contentsOf: self.playlists.reduce([], { $0 + $1.sounds }))
return allSounds.randomElement() ?? Sound.allCases[0]
}
var soundName: String {
@ -120,3 +145,27 @@ extension Activity {
}
}
// MARK: - Storage convenience
fileprivate let separator = "|"
fileprivate let formatter: NumberFormatter = NumberFormatter()
extension String {
func enumItems<T : RawRepresentable<Int>>() -> [T] {
let ids: [String] = self.components(separatedBy: separator)
let intIds: [Int] = ids.compactMap { formatter.number(from: $0)?.intValue }
return intIds.compactMap { T(rawValue: $0) }
}
}
extension Array where Element : RawRepresentable<Int> {
var stringRepresentation: String {
let ids = self.compactMap { formatter.string(from: NSNumber(value: $0.rawValue)) }
return ids.joined(separator: separator)
}
}

@ -8,8 +8,88 @@
import Foundation
import AVFoundation
struct PlaylistSelection: Identifiable {
var id: Int { return self.playlist.id }
var playlist: Playlist
var selected: Bool {
didSet {
if selected {
self.sounds = playlist.sounds
} else {
self.sounds = []
}
}
}
fileprivate var _sounds: [Sound] = []
var sounds: [Sound] {
set {
_sounds = newValue
if !selected && (newValue.count == self.playlist.sounds.count) {
self.selected = true
} else if selected && (newValue.count != self.playlist.sounds.count) {
self.selected = false
}
}
get {
return _sounds
}
}
static func allPlaylists() -> [PlaylistSelection] {
var playlistSelections: [PlaylistSelection] = []
for playlist in Playlist.allCases {
let playlistSelection = PlaylistSelection(playlist: playlist, selected: false)
playlistSelections.append(playlistSelection)
}
return playlistSelections
}
}
struct SoundSelection: Identifiable {
var id: Int { return self.sound.id }
var sound: Sound
var selected: Bool
}
enum Playlist: Int, CaseIterable, Identifiable {
var id: Int { return self.rawValue }
case nature = 1
case fun
case stephanBodzin
var sounds: [Sound] {
switch self {
case .nature:
return Sound.allCases
case .fun:
return Sound.allCases
case .stephanBodzin:
return Sound.allCases
}
}
var localizedString: String {
switch self {
case .nature:
return NSLocalizedString("Nature", comment: "")
case .fun:
return NSLocalizedString("Fun", comment: "")
case .stephanBodzin:
return "Stephan Bodzin"
}
}
}
// Sound id are stored thus case order should not be changed
enum Sound : Int, CaseIterable, Identifiable {
enum Sound: Int, CaseIterable, Identifiable {
var id: Int { return self.rawValue }

@ -12,14 +12,25 @@ struct AlarmFormView: View {
var dateBinding: Binding<Date>
var imageBinding: Binding<CoolPic>
var soundBinding: Binding<Sound>
var soundsBinding: Binding<[Sound]>
var playlistsBinding: Binding<[Playlist]>
var repeatCountBinding: Binding<Int16>
var body: some View {
Form {
DatePicker("Time", selection: dateBinding, displayedComponents: .hourAndMinute)
SoundImageFormView(imageBinding: imageBinding, soundBinding: soundBinding, repeatCountBinding: self.repeatCountBinding)
Text("todo")
// DatePicker("Time", selection: dateBinding, displayedComponents: .hourAndMinute)
//
// SoundImageFormView(imageBinding: self.imageBinding,
// soundsBinding: self.soundBinding,
// playlistsBinding: self.playlistsBinding,
// repeatCountBinding: self.repeatCountBinding)
// SoundImageFormView(imageBinding: imageBinding, soundBinding: soundBinding, repeatCountBinding: self.repeatCountBinding)
}
}
}
@ -27,6 +38,6 @@ struct AlarmFormView: View {
struct AlarmFormView_Previews: PreviewProvider {
static var previews: some View {
AlarmFormView(dateBinding: .constant(Date()),
imageBinding: .constant(.pic1), soundBinding: .constant(.trainhorn), repeatCountBinding: .constant(2))
imageBinding: .constant(.pic1), soundsBinding: .constant([]), playlistsBinding: .constant([]), repeatCountBinding: .constant(2))
}
}

@ -36,7 +36,9 @@ struct AlarmEditView: View {
@State var nameString: String = ""
@State var sound: Sound = .trainhorn
@State var sounds: [Sound] = [.trainhorn]
@State var playlists: [Playlist] = []
@State var soundRepeatCount: Int16 = 0
@State var image: CoolPic = .pic1
@ -65,10 +67,14 @@ struct AlarmEditView: View {
self._save()
}
}
AlarmFormView(dateBinding: self.$time,
imageBinding: self.$image,
soundBinding: self.$sound,
repeatCountBinding: self.$soundRepeatCount)
Text("todo")
// AlarmFormView(dateBinding: self.$time,
// imageBinding: self.$image,
//
//
// soundBinding: self.$sound,
// repeatCountBinding: self.$soundRepeatCount)
.onAppear {
self._onAppear()
}
@ -146,9 +152,8 @@ struct AlarmEditView: View {
self.nameString = name
}
if let sound = Sound(rawValue: Int(alarm.sound)) {
self.sound = sound
}
self.sounds = alarm.sounds
self.playlists = alarm.playlists
if let image = alarm.image, let coolpic = CoolPic(rawValue: image) {
self.image = coolpic
@ -177,7 +182,10 @@ struct AlarmEditView: View {
a.fireDate = self.time
a.image = self.image.rawValue
a.sound = Int16(self.sound.rawValue)
a.setSounds(self.sounds)
a.setPlaylists(self.playlists)
a.repeatCount = self.soundRepeatCount
if !self.nameString.isEmpty {

@ -10,7 +10,9 @@ import SwiftUI
struct SoundImageFormView : View {
var imageBinding: Binding<CoolPic>
var soundBinding: Binding<Sound>
var playlistBinding: Binding<[PlaylistSelection]>
var repeatCountBinding: Binding<Int16>? = nil
var optionalSound: Binding<Bool>? = nil
@ -27,25 +29,37 @@ struct SoundImageFormView : View {
Toggle("Play sound on end", isOn: optionalSound!)
if self.optionalSound?.wrappedValue == true {
Picker(selection: soundBinding) {
ForEach(Sound.allCases) { sound in
Text(sound.localizedString).tag(sound)
}
NavigationLink {
SoundSelectionView(playlistBinding: playlistBinding)
} label: {
Text("Sound")
}
// Picker(selection: soundBinding) {
// ForEach(Sound.allCases) { sound in
// Text(sound.localizedString).tag(sound)
// }
// } label: {
// Text("Sound")
// }
}
} else {
Picker(selection: soundBinding) {
ForEach(Sound.allCases) { sound in
Text(sound.localizedString).tag(sound)
}
} label: {
Text("Sound")
}
// Picker(selection: soundBinding) {
// ForEach(Sound.allCases) { sound in
// Text(sound.localizedString).tag(sound)
// }
// } label: {
// Text("Sound")
// }
}
NavigationLink {
SoundSelectionView(playlistBinding: playlistBinding)
} label: {
Text("Sound")
}
Picker("Repeat Count", selection: self.repeatCountBinding!) {
ForEach(0..<6) {
let count = Int16($0)
@ -54,17 +68,6 @@ struct SoundImageFormView : View {
}
// if self.repeatCountBinding != nil {
// Picker(selection: self.repeatCountBinding!) {
// ForEach(0..<6) { count in
// Text("\(count)").tag(count)
// }
// } label: {
// Text("Repeat count")
// }
//
//// Toggle("Sound repeats", isOn: repeatsBinding!)
// }
}
Section(header: Text("Background")) {
@ -100,7 +103,7 @@ struct SoundImageFormView_Previews: PreviewProvider {
Form {
SoundImageFormView(
imageBinding: .constant(.pic1),
soundBinding: .constant(.forestStream),
playlistBinding: .constant([]),
repeatCountBinding: .constant(2))
}
}

@ -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([]))
}
}

@ -15,7 +15,7 @@ struct CountdownFormView : View {
var nameBinding: Binding<String>
var imageBinding: Binding<CoolPic>
var soundBinding: Binding<Sound>
var playlistBinding: Binding<[PlaylistSelection]>
var repeatCountBinding: Binding<Int16>
var textFieldIsFocused: FocusState<Bool>.Binding
@ -37,7 +37,7 @@ struct CountdownFormView : View {
SoundImageFormView(
imageBinding: imageBinding,
soundBinding: soundBinding,
playlistBinding: playlistBinding,
repeatCountBinding: repeatCountBinding)
}
@ -51,6 +51,6 @@ struct CountdownFormView_Previews: PreviewProvider {
static var previews: some View {
CountdownFormView(secondsBinding: .constant(""), minutesBinding: .constant(""),
nameBinding: .constant(""), imageBinding: .constant(.pic3), soundBinding: .constant(.trainhorn), repeatCountBinding: .constant(2), textFieldIsFocused: $textFieldIsFocused)
nameBinding: .constant(""), imageBinding: .constant(.pic3), playlistBinding: .constant([]), repeatCountBinding: .constant(2), textFieldIsFocused: $textFieldIsFocused)
}
}

@ -36,7 +36,8 @@ struct CountdownEditView : View {
@State var minutesString: String = ""
@State var nameString: String = ""
@State var sound: Sound = .trainhorn
// @State var sounds: [SoundSelection] = []
@State var playlists: [PlaylistSelection] = []
@State var soundRepeatCount: Int16 = 0
@State var image: CoolPic = .pic1
@ -70,7 +71,7 @@ struct CountdownEditView : View {
minutesBinding: $minutesString,
nameBinding: $nameString,
imageBinding: $image,
soundBinding: $sound,
playlistBinding: $playlists,
repeatCountBinding: $soundRepeatCount,
textFieldIsFocused: $textFieldIsFocused)
.onAppear {
@ -138,6 +139,8 @@ struct CountdownEditView : View {
fileprivate func _onAppear() {
self.playlists = PlaylistSelection.allPlaylists()
self._isAdding = (self.countdown == nil)
if let countdown {
@ -157,9 +160,11 @@ struct CountdownEditView : View {
self.nameString = name
}
if let sound = Sound(rawValue: Int(countdown.sound)) {
self.sound = sound
}
// self.sounds = countdown.sounds
// if let sound = Sound(rawValue: Int(countdown.sound)) {
// self.sound = sound
// }
self.soundRepeatCount = countdown.repeatCount
if let image = countdown.image, let coolpic = CoolPic(rawValue: image) {
@ -200,7 +205,8 @@ struct CountdownEditView : View {
}
cd.image = self.image.rawValue
cd.sound = Int16(self.sound.rawValue)
// cd.setSounds(self.sounds)
// cd.setPlaylists(self.playlists)
cd.repeatCount = self.soundRepeatCount
if !self.nameString.isEmpty {

@ -114,7 +114,7 @@ struct DialView_Previews: PreviewProvider {
DialView(
timer: Countdown.fake(context: PersistenceController.preview.container.viewContext),
isEditingBinding: .constant(true), frameSize: 150.0)
isEditingBinding: .constant(false), frameSize: 150.0)
.environmentObject(Conductor.maestro)
.environmentObject(BoringContext())

@ -37,7 +37,7 @@ struct StopwatchEditView: View {
@State var nameString: String = ""
@State var playSound: Bool = false
@State var sound: Sound = .trainhorn
@State var playlists: [PlaylistSelection] = []
@State var image: CoolPic = .pic1
@State var deleteConfirmationShown: Bool = false
@ -67,7 +67,8 @@ struct StopwatchEditView: View {
}
StopwatchFormView(nameBinding: self.$nameString,
imageBinding: self.$image,
soundBinding: self.$sound, playSoundBinding: self.$playSound,
playSoundBinding: self.$playSound,
playlistBinding: self.$playlists,
textFieldIsFocused: $textFieldIsFocused)
.onAppear {
self._onAppear()
@ -142,9 +143,9 @@ struct StopwatchEditView: View {
self.nameString = name
}
if let sound = Sound(rawValue: Int(stopwatch.sound)) {
self.sound = sound
}
// if let sound = Sound(rawValue: Int(stopwatch.sound)) {
// self.sound = sound
// }
if let image = stopwatch.image, let coolpic = CoolPic(rawValue: image) {
self.image = coolpic
@ -174,11 +175,11 @@ struct StopwatchEditView: View {
sw.image = self.image.rawValue
if self.playSound {
sw.sound = Int16(self.sound.rawValue)
} else {
// sw.sound = nil
}
// if self.playSound {
// sw.sound = Int16(self.sound.rawValue)
// } else {
//// sw.sound = nil
// }
if !self.nameString.isEmpty {

@ -11,9 +11,10 @@ struct StopwatchFormView: View {
var nameBinding: Binding<String>
var imageBinding: Binding<CoolPic>
var soundBinding: Binding<Sound>
var playSoundBinding: Binding<Bool>
var playlistBinding: Binding<[PlaylistSelection]>
var textFieldIsFocused: FocusState<Bool>.Binding
var body: some View {
@ -25,7 +26,7 @@ struct StopwatchFormView: View {
}
SoundImageFormView(imageBinding: imageBinding,
soundBinding: soundBinding,
playlistBinding: playlistBinding,
optionalSound: playSoundBinding)
}
@ -39,6 +40,7 @@ struct StopwatchFormView_Previews: PreviewProvider {
static var previews: some View {
StopwatchFormView(nameBinding: .constant(""),
imageBinding: .constant(.pic1),
soundBinding: .constant(.trainhorn), playSoundBinding: .constant(true), textFieldIsFocused: $textFieldIsFocused)
playSoundBinding: .constant(true),
playlistBinding: .constant([]), textFieldIsFocused: $textFieldIsFocused)
}
}

Loading…
Cancel
Save