Skip to content
Provenance-EmuPublic

About

Home screen game widgets shared by Provenance, iCube and iFly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PVWidgets

Home screen game widgets shared by Provenance, iCube and iFly.

One package draws a feed of games (recently played, favorites, continues, and whatever else an app supplies) as a grid or a list, at every widget size. The arrangement is worked out from the widget's real size, so covers and titles are never clipped on any iPhone or iPad.

Each app keeps its own stored data and its own look: it maps its data into WidgetItem through a WidgetDataSource, and passes a WidgetTheme.

Targets

  • PVWidgetsLayout: Foundation only. WidgetLayoutEngine turns a size, a style and a game count into a WidgetLayout (one game, a grid, or a list).
  • PVWidgets: the SwiftUI views, the cover loader, the edit-screen intent and the timeline provider.

Using it in a widget extension

import PVWidgets
import SwiftUI
import WidgetKit

struct MyDataSource: WidgetDataSource {
    var feeds: [WidgetFeed] { [.recentlyPlayed, .favorites] }

    func items(for feed: WidgetFeed.ID, limit: Int) -> [WidgetItem] {
        // Read your app group and map each game into a WidgetItem.
        []
    }
}

struct RecentlyPlayedWidget: Widget {
    var body: some WidgetConfiguration {
        FeedWidgetDefinition(
            kind: "RecentlyPlayedWidget",
            displayName: "Recently Played",
            description: "The games you played most recently.",
            defaultFeed: .recentlyPlayed
        ).configuration
    }
}

@main
struct MyWidgets: WidgetBundle {
    init() {
        PVWidgetsHost.configure(dataSource: MyDataSource(), theme: WidgetTheme())
    }

    var body: some Widget {
        RecentlyPlayedWidget()
    }
}

// So the system finds the package's edit-screen options.
struct MyWidgetsIntents: AppIntentsPackage {
    static var includedPackages: [any AppIntentsPackage.Type] { [PVWidgetsIntentsPackage.self] }
}

The widget's edit screen then offers Show (the app's feeds) and Layout (Automatic, Grid, List). A widget with no feed chosen shows its defaultFeed, so a Recently Played widget and a Favorites widget can share the one intent.

Covers are files: give each WidgetItem an artworkURL inside the app group container. The provider decodes only the covers the layout shows, each to the size it is drawn at.

Tests

swift test

Set PVWIDGETS_RENDER_DIR to a folder to keep a PNG of every size, style and game count:

PVWIDGETS_RENDER_DIR=Renders swift test

About

Home screen game widgets shared by Provenance, iCube and iFly

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages

⌂ 换网址