-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
1995 lines (1914 loc) · 55 KB
/
Copy pathApp.tsx
File metadata and controls
1995 lines (1914 loc) · 55 KB
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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import {
ActivityIndicator,
Image,
Modal,
Platform,
ScrollView,
StatusBar,
StyleSheet,
Text,
TextInput,
Pressable,
TouchableOpacity,
View,
Keyboard,
type ViewProps,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import WebView from 'react-native-webview';
import { requireNativeComponent } from 'react-native';
if (__DEV__) {
// @ts-ignore
console.disableYellowBox = true;
try {
const RN = require('react-native');
if (RN?.LogBox?.ignoreAllLogs) {
RN.LogBox.ignoreAllLogs(true);
} else if (RN?.YellowBox?.ignoreWarnings) {
RN.YellowBox.ignoreWarnings(['']);
}
} catch {
// ignore
}
}
type PlannerGuest = {
login: { uuid: string };
name: { title: string; first: string; last: string };
email: string;
phone: string;
cell: string;
picture: { large: string; medium: string; thumbnail: string };
location: { city: string; country: string };
};
type FlowVariant = 'original' | 'alternate';
type FlowRouteParams = {
variant: FlowVariant;
name: string;
uniqueId: string;
};
type RootStackParamList = {
Home: undefined;
Recharge: undefined;
Planner: FlowRouteParams;
NativeJourney: FlowRouteParams;
NativeHybrid: FlowRouteParams;
GuestLookup: FlowRouteParams;
WebChecklist: FlowRouteParams;
Summary: FlowRouteParams;
};
const Stack = createNativeStackNavigator<RootStackParamList>();
const UI = {
homeScreen: 'home.screen',
homeScroll: 'home.scroll',
homeHero: 'home.hero',
homeHeroImage: 'home.hero.image',
homeHeroEyebrow: 'home.hero.eyebrow',
homeHeroTitle: 'home.hero.title',
homeHeroBody: 'home.hero.body',
homeHeroBadge: 'home.hero.badge',
homeWorkflowPanel: 'home.panel.workflows',
homeNamePanel: 'home.panel.name',
homeNameLabel: 'home.label.name',
homeNameInput: 'home.input.name',
homeNameHelper: 'home.helper.name',
homeVersion: 'home.version',
brandCredit: 'brand.credit',
brandCreditLogo: 'brand.credit.logo',
brandCreditText: 'brand.credit.text',
homeRechargeButton: 'home.button.recharge',
homePlannerButton: 'home.button.planner',
plannerModeModal: 'planner.mode.modal',
plannerModePanel: 'planner.mode.panel',
plannerModeOriginalButton: 'planner.mode.button.original',
plannerModeAlternateButton: 'planner.mode.button.alternate',
plannerModeCancelButton: 'planner.mode.button.cancel',
plannerScreen: 'planner.screen',
plannerScroll: 'planner.scroll',
plannerTipBanner: 'planner.tipBanner',
plannerTipTitle: 'planner.tipBanner.title',
plannerTipText: 'planner.tipBanner.text',
plannerNextNativeButton: 'planner.button.next.native',
rechargeScreen: 'recharge.screen',
rechargeFrame: 'recharge.frame',
rechargeWebView: 'recharge.webview',
guestLookupScreen: 'guestLookup.screen',
guestLookupScroll: 'guestLookup.scroll',
guestLookupPanel: 'guestLookup.panel',
guestLookupInputLabel: 'guestLookup.label.count',
guestLookupInput: 'guestLookup.input.count',
guestLookupHelper: 'guestLookup.helper.count',
guestLookupFetchButton: 'guestLookup.button.fetch',
guestLookupLoader: 'guestLookup.loader',
guestLookupLoaderText: 'guestLookup.loader.text',
guestLookupResults: 'guestLookup.results',
guestLookupCards: 'guestLookup.cards',
guestLookupCardsList: 'guestLookup.cards.list',
guestLookupResultsNextButton: 'guestLookup.button.next',
nativeJourneyScreen: 'nativeJourney.screen',
nativeJourneyScroll: 'nativeJourney.scroll',
nativeJourneyPanel: 'nativeJourney.panel',
nativeJourneyView: 'nativeJourney.nativeView',
nativeJourneyContinue: 'nativeJourney.button.continue',
nativeJourneyModeNote: 'nativeJourney.mode.native',
nativeHybridScreen: 'nativeHybrid.screen',
nativeHybridView: 'nativeHybrid.nativeView',
nativeHybridContinue: 'nativeHybrid.button.continue',
nativeHybridModeNote: 'nativeHybrid.mode.hybrid',
webChecklistScreen: 'webChecklist.screen',
webChecklistTop: 'webChecklist.top',
webChecklistLoading: 'webChecklist.loading',
webChecklistReady: 'webChecklist.ready',
webChecklistFrame: 'webChecklist.frame',
webChecklistWebView: 'webChecklist.webview',
webChecklistContinue: 'webChecklist.button.continue',
summaryScreen: 'summary.screen',
summaryScroll: 'summary.scroll',
summaryCard: 'summary.card',
summaryEyebrow: 'summary.eyebrow',
summaryTitle: 'summary.title',
summaryBody: 'summary.body',
summaryThankYou: 'summary.thankYou',
summaryUniqueId: 'summary.uniqueId',
summaryRestartButton: 'summary.button.restart',
};
const generateUniqueId = () => {
const random = Math.random().toString(36).slice(2, 6).toUpperCase();
const stamp = Date.now().toString(36).slice(-4).toUpperCase();
return `CMP-${stamp}${random}`;
};
const normalizeName = (value: string) => {
const trimmed = value.trim();
return trimmed.length > 0 ? trimmed : 'Guest';
};
const getHighlightId = (index: number) => `home.highlight.${index + 1}`;
const getSectionTitleId = (scope: string, part: 'eyebrow' | 'title' | 'body') =>
`${scope}.${part}`;
const getAgendaId = (
index: number,
part: 'card' | 'index' | 'title' | 'body',
) => `planner.agenda.${index + 1}.${part}`;
const getProfileId = (
index: number,
part: 'card' | 'avatar' | 'name' | 'email' | 'location' | 'phone',
) => `guestLookup.profile.${index + 1}.${part}`;
const getRecapId = (index: number) => `summary.recap.${index + 1}`;
const nativePlatformName = Platform.select({ android: 'AndroidX', ios: 'Swift' }) ?? 'Native';
const nativePlatformSuffix = Platform.select({ android: 'androidx', ios: 'swift' }) ?? 'native';
const reactNativeModeLabel = 'React Native View';
const nativeViewModeLabel = `${nativePlatformName} Native View`;
const hybridViewModeLabel = `${nativePlatformName} Hybrid Native Views`;
const APP_VERSION = 'Version 1.1';
const FEATURE_HIGHLIGHTS = [
'Create a small event agenda in native screens',
'Review vertically scrollable activity cards',
'Fetch attendee profiles from a real API',
'Validate input and show dismissible error dialogs',
'Complete one lightweight interaction inside a webview',
];
const AGENDA_STEPS = [
{
title: 'Welcome Wall',
subtitle: 'Guests arrive, scan the day plan, and pick their pace.',
},
{
title: 'Snack Voting',
subtitle: 'The team chooses between coffee, juices, and street food.',
},
{
title: 'Icebreaker Sprint',
subtitle: 'Each group shares one app idea they would build in a weekend.',
},
{
title: 'Mini Demos',
subtitle: 'Product, QA, and automation folks each show a tiny win.',
},
{
title: 'Wrap-up Notes',
subtitle: 'Attendees leave with contacts and follow-up actions.',
},
{
title: 'Photo Wall',
subtitle:
'A slow stroll past a few snapshots from the day before everyone moves on.',
},
{
title: 'Team Kudos',
subtitle:
'A calm moment for a couple of shout-outs and small celebrations.',
},
{
title: 'Exit Snacks',
subtitle:
'A final friendly stop for refreshments, quick goodbyes, and the last scroll of the page.',
},
];
const ALTERNATE_AGENDA_STEPS = [
{
title: 'Welcome Wall',
subtitle:
'Guests arrive, scan the updated day plan, and settle into a relaxed pace.',
},
{
title: 'Snack Voting',
subtitle: 'The team picks between coffee, juices, and neighborhood snacks.',
},
{
title: 'Icebreaker Sprint',
subtitle:
'Each group shares one app idea they would happily prototype over a weekend.',
},
{
title: 'Mini Demos',
subtitle: 'Product, QA, and automation folks each highlight one tiny win.',
},
{
title: 'Wrap-up Notes',
subtitle:
'Attendees leave with fresh contacts and a few follow-up actions.',
},
{
title: 'Photo Wall',
subtitle:
'A longer, slower pass where guests can browse snapshots from the day and tap into the memories.',
},
{
title: 'Team Kudos',
subtitle:
'A final stretch for shout-outs, quick thank-yous, and a couple of small wins from the event.',
},
{
title: 'Exit Snacks',
subtitle:
'One last scroll-friendly stop with refreshments and a quiet finish before everyone heads out.',
},
];
const NativeJourneyView = requireNativeComponent<ViewProps>('NativeJourneyView');
const NativeHybridView = requireNativeComponent<ViewProps>('NativeHybridView');
const CHECKLIST_HTML = `
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
background: linear-gradient(180deg, #eef1fa 0%, #f4f9ff 100%);
color: #21309B;
}
.wrap {
padding: 24px 18px 40px;
}
.card {
background: #ffffff;
border-radius: 18px;
padding: 18px;
box-shadow: 0 10px 30px rgba(33, 48, 155, 0.08);
}
h1 {
margin: 0 0 10px;
font-size: 28px;
}
p {
margin: 0 0 16px;
line-height: 1.45;
}
button {
width: 100%;
border: 0;
border-radius: 14px;
padding: 14px 16px;
font-size: 16px;
font-weight: 700;
color: #ffffff;
background: #C8202E;
}
.done {
margin-top: 16px;
display: none;
padding: 14px;
border-radius: 14px;
background: #e4f6ea;
color: #0f7a35;
font-weight: 600;
}
</style>
</head>
<body>
<div class="wrap">
<div class="card">
<h1>Quick Web Check-in</h1>
<p>Tap the button below to confirm that the venue checklist was reviewed.</p>
<button id="confirmButton">Mark checklist as ready</button>
<div id="doneMessage" class="done">Checklist confirmed. You can return to the app flow.</div>
</div>
</div>
<script>
const button = document.getElementById('confirmButton');
const doneMessage = document.getElementById('doneMessage');
button.addEventListener('click', function () {
doneMessage.style.display = 'block';
button.textContent = 'Ready';
button.disabled = true;
button.style.background = '#0f7a35';
window.ReactNativeWebView && window.ReactNativeWebView.postMessage('checklist-complete');
});
</script>
</body>
</html>
`;
const EOT_LOGO = require('./assets/images/eot-logo.jpg');
function PoweredByEssence({ testID }: { testID?: string }) {
return (
<View
accessibilityLabel={UI.brandCredit}
style={styles.brandCredit}
testID={testID ?? UI.brandCredit}
>
<Image
source={EOT_LOGO}
style={styles.brandCreditLogo}
resizeMode="contain"
testID={UI.brandCreditLogo}
/>
<Text style={styles.brandCreditText} testID={UI.brandCreditText}>
Powered by Essence of Testing
</Text>
</View>
);
}
function PrimaryButton({
label,
onPress,
disabled,
testID,
}: {
label: string;
onPress: () => void;
disabled?: boolean;
testID?: string;
}) {
return (
<TouchableOpacity
accessible
accessibilityLabel={testID ?? label}
accessibilityRole="button"
disabled={disabled}
onPress={onPress}
style={[styles.primaryButton, disabled && styles.primaryButtonDisabled]}
testID={testID}
>
<Text style={styles.primaryButtonText}>
{label}
</Text>
</TouchableOpacity>
);
}
function SecondaryButton({
label,
onPress,
testID,
}: {
label: string;
onPress: () => void;
testID?: string;
}) {
return (
<TouchableOpacity
accessible
accessibilityLabel={testID ?? label}
accessibilityRole="button"
onPress={onPress}
style={styles.secondaryButton}
testID={testID}
>
<Text style={styles.secondaryButtonText}>
{label}
</Text>
</TouchableOpacity>
);
}
function SectionTitle({
eyebrow,
title,
body,
testID,
}: {
eyebrow: string;
title: string;
body: string;
testID: string;
}) {
return (
<View
accessibilityLabel={testID}
style={styles.sectionTitleWrap}
testID={testID}
>
<Text
accessibilityLabel={getSectionTitleId(testID, 'eyebrow')}
style={styles.eyebrow}
testID={getSectionTitleId(testID, 'eyebrow')}
>
{eyebrow}
</Text>
<Text
accessibilityLabel={getSectionTitleId(testID, 'title')}
style={styles.sectionTitle}
testID={getSectionTitleId(testID, 'title')}
>
{title}
</Text>
<Text
accessibilityLabel={getSectionTitleId(testID, 'body')}
style={styles.sectionBody}
testID={getSectionTitleId(testID, 'body')}
>
{body}
</Text>
</View>
);
}
function ScreenModeNote({
label,
testID,
}: {
label: string;
testID: string;
}) {
return (
<View
accessibilityLabel={testID}
style={styles.modeNote}
testID={testID}
>
<Text style={styles.modeNoteText}>{label}</Text>
</View>
);
}
function HomeScreen({ navigation }: any) {
const [isPlannerModeVisible, setIsPlannerModeVisible] = useState(false);
const [name, setName] = useState('');
const openPlannerModeChooser = useCallback(() => {
setIsPlannerModeVisible(true);
}, []);
const closePlannerModeChooser = useCallback(() => {
setIsPlannerModeVisible(false);
}, []);
const startPlannerFlow = useCallback(
(variant: FlowVariant) => {
setIsPlannerModeVisible(false);
navigation.navigate('Planner', {
variant,
name: normalizeName(name),
uniqueId: generateUniqueId(),
});
},
[navigation, name],
);
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.homeScreen} testID={UI.homeScreen}>
<StatusBar barStyle="dark-content" backgroundColor="#eef1fa" />
<View style={styles.screenTopActions}>
<PrimaryButton
label="Recharge Phone Number"
onPress={() => navigation.navigate('Recharge')}
testID={UI.homeRechargeButton}
/>
<View style={styles.actionSpacer} />
<PrimaryButton
label="Community Meeting Planner"
onPress={openPlannerModeChooser}
testID={UI.homePlannerButton}
/>
</View>
<ScrollView
contentContainerStyle={styles.scrollContent}
showsVerticalScrollIndicator={false}
testID={UI.homeScroll}
>
<View
accessibilityLabel={UI.homeHero}
style={styles.heroCard}
testID={UI.homeHero}
>
<Image
source={require('./assets/images/jio-logo.jpg')}
style={styles.heroLogo}
testID={UI.homeHeroImage}
resizeMode="cover"
/>
<View style={styles.heroBadge} testID={UI.homeHeroBadge}>
<Image
source={EOT_LOGO}
style={styles.heroBadgeLogo}
resizeMode="contain"
/>
</View>
<View style={styles.heroOverlay}>
<Text style={styles.heroEyebrow} testID={UI.homeHeroEyebrow}>
Cross-platform Demo
</Text>
<Text style={styles.heroTitle} testID={UI.homeHeroTitle}>
App Automation Playground
</Text>
<Text style={styles.heroBody} testID={UI.homeHeroBody}>
A small native workflow for Android and iOS with scrolling,
validation, API data, and a webview step.
</Text>
</View>
</View>
<View
accessibilityLabel={UI.homeNamePanel}
style={styles.panel}
testID={UI.homeNamePanel}
>
<Text
style={styles.inputLabel}
testID={UI.homeNameLabel}
>
Your name
</Text>
<TextInput
accessibilityLabel={UI.homeNameInput}
autoCapitalize="words"
onChangeText={setName}
placeholder="Enter your name"
placeholderTextColor="#7f8b97"
style={styles.input}
testID={UI.homeNameInput}
value={name}
/>
<Text style={styles.helperText} testID={UI.homeNameHelper}>
Used to personalize your summary at the end of the workflow.
</Text>
</View>
<View
accessibilityLabel={UI.homeWorkflowPanel}
style={styles.panel}
testID={UI.homeWorkflowPanel}
>
<ScreenModeNote label={reactNativeModeLabel} testID="home.mode.native" />
<SectionTitle
eyebrow="What It Shows"
title="Choose a demo workflow"
body="The original recharge experience is still available, and the meetup planner adds a richer native plus web journey."
testID="home.section.workflows"
/>
{FEATURE_HIGHLIGHTS.map((item, index) => (
<View
accessibilityLabel={getHighlightId(index)}
key={item}
style={styles.bulletRow}
testID={getHighlightId(index)}
>
<View style={styles.bulletDot} />
<Text
style={styles.bulletText}
testID={`${getHighlightId(index)}.text`}
>
{item}
</Text>
</View>
))}
</View>
<Text style={styles.versionText} testID={UI.homeVersion}>
{APP_VERSION}
</Text>
<PoweredByEssence testID="home.brand.credit" />
</ScrollView>
<Modal
animationType="fade"
transparent
visible={isPlannerModeVisible}
onRequestClose={closePlannerModeChooser}
>
<View style={styles.modalBackdrop} testID={UI.plannerModeModal}>
<View style={styles.modalCard} testID={UI.plannerModePanel}>
<Text style={styles.modalEyebrow}>Community Meeting Planner</Text>
<Text style={styles.modalTitle}>Choose the planner flow</Text>
<Text style={styles.modalBody}>
The alternate flow keeps the overall journey the same, but adds
subtle visual differences for screenshot and visual testing.
</Text>
<PrimaryButton
label="Open Original Flow"
onPress={() => startPlannerFlow('original')}
testID={UI.plannerModeOriginalButton}
/>
<View style={styles.actionSpacer} />
<PrimaryButton
label="Open Alternate Flow"
onPress={() => startPlannerFlow('alternate')}
testID={UI.plannerModeAlternateButton}
/>
<View style={styles.actionSpacer} />
<SecondaryButton
label="Cancel"
onPress={closePlannerModeChooser}
testID={UI.plannerModeCancelButton}
/>
</View>
</View>
</Modal>
</SafeAreaView>
);
}
function RechargeScreen() {
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.rechargeScreen} testID={UI.rechargeScreen}>
<View style={styles.screenHeader}>
<ScreenModeNote label="Web view" testID="recharge.mode.web" />
</View>
<View
accessibilityLabel={UI.rechargeFrame}
style={styles.webviewFrame}
testID={UI.rechargeFrame}
>
<WebView
source={{ uri: 'http://localhost:8080' }}
javaScriptEnabled
domStorageEnabled
startInLoadingState
webviewDebuggingEnabled
accessibilityLabel={UI.rechargeWebView}
testID={UI.rechargeWebView}
/>
</View>
</SafeAreaView>
);
}
function NativeJourneyScreen({ navigation, route }: any) {
const variant: FlowVariant = route.params?.variant ?? 'original';
const name: string = route.params?.name ?? 'Guest';
const uniqueId: string = route.params?.uniqueId ?? '';
const isAlternate = variant === 'alternate';
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.nativeJourneyScreen} testID={UI.nativeJourneyScreen}>
<View style={styles.screenTopActions}>
<PrimaryButton
label="Next: Hybrid Native Views"
onPress={() => navigation.push('NativeHybrid', { variant, name, uniqueId })}
testID={UI.nativeJourneyContinue}
/>
</View>
<ScrollView
contentContainerStyle={[
styles.scrollContent,
isAlternate && styles.scrollContentAlternate,
]}
showsVerticalScrollIndicator={false}
testID={UI.nativeJourneyScroll}
>
<View style={styles.screenHeader}>
<ScreenModeNote
label={nativeViewModeLabel}
testID={`${UI.nativeJourneyModeNote}.${nativePlatformSuffix}`}
/>
</View>
<SectionTitle
eyebrow="Step 2A"
title={
isAlternate
? `${nativePlatformName} native detail with extra breathing room`
: `A longer ${nativePlatformName} native screen`
}
body={
`This scrollable screen is rendered entirely with ${nativePlatformName} platform views before the workflow continues.`
}
testID="nativeJourney.section.intro"
/>
<NativeJourneyView
accessibilityLabel={UI.nativeJourneyView}
testID={UI.nativeJourneyView}
style={styles.nativeJourneyView}
/>
</ScrollView>
</SafeAreaView>
);
}
function NativeHybridScreen({ navigation, route }: any) {
const variant: FlowVariant = route.params?.variant ?? 'original';
const name: string = route.params?.name ?? 'Guest';
const uniqueId: string = route.params?.uniqueId ?? '';
const isAlternate = variant === 'alternate';
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.nativeHybridScreen} testID={UI.nativeHybridScreen}>
<View style={styles.screenTopActions}>
<PrimaryButton
label="Next: Load Guest Profiles"
onPress={() => navigation.navigate('GuestLookup', { variant, name, uniqueId })}
testID={UI.nativeHybridContinue}
/>
</View>
<View style={styles.nativeHybridShell}>
<View style={styles.screenHeader}>
<ScreenModeNote
label={hybridViewModeLabel}
testID={`${UI.nativeHybridModeNote}.${nativePlatformSuffix}`}
/>
</View>
<SectionTitle
eyebrow="Step 2B"
title={
isAlternate
? `${nativePlatformName} hybrid native views before profiles`
: `A compact ${nativePlatformName} hybrid native views`
}
body="This screen combines React Native layout with a fixed native component, and it does not scroll."
testID="nativeHybrid.section.intro"
/>
<NativeHybridView
accessibilityLabel={UI.nativeHybridView}
testID={UI.nativeHybridView}
style={styles.nativeHybridView}
/>
</View>
</SafeAreaView>
);
}
function PlannerScreen({ navigation, route }: any) {
const variant: FlowVariant = route.params?.variant ?? 'original';
const name: string = route.params?.name ?? 'Guest';
const uniqueId: string = route.params?.uniqueId ?? '';
const isAlternate = variant === 'alternate';
const agendaSteps = isAlternate ? ALTERNATE_AGENDA_STEPS : AGENDA_STEPS;
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.plannerScreen} testID={UI.plannerScreen}>
<View style={styles.screenTopActions}>
<PrimaryButton
label="Next: Native Detail"
onPress={() => navigation.push('NativeJourney', { variant, name, uniqueId })}
testID={UI.plannerNextNativeButton}
/>
</View>
<ScrollView
contentContainerStyle={[
styles.scrollContent,
isAlternate && styles.scrollContentAlternate,
]}
showsVerticalScrollIndicator={false}
style={styles.plannerScroll}
testID={UI.plannerScroll}
>
<SectionTitle
eyebrow="Step 1"
title={
isAlternate ? 'Build the event atmosphere' : 'Build the event mood'
}
body={
isAlternate
? 'This version keeps the same screen structure, but introduces subtle layout and typography changes for visual comparison.'
: 'This screen is intentionally scrollable so the demo includes a natural vertical swipe interaction.'
}
testID="planner.section.intro"
/>
<ScreenModeNote label={reactNativeModeLabel} testID="planner.mode.native" />
{agendaSteps.map((step, index) => (
<View
accessibilityLabel={getAgendaId(index, 'card')}
key={step.title}
style={[
styles.agendaCard,
isAlternate && styles.agendaCardAlternate,
]}
testID={getAgendaId(index, 'card')}
>
<Text
style={[
styles.agendaIndex,
isAlternate && styles.agendaIndexAlternate,
]}
testID={getAgendaId(index, 'index')}
>
0{index + 1}
</Text>
<Text
style={[
styles.agendaTitle,
isAlternate && styles.agendaTitleAlternate,
]}
testID={getAgendaId(index, 'title')}
>
{step.title}
</Text>
<Text
style={[
styles.agendaSubtitle,
isAlternate && styles.agendaSubtitleAlternate,
]}
testID={getAgendaId(index, 'body')}
>
{step.subtitle}
</Text>
</View>
))}
<View
style={[styles.tipBanner, isAlternate && styles.tipBannerAlternate]}
testID={UI.plannerTipBanner}
>
<Text
style={[styles.tipTitle, isAlternate && styles.tipTitleAlternate]}
testID={UI.plannerTipTitle}
>
Demo Tip
</Text>
<Text
style={[styles.tipText, isAlternate && styles.tipTextAlternate]}
testID={UI.plannerTipText}
>
{isAlternate
? 'Scan the refreshed cards, then move ahead to load attendee profiles from the API.'
: 'Scroll through the agenda, then move forward to fetch attendee profiles from the API.'}
</Text>
</View>
</ScrollView>
</SafeAreaView>
);
}
function GuestLookupScreen({ navigation, route }: any) {
const variant: FlowVariant = route.params?.variant ?? 'original';
const name: string = route.params?.name ?? 'Guest';
const uniqueId: string = route.params?.uniqueId ?? '';
const isAlternate = variant === 'alternate';
const [guestCount, setGuestCount] = useState('');
const [guests, setGuests] = useState<PlannerGuest[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [activeAlert, setActiveAlert] = useState<{
title: string;
message: string;
} | null>(null);
const dismissActiveAlert = useCallback(() => {
setActiveAlert(null);
}, []);
const validateGuestCount = useCallback((value: string) => {
const trimmedValue = value.trim();
if (!/^\d+$/.test(trimmedValue)) {
return 'Please enter a whole number from 1 to 15.';
}
const parsedValue = Number(trimmedValue);
if (parsedValue < 1 || parsedValue > 15) {
return 'Please enter a number between 1 and 15.';
}
return null;
}, []);
const loadGuests = useCallback(async () => {
Keyboard.dismiss();
const validationMessage = validateGuestCount(guestCount);
if (validationMessage) {
setActiveAlert({
title: 'Invalid guest count',
message: validationMessage,
});
return;
}
setIsLoading(true);
try {
const response = await fetch(
`https://randomuser.me/api/?results=${guestCount.trim()}`,
);
if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}
const payload = await response.json();
setGuests(Array.isArray(payload?.results) ? payload.results : []);
} catch {
setActiveAlert({
title: 'Unable to load profiles',
message: 'Please try again in a moment.',
});
} finally {
setIsLoading(false);
}
}, [guestCount, validateGuestCount]);
return (
<SafeAreaView style={styles.screen} accessibilityLabel={UI.guestLookupScreen} testID={UI.guestLookupScreen}>
<View style={styles.screenTopActions}>
<PrimaryButton
label={isLoading ? 'Loading Profiles...' : 'Load Profiles'}
onPress={loadGuests}
disabled={isLoading || guests.length > 0}
testID={UI.guestLookupFetchButton}
/>
<View style={styles.actionSpacer} />
<PrimaryButton
label="Next: Open Web Checklist"
onPress={() => navigation.navigate('WebChecklist', { variant, name, uniqueId })}
disabled={guests.length === 0}
testID={UI.guestLookupResultsNextButton}
/>
</View>
<Modal
animationType="fade"
transparent
visible={activeAlert !== null}
onRequestClose={dismissActiveAlert}
>
<Pressable
accessibilityLabel="guestLookup.alert.backdrop"
style={styles.alertBackdrop}
testID="guestLookup.alert.backdrop"
onPress={dismissActiveAlert}
>
<Pressable
accessibilityLabel="guestLookup.alert.card"
style={styles.alertCard}
testID="guestLookup.alert.card"
onPress={() => undefined}
>
<Text style={styles.alertTitle} testID="guestLookup.alert.title">
{activeAlert?.title}
</Text>
<Text style={styles.alertBody} testID="guestLookup.alert.body">
{activeAlert?.message}
</Text>
<SecondaryButton
label="Ok"
onPress={dismissActiveAlert}
testID="guestLookup.alert.ok"
/>
</Pressable>
</Pressable>
</Modal>
<ScrollView
contentContainerStyle={[
styles.scrollContent,