mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 01:57:57 +00:00
* feat(mobile): light and dark themes with desktop's palettes Settings → Appearance offers System, Light and Dark. The shell passes the resolved scheme to over-the-air pages in its init frame. Fixes #22184 * fix(mobile): draw your chat messages in desktop's user bubble Desktop uses a faint surface with a hairline border in both themes; the inverted fill went black in light. * test(mobile): re-measure the page script sweep after the shared theme hooks Every route now imports the theme hooks while the entry does not, so they emit one shared script (96 for the tree). Re-swept every route prefix; the worst route step is now 15. * test(mobile): read themed stylesheets in the text-input font-size census The census only unwrapped StyleSheet.create({...}); inputs styled through themedStyleSheet(() => ({...})) came back unread.
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { useCallback, useEffect, useState } from 'react'
|
|
import { ActivityIndicator, Linking, Pressable, Text, View } from 'react-native'
|
|
import { useLocalSearchParams, useRouter } from 'expo-router'
|
|
import { colors, radii, spacing, typography } from '../src/theme/mobile-theme'
|
|
import { themedStyleSheet } from '../src/theme/themed-styles'
|
|
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
|
|
import { extractPairingCodeFromUrl } from '../src/transport/pairing'
|
|
|
|
export default function PairRedirectScreen() {
|
|
useMobileColorScheme()
|
|
const router = useRouter()
|
|
const params = useLocalSearchParams<{ code?: string }>()
|
|
const [missingCode, setMissingCode] = useState(false)
|
|
|
|
const goHome = useCallback(() => {
|
|
router.replace('/')
|
|
}, [router])
|
|
|
|
useEffect(() => {
|
|
let disposed = false
|
|
|
|
async function redirectToConfirm() {
|
|
const codeParam = Array.isArray(params.code) ? params.code[0] : params.code
|
|
if (codeParam) {
|
|
router.replace({ pathname: '/pair-confirm', params: { code: codeParam } })
|
|
return
|
|
}
|
|
|
|
const initialUrl = await Linking.getInitialURL().catch(() => null)
|
|
const code = initialUrl ? extractPairingCodeFromUrl(initialUrl) : null
|
|
if (disposed) {
|
|
return
|
|
}
|
|
if (code) {
|
|
router.replace({ pathname: '/pair-confirm', params: { code } })
|
|
return
|
|
}
|
|
setMissingCode(true)
|
|
}
|
|
|
|
void redirectToConfirm()
|
|
return () => {
|
|
disposed = true
|
|
}
|
|
}, [params.code, router])
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
{missingCode ? (
|
|
<>
|
|
<Text style={styles.errorText}>Missing pairing code</Text>
|
|
<Pressable style={styles.primaryButton} onPress={goHome}>
|
|
<Text style={styles.primaryButtonText}>Back to home</Text>
|
|
</Pressable>
|
|
</>
|
|
) : (
|
|
<ActivityIndicator size="large" color={colors.textSecondary} />
|
|
)}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = themedStyleSheet(() => ({
|
|
container: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
backgroundColor: colors.bgBase,
|
|
padding: spacing.lg
|
|
},
|
|
errorText: {
|
|
color: colors.statusRed,
|
|
fontSize: typography.bodySize,
|
|
lineHeight: 20,
|
|
marginBottom: spacing.xl,
|
|
textAlign: 'center'
|
|
},
|
|
primaryButton: {
|
|
alignItems: 'center',
|
|
backgroundColor: colors.textPrimary,
|
|
borderRadius: radii.button,
|
|
paddingHorizontal: spacing.xl,
|
|
paddingVertical: spacing.sm + 2
|
|
},
|
|
primaryButtonText: {
|
|
color: colors.bgBase,
|
|
fontSize: typography.bodySize,
|
|
fontWeight: '600'
|
|
}
|
|
}))
|