-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Feat] Widget * Merge branch 'develop' into Widget
- Loading branch information
Showing
12 changed files
with
417 additions
and
8 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
AsyncSwiftWidget/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
AsyncSwiftWidget/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
AsyncSwiftWidget/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,60 @@ | ||
// | ||
// AsyncSwiftWidget.swift | ||
// AsyncSwiftWidget | ||
// | ||
// Created by 김인섭 on 2023/10/01. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct Provider: TimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date(), imageData: getRemoteImage()) | ||
} | ||
|
||
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date(), imageData: getRemoteImage()) | ||
completion(entry) | ||
} | ||
|
||
func getTimeline(in context: Context, completion: @escaping (Timeline<SimpleEntry>) -> ()) { | ||
|
||
let entry = SimpleEntry(date: Date(), imageData: getRemoteImage()) | ||
let nextUpdate = Calendar.current.date(byAdding: .minute, value: 15, to: Date()) | ||
let timeline = Timeline(entries: [entry], policy: .after(nextUpdate!)) | ||
completion(timeline) | ||
} | ||
|
||
func getRemoteImage() -> Data? { | ||
let urlString = "https://raw.githubusercontent.com/Async-Swift/jsonstorage/a94eb982e9b9db90543de1d574a6dc5f0c637f5b/Images/widget-large.svg" | ||
return try? Data(contentsOf: URL(string: urlString)!) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
var date: Date | ||
let imageData: Data? | ||
} | ||
|
||
struct AsyncSwiftWidget: Widget { | ||
let kind: String = "AsyncSwiftWidget" | ||
|
||
var body: some WidgetConfiguration { | ||
StaticConfiguration(kind: kind, provider: Provider()) { entry in | ||
AsyncSwiftWidgetEntryView(entry: entry) | ||
} | ||
.configurationDisplayName("AsyncSwift") | ||
.description("행사 정보를 확인하세요.") | ||
.supportedFamilies( | ||
[.systemLarge] | ||
) | ||
} | ||
} | ||
|
||
struct AsyncSwiftWidget_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AsyncSwiftWidgetEntryView(entry: SimpleEntry(date: Date(), imageData: nil)) | ||
.previewContext(WidgetPreviewContext(family: .systemSmall)) | ||
} | ||
} |
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,16 @@ | ||
// | ||
// AsyncSwiftWidgetBundle.swift | ||
// AsyncSwiftWidget | ||
// | ||
// Created by 김인섭 on 2023/10/01. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct AsyncSwiftWidgetBundle: WidgetBundle { | ||
var body: some Widget { | ||
AsyncSwiftWidget() | ||
} | ||
} |
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,25 @@ | ||
// | ||
// AsyncSwiftWidgetEntryView.swift | ||
// AsyncSwift | ||
// | ||
// Created by 김인섭 on 2023/10/01. | ||
// | ||
|
||
import SwiftUI | ||
import WidgetKit | ||
import SVGKit | ||
|
||
struct AsyncSwiftWidgetEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
if let imageData = entry.imageData, let image = SVGKImage(data: imageData) { | ||
Image(uiImage: image.uiImage) | ||
.resizable() | ||
.scaledToFill() | ||
.offset(y: 10) | ||
} else { | ||
Text("다음 행사때 만나요. 🤗") | ||
} | ||
} | ||
} |
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,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.com.kim.AsyncSwift</string> | ||
</array> | ||
</dict> | ||
</plist> |