//
//  SiriTimerView.swift
//  LeCountdown
//
//  Created by Laurent Morvillier on 10/03/2023.
//

import SwiftUI
import _AppIntents_SwiftUI

struct SiriTimerView: View {
    
    var timer: AbstractTimer? = nil
    
    @State var isVisible = true
    
    var body: some View {
        if self.timer != nil {
            SiriTipView(intent: self.intent(), isVisible: self.$isVisible)
                .siriTipViewStyle(SiriTipViewStyle.dark).padding()
        } else {
            EmptyView()
        }
    }
    
    fileprivate func intent() -> StartTimerIntent {
        let intent = StartTimerIntent()
        if let timer {
            intent.timer = TimerIdentifierAppEntity(id: timer.stringId, displayString: timer.displayName)
        }
        return intent
    }
    
}

struct SiriTimerView_Previews: PreviewProvider {
    static var previews: some View {
        SiriTimerView()
    }
}
