Skip to content

muhittincamdali/iOS-Widget-Development-Kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
╔══════════════════════════════════════════════════════════════════════════════════════╗
β•‘                                                                                      β•‘
β•‘   β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—  β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—           β•‘
β•‘   β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•    β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•           β•‘
β•‘   β–ˆβ–ˆβ•‘ β–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘              β•‘
β•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•     β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘              β•‘
β•‘   β•šβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘       β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘              β•‘
β•‘    β•šβ•β•β•β•šβ•β•β• β•šβ•β•β•šβ•β•β•β•β•β•  β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β•β•   β•šβ•β•       β•šβ•β•  β•šβ•β•β•šβ•β•   β•šβ•β•              β•‘
β•‘                                                                                      β•‘
β•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β•‘
β•‘   β–ˆ  The Ultimate iOS Widget Development Framework β€” 50+ Templates Included!    β–ˆ   β•‘
β•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   β•‘
β•‘                                                                                      β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

The most comprehensive iOS widget development kit with 50+ production-ready templates, Live Activities, Dynamic Island, Interactive Widgets, and StandBy mode support.

Swift iOS WidgetKit SPM License

Features β€’ Templates β€’ Live Activities β€’ Interactive β€’ StandBy β€’ Charts β€’ Docs


πŸ† Why Choose This Kit?

Feature This Kit Others
Widget Templates 50+ 5-10
Live Activity Templates 15 2-3
Interactive Widgets βœ… ❌
StandBy Mode βœ… ❌
Dynamic Island βœ… Partial
Lock Screen Widgets 15 3-5
SwiftUI Charts βœ… ❌
Network Data Support βœ… Basic
Timeline Management Advanced Basic
Deep Linking βœ… ❌
Production Ready βœ… ❌

πŸ“‹ Table of Contents


✨ Features

Widget Types

  • 🏠 Home Screen Widgets β€” Small, Medium, Large, Extra Large
  • πŸ”’ Lock Screen Widgets β€” Circular, Rectangular, Inline
  • ⚑ Live Activities β€” Real-time updates on lock screen
  • 🏝️ Dynamic Island β€” Compact and expanded views
  • πŸ“Ί StandBy Mode β€” Full-screen widgets (iOS 17+)
  • πŸ–±οΈ Interactive Widgets β€” Buttons, toggles, counters (iOS 17+)

Advanced Features

  • πŸ“Š SwiftUI Charts β€” Bar, line, pie, sparkline charts
  • 🌐 Network Data β€” Fetch and cache remote data
  • ⏱️ Smart Timeline β€” Battery-aware refresh strategies
  • πŸ”— Deep Linking β€” Open specific app content
  • βš™οΈ Configuration β€” User-customizable widgets
  • 🎨 Theming β€” Custom colors and styles

🎨 Widget Templates (50+)

Home Screen Widgets (20)

Template Description Size
GradientCardWidget Beautiful gradient cards S/M/L
StatsWidget Statistics with progress bars M/L
CalendarWidget Upcoming events display M/L
WeatherWidget Weather conditions S/M/L
CountdownWidget Event countdown timer S/M
QuoteWidget Inspirational quotes M/L
MusicWidget Now playing info M
FitnessWidget Activity rings S/M
HabitTrackerWidget Habit tracking streaks M/L
FinanceWidget Account balances M/L
PhotoFrameWidget Photo display S/M/L
NotesWidget Quick notes preview M/L
BatteryWidget Device battery status S/M
ShortcutsWidget Quick action grid M
SocialStatsWidget Social media stats M
ClockWidget Analog/Digital clock S/M
TodoWidget Task list M/L
PodcastWidget Podcast player M
NewsWidget News headlines M/L
WaterTrackerWidget Water intake S/M

Usage Example

import SwiftUI
import WidgetKit
import iOSWidgetKit

struct MyWidgetView: View {
    var entry: SimpleEntry
    
    var body: some View {
        WeatherWidget(
            temperature: 72,
            condition: .sunny,
            location: "San Francisco",
            high: 78,
            low: 65
        )
    }
}

⚑ Live Activities

10 Live Activity Templates

Template Use Case
DeliveryActivity Food/package delivery
RideActivity Uber/Lyft style rides
SportsScoreActivity Live sports scores
TimerActivity Countdown timer
WorkoutActivity Fitness tracking
NowPlayingActivity Music player
FlightActivity Flight tracking
ParkingActivity Parking meter
OrderActivity Order status
MeetingActivity Calendar meetings

