Skip to content

Commit c5b0cbb

Browse files
authored
Merge pull request #63 from DeveloperAcademy-POSTECH/back
Back
2 parents c9780f1 + c9e8b5e commit c5b0cbb

File tree

121 files changed

+4295
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4295
-143
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.DS_Store

hearo/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# macOS에서 생성되는 시스템 파일
2+
.DS_Store
3+
4+
# Xcode 사용자 설정 파일
5+
*.xcuserstate
6+
7+
# Xcode 빌드 파일
8+
build/
9+
10+
# 특정 파일 무시
11+
hearo/.DS_Store
12+
.DS_Store
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// AppIntent.swift
3+
// DynamicIslandWidget
4+
//
5+
// Created by Pil_Gaaang on 10/17/24.
6+
//
7+
8+
import WidgetKit
9+
import AppIntents
10+
11+
struct ConfigurationAppIntent: WidgetConfigurationIntent {
12+
static var title: LocalizedStringResource = "Configuration"
13+
static var description = IntentDescription("This is an example widget.")
14+
15+
// An example configurable parameter.
16+
@Parameter(title: "Favorite Emoji", default: "😃")
17+
var favoriteEmoji: String
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// DynamicIslandWidget.swift
3+
// DynamicIslandWidget
4+
//
5+
// Created by Pil_Gaaang on 10/17/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
11+
struct Provider: AppIntentTimelineProvider {
12+
func placeholder(in context: Context) -> SimpleEntry {
13+
SimpleEntry(date: Date(), configuration: ConfigurationAppIntent())
14+
}
15+
16+
func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry {
17+
SimpleEntry(date: Date(), configuration: configuration)
18+
}
19+
20+
func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> {
21+
var entries: [SimpleEntry] = []
22+
23+
// Generate a timeline consisting of five entries an hour apart, starting from the current date.
24+
let currentDate = Date()
25+
for hourOffset in 0 ..< 5 {
26+
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
27+
let entry = SimpleEntry(date: entryDate, configuration: configuration)
28+
entries.append(entry)
29+
}
30+
31+
return Timeline(entries: entries, policy: .atEnd)
32+
}
33+
}
34+
35+
struct SimpleEntry: TimelineEntry {
36+
let date: Date
37+
let configuration: ConfigurationAppIntent
38+
}
39+
40+
struct DynamicIslandWidgetEntryView : View {
41+
var entry: Provider.Entry
42+
43+
var body: some View {
44+
VStack {
45+
Text("Time:")
46+
Text(entry.date, style: .time)
47+
48+
Text("Favorite Emoji:")
49+
Text(entry.configuration.favoriteEmoji)
50+
}
51+
}
52+
}
53+
54+
struct DynamicIslandWidget: Widget {
55+
let kind: String = "DynamicIslandWidget"
56+
57+
var body: some WidgetConfiguration {
58+
AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in
59+
DynamicIslandWidgetEntryView(entry: entry)
60+
.containerBackground(.fill.tertiary, for: .widget)
61+
}
62+
}
63+
}
64+
65+
extension ConfigurationAppIntent {
66+
fileprivate static var smiley: ConfigurationAppIntent {
67+
let intent = ConfigurationAppIntent()
68+
intent.favoriteEmoji = "😀"
69+
return intent
70+
}
71+
72+
fileprivate static var starEyes: ConfigurationAppIntent {
73+
let intent = ConfigurationAppIntent()
74+
intent.favoriteEmoji = "🤩"
75+
return intent
76+
}
77+
}
78+
79+
#Preview(as: .systemSmall) {
80+
DynamicIslandWidget()
81+
} timeline: {
82+
SimpleEntry(date: .now, configuration: .smiley)
83+
SimpleEntry(date: .now, configuration: .starEyes)
84+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// DynamicIslandWidgetBundle.swift
3+
// DynamicIslandWidget
4+
//
5+
// Created by Pil_Gaaang on 10/17/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
11+
@main
12+
struct DynamicIslandWidgetBundle: WidgetBundle {
13+
var body: some Widget {
14+
DynamicIslandWidget()
15+
DynamicIslandWidgetLiveActivity()
16+
}
17+
}

0 commit comments

Comments
 (0)