import AppIntents
import SwiftUI
import WidgetKit

// 控制中心两控件（iOS 18+ ControlWidget，PLAN 决策 C / §I4）：上传 / 拉取云剪贴板，零推送、
// 用户主动触发。控件标签经 t() 跟随设备语言（i18n 单一真源，随扩展 bundle 一并打包）。另含主屏交互式
// 小组件 CloudClipboardWidget（#6）：同样的上传 / 拉取，可放主屏 / 锁屏。
@main
struct CDropWidgetBundle: WidgetBundle
{
    var body: some Widget
    {
        UploadClipboardControl()
        PullClipboardControl()
        CloudClipboardWidget()
    }
}

struct UploadClipboardControl: ControlWidget
{
    var body: some ControlWidgetConfiguration
    {
        StaticControlConfiguration(kind: "net.commilitia.cdrop.control.upload")
        {
            ControlWidgetButton(action: UploadClipboardIntent())
            {
                Label(t("ios.control.upload"), systemImage: "square.and.arrow.up")
            }
        }
        .displayName("上传剪贴板")
    }
}

struct PullClipboardControl: ControlWidget
{
    var body: some ControlWidgetConfiguration
    {
        StaticControlConfiguration(kind: "net.commilitia.cdrop.control.pull")
        {
            ControlWidgetButton(action: PullClipboardIntent())
            {
                Label(t("ios.control.pull"), systemImage: "square.and.arrow.down")
            }
        }
        .displayName("拉取剪贴板")
    }
}
