-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS 14 widget for debug view of active recorders
- Loading branch information
Showing
11 changed files
with
472 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
RecordersWidget/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
RecordersWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
RecordersWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>RecordersWidget</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.widgetkit-extension</string> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// RecordersWidget.swift | ||
// RecordersWidget | ||
// | ||
// Created by Matt Greenfield on 28/6/20. | ||
// Copyright © 2020 Matt Greenfield. All rights reserved. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
import LocoKit | ||
|
||
struct Provider: TimelineProvider { | ||
public typealias Entry = SimpleEntry | ||
|
||
let appGroup = AppGroup(appName: .arcMini, suiteName: "group.ArcApp", readOnly: true) | ||
|
||
public func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date(), sortedApps: appGroup.sortedApps) | ||
completion(entry) | ||
} | ||
|
||
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | ||
let appGroup = AppGroup(appName: .arcMini, suiteName: "group.ArcApp", readOnly: true) | ||
let entries: [SimpleEntry] = [SimpleEntry(date: Date(), sortedApps: appGroup.sortedApps)] | ||
let timeline = Timeline(entries: entries, policy: .atEnd) | ||
completion(timeline) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
public let date: Date | ||
public let sortedApps: [LocoKit.AppGroup.AppState] | ||
} | ||
|
||
struct PlaceholderView: View { | ||
var body: some View { | ||
Text("Placeholder View") | ||
} | ||
} | ||
|
||
struct RecordersWidgetEntryView: View { | ||
var entry: Provider.Entry | ||
|
||
let appGroup = AppGroup(appName: .arcMini, suiteName: "group.ArcApp", readOnly: true) | ||
|
||
var body: some View { | ||
VStack { | ||
Text(entry.date, style: .time) | ||
ForEach(appGroup.sortedApps, id: \.updated) { appState in | ||
self.row( | ||
leftText: appState.appName.rawValue, | ||
rightText: "\(appState.recordingState.rawValue) (\(String(duration: appState.updated.age)) ago)", | ||
highlight: appState.isAliveAndRecording, fade: !appState.isAlive | ||
).frame(height: 20) | ||
} | ||
}.padding([.leading, .trailing], 20) | ||
} | ||
|
||
func row(leftText: String, rightText: String, highlight: Bool = false, fade: Bool = false) -> some View { | ||
let font = highlight ? Font.system(.footnote).bold() : Font.system(.footnote) | ||
return HStack { | ||
Text(leftText).font(font).opacity(fade ? 0.6 : 1) | ||
Spacer() | ||
Text(rightText).font(font).opacity(0.6).opacity(fade ? 0.6 : 1) | ||
} | ||
} | ||
|
||
} | ||
|
||
@main | ||
struct RecordersWidget: Widget { | ||
private let kind: String = "RecordersWidget" | ||
|
||
public var body: some WidgetConfiguration { | ||
StaticConfiguration(kind: kind, provider: Provider(), placeholder: PlaceholderView()) { entry in | ||
RecordersWidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("Arc Recorders") | ||
.description("The currently alive Arc recorders.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// WidgetState.swift | ||
// Arc Mini | ||
// | ||
// Created by Matt Greenfield on 28/6/20. | ||
// Copyright © 2020 Matt Greenfield. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import LocoKit | ||
|
||
class WidgetState: ObservableObject { | ||
var appGroup = AppGroup(appName: .arcMini, suiteName: "group.ArcApp") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.application-groups</key> | ||
<array> | ||
<string>group.ArcApp</string> | ||
</array> | ||
</dict> | ||
</plist> |