Repository navigation
flutterflow_live_activity: JSON spec, validate/generate/apply and a typed app API - #3
Conversation
sbis04
left a comment
There was a problem hiding this comment.
LGTM. Checked: CI steps pass locally (135 / 52 / 26), home widget output is byte-identical to #1, and apply into a fresh flutter create app is idempotent (28 files, then 0). flutter analyze is clean with the typed API called, and flutter build ios --simulator builds with LiveActivity.appex embedded. The expanded-island fallback is a separate model and empty image defaults are rejected, so my #2 notes are covered for JSON specs. Limits match ff_protos/live_activity_layouts.dart.
One suggestion: apply doesn't check iosBundleId against the Runner's PRODUCT_BUNDLE_IDENTIFIER. Applying the example spec as-is to an app with another id succeeds, then flutter build ios fails with "Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier" (and the keychain group is wrong too). It already parses the pbxproj, so it could refuse on a mismatch.
On the questions:
- Keep the overrides until codegen moves onto the package.
- Keep the fallback, it matches the editor.
- Manifest: nice to have, low priority.
- Narrower: keep
SpecJsonReaderundersrc/behind a JSON-specific export. - Yes, codegen should import the limits from here once it depends on the package (they're duplicated in
ff_protostoday). - Yes, worth a follow-up.
- Fine as is.
|
Thanks for checking all of that. I'll add both to this PR before it merges, since the second one changes public API:
The manifest (3) and the home widget reader using |
|
Thanks for the review. Two changes, pushed to this branch:
Your answers are in the PR description. Tests: LA 141, core 52, home widget 26 pass; analyze and format are clean; generated output for the sample apps is unchanged. |
nativeLayoutFromJson and nativeLayoutToJson move here from the home widget package's json.dart, so Live Activity cards share one layout format. With card: true the reader also takes what only a card draws: a count-up text, an image showing an Image value, a bar timed between two dates, a Stages bar, and the layout's stagesSpecs. darkColors and behind read a layout for the Dynamic Island (dark colours, labels fitted on black). The writer leaves out stagesSpecs that are what the bars draw. SpecJsonReader and NativeLayoutJsonException give readers of other spec JSON the same paths and messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The layout reader and writer in json.dart are the core's now. The format is unchanged, except that the forms only a Live Activity card draws are an error in a widget's layout instead of being ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
liveActivityAppFromJson and liveActivityAppToJson read and write the spec with specVersion 1. Layouts are the core's layout JSON with the card forms. A fixed template is a preset with no values, layouts or Android settings. Without an islandExpanded layout the Lock Screen one is read for the island; null means none. The writer leaves out what the reader fills in the same way (that island, Android defaults that are the values' own), so read, write and read again generates the same files. Unknown fields are errors, with their path. validateLiveActivityApp lists the spec's problems with paths: limits (24 values, 4 Image values, 80 nodes, 2 to 6 stages, kept in spec.dart), value types and defaults, surfaces, bindings, Stages bars, taps, card heights and Android slots and defaults; and warnings that do not stop generation. liveActivityTypedApiFiles writes package:ff_live_activity/live_activities.dart: a class per activity with typed start, update and end over FFLiveActivity, filling template, accent colour, icon, channel name and defaults from the spec. It is not part of generateLiveActivityFiles, whose output is unchanged. example/live_activities.json is a complete spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
applyLiveActivities (io.dart) adds an app's Live Activities to a flutter create app: the generated files and typed API, the plugin in pubspec.yaml, the extension target in project.pbxproj (signed with the Runner's development team per configuration), NSSupportsLiveActivities in the Runner's Info.plist and, for an Image value, the keychain group in Info.plist and Runner.entitlements. It works everything out before writing, writes only what changed, and a second run changes nothing. A target added for a spec with other files is an error rather than being rewritten. bin/flutterflow_live_activity.dart runs validate, generate and apply; problems stop generate and apply, warnings do not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tch the Runner's iosBundleId is the app's id (the extension is <id>.LiveActivity). apply now reads the Runner's PRODUCT_BUNDLE_IDENTIFIER in every build configuration before writing anything, and refuses with both ids when the spec's does not match: iOS rejects an embedded extension whose id is not prefixed with the app's. A Runner id that is a build setting is reported as a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SpecJsonReader and NativeLayoutJsonException are no longer exported from flutterflow_native_layout.dart. package:flutterflow_native_layout/layout_json.dart exports them with nativeLayoutFromJson, nativeLayoutToJson and the color helpers; the home widget and Live Activity packages import it from there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4221ec0 to
650e2e1
Compare
All three packages move to 0.3.0 together. The README shows how to depend on the Live Activity package from the same tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #2; review that first. This PR adds the JSON spec, the commands and the typed app API on top of it.
What this does
Makes
flutterflow_live_activityusable from any Flutter project the wayflutterflow_home_widgetis: describe Live Activities in JSON, then validate, generate or apply them.flutterflow_native_layout,lib/src/layout/layout_json.dart): reads and writes the layout node JSON, including the nodes only Live Activity cards use (count-up text, Image values, timed bars, stages, root mode). The home widget package now reads and writes its layouts through it.LiveActivityApp, withspecVersionfrom the start:"template": "progress"with no values or surfaces.customactivities hold one layout per surface. IfislandExpandedis left out, it is filled fromlockScreen.androidDefaultsandstagesSpecs, for specs that need Android defaults or stage colours different from what the package derives. The writer leaves them out when they equal the derived values.validate: limits (24 values, 4 images, 80 layout nodes, 2 to 6 stages, defined once in the package), taps (a card can only open a page), value types, surfaces, Android slots and presets.dart run flutterflow_live_activity <validate|generate|apply>):generatewrites the files to a folder.applywrites them into a Flutter project: the widget extension target and files in Xcode, the Android module, the Dart plugin package and the Info.plist entries. A second run changes nothing.start,updateandend. It fills the accent colour, icon and channel name from the spec. The platform channel is unchanged.apply:iosBundleIdis the app's id (the extension is<id>.LiveActivity).applyreads the Runner'sPRODUCT_BUNDLE_IDENTIFIERin every build configuration before writing anything and refuses, naming both ids, when the spec's does not match (iOS rejects an embedded extension whose id is not prefixed with the app's). A Runner id that is a build setting ($(...)) is a warning. The example spec and README say the id must start with the app's own.SpecJsonReader,NativeLayoutJsonExceptionand the layout JSON functions are inpackage:flutterflow_native_layout/layout_json.dart, no longer exported from the main library.example/live_activities.json, README sections, and changelog entries under Unreleased.Changes to existing behaviour
How it was tested
flutterflow_live_activitytestsflutterflow_native_layout/flutterflow_home_widgettestsapplyinto a freshflutter createappflutter analyzeis clean with the app calling the typed API.flutter build apk --debugbuildsapplywith a mismatching bundle iddart analyze --fatal-infos,dart formatReview questions, answered
androidDefaultsandstagesSpecsuntil codegen moves onto the package.SpecJsonReaderstays undersrc/, exported fromlayout_json.dartonly.SpecJsonReader: a follow-up.🤖 Generated with Claude Code