Create a Live Activity

import ActivityKit
import iOSWidgetKit

// Define your activity
let attributes = DeliveryAttributes(
    orderNumber: "12345",
    restaurantName: "Pizza Place"
)

let state = DeliveryAttributes.ContentState(
    status: .onTheWay,
    estimatedArrival: Date().addingTimeInterval(1800),
    driverName: "John",
    currentStep: 2
)

// Start the activity
let activity = try LiveActivityManager.shared.startActivity(
    attributes: attributes,
    contentState: state
)

// Update
await LiveActivityManager.shared.updateActivity(
    activity,
    with: DeliveryAttributes.ContentState(
        status: .arriving,
        estimatedArrival: Date().addingTimeInterval(300),
        driverName: "John",
        currentStep: 3
    )
)

// End
await LiveActivityManager.shared.endActivity(activity)

Dynamic Island Views

struct DeliveryActivityConfiguration: Widget {
    var body: some WidgetConfiguration {
        ActivityConfiguration(for: DeliveryAttributes.self) { context in
            // Lock screen view
            DeliveryActivityView(context: context)
        } dynamicIsland: { context in
            DynamicIsland {
                // Expanded view
                DynamicIslandExpandedRegion(.leading) {
                    Image(systemName: context.state.status.icon)
                }
                DynamicIslandExpandedRegion(.trailing) {
                    Text(context.state.estimatedArrival, style: .timer)
                }
                DynamicIslandExpandedRegion(.bottom) {
                    ProgressView(value: Double(context.state.currentStep), total: 4)
                }
            } compactLeading: {
                Image(systemName: context.state.status.icon)
            } compactTrailing: {
                Text(context.state.estimatedArrival, style: .timer)
            } minimal: {
                Image(systemName: context.state.status.icon)
            }
        }
    }
}

πŸ–±οΈ Interactive Widgets

iOS 17+ Only β€” Add buttons, toggles, and interactive elements.

Available Interactive Templates

  • InteractiveToggleWidget β€” Toggle switches
  • InteractiveCounterWidget β€” Increment/decrement counters
  • InteractiveTaskListWidget β€” Task completion toggles
  • InteractiveQuickActionsWidget β€” Action buttons grid
  • InteractiveTimerWidget β€” Timer controls
  • InteractiveHabitWidget β€” Habit checkmarks
  • InteractiveRatingWidget β€” Star ratings
  • InteractiveWaterWidget β€” Water intake buttons

Example

import AppIntents
import iOSWidgetKit

// Interactive counter widget
struct MyInteractiveWidget: View {
    let counterId = "daily_counter"
    @AppStorage("counter_daily_counter", store: UserDefaults(suiteName: "group.widget"))
    var count = 0
    
    var body: some View {
        InteractiveCounterWidget(
            title: "Daily Count",
            counterId: counterId,
            currentValue: count,
            accentColor: .blue
        )
    }
}

// Task list with toggles
struct TaskWidget: View {
    var body: some View {
        InteractiveTaskListWidget(
            tasks: [
                .init(id: "1", title: "Morning workout", isCompleted: true, priority: .high),
                .init(id: "2", title: "Read 30 minutes", isCompleted: false, priority: .medium),
                .init(id: "3", title: "Call mom", isCompleted: false, priority: .low)
            ],
            listTitle: "Today's Tasks"
        )
    }
}

πŸ“Ί StandBy Mode

iOS 17+ Only β€” Full-screen widgets for StandBy mode on iPhone.

StandBy Templates

Template Description
StandByClockWidget Digital/Analog clocks
StandByPhotoWidget Photo frames
StandByWeatherWidget Weather display
StandByCalendarWidget Calendar view
StandByFitnessWidget Activity rings
StandByMusicWidget Now playing
StandByCountdownWidget Event countdown

Example

import iOSWidgetKit

struct MyStandByWidget: View {
    var body: some View {
        StandByClockWidget(
            date: Date(),
            style: .flipClock,
            showDate: true,
            accentColor: .white
        )
    }
}

// Apply StandBy optimizations
struct OptimizedWidget: View {
    var body: some View {
        VStack {
            Text("Hello")
        }
        .standByOptimized(nightModeColor: .red)
    }
}

