Small improvements

main
Laurent 3 years ago
parent 29d310bb41
commit 1dffd82236
  1. 11
      LeCountdown/Sound/Sound.swift
  2. 7
      LeCountdown/Views/ContentView.swift
  3. 2
      LeCountdown/Views/Reusable/SoundFormView.swift
  4. 5
      LeCountdown/Views/Reusable/TimerModel.swift
  5. 2
      LeCountdown/Views/StartView.swift
  6. 1
      LeCountdown/Views/TimersView.swift

@ -77,7 +77,7 @@ enum Playlist: String, CaseIterable, Identifiable, Localized {
case .nature:
return NSLocalizedString("Nature", comment: "")
case .stephanBodzin:
return "Boavista"
return "Stephan Bodzin - Boavista"
case .custom:
return NSLocalizedString("Custom", comment: "")
case .relax:
@ -87,6 +87,15 @@ enum Playlist: String, CaseIterable, Identifiable, Localized {
}
}
var shortName: String {
switch self {
case .stephanBodzin:
return "Boavista"
default:
return self.localizedString
}
}
}
// Sound id are stored thus case order should not be changed

@ -27,6 +27,11 @@ struct ContentView<T : AbstractTimer>: View {
@State private var showStatsSheet: Bool = false
@State private var showSubscriptionSheet: Bool = false
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \AbstractTimer.order, ascending: true)],
animation: .default)
private var timers: FetchedResults<AbstractTimer>
var body: some View {
VStack {
@ -56,7 +61,7 @@ struct ContentView<T : AbstractTimer>: View {
.foregroundColor(.black)
.background(self._backgroundColor)
.cornerRadius(32.0, corners: [.topRight, .topLeft])
} else if let tip = self.showTip {
} else if let tip = self.showTip, self.timers.count > 0 {
TipView(tip: tip) {
Preferences.lastShownTip = tip.rawValue
self.showTip = nil

@ -72,7 +72,7 @@ struct SoundLinkView: View {
catalog: self.catalog)
}
} label: {
LabeledContent(self.title, value: self.soundModel.soundSelection)
LabeledContent(self.title, value: self.soundModel.soundSelection())
}
}

@ -52,9 +52,10 @@ class SoundModel: ObservableObject, SoundHolder {
}
}
var soundSelection: String {
func soundSelection(short: Bool = false) -> String {
if self.playlists.count == 1 {
return self.playlists.first!.localizedString
let playlist = self.playlists.first!
return short ? playlist.shortName : playlist.localizedString
}
if !sounds.isEmpty {
if sounds.count == 1 {

@ -160,7 +160,7 @@ struct SoundButtonView: View {
self.showSoundSheet = true
} label: {
Image(systemName: "music.note")
Text(self.soundModel.soundSelection)
Text(self.soundModel.soundSelection(short: true))
}.sheet(isPresented: $showSoundSheet) {
PlaylistsView(model: self.soundModel,
catalog: .ring)

@ -25,7 +25,6 @@ struct TimersView: View {
fileprivate let itemSpacing: CGFloat = 10.0
var body: some View {
let abstractTimers: [AbstractTimer] = Array(self.timers)

Loading…
Cancel
Save