-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add supplemental activity families support for iOS 18+ #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mrevanzak
wants to merge
19
commits into
callstackincubator:main
Choose a base branch
from
mrevanzak:feat/activity-family
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2fcfa62
feat(types): add supplemental activity families to LiveActivityVariants
mrevanzak 550a48d
feat(renderer): add supplemental family region rendering
mrevanzak 4f92fd8
feat(swift): add supplemental family cases to VoltraRegion
mrevanzak 8cf3bd7
feat(swift): add iOS 18 supplementalActivityFamilies support with ada…
mrevanzak 0b961ce
feat(plugin): add ActivityFamily types for supplemental families config
mrevanzak 9b1c236
feat(plugin): add activity family constants and Swift mapping
mrevanzak 6f962ff
feat(plugin): add validation for supplemental activity families
mrevanzak 678dce5
feat(plugin): generate supplementalActivityFamilies in widget bundle
mrevanzak 0fc1175
feat(plugin): wire up liveActivity config to iOS generation
mrevanzak ed1ae53
test: add tests for supplemental families and example Watch demo
mrevanzak 696414e
fix(swift): separate @unknown default into own case in switch statement
mrevanzak 80c8428
docs: add supplemental activity families documentation for website
mrevanzak 1ac4a0a
refactor: rename supplementalFamilies to supplementalActivityFamilies
mrevanzak 3fec03b
refactor: rename
mrevanzak 66d2a18
fix: restore accidentally removed comments
mrevanzak 7cd3db9
refactor: wording
mrevanzak 0c054cc
refactor: wording
mrevanzak 84e9362
docs: no need to dive into technical on web docs
mrevanzak 432aa5a
Merge branch 'main' into feat/activity-family
mrevanzak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
example/components/live-activities/WatchLiveActivityUI.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React from 'react' | ||
| import { Voltra } from 'voltra' | ||
|
|
||
| export function WatchLiveActivityLockScreen() { | ||
| return ( | ||
| <Voltra.VStack id="watch-lock-screen" spacing={12} style={{ padding: 16 }}> | ||
| <Voltra.HStack spacing={12} alignment="center"> | ||
| <Voltra.Image | ||
| source={{ assetName: 'voltra-icon' }} | ||
| style={{ width: 48, height: 48, borderRadius: 10 }} | ||
| resizeMode="stretch" | ||
| /> | ||
| <Voltra.VStack spacing={4} alignment="leading"> | ||
| <Voltra.Text | ||
| style={{ | ||
| color: '#F0F9FF', | ||
| fontSize: 20, | ||
| fontWeight: '700', | ||
| }} | ||
| > | ||
| Workout Active | ||
| </Voltra.Text> | ||
| <Voltra.Text | ||
| style={{ | ||
| color: '#94A3B8', | ||
| fontSize: 14, | ||
| }} | ||
| > | ||
| Running · 3.2 km | ||
| </Voltra.Text> | ||
| </Voltra.VStack> | ||
| </Voltra.HStack> | ||
|
|
||
| <Voltra.HStack distribution="equalSpacing"> | ||
| <Voltra.VStack alignment="center"> | ||
| <Voltra.Text style={{ color: '#10B981', fontSize: 24, fontWeight: '700' }}>25:42</Voltra.Text> | ||
| <Voltra.Text style={{ color: '#64748B', fontSize: 12 }}>Duration</Voltra.Text> | ||
| </Voltra.VStack> | ||
| <Voltra.VStack alignment="center"> | ||
| <Voltra.Text style={{ color: '#F59E0B', fontSize: 24, fontWeight: '700' }}>142</Voltra.Text> | ||
| <Voltra.Text style={{ color: '#64748B', fontSize: 12 }}>BPM</Voltra.Text> | ||
| </Voltra.VStack> | ||
| <Voltra.VStack alignment="center"> | ||
| <Voltra.Text style={{ color: '#8B5CF6', fontSize: 24, fontWeight: '700' }}>312</Voltra.Text> | ||
| <Voltra.Text style={{ color: '#64748B', fontSize: 12 }}>Calories</Voltra.Text> | ||
| </Voltra.VStack> | ||
| </Voltra.HStack> | ||
| </Voltra.VStack> | ||
| ) | ||
| } | ||
|
|
||
| export function WatchLiveActivitySmall() { | ||
| return ( | ||
| <Voltra.VStack id="watch-small" spacing={4} alignment="center" style={{ padding: 8 }}> | ||
| <Voltra.Text style={{ color: '#10B981', fontSize: 18, fontWeight: '700' }}>25:42</Voltra.Text> | ||
| <Voltra.Text style={{ color: '#F59E0B', fontSize: 14, fontWeight: '600' }}>142 BPM</Voltra.Text> | ||
| </Voltra.VStack> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React, { forwardRef, useEffect, useImperativeHandle } from 'react' | ||
| import { useLiveActivity } from 'voltra/client' | ||
|
|
||
| import { | ||
| WatchLiveActivityLockScreen, | ||
| WatchLiveActivitySmall, | ||
| } from '../../components/live-activities/WatchLiveActivityUI' | ||
| import { LiveActivityExampleComponent } from './types' | ||
|
|
||
| const WatchLiveActivity: LiveActivityExampleComponent = forwardRef( | ||
| ({ autoUpdate = true, autoStart = false, onIsActiveChange }, ref) => { | ||
| const { start, update, end, isActive } = useLiveActivity( | ||
| { | ||
| lockScreen: { | ||
| content: <WatchLiveActivityLockScreen />, | ||
| }, | ||
| supplementalActivityFamilies: { | ||
| small: <WatchLiveActivitySmall />, | ||
| }, | ||
| island: { | ||
| keylineTint: '#10B981', | ||
| }, | ||
| }, | ||
| { | ||
| activityName: 'watch-demo', | ||
| autoUpdate, | ||
| autoStart, | ||
| deepLinkUrl: '/voltraui/watch-demo', | ||
| } | ||
| ) | ||
|
|
||
| useEffect(() => { | ||
| onIsActiveChange?.(isActive) | ||
| }, [isActive, onIsActiveChange]) | ||
|
|
||
| useImperativeHandle(ref, () => ({ | ||
| start, | ||
| update, | ||
| end, | ||
| })) | ||
|
|
||
| return null | ||
| } | ||
| ) | ||
|
|
||
| WatchLiveActivity.displayName = 'WatchLiveActivity' | ||
|
|
||
| export default WatchLiveActivity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { ActivityFamily } from '../types' | ||
|
|
||
| /** | ||
| * Activity-related constants for the Voltra plugin | ||
| */ | ||
|
|
||
| /** Default supplemental activity families when not specified */ | ||
| export const DEFAULT_ACTIVITY_FAMILIES: ActivityFamily[] = ['small'] | ||
|
|
||
| /** Maps JS activity family names to SwiftUI ActivityFamily enum cases */ | ||
| export const ACTIVITY_FAMILY_MAP: Record<ActivityFamily, string> = { | ||
| small: '.small', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand this better. Apple’s docs aren't very clear about what behavior to expect 👌