import AppIntents
import SwiftUI
import WidgetKit

/// A Control Center control for Jarvis, so the Action Button can reach it.
///
/// WHY THIS EXISTS. The Action Button's action list is fixed — Workout,
/// Stopwatch, Waypoint, Flashlight, Shortcut, Voice Memo and the rest — and no
/// app can add a row to it. Its two third-party doors are "Shortcut", which
/// only offers shortcuts built on the iPhone (and an iPhone shortcut cannot
/// start a recording on the watch), and "Control". So a control is the only
/// way the orange button can reach this app.
///
/// Controls became available to apps in watchOS 26; ControlWidget,
/// StaticControlConfiguration and ControlWidgetButton are all marked
/// watchOS 26.0 in the SDK.

struct RecordMemoControl: ControlWidget {
    var body: some ControlWidgetConfiguration {
        StaticControlConfiguration(kind: "com.etpics.StewardWatch.RecordMemo") {
            ControlWidgetButton(action: ControlRecordMemoIntent()) {
                Label("Record a Memo", systemImage: "mic.fill")
            }
        }
        .displayName("Record a Memo")
        .description("Start a memo for Jarvis.")
    }
}

@main
struct JarvisControlsBundle: WidgetBundle {
    var body: some Widget {
        RecordMemoControl()
    }
}
