Skip to content

Commit f0b7e20

Browse files
authored
Merge pull request #39 from eunjooChoi/planting-mind-widget-setup
2 parents ddbe113 + dd175f6 commit f0b7e20

File tree

12 files changed

+511
-1
lines changed

12 files changed

+511
-1
lines changed

PlantingMind/PlantingMind.xcodeproj/project.pbxproj

+204
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict/>
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<true/>
7+
</dict>
58
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
4+
wasCreatedForAppExtension = "YES"
5+
version = "2.0">
6+
<BuildAction
7+
parallelizeBuildables = "YES"
8+
buildImplicitDependencies = "YES">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "7B11F8232B4549DF00346A41"
19+
BuildableName = "PlantingMind.app"
20+
BlueprintName = "PlantingMind"
21+
ReferencedContainer = "container:PlantingMind.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
<BuildActionEntry
25+
buildForTesting = "YES"
26+
buildForRunning = "YES"
27+
buildForProfiling = "YES"
28+
buildForArchiving = "YES"
29+
buildForAnalyzing = "YES">
30+
<BuildableReference
31+
BuildableIdentifier = "primary"
32+
BlueprintIdentifier = "7B63CA9A2BA9CB4600943DED"
33+
BuildableName = "PlantingWidgetExtension.appex"
34+
BlueprintName = "PlantingWidgetExtension"
35+
ReferencedContainer = "container:PlantingMind.xcodeproj">
36+
</BuildableReference>
37+
</BuildActionEntry>
38+
</BuildActionEntries>
39+
</BuildAction>
40+
<TestAction
41+
buildConfiguration = "Debug"
42+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
43+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
shouldUseLaunchSchemeArgsEnv = "YES"
45+
shouldAutocreateTestPlan = "YES">
46+
</TestAction>
47+
<LaunchAction
48+
buildConfiguration = "Debug"
49+
selectedDebuggerIdentifier = ""
50+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
51+
launchStyle = "0"
52+
askForAppToLaunch = "Yes"
53+
useCustomWorkingDirectory = "NO"
54+
ignoresPersistentStateOnLaunch = "NO"
55+
debugDocumentVersioning = "YES"
56+
debugServiceExtension = "internal"
57+
allowLocationSimulation = "YES"
58+
launchAutomaticallySubstyle = "2">
59+
<RemoteRunnable
60+
runnableDebuggingMode = "2"
61+
BundleIdentifier = "com.apple.springboard">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "7B63CA9A2BA9CB4600943DED"
65+
BuildableName = "PlantingWidgetExtension.appex"
66+
BlueprintName = "PlantingWidgetExtension"
67+
ReferencedContainer = "container:PlantingMind.xcodeproj">
68+
</BuildableReference>
69+
</RemoteRunnable>
70+
<MacroExpansion>
71+
<BuildableReference
72+
BuildableIdentifier = "primary"
73+
BlueprintIdentifier = "7B11F8232B4549DF00346A41"
74+
BuildableName = "PlantingMind.app"
75+
BlueprintName = "PlantingMind"
76+
ReferencedContainer = "container:PlantingMind.xcodeproj">
77+
</BuildableReference>
78+
</MacroExpansion>
79+
<EnvironmentVariables>
80+
<EnvironmentVariable
81+
key = "_XCWidgetKind"
82+
value = ""
83+
isEnabled = "YES">
84+
</EnvironmentVariable>
85+
<EnvironmentVariable
86+
key = "_XCWidgetDefaultView"
87+
value = "timeline"
88+
isEnabled = "YES">
89+
</EnvironmentVariable>
90+
<EnvironmentVariable
91+
key = "_XCWidgetFamily"
92+
value = "systemMedium"
93+
isEnabled = "YES">
94+
</EnvironmentVariable>
95+
</EnvironmentVariables>
96+
</LaunchAction>
97+
<ProfileAction
98+
buildConfiguration = "Release"
99+
shouldUseLaunchSchemeArgsEnv = "YES"
100+
savedToolIdentifier = ""
101+
useCustomWorkingDirectory = "NO"
102+
debugDocumentVersioning = "YES"
103+
askForAppToLaunch = "Yes"
104+
launchAutomaticallySubstyle = "2">
105+
<BuildableProductRunnable
106+
runnableDebuggingMode = "0">
107+
<BuildableReference
108+
BuildableIdentifier = "primary"
109+
BlueprintIdentifier = "7B11F8232B4549DF00346A41"
110+
BuildableName = "PlantingMind.app"
111+
BlueprintName = "PlantingMind"
112+
ReferencedContainer = "container:PlantingMind.xcodeproj">
113+
</BuildableReference>
114+
</BuildableProductRunnable>
115+
</ProfileAction>
116+
<AnalyzeAction
117+
buildConfiguration = "Debug">
118+
</AnalyzeAction>
119+
<ArchiveAction
120+
buildConfiguration = "Release"
121+
revealArchiveInOrganizer = "YES">
122+
</ArchiveAction>
123+
</Scheme>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>com.apple.security.application-groups</key>
6+
<array>
7+
<string>group.eunjoo.planting-mind.PlantingMind</string>
8+
</array>
9+
</dict>
10+
</plist>
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+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
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+
}
+11
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// PlantingWidget.swift
3+
// PlantingWidget
4+
//
5+
// Created by 최은주 on 3/19/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
11+
struct Provider: TimelineProvider {
12+
func placeholder(in context: Context) -> SimpleEntry {
13+
SimpleEntry(date: Date(), emoji: "😀")
14+
}
15+
16+
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
17+
let entry = SimpleEntry(date: Date(), emoji: "😀")
18+
completion(entry)
19+
}
20+
21+
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
22+
var entries: [SimpleEntry] = []
23+
24+
// Generate a timeline consisting of five entries an hour apart, starting from the current date.
25+
let currentDate = Date()
26+
for hourOffset in 0 ..< 5 {
27+
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
28+
let entry = SimpleEntry(date: entryDate, emoji: "😀")
29+
entries.append(entry)
30+
}
31+
32+
let timeline = Timeline(entries: entries, policy: .atEnd)
33+
completion(timeline)
34+
}
35+
}
36+
37+
struct SimpleEntry: TimelineEntry {
38+
let date: Date
39+
let emoji: String
40+
}
41+
42+
struct PlantingWidgetEntryView : View {
43+
var entry: Provider.Entry
44+
45+
var body: some View {
46+
HStack {
47+
VStack(spacing: 4) {
48+
ForEach(Calendar.current.veryShortWeekdaySymbols, id: \.self) { symbol in
49+
Text(symbol)
50+
.font(.caption)
51+
.fontWeight(.semibold)
52+
}
53+
}
54+
55+
LazyHGrid(rows: Array(repeating: GridItem(.flexible(maximum: 15), spacing: 3), count: 7), spacing: 4, content: {
56+
ForEach(0...31, id: \.self) { item in
57+
RoundedRectangle(cornerRadius: 2)
58+
.foregroundColor(Color.cyan)
59+
.frame(width: 18)
60+
}
61+
})
62+
}
63+
}
64+
}
65+
66+
struct PlantingWidget: Widget {
67+
let kind: String = "com.eunjoo.planting-mind.PlantingWidget"
68+
69+
var body: some WidgetConfiguration {
70+
StaticConfiguration(kind: kind, provider: Provider()) { entry in
71+
if #available(iOS 17.0, *) {
72+
PlantingWidgetEntryView(entry: entry)
73+
.containerBackground(.fill.tertiary, for: .widget)
74+
} else {
75+
PlantingWidgetEntryView(entry: entry)
76+
.padding()
77+
.background()
78+
}
79+
}
80+
.configurationDisplayName("planting_mind")
81+
.description("심어놓은 기분을 위젯으로 확인하세요.")
82+
.supportedFamilies([.systemSmall, .systemMedium])
83+
}
84+
}
85+
86+
@available(iOS 17.0, *)
87+
#Preview(as: .systemSmall) {
88+
PlantingWidget()
89+
} timeline: {
90+
SimpleEntry(date: .now, emoji: "😀")
91+
SimpleEntry(date: .now, emoji: "🤩")
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// PlantingWidgetBundle.swift
3+
// PlantingWidget
4+
//
5+
// Created by 최은주 on 3/19/24.
6+
//
7+
8+
import WidgetKit
9+
import SwiftUI
10+
11+
@main
12+
struct PlantingWidgetBundle: WidgetBundle {
13+
var body: some Widget {
14+
PlantingWidget()
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>com.apple.security.application-groups</key>
6+
<array>
7+
<string>group.eunjoo.planting-mind.PlantingMind</string>
8+
</array>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)