Skip to content

Commit

Permalink
Merge pull request #29 from DeveloperAcademy-POSTECH/feat/#25
Browse files Browse the repository at this point in the history
Feat/#25: live activity 구현
  • Loading branch information
grootwo authored May 21, 2024
2 parents f626c3a + dea3211 commit 07cb07a
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 3 deletions.
13 changes: 13 additions & 0 deletions LiveTimeWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
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
}
}
6 changes: 6 additions & 0 deletions LiveTimeWidget/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions LiveTimeWidget/Assets.xcassets/CustomGreen.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.110",
"green" : "0.867",
"red" : "0.498"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
11 changes: 11 additions & 0 deletions LiveTimeWidget/Info.plist
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>
59 changes: 59 additions & 0 deletions LiveTimeWidget/LiveTimeWidget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// LiveTimeWidget.swift
// LiveTimeWidget
//
// Created by Groo on 5/20/24.
//

import WidgetKit
import SwiftUI
import ActivityKit

struct LiveTimeWidget: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: LiveTimeAttributes.self) { context in
HStack {
Image(systemName: "leaf.fill")
.foregroundStyle(.customGreen)
Text("잔디를 심을 시간이에요!")
Spacer()
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
.frame(width: 77, height: 30)
}
.padding()
} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.bottom) {
VStack {
Text("잔디 심을 시간이에요!")
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
Button("click") {}
.tint(.customGreen)
}
.padding()
}
} compactLeading: {
Image(systemName: "leaf.fill")
.foregroundStyle(.customGreen)
} compactTrailing: {
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
.frame(width: 66)
} minimal: {
Text(context.state.restOfTime, style: .relative)
.foregroundStyle(.customGreen)
}
}
}
}

struct TimeWidgetView: View {
let context: ActivityViewContext<LiveTimeAttributes>

var body: some View {
Text(context.state.restOfTime, style: .relative)
}
}

16 changes: 16 additions & 0 deletions LiveTimeWidget/LiveTimeWidgetBundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// LiveTimeWidgetBundle.swift
// LiveTimeWidget
//
// Created by Groo on 5/20/24.
//

import WidgetKit
import SwiftUI

@main
struct LiveTimeWidgetBundle: WidgetBundle {
var body: some Widget {
LiveTimeWidget()
}
}
Loading

0 comments on commit 07cb07a

Please sign in to comment.