File size: 30,365 Bytes
4a5ef51 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | import React from 'react';
import { View, Text, ScrollView, Pressable, StyleSheet, TextInput, Clipboard, Switch, PanResponder } from 'react-native';
import { VideoView, useVideoPlayer } from 'expo-video';
import { LinearGradient } from 'expo-linear-gradient';
import Svg, { Path, Polyline, Rect } from 'react-native-svg';
import WebView from 'react-native-webview';
import { MentraVideoStreamReceiverView } from '@mentra/react-native-video-stream-receiver';
import { Header } from '../components/Header';
import { useScrollBottomPadding } from '../components/keyboardLayout';
import { OfflineNotice } from '../components/OfflineNotice';
import { colors } from '../components/theme';
import { isGlassesConnected, isGlassesWifiConnected, streamUptime } from '../sdkFormat';
import {
STREAM_DEFAULT_URLS,
STREAM_MAX_FPS,
STREAM_MIN_FPS,
streamPreviewTarget,
type BluetoothSdkExampleModel,
type StreamPreviewTarget,
type StreamProtocol,
} from '../useBluetoothSdkExample';
const bars = [18, 32, 48, 24, 40, 56, 30, 44, 22, 36, 50, 28, 40];
function streamSdkCall(useCloudServer: boolean, fps: number) {
if (!useCloudServer) {
return `const receiver = await MentraVideoStreamReceiver.startWebRtcReceiver();
const streamId = \`rn-\${Date.now()}\`;
const started = await BluetoothSdk.startStream({
type: 'start_stream',
streamId,
streamUrl: receiver.streamUrl,
video: { fps: ${fps} },
});
console.log('Stream started', started.status)`;
}
return `const streamId = \`rn-\${Date.now()}\`;
const started = await BluetoothSdk.startStream({
type: 'start_stream',
streamId,
streamUrl,
video: { fps: ${fps} },
});
console.log('Stream started', started.status)`;
}
export function StreamScreen({ sdk }: { sdk: BluetoothSdkExampleModel }) {
const scrollRef = React.useRef<React.ElementRef<typeof ScrollView>>(null);
const streamUrlInputRef = React.useRef<React.ElementRef<typeof TextInput>>(null);
const [resolvedConfigExpanded, setResolvedConfigExpanded] = React.useState(false);
const scrollBottomPadding = useScrollBottomPadding();
const connected = isGlassesConnected(sdk.glasses);
const glassesWifiConnected = isGlassesWifiConnected(sdk.glasses);
const streamActive = sdk.streamRequested || sdk.streamStartedAt !== null;
const streamStarting = sdk.streamStartPending && !streamActive;
const streamButtonDisabled = streamStarting || ((!connected || !glassesWifiConnected) && !streamActive);
const wifiRequired = connected && !glassesWifiConnected && !streamActive;
const previewReady = streamActive && sdk.streamPreviewReady;
const previewPending = streamActive || streamStarting;
const uptime = streamUptime(sdk.streamStartedAt);
const setupHint = sdk.streamCloudServerEnabled
? localStreamSetupHint(sdk.streamProtocol, sdk.streamUrl, sdk.streamStatus)
: null;
const previewTarget = sdk.streamCloudServerEnabled && previewReady
? streamPreviewTarget(sdk.streamProtocol, sdk.streamUrl)
: null;
const sdkCall = streamSdkCall(sdk.streamCloudServerEnabled, sdk.streamFps);
const statusFailed = isStreamStatusFailure(sdk.streamStatus);
const focusStreamUrlInput = React.useCallback(() => {
scrollRef.current?.scrollToEnd({ animated: true });
requestAnimationFrame(() => {
streamUrlInputRef.current?.focus();
setTimeout(() => scrollRef.current?.scrollToEnd({ animated: true }), 250);
});
}, []);
const handleStreamPress = React.useCallback(() => {
if (sdk.streamCloudServerEnabled && !streamActive && sdk.streamUrl.includes('<computer-ip>')) {
focusStreamUrlInput();
}
void sdk.toggleStream();
}, [focusStreamUrlInput, sdk, streamActive]);
return (
<ScrollView
ref={scrollRef}
keyboardDismissMode="interactive"
keyboardShouldPersistTaps="handled"
style={{ flex: 1, backgroundColor: colors.bg }}
contentContainerStyle={{ paddingBottom: scrollBottomPadding }}>
<Header title="Stream" />
{!connected ? (
<OfflineNotice />
) : wifiRequired ? (
<OfflineNotice message="Connect the glasses to Wi-Fi from the System tab before streaming. Streams are published over the glasses network connection." />
) : null}
{/* Live preview */}
<LinearGradient colors={['rgba(255,255,255,0.78)', 'rgba(255,255,255,0.55)']} style={styles.card}>
<View style={styles.previewWrap}>
<View style={styles.preview}>
{previewTarget ? (
<LiveStreamPreview target={previewTarget} />
) : !sdk.streamCloudServerEnabled && previewReady ? (
<MentraVideoStreamReceiverView style={styles.previewFill} />
) : (
<PlaceholderStreamPreview
message={previewPending ? streamPreviewWaitingMessage(sdk.streamStatus) : undefined}
/>
)}
<View style={styles.livePill}>
<View style={[styles.liveDot, !previewPending && styles.readyDot]} />
<Text style={styles.liveText}>{previewReady ? 'LIVE' : previewPending ? 'STARTING' : 'READY'}</Text>
</View>
<Text style={styles.timer}>{uptime}</Text>
{!previewReady ? (
<Text style={styles.previewMeta}>
{previewPending
? 'Waiting for preview'
: sdk.streamCloudServerEnabled
? 'Ready · enter stream URL'
: 'Ready · WebRTC to phone'}
</Text>
) : null}
</View>
</View>
<Pressable disabled={streamButtonDisabled} onPress={handleStreamPress}>
<LinearGradient colors={streamActive ? ['#DE3A30', '#C43B30'] : ['#26473A', '#1F3A2A']} style={[styles.endBtn, streamButtonDisabled && styles.disabled]}>
{streamActive ? <View style={styles.stopSquare} /> : <StreamPlayIcon />}
<Text style={styles.endText}>
{!connected && !streamActive
? 'Connect glasses first'
: !glassesWifiConnected && !streamActive
? 'Connect glasses to Wi-Fi'
: streamStarting
? 'Starting stream...'
: streamActive
? 'End stream'
: 'Start stream'}
</Text>
</LinearGradient>
</Pressable>
</LinearGradient>
{/* SDK call */}
<LinearGradient colors={['rgba(255,255,255,0.7)', 'rgba(255,255,255,0.5)']} style={styles.sdkCard}>
<View style={styles.sdkBlock}>
<View style={styles.cardHead}>
<Text style={styles.sdkEyebrow}>SDK CALL</Text>
<Pressable style={({pressed}) => [styles.copyChip, pressed && styles.copyChipPressed]} onPress={() => Clipboard.setString(sdkCall)}>
<Svg width={10} height={10} viewBox="0 0 24 24" fill="none" stroke={colors.consoleText} strokeWidth={2.2} strokeLinecap="round" strokeLinejoin="round">
<Rect x={9} y={9} width={13} height={13} rx={2} />
<Path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
</Svg>
<Text style={styles.copyText}>Copy</Text>
</Pressable>
</View>
<Text style={styles.sdkCode}>{sdkCall}</Text>
</View>
<View style={styles.statusBar}>
<View style={[styles.statusCircle, statusFailed ? styles.statusCircleError : styles.statusCircleOk]}>
<View style={[styles.statusDot, statusFailed ? styles.statusDotError : styles.statusDotOk]} />
</View>
<View style={{ flex: 1 }}>
<Text style={styles.statusTitle}>{sdk.streamStatus}</Text>
<Text style={styles.statusSub}>uptime {uptime} · SDK keep-alive</Text>
</View>
</View>
</LinearGradient>
<ResolvedStreamConfigCard
config={sdk.streamResolvedConfig}
expanded={resolvedConfigExpanded}
onToggle={() => setResolvedConfigExpanded((expanded) => !expanded)}
/>
{/* Protocol */}
<LinearGradient colors={['rgba(255,255,255,0.7)', 'rgba(255,255,255,0.5)']} style={styles.protocolCard}>
<View style={styles.cardHead}>
<Text style={styles.eyebrow}>DESTINATION</Text>
</View>
<View style={styles.cloudToggleRow}>
<Text style={styles.cloudToggleLabel}>Use cloud server</Text>
<Switch
ios_backgroundColor="rgba(15,42,29,0.18)"
onValueChange={sdk.setStreamCloudServerEnabled}
thumbColor="#fff"
trackColor={{ false: 'rgba(15,42,29,0.18)', true: colors.greenAccent }}
value={sdk.streamCloudServerEnabled}
/>
</View>
{sdk.streamCloudServerEnabled ? (
<>
<View style={styles.tabs}>
{(['rtmp', 'srt', 'webrtc'] satisfies StreamProtocol[]).map((protocol) => (
<Pressable key={protocol} style={[styles.protoTab, sdk.streamProtocol === protocol && styles.protoTabActive]} onPress={() => sdk.selectProtocol(protocol)}>
<Text style={[styles.protoText, sdk.streamProtocol === protocol && styles.protoTextActive]}>{protocol.toUpperCase()}</Text>
</Pressable>
))}
</View>
<View style={styles.urlBar}>
<Text style={styles.method}>{streamProtocolLabel(sdk.streamProtocol)}</Text>
<View style={styles.divider} />
<TextInput
ref={streamUrlInputRef}
autoCapitalize="none"
autoCorrect={false}
keyboardType="url"
onChangeText={sdk.setStreamUrl}
onFocus={focusStreamUrlInput}
placeholder={STREAM_DEFAULT_URLS[sdk.streamProtocol]}
placeholderTextColor={colors.muted}
returnKeyType="done"
selectTextOnFocus
style={styles.url}
value={sdk.streamUrl}
/>
<Svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke={colors.muted} strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
<Path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
<Path d="m18.5 2.5 3 3L12 15l-4 1 1-4z" />
</Svg>
</View>
{setupHint ? <Text style={styles.setupHint}>{setupHint}</Text> : null}
</>
) : (
<Text style={styles.setupHint}>
The phone starts a local WebRTC receiver, sends its WHIP URL to the glasses, and previews incoming frames here.
</Text>
)}
<FpsSlider
disabled={streamActive}
max={STREAM_MAX_FPS}
min={STREAM_MIN_FPS}
onChange={sdk.setStreamFps}
value={sdk.streamFps}
/>
</LinearGradient>
</ScrollView>
);
}
function ResolvedStreamConfigCard({
config,
expanded,
onToggle,
}: {
config: BluetoothSdkExampleModel['streamResolvedConfig'];
expanded: boolean;
onToggle: () => void;
}) {
return (
<LinearGradient colors={['rgba(255,255,255,0.7)', 'rgba(255,255,255,0.5)']} style={styles.resolvedCard}>
<Pressable style={styles.resolvedHeader} onPress={onToggle}>
<View style={{ flex: 1 }}>
<Text style={styles.eyebrow}>RESOLVED STREAM CONFIG</Text>
<Text style={styles.resolvedSummary}>{streamResolvedConfigSummary(config)}</Text>
</View>
<Text style={styles.resolvedChevron}>{expanded ? 'Hide' : 'Show'}</Text>
</Pressable>
{expanded ? (
<View style={styles.resolvedBody}>
{streamResolvedConfigRows(config).map((row) => (
<View key={row.label} style={styles.resolvedRow}>
<Text style={styles.resolvedLabel}>{row.label}</Text>
<Text style={styles.resolvedValue}>{row.value}</Text>
</View>
))}
</View>
) : null}
</LinearGradient>
);
}
function FpsSlider({
disabled,
max,
min,
onChange,
value,
}: {
disabled: boolean;
max: number;
min: number;
onChange: (value: number) => void;
value: number;
}) {
const trackRef = React.useRef<React.ElementRef<typeof View>>(null);
const trackLeftRef = React.useRef(0);
const trackWidthRef = React.useRef(0);
const [trackWidth, setTrackWidth] = React.useState(0);
const progress = (value - min) / (max - min);
const clampedProgress = Math.max(0, Math.min(1, progress));
const clampAndSnap = React.useCallback(
(nextValue: number) => Math.max(min, Math.min(max, Math.round(nextValue))),
[max, min],
);
const updateFromPageX = React.useCallback(
(pageX: number, measuredLeft = trackLeftRef.current, measuredWidth = trackWidthRef.current || trackWidth) => {
if (disabled || measuredWidth <= 0) {
return;
}
const x = pageX - measuredLeft;
const ratio = Math.max(0, Math.min(1, x / measuredWidth));
onChange(clampAndSnap(min + ratio * (max - min)));
},
[clampAndSnap, disabled, max, min, onChange, trackWidth],
);
const measureAndUpdate = React.useCallback(
(pageX: number) => {
trackRef.current?.measureInWindow((left, _top, width) => {
trackLeftRef.current = left;
trackWidthRef.current = width;
setTrackWidth(width);
updateFromPageX(pageX, left, width);
});
},
[updateFromPageX],
);
const adjust = React.useCallback(
(delta: number) => {
if (!disabled) {
onChange(clampAndSnap(value + delta));
}
},
[clampAndSnap, disabled, onChange, value],
);
const panResponder = React.useMemo(
() =>
PanResponder.create({
onStartShouldSetPanResponder: () => !disabled,
onMoveShouldSetPanResponder: () => !disabled,
onPanResponderGrant: (event) => measureAndUpdate(event.nativeEvent.pageX),
onPanResponderMove: (_event, gestureState) => updateFromPageX(gestureState.moveX),
}),
[disabled, measureAndUpdate, updateFromPageX],
);
return (
<View style={[styles.fpsCard, disabled && styles.fpsCardDisabled]}>
<View style={styles.fpsHeader}>
<Text style={styles.fpsLabel}>STREAM FPS</Text>
<Text style={styles.fpsValue}>{value} fps</Text>
</View>
<View style={styles.fpsControlRow}>
<SliderStepButton disabled={disabled || value <= min} label="-" onPress={() => adjust(-1)} />
<View
ref={trackRef}
{...panResponder.panHandlers}
onLayout={(event) => {
const width = event.nativeEvent.layout.width;
trackWidthRef.current = width;
setTrackWidth(width);
}}
style={styles.fpsTrack}>
<View style={styles.fpsTrackBase} />
<View style={[styles.fpsTrackFill, {width: `${clampedProgress * 100}%`}]} />
<View style={[styles.fpsThumb, {left: `${clampedProgress * 100}%`}]} />
</View>
<SliderStepButton disabled={disabled || value >= max} label="+" onPress={() => adjust(1)} />
</View>
<View style={styles.fpsRangeRow}>
<Text style={styles.fpsRangeText}>{min}</Text>
{disabled ? <Text style={styles.fpsHint}>Read-only while streaming</Text> : <View />}
<Text style={styles.fpsRangeText}>{max}</Text>
</View>
</View>
);
}
function SliderStepButton({
disabled,
label,
onPress,
}: {
disabled: boolean;
label: string;
onPress: () => void;
}) {
return (
<Pressable
accessibilityRole="button"
disabled={disabled}
onPress={onPress}
style={({pressed}) => [styles.sliderStepButton, disabled && styles.sliderStepButtonDisabled, pressed && styles.copyChipPressed]}>
<Text style={[styles.sliderStepText, disabled && styles.sliderStepTextDisabled]}>{label}</Text>
</Pressable>
);
}
function PlaceholderStreamPreview({message}: {message?: string}) {
return (
<LinearGradient colors={['#163A26', '#26583E', '#7DD89E', '#3F8F5C']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={styles.previewFill}>
<View style={styles.glow1} />
<View style={styles.glow2} />
{message ? (
<Text style={styles.previewMessage}>{message}</Text>
) : (
<View style={styles.eqWrap}>
{bars.map((height, index) => (
<View
key={index}
style={[
styles.eqBar,
{
height,
backgroundColor: index % 3 === 2 ? '#fff' : 'rgba(255,255,255,0.85)',
},
]}
/>
))}
</View>
)}
</LinearGradient>
);
}
function LiveStreamPreview({target}: {target: StreamPreviewTarget}) {
if (target.kind === 'hls') {
return <HlsStreamPreview url={target.url} />;
}
return (
<WebView
allowsInlineMediaPlayback
domStorageEnabled
javaScriptEnabled
mediaPlaybackRequiresUserAction={false}
source={{uri: target.url}}
style={styles.previewFill}
/>
);
}
function HlsStreamPreview({url}: {url: string}) {
const source = React.useMemo(() => ({uri: url, contentType: 'hls' as const}), [url]);
const player = useVideoPlayer(source, (videoPlayer) => {
videoPlayer.muted = true;
videoPlayer.play();
});
React.useEffect(() => {
void player
.replaceAsync(source)
.then(() => {
player.muted = true;
player.play();
})
.catch(() => {});
}, [player, source]);
return (
<VideoView
contentFit="cover"
nativeControls={false}
player={player}
style={styles.previewFill}
/>
);
}
function streamProtocolLabel(protocol: StreamProtocol) {
return protocol === 'webrtc' ? 'WHIP' : protocol.toUpperCase();
}
function streamResolvedConfigSummary(
config: BluetoothSdkExampleModel['streamResolvedConfig'],
) {
if (!config) {
return 'Waiting for stream status from the glasses';
}
const video = config.video;
return [
config.transport?.toUpperCase(),
video ? `${video.width}x${video.height}` : null,
video ? `${video.fps} fps` : null,
video ? bitrateLabel(video.bitrate) : null,
]
.filter(Boolean)
.join(' · ');
}
function streamResolvedConfigRows(
config: BluetoothSdkExampleModel['streamResolvedConfig'],
) {
if (!config) {
return [{label: 'Status', value: 'No resolved config received yet'}];
}
const rows = [{label: 'Transport', value: config.transport?.toUpperCase() ?? 'Unknown'}];
if (config.video) {
rows.push(
{label: 'Video', value: `${config.video.width} x ${config.video.height}`},
{
label: 'Capture',
value:
config.video.captureWidth && config.video.captureHeight
? `${config.video.captureWidth} x ${config.video.captureHeight}`
: 'Same as video',
},
{label: 'FPS', value: `${config.video.fps}`},
{label: 'Video bitrate', value: bitrateLabel(config.video.bitrate)},
);
}
if (config.audio) {
rows.push(
{
label: 'Audio bitrate',
value: config.audio.bitrate ? bitrateLabel(config.audio.bitrate) : 'Not reported',
},
{
label: 'Sample rate',
value: config.audio.sampleRate ? `${config.audio.sampleRate} Hz` : 'Not reported',
},
{
label: 'Echo cancellation',
value: config.audio.echoCancellation === undefined ? 'Not reported' : config.audio.echoCancellation ? 'On' : 'Off',
},
{
label: 'Noise suppression',
value: config.audio.noiseSuppression === undefined ? 'Not reported' : config.audio.noiseSuppression ? 'On' : 'Off',
},
);
}
return rows;
}
function bitrateLabel(bitsPerSecond: number) {
if (bitsPerSecond >= 1_000_000) {
return `${(bitsPerSecond / 1_000_000).toFixed(1)} Mbps`;
}
if (bitsPerSecond >= 1_000) {
return `${Math.round(bitsPerSecond / 1_000)} kbps`;
}
return `${bitsPerSecond} bps`;
}
function isStreamStatusFailure(status: string) {
const normalized = status.toLowerCase();
return (
normalized.includes('failed') ||
normalized.includes('not reachable') ||
normalized.includes('required') ||
normalized.includes('replace') ||
normalized.includes('error') ||
normalized.includes('connect the glasses to wi-fi') ||
normalized.includes('connect glasses first')
);
}
function streamPreviewWaitingMessage(status: string) {
return status.toLowerCase().includes('stalled')
? status
: 'Starting stream...\nWaiting for preview';
}
function localStreamSetupHint(protocol: StreamProtocol, streamUrl: string, status: string) {
if (protocol !== 'rtmp' && protocol !== 'srt' && protocol !== 'webrtc') {
return null;
}
const normalized = status.toLowerCase();
const url = streamUrl.trim();
const needsSetup =
url.length === 0 ||
url.includes('<computer-ip>') ||
url.includes('YOUR_') ||
normalized.includes('not reachable') ||
normalized.includes('replace') ||
normalized.includes('required');
if (!needsSetup) {
return null;
}
if (protocol === 'rtmp') {
return 'Local RTMP setup: run python3 local-demo-cloud/server.py, paste the printed RTMP publish URL here, then start streaming. The app previews the derived HLS URL; the printed ffplay command is optional for debugging.';
}
if (protocol === 'srt') {
return 'Local SRT setup: run python3 local-demo-cloud/server.py, paste the printed SRT publish URL here, then start streaming. The app previews the derived HLS URL; the printed SRT ffplay command is optional for debugging.';
}
return 'Local WebRTC setup: run python3 local-demo-cloud/server.py, paste the printed WHIP publish URL here, then start streaming. The app previews the MediaMTX WebRTC page.';
}
function StreamPlayIcon() {
return (
<Svg width={18} height={18} viewBox="0 0 24 24">
<Path d="M8 5v14l11-7z" fill="#fff" />
</Svg>
);
}
const styles = StyleSheet.create({
card: { marginHorizontal: 16, marginTop: 8, borderRadius: 28, paddingTop: 8, paddingBottom: 14, borderWidth: 1, borderColor: colors.border, paddingHorizontal: 8 },
previewWrap: { borderRadius: 22, overflow: 'hidden', height: 160 },
preview: { flex: 1, backgroundColor: '#000' },
previewFill: { ...StyleSheet.absoluteFillObject },
glow1: { position: 'absolute', top: -60, left: -40, width: 220, height: 220, borderRadius: 999, backgroundColor: 'rgba(255,255,255,0.18)' },
glow2: { position: 'absolute', bottom: -80, right: -50, width: 240, height: 240, borderRadius: 999, backgroundColor: 'rgba(125,216,158,0.25)' },
livePill: { position: 'absolute', top: 14, left: 14, flexDirection: 'row', alignItems: 'center', gap: 6, backgroundColor: 'rgba(0,0,0,0.45)', paddingVertical: 6, paddingHorizontal: 11, borderRadius: 999, borderWidth: 1, borderColor: 'rgba(255,255,255,0.18)' },
liveDot: { width: 7, height: 7, borderRadius: 999, backgroundColor: colors.redLive },
readyDot: { backgroundColor: colors.greenSoft },
liveText: { color: '#fff', fontSize: 11, fontWeight: '700', letterSpacing: 0.8 },
timer: { position: 'absolute', top: 14, right: 14, color: '#fff', fontSize: 13, fontWeight: '600' },
eqWrap: { position: 'absolute', bottom: 56, left: 0, right: 0, flexDirection: 'row', alignItems: 'flex-end', justifyContent: 'center', gap: 5, height: 56 },
eqBar: { width: 5, borderRadius: 3 },
previewMessage: { position: 'absolute', left: 24, right: 24, top: 58, color: '#fff', fontSize: 16, fontWeight: '600', lineHeight: 21, textAlign: 'center' },
previewMeta: { position: 'absolute', bottom: 14, left: 14, color: 'rgba(255,255,255,0.85)', fontSize: 11, fontWeight: '500' },
endBtn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 18, paddingVertical: 16, marginTop: 14, marginHorizontal: 6, gap: 10 },
stopSquare: { width: 12, height: 12, backgroundColor: '#fff', borderRadius: 3 },
endText: { color: '#fff', fontSize: 15, fontWeight: '600' },
disabled: { opacity: 0.45 },
sdkCard: { marginHorizontal: 16, marginTop: 12, borderRadius: 22, overflow: 'hidden', borderWidth: 1, borderColor: colors.borderSoft },
sdkBlock: { backgroundColor: '#0E1A14', paddingVertical: 14, paddingHorizontal: 16, gap: 8 },
cardHead: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
sdkEyebrow: { color: colors.greenAccent, fontSize: 9, fontWeight: '700', letterSpacing: 1.1 },
copyChip: { flexDirection: 'row', alignItems: 'center', minHeight: 36, gap: 5, backgroundColor: 'rgba(255,255,255,0.06)', paddingVertical: 7, paddingHorizontal: 10, borderRadius: 9 },
copyChipPressed: { opacity: 0.6 },
copyText: { color: colors.consoleText, fontSize: 12, fontWeight: '600' },
sdkCode: { color: colors.consoleText, fontSize: 11, lineHeight: 16, fontFamily: 'Courier' },
statusBar: { flexDirection: 'row', alignItems: 'center', paddingVertical: 12, paddingHorizontal: 16, gap: 10 },
statusCircle: { width: 22, height: 22, borderRadius: 999, alignItems: 'center', justifyContent: 'center' },
statusCircleOk: { backgroundColor: 'rgba(52,199,89,0.16)' },
statusCircleError: { backgroundColor: 'rgba(255,59,48,0.16)' },
statusDot: { width: 8, height: 8, borderRadius: 999 },
statusDotOk: { backgroundColor: colors.greenAccent },
statusDotError: { backgroundColor: colors.red },
statusTitle: { color: colors.ink, fontSize: 12, fontWeight: '600' },
statusSub: { color: colors.muted, fontSize: 11, fontWeight: '500' },
resolvedCard: { marginHorizontal: 16, marginTop: 12, borderRadius: 18, paddingVertical: 12, paddingHorizontal: 14, borderWidth: 1, borderColor: colors.borderSoft },
resolvedHeader: { flexDirection: 'row', alignItems: 'center', gap: 12 },
resolvedSummary: { color: colors.ink, fontSize: 12, fontWeight: '600', marginTop: 4 },
resolvedChevron: { color: colors.greenAccent, fontSize: 12, fontWeight: '700' },
resolvedBody: { marginTop: 12, borderTopWidth: 1, borderTopColor: 'rgba(15,42,29,0.08)', paddingTop: 8 },
resolvedRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingVertical: 5, gap: 12 },
resolvedLabel: { color: colors.muted, fontSize: 11, fontWeight: '600' },
resolvedValue: { color: colors.ink, fontSize: 12, fontWeight: '600', textAlign: 'right', flexShrink: 1 },
protocolCard: { marginHorizontal: 16, marginTop: 12, borderRadius: 22, paddingVertical: 14, paddingHorizontal: 14, gap: 12, borderWidth: 1, borderColor: colors.borderSoft },
eyebrow: { color: colors.muted, fontSize: 10, fontWeight: '600', letterSpacing: 1.2 },
cloudToggleRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44, backgroundColor: 'rgba(15,42,29,0.04)', borderRadius: 12, paddingVertical: 9, paddingHorizontal: 12 },
cloudToggleLabel: { color: colors.ink, fontSize: 14, fontWeight: '600' },
tabs: { flexDirection: 'row', gap: 4, backgroundColor: 'rgba(15,42,29,0.05)', borderRadius: 14, padding: 4 },
protoTab: { flex: 1, minHeight: 44, paddingVertical: 12, paddingHorizontal: 8, alignItems: 'center', justifyContent: 'center', borderRadius: 10 },
protoTabActive: { backgroundColor: '#fff' },
protoText: { color: colors.muted, fontSize: 13, fontWeight: '500' },
protoTextActive: { color: colors.ink, fontWeight: '700' },
urlBar: { flexDirection: 'row', alignItems: 'center', backgroundColor: 'rgba(15,42,29,0.04)', borderRadius: 12, paddingVertical: 12, paddingHorizontal: 14, gap: 10 },
setupHint: { color: colors.muted, fontSize: 12, fontWeight: '500', lineHeight: 16, backgroundColor: 'rgba(15,42,29,0.04)', borderRadius: 12, paddingVertical: 10, paddingHorizontal: 12 },
method: { color: colors.greenAccent, fontSize: 11, fontWeight: '600', letterSpacing: 0.5 },
divider: { width: 1, height: 14, backgroundColor: 'rgba(15,42,29,0.12)' },
url: { flex: 1, color: colors.ink, fontSize: 13, fontWeight: '500' },
fpsCard: { backgroundColor: 'rgba(15,42,29,0.04)', borderRadius: 12, paddingHorizontal: 14, paddingVertical: 12 },
fpsCardDisabled: { opacity: 0.62 },
fpsHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
fpsLabel: { color: colors.muted, fontSize: 10, fontWeight: '700', letterSpacing: 1.1 },
fpsValue: { color: colors.ink, fontSize: 13, fontWeight: '700' },
fpsControlRow: { flexDirection: 'row', alignItems: 'center', gap: 10, marginTop: 8 },
fpsTrack: { flex: 1, height: 40, justifyContent: 'center' },
fpsTrackBase: { position: 'absolute', left: 0, right: 0, height: 8, borderRadius: 999, backgroundColor: 'rgba(15,42,29,0.12)' },
fpsTrackFill: { position: 'absolute', left: 0, height: 8, borderRadius: 999, backgroundColor: colors.greenAccent },
fpsThumb: { position: 'absolute', marginLeft: -14, width: 28, height: 28, borderRadius: 999, backgroundColor: '#fff', borderWidth: 2, borderColor: colors.greenAccent, shadowColor: '#000', shadowOpacity: 0.14, shadowRadius: 5, shadowOffset: {width: 0, height: 2} },
fpsRangeRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
fpsRangeText: { color: colors.muted, fontSize: 11, fontWeight: '600' },
fpsHint: { color: colors.muted, fontSize: 11, fontWeight: '500' },
sliderStepButton: { width: 34, height: 34, borderRadius: 999, alignItems: 'center', justifyContent: 'center', backgroundColor: 'rgba(255,255,255,0.78)', borderWidth: 1, borderColor: 'rgba(15,42,29,0.08)' },
sliderStepButtonDisabled: { opacity: 0.4 },
sliderStepText: { color: colors.ink, fontSize: 18, lineHeight: 20, fontWeight: '800' },
sliderStepTextDisabled: { color: colors.muted },
});
|