6
6
* @flow strict-local
7
7
*/
8
8
9
- import React from 'react' ;
9
+ import * as React from 'react' ;
10
+ import { useRef , useState } from 'react' ;
10
11
import type { Node } from 'react' ;
11
12
import NativeAnswerSolver from './js/NativeAnswerSolver' ;
12
13
import {
@@ -27,6 +28,8 @@ import {
27
28
ReloadInstructions ,
28
29
} from 'react-native/Libraries/NewAppScreen' ;
29
30
import Button from "react-native/Libraries/Components/Button" ;
31
+ import AnswerViewer , { Commands as AnswerViewerCommands } from './js/NativeAnswerViewer' ;
32
+ import type { AnswerViewerViewType } from './js/NativeAnswerViewer' ;
30
33
31
34
const Section = ( { children, title} ) : Node => {
32
35
const isDarkMode = useColorScheme ( ) === 'dark' ;
@@ -61,15 +64,21 @@ const App: () => Node = () => {
61
64
backgroundColor : isDarkMode ? Colors . darker : Colors . lighter ,
62
65
} ;
63
66
67
+ const ref = useRef < React . ElementRef < AnswerViewerViewType > | null > ( null ) ;
68
+ const [ step , setStep ] = useState ( 1 ) ;
69
+
64
70
const onPress = ( ) => {
65
71
const theAnswer = NativeAnswerSolver ?. answerTheUltimateQuestion ( "What's the Answer to the Ultimate Question of Life, the Universe, and Everything" ) || ""
66
72
console . log ( 'The answer is: ' + theAnswer ) ;
73
+ setStep ( step + 1 ) ;
74
+ AnswerViewerCommands . changeBackgroundColor ( ref . current , "red" ) ;
67
75
} ;
68
76
69
77
return (
70
78
< SafeAreaView style = { backgroundStyle } >
71
79
< StatusBar barStyle = { isDarkMode ? 'light-content' : 'dark-content' } />
72
80
< Button title = "Click to invoke your Turbo Module!" onPress = { onPress } />
81
+ < AnswerViewer ref = { ref } style = { { width : "100%" , height : 50 } } color = "yellow" step = { step } />
73
82
< ScrollView
74
83
contentInsetAdjustmentBehavior = "automatic"
75
84
style = { backgroundStyle } >
0 commit comments