πŸ”’ Lock Screen Widgets

15 Lock Screen Templates

Circular Widgets:

  • CircularProgressWidget β€” Progress gauge
  • CircularIconWidget β€” Simple icon
  • CircularRingWidget β€” Activity rings

Rectangular Widgets:

  • RectangularTextWidget β€” Multi-line text
  • RectangularStatsWidget β€” Statistics
  • RectangularProgressWidget β€” Progress bar
  • RectangularCalendarWidget β€” Events
  • RectangularWeatherWidget β€” Weather

Inline Widgets:

  • InlineTextWidget β€” Text with icon
  • InlineStatsWidget β€” Quick stats

Multi-Family Widgets:

  • LockScreenBatteryWidget β€” Battery (all sizes)
  • LockScreenTimerWidget β€” Timer (all sizes)
  • LockScreenFitnessWidget β€” Fitness (all sizes)
  • LockScreenCountdownWidget β€” Countdown (all sizes)
  • LockScreenQuickActionWidget β€” Actions (all sizes)

Example

struct MyLockScreenWidget: Widget {
    var body: some WidgetConfiguration {
        StaticConfiguration(kind: "LockScreen", provider: Provider()) { entry in
            // Automatically adapt to family
            switch entry.family {
            case .accessoryCircular:
                CircularProgressWidget(
                    progress: 0.7,
                    icon: "star.fill",
                    accentColor: .blue
                )
            case .accessoryRectangular:
                RectangularStatsWidget(
                    stats: [("Steps", "8,234"), ("Cal", "450"), ("Dist", "4.2mi")],
                    title: "Today"
                )
            case .accessoryInline:
                InlineTextWidget(icon: "flame.fill", text: "450 calories burned")
            default:
                EmptyView()
            }
        }
        .supportedFamilies([.accessoryCircular, .accessoryRectangular, .accessoryInline])
    }
}

πŸ“Š Charts in Widgets

SwiftUI Charts integration for beautiful data visualization.

Available Chart Types

Chart Description
WidgetBarChart Vertical bar chart
WidgetLineChart Line chart with area
WidgetSparkline Minimal sparkline
WidgetPieChart Pie/donut chart
WidgetProgressRing Circular progress
WidgetMultiLineChart Multiple series
WidgetHorizontalBarChart Horizontal bars
WidgetActivityChart GitHub-style activity
WidgetStatsChart Stats with sparkline

Example

import iOSWidgetKit
import Charts

struct ChartWidget: View {
    var body: some View {
        VStack {
            // Sparkline
            WidgetSparkline(
                values: [10, 25, 15, 30, 22, 35, 28],
                color: .blue,
                showGradient: true
            )
            .frame(height: 50)
            
            // Stats with chart
            WidgetStatsChart(
                title: "Revenue",
                value: "$12,450",
                change: 12.5,
                sparklineData: [100, 120, 110, 145, 160, 155, 180],
                accentColor: .green
            )
            
            // Horizontal bar comparison
            WidgetHorizontalBarChart(
                data: [
                    .init(label: "Mon", value: 45),
                    .init(label: "Tue", value: 62),
                    .init(label: "Wed", value: 38)
                ],
                accentColor: .purple
            )
        }
    }
}

⏱️ Timeline Management

Advanced timeline management for optimal battery and freshness.

Features

  • Smart Refresh Strategies β€” Time-based, battery-aware, content-aware
  • Caching β€” Built-in cache layer
  • Timeline Builder β€” Fluent API
  • Metrics β€” Performance tracking

Example

import iOSWidgetKit

// Use Timeline Builder
let timeline = TimelineBuilder<MyEntry>()
    .addEntry(MyEntry(date: Date(), data: currentData))
    .addEntry(MyEntry(date: Date().addingTimeInterval(3600), data: currentData))
    .reloadAfter(1800) // 30 minutes
    .build()

// Battery-aware refresh
let strategy = BatteryAwareRefreshStrategy(
    normalInterval: 900,      // 15 min normally
    lowBatteryInterval: 3600, // 1 hour on low battery
    lowBatteryThreshold: 0.2
)

// Use cache
TimelineCacheManager.shared.store(myData, forKey: "widget_data", expiration: 300)
if let cached: MyData = TimelineCacheManager.shared.retrieve(MyData.self, forKey: "widget_data") {
    // Use cached data
}

