//
//  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)
                .font(.footnote)
            Spacer()
            Image(systemName: "xmark.circle.fill")
                .padding(8.0)
        }.onTapGesture {
            withAnimation {
                self.handler()
            }
        }
        .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: {})
            }
        }
    }
}
