Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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 FavouriteCardsWiget/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"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
}
}
73 changes: 73 additions & 0 deletions FavouriteCardsWiget/FavouriteCardsWiget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// FavouriteCardsWiget.swift
// FavouriteCardsWiget
//
// Created by Pushpinder Pal Singh on 04/05/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>) -> ()) {
let entry = SimpleEntry(date: .now, emoji: "😀")
let timeline = Timeline(entries: [entry], policy: .never)
completion(timeline)
}
}

struct SimpleEntry: TimelineEntry {
let date: Date
let emoji: String
}

struct FavouriteCardsWigetEntryView : View {
var entry: Provider.Entry

var body: some View {
HStack{
VStack(alignment: .leading) {
Image("4".getCardNetwork().rawValue)
Text("Axis Magnus")
.font(.title2)
.fontWeight(.semibold)
}
Spacer()
}
}
}

struct FavouriteCardsWiget: Widget {
let kind: String = "FavouriteCardsWiget"

var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
if #available(iOS 17.0, *) {
FavouriteCardsWigetEntryView(entry: entry)
.containerBackground(.fill.tertiary, for: .widget)
} else {
FavouriteCardsWigetEntryView(entry: entry)
.padding()
.background()
}
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
}
}

#Preview(as: .systemSmall) {
FavouriteCardsWiget()
} timeline: {
SimpleEntry(date: .now, emoji: "😀")
SimpleEntry(date: .now, emoji: "🤩")
}
16 changes: 16 additions & 0 deletions FavouriteCardsWiget/FavouriteCardsWigetBundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// FavouriteCardsWigetBundle.swift
// FavouriteCardsWiget
//
// Created by Pushpinder Pal Singh on 04/05/24.
//

import WidgetKit
import SwiftUI

@main
struct FavouriteCardsWigetBundle: WidgetBundle {
var body: some Widget {
FavouriteCardsWiget()
}
}
11 changes: 11 additions & 0 deletions FavouriteCardsWiget/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>
Loading