parent
c5bd812620
commit
d85761a82f
@ -0,0 +1,29 @@ |
||||
// |
||||
// TipsManager.swift |
||||
// LeCountdown |
||||
// |
||||
// Created by Laurent Morvillier on 27/02/2023. |
||||
// |
||||
|
||||
import Foundation |
||||
|
||||
enum Tip: Int, CaseIterable, Identifiable { |
||||
case siri |
||||
case widget |
||||
|
||||
var id: Int { self.rawValue } |
||||
|
||||
var localizedString: String { |
||||
switch self { |
||||
case .widget: return NSLocalizedString("You can add widget for your timers and countdowns by modifying your home or lock screen", comment: "") |
||||
case .siri: return NSLocalizedString("You can ask Siri to create and launch countdowns and stopwatches", comment: "") |
||||
} |
||||
} |
||||
|
||||
var pictoName: String { |
||||
switch self { |
||||
case .siri: return "wave.3.right" //"dot.radiowaves.right" |
||||
case .widget: return "app.badge" |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// |
||||
// TipView.swift |
||||
// LeCountdown |
||||
// |
||||
// Created by Laurent Morvillier on 27/02/2023. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct TipView: View { |
||||
|
||||
var tip: Tip |
||||
|
||||
var handler: () -> () |
||||
|
||||
var body: some View { |
||||
|
||||
HStack { |
||||
Image(systemName: tip.pictoName) |
||||
Text(tip.localizedString).padding(.trailing) |
||||
Spacer() |
||||
Button { |
||||
self.handler() |
||||
} label: { |
||||
Image(systemName: "xmark.circle.fill") |
||||
.padding(8.0) |
||||
}.foregroundColor(.white) |
||||
|
||||
} |
||||
.padding(12.0) |
||||
.foregroundColor(.white) |
||||
.background(.cyan) |
||||
.cornerRadius(16.0) |
||||
} |
||||
} |
||||
|
||||
struct TipView_Previews: PreviewProvider { |
||||
|
||||
static var previews: some View { |
||||
|
||||
VStack { |
||||
ForEach(Tip.allCases) { tip in |
||||
TipView(tip: tip, handler: {}) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue