Skip to content

dartnative_home_widget: per-instance configuration (AppIntentConfiguration) and a refresh hook in the extension #121

Backlog

Description

@tayormi

Select your plan

Standard - priority support

Confirmations

  • I searched the existing feature requests and this is not a duplicate.

Framework or plugin?

Plugin

Platform

iOS

Use case

We want a home-screen widget the user configures per copy, e.g. "next buses at this stop", with two copies on the home screen showing two different stops. dartnative_home_widget 0.1.1 (bundled with 1.10.0) can't do that:

  • HomeWidgets.update(String id, {design, values, timeline, …}) takes the widget kind (lib/src/home_widgets.dart), so every placed copy gets the same values.
  • HomeWidgets.placed() returns HomeWidgetPlacement(widget, size) only, with no instance identity or configuration.
  • The extension side is HomeWidget.configuration(kind:name:description:sizes:) on a plain TimelineProvider (from the extension framework's .swiftinterface), so there's no AppIntentConfiguration, no "Edit Widget" options, and no hook to fetch fresh data from the extension. Values only change when the app runs and calls update.

Repro: declare one widget, place two copies, call HomeWidgets.update('saved_stop', values: {...}). Both copies show the same values and there's no API to address one of them.

Our workaround for now is a single widget meaning "my first saved stop". The alternative is writing our own extension (AppIntentConfiguration + AppIntentTimelineProvider + an entity query), which means giving up the plugin's Dart-designed layouts.

Proposal

  • A configurable: option on the widget declaration that generates an AppIntentConfiguration with one parameter, backed by an entity query whose options come from the App Group store, written from Dart:

    await HomeWidgets.setOptions('saved_stop', [
      HomeWidgetOption(id: '1234', title: 'Main St & 5th'),
      HomeWidgetOption(id: '5678', title: 'Central Station'),
    ]);
  • update(id, instance: optionId, values: …) so values are keyed by the chosen option, and the timeline provider picks the entry matching each copy's configuration.

  • placed() returning each copy's chosen option, so the app knows which instances to keep fresh.

  • Optionally, a background refresh hook (e.g. a URL the extension fetches, with the response mapped to values) so the widget can update without the app opening.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions