mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
make live activity menu item toggle properly
This commit is contained in:
parent
4ca3cf89ab
commit
00d9f7b474
3 changed files with 87 additions and 19 deletions
|
|
@ -225,7 +225,7 @@ struct Connect: View {
|
|||
HStack(alignment: .center) {
|
||||
Spacer()
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
|
||||
if bleManager.connectedPeripheral != nil {
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ struct Connect: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Spacer()
|
||||
}
|
||||
.padding(.bottom, 10)
|
||||
|
|
@ -336,6 +336,7 @@ func startNodeActivity() {
|
|||
}
|
||||
|
||||
func endActivity() {
|
||||
liveActivityStarted = false
|
||||
Task {
|
||||
if #available(iOS 16.2, *) {
|
||||
for activity in Activity<MeshActivityAttributes>.activities {
|
||||
|
|
|
|||
|
|
@ -1,20 +1,66 @@
|
|||
////
|
||||
//// Widgets.swift
|
||||
//// Widgets
|
||||
////
|
||||
//// Created by Garth Vander Houwen on 2/28/23.
|
||||
////
|
||||
//
|
||||
// WidgetsBundle.swift
|
||||
// Widgets
|
||||
//import WidgetKit
|
||||
//import SwiftUI
|
||||
//
|
||||
// Created by Garth Vander Houwen on 2/28/23.
|
||||
//struct Provider: TimelineProvider {
|
||||
// func placeholder(in context: Context) -> SimpleEntry {
|
||||
// SimpleEntry(date: Date())
|
||||
// }
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct Widgets: WidgetBundle {
|
||||
var body: some Widget {
|
||||
|
||||
// MARK: - Live Activity Widgets
|
||||
#if canImport(ActivityKit)
|
||||
MeshActivityWidget()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
|
||||
// let entry = SimpleEntry(date: Date())
|
||||
// completion(entry)
|
||||
// }
|
||||
//
|
||||
// func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||
// var entries: [SimpleEntry] = []
|
||||
//
|
||||
// // Generate a timeline consisting of five entries an hour apart, starting from the current date.
|
||||
// let currentDate = Date()
|
||||
// for hourOffset in 0 ..< 5 {
|
||||
// let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
|
||||
// let entry = SimpleEntry(date: entryDate)
|
||||
// entries.append(entry)
|
||||
// }
|
||||
//
|
||||
// let timeline = Timeline(entries: entries, policy: .atEnd)
|
||||
// completion(timeline)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//struct SimpleEntry: TimelineEntry {
|
||||
// let date: Date
|
||||
//}
|
||||
//
|
||||
//struct WidgetsEntryView : View {
|
||||
// var entry: Provider.Entry
|
||||
//
|
||||
// var body: some View {
|
||||
// Text(entry.date, style: .time)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//struct Widgets: Widget {
|
||||
// let kind: String = "Widgets"
|
||||
//
|
||||
// var body: some WidgetConfiguration {
|
||||
// StaticConfiguration(kind: kind, provider: Provider()) { entry in
|
||||
// WidgetsEntryView(entry: entry)
|
||||
// }
|
||||
// .configurationDisplayName("My Widget")
|
||||
// .description("This is an example widget.")
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//struct Widgets_Previews: PreviewProvider {
|
||||
// static var previews: some View {
|
||||
// WidgetsEntryView(entry: SimpleEntry(date: Date()))
|
||||
// .previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
21
Widgets/WidgetsBundle.swift
Normal file
21
Widgets/WidgetsBundle.swift
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// WidgetsBundle.swift
|
||||
// Widgets
|
||||
//
|
||||
// Created by Garth Vander Houwen on 2/28/23.
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@available(iOSApplicationExtension 16.2, *)
|
||||
@main
|
||||
struct WidgetsBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
//Widgets()
|
||||
#if canImport(ActivityKit)
|
||||
WidgetsLiveActivity()
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue