Skip to content

Commit 07cb07a

Browse files
authored
Merge pull request #29 from DeveloperAcademy-POSTECH/feat/#25
Feat/#25: live activity 구현
2 parents f626c3a + dea3211 commit 07cb07a

File tree

10 files changed

+383
-3
lines changed

10 files changed

+383
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"platform" : "ios",
6+
"size" : "1024x1024"
7+
}
8+
],
9+
"info" : {
10+
"author" : "xcode",
11+
"version" : 1
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.110",
9+
"green" : "0.867",
10+
"red" : "0.498"
11+
}
12+
},
13+
"idiom" : "universal"
14+
}
15+
],
16+
"info" : {
17+
"author" : "xcode",
18+
"version" : 1
19+
}
20+
}
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+
}

LiveTimeWidget/Info.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSExtension</key>
6+
<dict>
7+
<key>NSExtensionPointIdentifier</key>
8+
<string>com.apple.widgetkit-extension</string>
9+
</dict>
10+
</dict>
11+
</plist>

LiveTimeWidget/LiveTimeWidget.swift

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// LiveTimeWidget.swift
3+
// LiveTimeWidget
4+
//
5+
// Created by Groo on 5/20/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
import ActivityKit
11+
12+
struct LiveTimeWidget: Widget {
13+
var body: some WidgetConfiguration {
14+
ActivityConfiguration(for: LiveTimeAttributes.self) { context in
15+
HStack {
16+
Image(systemName: "leaf.fill")
17+
.foregroundStyle(.customGreen)
18+
Text("잔디를 심을 시간이에요!")
19+
Spacer()
20+
Text(context.state.restOfTime, style: .relative)
21+
.foregroundStyle(.customGreen)
22+
.frame(width: 77, height: 30)
23+
}
24+
.padding()
25+
} dynamicIsland: { context in
26+
DynamicIsland {
27+
DynamicIslandExpandedRegion(.bottom) {
28+
VStack {
29+
Text("잔디 심을 시간이에요!")
30+
Text(context.state.restOfTime, style: .relative)
31+
.foregroundStyle(.customGreen)
32+
Button("click") {}
33+
.tint(.customGreen)
34+
}
35+
.padding()
36+
}
37+
} compactLeading: {
38+
Image(systemName: "leaf.fill")
39+
.foregroundStyle(.customGreen)
40+
} compactTrailing: {
41+
Text(context.state.restOfTime, style: .relative)
42+
.foregroundStyle(.customGreen)
43+
.frame(width: 66)
44+
} minimal: {
45+
Text(context.state.restOfTime, style: .relative)
46+
.foregroundStyle(.customGreen)
47+
}
48+
}
49+
}
50+
}
51+
52+
struct TimeWidgetView: View {
53+
let context: ActivityViewContext<LiveTimeAttributes>
54+
55+
var body: some View {
56+
Text(context.state.restOfTime, style: .relative)
57+
}
58+
}
59+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// LiveTimeWidgetBundle.swift
3+
// LiveTimeWidget
4+
//
5+
// Created by Groo on 5/20/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
11+
@main
12+
struct LiveTimeWidgetBundle: WidgetBundle {
13+
var body: some Widget {
14+
LiveTimeWidget()
15+
}
16+
}

0 commit comments

Comments
 (0)