-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
268 additions
and
4 deletions.
There are no files selected for viewing
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,19 @@ | ||
// | ||
// AppIntent.swift | ||
// midile-widget | ||
// | ||
// Created by Matthias Frick on 29.10.23. | ||
// Copyright © 2023 Matthias Frick. All rights reserved. | ||
// | ||
|
||
import WidgetKit | ||
import AppIntents | ||
|
||
struct ConfigurationAppIntent: WidgetConfigurationIntent { | ||
static var title: LocalizedStringResource = "Configuration" | ||
static var description = IntentDescription("This is an example widget.") | ||
|
||
// An example configurable parameter. | ||
@Parameter(title: "Favorite Emoji", default: "😃") | ||
var favoriteEmoji: String | ||
} |
11 changes: 11 additions & 0 deletions
11
midile-widget/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 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
midile-widget/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,13 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"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
midile-widget/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,11 @@ | ||
<?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>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,9 @@ | ||
// | ||
// MIDIActivityAttribute.swift | ||
// midimittr | ||
// | ||
// Created by Matthias Frick on 29.10.23. | ||
// Copyright © 2023 Matthias Frick. All rights reserved. | ||
// | ||
|
||
import Foundation |
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,85 @@ | ||
// | ||
// midile_widget.swift | ||
// midile-widget | ||
// | ||
// Created by Matthias Frick on 29.10.23. | ||
// Copyright © 2023 Matthias Frick. All rights reserved. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct Provider: AppIntentTimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) | ||
} | ||
|
||
func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { | ||
SimpleEntry(date: Date(), configuration: configuration) | ||
} | ||
|
||
func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> { | ||
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, configuration: configuration) | ||
entries.append(entry) | ||
} | ||
|
||
return Timeline(entries: entries, policy: .atEnd) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
let configuration: ConfigurationAppIntent | ||
} | ||
|
||
struct midile_widgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
VStack { | ||
Text("Time:") | ||
Text(entry.date, style: .time) | ||
|
||
Text("Favorite Emoji:") | ||
Text(entry.configuration.favoriteEmoji) | ||
} | ||
} | ||
} | ||
|
||
struct midile_widget: Widget { | ||
let kind: String = "midile_widget" | ||
|
||
var body: some WidgetConfiguration { | ||
AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in | ||
midile_widgetEntryView(entry: entry) | ||
.containerBackground(.fill.tertiary, for: .widget) | ||
} | ||
} | ||
} | ||
|
||
extension ConfigurationAppIntent { | ||
fileprivate static var smiley: ConfigurationAppIntent { | ||
let intent = ConfigurationAppIntent() | ||
intent.favoriteEmoji = "😀" | ||
return intent | ||
} | ||
|
||
fileprivate static var starEyes: ConfigurationAppIntent { | ||
let intent = ConfigurationAppIntent() | ||
intent.favoriteEmoji = "🤩" | ||
return intent | ||
} | ||
} | ||
|
||
#Preview(as: .systemSmall) { | ||
midile_widget() | ||
} timeline: { | ||
SimpleEntry(date: .now, configuration: .smiley) | ||
SimpleEntry(date: .now, configuration: .starEyes) | ||
} |
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,18 @@ | ||
// | ||
// midile_widgetBundle.swift | ||
// midile-widget | ||
// | ||
// Created by Matthias Frick on 29.10.23. | ||
// Copyright © 2023 Matthias Frick. All rights reserved. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct midile_widgetBundle: WidgetBundle { | ||
var body: some Widget { | ||
midile_widget() | ||
midile_widgetLiveActivity() | ||
} | ||
} |
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,81 @@ | ||
// | ||
// midile_widgetLiveActivity.swift | ||
// midile-widget | ||
// | ||
// Created by Matthias Frick on 29.10.23. | ||
// Copyright © 2023 Matthias Frick. All rights reserved. | ||
// | ||
|
||
import ActivityKit | ||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct midile_widgetAttributes: ActivityAttributes { | ||
public struct ContentState: Codable, Hashable { | ||
// Dynamic stateful properties about your activity go here! | ||
var emoji: String | ||
} | ||
|
||
// Fixed non-changing properties about your activity go here! | ||
var name: String | ||
} | ||
|
||
struct midile_widgetLiveActivity: Widget { | ||
var body: some WidgetConfiguration { | ||
ActivityConfiguration(for: midile_widgetAttributes.self) { context in | ||
// Lock screen/banner UI goes here | ||
VStack { | ||
Text("Hello \(context.state.emoji)") | ||
} | ||
.activityBackgroundTint(Color.cyan) | ||
.activitySystemActionForegroundColor(Color.black) | ||
|
||
} dynamicIsland: { context in | ||
DynamicIsland { | ||
// Expanded UI goes here. Compose the expanded UI through | ||
// various regions, like leading/trailing/center/bottom | ||
DynamicIslandExpandedRegion(.leading) { | ||
Text("Leading") | ||
} | ||
DynamicIslandExpandedRegion(.trailing) { | ||
Text("Trailing") | ||
} | ||
DynamicIslandExpandedRegion(.bottom) { | ||
Text("Bottom \(context.state.emoji)") | ||
// more content | ||
} | ||
} compactLeading: { | ||
Text("L") | ||
} compactTrailing: { | ||
Text("T \(context.state.emoji)") | ||
} minimal: { | ||
Text(context.state.emoji) | ||
} | ||
.widgetURL(URL(string: "http://www.apple.com")) | ||
.keylineTint(Color.red) | ||
} | ||
} | ||
} | ||
|
||
extension midile_widgetAttributes { | ||
fileprivate static var preview: midile_widgetAttributes { | ||
midile_widgetAttributes(name: "World") | ||
} | ||
} | ||
|
||
extension midile_widgetAttributes.ContentState { | ||
fileprivate static var smiley: midile_widgetAttributes.ContentState { | ||
midile_widgetAttributes.ContentState(emoji: "😀") | ||
} | ||
|
||
fileprivate static var starEyes: midile_widgetAttributes.ContentState { | ||
midile_widgetAttributes.ContentState(emoji: "🤩") | ||
} | ||
} | ||
|
||
#Preview("Notification", as: .content, using: midile_widgetAttributes.preview) { | ||
midile_widgetLiveActivity() | ||
} contentStates: { | ||
midile_widgetAttributes.ContentState.smiley | ||
midile_widgetAttributes.ContentState.starEyes | ||
} |
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
Binary file modified
BIN
+9.86 KB
(110%)
...roj/project.xcworkspace/xcuserdata/sierenmusic.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.