generated from GDGVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8952b53
commit c3f25ae
Showing
8 changed files
with
320 additions
and
5 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
VITTY/vittyios-widgets/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
VITTY/vittyios-widgets/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
VITTY/vittyios-widgets/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,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,80 @@ | ||
// | ||
// vittyios_widgets.swift | ||
// vittyios-widgets | ||
// | ||
// Created by Chandram Dutta on 18/06/24. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
struct Provider: TimelineProvider { | ||
func placeholder(in context: Context) -> SimpleEntry { | ||
SimpleEntry(date: Date(), emoji: "😀") | ||
} | ||
|
||
func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) { | ||
let entry = SimpleEntry(date: Date(), emoji: "😀") | ||
completion(entry) | ||
} | ||
|
||
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | ||
var entries: [SimpleEntry] = [] | ||
|
||
// Generate a timeline consisting of five entries an hour apart, starting from the current date. | ||
let currentDate = Date() | ||
for hourOffset in 0 ..< 5 { | ||
let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! | ||
let entry = SimpleEntry(date: entryDate, emoji: "😀") | ||
entries.append(entry) | ||
} | ||
|
||
let timeline = Timeline(entries: entries, policy: .atEnd) | ||
completion(timeline) | ||
} | ||
} | ||
|
||
struct SimpleEntry: TimelineEntry { | ||
let date: Date | ||
let emoji: String | ||
} | ||
|
||
struct vittyios_widgetsEntryView : View { | ||
var entry: Provider.Entry | ||
|
||
var body: some View { | ||
VStack { | ||
Text("Time:") | ||
Text(entry.date, style: .time) | ||
|
||
Text("Emoji:") | ||
Text(entry.emoji) | ||
} | ||
} | ||
} | ||
|
||
struct vittyios_widgets: Widget { | ||
let kind: String = "vittyios_widgets" | ||
|
||
var body: some WidgetConfiguration { | ||
StaticConfiguration(kind: kind, provider: Provider()) { entry in | ||
if #available(iOS 17.0, *) { | ||
vittyios_widgetsEntryView(entry: entry) | ||
.containerBackground(.fill.tertiary, for: .widget) | ||
} else { | ||
vittyios_widgetsEntryView(entry: entry) | ||
.padding() | ||
.background() | ||
} | ||
} | ||
.configurationDisplayName("My Widget") | ||
.description("This is an example widget.") | ||
} | ||
} | ||
|
||
#Preview(as: .systemSmall) { | ||
vittyios_widgets() | ||
} timeline: { | ||
SimpleEntry(date: .now, emoji: "😀") | ||
SimpleEntry(date: .now, emoji: "🤩") | ||
} |
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 @@ | ||
// | ||
// vittyios_widgetsBundle.swift | ||
// vittyios-widgets | ||
// | ||
// Created by Chandram Dutta on 18/06/24. | ||
// | ||
|
||
import WidgetKit | ||
import SwiftUI | ||
|
||
@main | ||
struct vittyios_widgetsBundle: WidgetBundle { | ||
var body: some Widget { | ||
vittyios_widgets() | ||
} | ||
} |