🌐 Network Data Support

Fetch and display remote data in widgets.

import iOSWidgetKit

// Simple fetch
let data = try await NetworkDataProvider.shared.fetch(
    WeatherResponse.self,
    from: URL(string: "https://api.weather.com/data")!
)

// With caching
let provider = CachedNetworkProvider<WeatherResponse>(
    cacheKey: "weather",
    cacheDuration: 600
)
let weather = try await provider.fetch(from: url)

// Background refresh
BackgroundRefreshCoordinator.shared.scheduleBackgroundRefresh(
    identifier: "weather_widget",
    afterInterval: 1800
)

πŸ”— Deep Linking

Connect widget taps to specific app content.

import iOSWidgetKit

// Build deep link URL
let url = WidgetDeepLinkManager.shared.buildContentURL(
    contentType: "task",
    contentId: "123",
    parameters: ["source": "widget"]
)

// In widget view
Link(destination: url!) {
    TaskRow(task: task)
}

// Handle in app
@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .onWidgetURL { url in
                    let params = WidgetDeepLinkManager.shared.parseParameters(from: url)
                    // Navigate to content
                }
        }
    }
}

πŸ“¦ Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/muhittincamdali/iOS-Widget-Development-Kit.git", from: "2.0.0")
]

CocoaPods

pod 'WidgetDevelopmentKit', '~> 2.0'

πŸš€ Quick Start

1. Add Widget Extension

File β†’ New β†’ Target β†’ Widget Extension

2. Import the Kit

import WidgetKit
import SwiftUI
import iOSWidgetKit

3. Create Your Widget

struct MyWidget: Widget {
    let kind: String = "MyWidget"
    
    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind, provider: MyProvider()) { entry in
            WeatherWidget(
                temperature: entry.temperature,
                condition: entry.condition,
                location: entry.location,
                high: entry.high,
                low: entry.low
            )
        }
        .configurationDisplayName("Weather")
        .description("Shows current weather.")
        .supportedFamilies([.systemSmall, .systemMedium])
    }
}

πŸ“ Project Structure

iOS-Widget-Development-Kit/
β”œβ”€β”€ Sources/
β”‚   β”œβ”€β”€ Templates/          # 20+ Home Screen widget templates
β”‚   β”œβ”€β”€ LiveActivities/     # 10+ Live Activity templates
β”‚   β”œβ”€β”€ Interactive/        # iOS 17 interactive widgets
β”‚   β”œβ”€β”€ StandBy/            # StandBy mode widgets
β”‚   β”œβ”€β”€ LockScreen/         # 15 Lock Screen widgets
β”‚   β”œβ”€β”€ Charts/             # SwiftUI Charts for widgets
β”‚   β”œβ”€β”€ Core/               # Timeline management
β”‚   β”œβ”€β”€ Network/            # Network data support
β”‚   └── Configuration/      # Deep linking & config
β”œβ”€β”€ Examples/               # Sample implementations
β”œβ”€β”€ Tests/                  # Comprehensive tests
└── Documentation/          # Guides & tutorials

πŸ“‹ Requirements

Requirement Minimum
iOS 16.0+
Xcode 15.0+
Swift 5.9+

Feature Requirements:

Feature iOS Version
Home Screen Widgets 14.0+
Lock Screen Widgets 16.0+
Live Activities 16.1+
Dynamic Island 16.1+
Interactive Widgets 17.0+
StandBy Mode 17.0+

πŸ“– Documentation

Guide Description
Widget Design Guide Design best practices
Timeline Management Refresh strategies
Live Activities Guide Dynamic Island setup
Interactive Widgets iOS 17 interactions
StandBy Mode Full-screen widgets
Network Data Remote data fetching
Best Practices Performance tips

🀝 Contributing

Contributions welcome! See CONTRIBUTING.md.

git checkout -b feature/amazing-widget
git commit -m "feat(widgets): add amazing widget template"
git push origin feature/amazing-widget

πŸ“„ License

MIT License β€” see LICENSE for details.


πŸ‘¨β€πŸ’» Author

Muhittin Camdali

GitHub LinkedIn


⭐ Star this repo if you find it useful!


πŸ“ˆ Star History

Star History Chart

Sponsor this project

Packages

 
 
 

Contributors

Languages