You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
//
|
|
// 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)
|
|
VStack(alignment: .leading) {
|
|
Text(tip.localizedString)
|
|
if let link = tip.link {
|
|
Button {
|
|
UIApplication.shared.open(link)
|
|
} label: {
|
|
Text("Learn more")
|
|
}.buttonStyle(.bordered)
|
|
}
|
|
}.font(.footnote)
|
|
Spacer()
|
|
Image(systemName: "xmark.circle.fill")
|
|
.padding(8.0)
|
|
}.onTapGesture {
|
|
withAnimation {
|
|
self.handler()
|
|
}
|
|
}
|
|
.monospaced()
|
|
.padding(12.0)
|
|
.foregroundColor(.white)
|
|
.background(Color.accentColor)
|
|
.cornerRadius(16.0)
|
|
}
|
|
}
|
|
|
|
struct TipView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
VStack {
|
|
ForEach(Tip.allCases) { tip in
|
|
TipView(tip: tip, handler: {})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|