Update: 2026-07-30 02:27:45
This commit is contained in:
@@ -2,53 +2,15 @@
|
||||
// MusadaqLiveActivityControl.swift
|
||||
// MusadaqLiveActivity
|
||||
//
|
||||
// Created by Hamza Aleghwairyeen on 07/05/2026.
|
||||
// Intentionally empty.
|
||||
//
|
||||
// This file used to hold the stock Xcode ControlWidget template — a "Start
|
||||
// Timer" toggle whose `perform()` body was an empty comment. It was not listed
|
||||
// in MusadaqLiveActivityBundle, so iOS never surfaced it; had it been surfaced,
|
||||
// it would have shown users a toggle that does nothing.
|
||||
//
|
||||
// Musadaq has no Control Center widget. If one is added later, declare it here
|
||||
// AND add it to MusadaqLiveActivityBundle.
|
||||
//
|
||||
|
||||
import AppIntents
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct MusadaqLiveActivityControl: ControlWidget {
|
||||
var body: some ControlWidgetConfiguration {
|
||||
StaticControlConfiguration(
|
||||
kind: "com.example.musadaqApp.MusadaqLiveActivity",
|
||||
provider: Provider()
|
||||
) { value in
|
||||
ControlWidgetToggle(
|
||||
"Start Timer",
|
||||
isOn: value,
|
||||
action: StartTimerIntent()
|
||||
) { isRunning in
|
||||
Label(isRunning ? "On" : "Off", systemImage: "timer")
|
||||
}
|
||||
}
|
||||
.displayName("Timer")
|
||||
.description("A an example control that runs a timer.")
|
||||
}
|
||||
}
|
||||
|
||||
extension MusadaqLiveActivityControl {
|
||||
struct Provider: ControlValueProvider {
|
||||
var previewValue: Bool {
|
||||
false
|
||||
}
|
||||
|
||||
func currentValue() async throws -> Bool {
|
||||
let isRunning = true // Check if the timer is running
|
||||
return isRunning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct StartTimerIntent: SetValueIntent {
|
||||
static let title: LocalizedStringResource = "Start a timer"
|
||||
|
||||
@Parameter(title: "Timer is running")
|
||||
var value: Bool
|
||||
|
||||
func perform() async throws -> some IntentResult {
|
||||
// Start / stop the timer based on `value`.
|
||||
return .result()
|
||||
}
|
||||
}
|
||||
import Foundation
|
||||
|
||||
Reference in New Issue
Block a user