6
6
* @flow strict-local
7
7
*/
8
8
9
- import React , { useRef } from 'react' ;
9
+ import React from 'react' ;
10
10
import type { PropsWithChildren } from 'react' ;
11
+ import { useState } from 'react' ;
11
12
12
13
import {
13
- findNodeHandle ,
14
14
SafeAreaView ,
15
15
ScrollView ,
16
16
StatusBar ,
@@ -20,19 +20,6 @@ import {
20
20
View ,
21
21
} from 'react-native' ;
22
22
23
- import {
24
- TextBox ,
25
- MenuFlyout ,
26
- MenuFlyoutItem ,
27
- TextBlock ,
28
- WinUI ,
29
- MediaPlayerElement ,
30
- Button ,
31
- ContentDialogState ,
32
- ContentDialog ,
33
- ContentDialogButton ,
34
- ContentDialogResult ,
35
- } from 'react-native-xaml' ;
36
23
import {
37
24
Colors ,
38
25
DebugInstructions ,
@@ -41,6 +28,39 @@ import {
41
28
ReloadInstructions ,
42
29
} from 'react-native/Libraries/NewAppScreen' ;
43
30
31
+ import {
32
+ HyperlinkButton ,
33
+ Border ,
34
+ TextBlock ,
35
+ StackPanel ,
36
+ Button ,
37
+ ComboBox ,
38
+ ComboBoxItem ,
39
+ NativeXamlControl ,
40
+ MenuFlyoutItem ,
41
+ TextBox ,
42
+ // BlankUserControl,
43
+ ClickMode ,
44
+ MenuFlyout ,
45
+ RichTextBlock ,
46
+ Run ,
47
+ Italic ,
48
+ LineBreak ,
49
+ Hyperlink ,
50
+ NavigationView ,
51
+ NavigationViewItem ,
52
+ NavigationViewItemHeader ,
53
+ FontIcon ,
54
+ WinUI ,
55
+ HorizontalAlignment ,
56
+ Visibility ,
57
+ WinUIEnums ,
58
+ SplitView ,
59
+ SplitViewPriority ,
60
+ SplitViewPanePlacement ,
61
+ Grid ,
62
+ } from 'react-native-xaml' ;
63
+
44
64
type SectionProps = PropsWithChildren < {
45
65
title : string ;
46
66
} > ;
@@ -69,7 +89,7 @@ function Section({children, title}: SectionProps): JSX.Element {
69
89
</ Text >
70
90
</ View >
71
91
) ;
72
- } ;
92
+ }
73
93
74
94
function App ( ) : JSX . Element {
75
95
const isDarkMode = useColorScheme ( ) === 'dark' ;
@@ -78,43 +98,153 @@ function App(): JSX.Element {
78
98
backgroundColor : isDarkMode ? Colors . darker : Colors . lighter ,
79
99
} ;
80
100
81
- const menu = useRef < MenuFlyout > ( null ) ;
82
- const _tbRef = React . useRef < TextBlock > ( null ) ;
83
- const _mpRef = React . useRef < MediaPlayerElement > ( null ) ;
84
- const [ x , setX ] = React . useState ( "100" ) ;
85
-
86
- const [ showState , setShowState ] = React . useState ( ContentDialogState . Hidden ) ;
87
-
88
-
101
+ const [ count , setCount ] = useState ( 0 ) ;
102
+ const [ isOpen , setIsOpen ] = useState ( false ) ;
103
+ const [ option , setOption ] = useState ( '' ) ;
104
+ const [ visible , setVisible ] = useState ( Visibility . Visible ) ;
89
105
return (
90
106
< SafeAreaView style = { backgroundStyle } >
91
107
< StatusBar barStyle = { isDarkMode ? 'light-content' : 'dark-content' } />
92
108
< ScrollView
93
109
contentInsetAdjustmentBehavior = "automatic"
94
110
style = { backgroundStyle } >
95
- < Header />
111
+ < WinUI . ProgressRing isActive = { true } width = { 40 } />
112
+ < WinUI . InfoBar
113
+ message = "the message"
114
+ title = "the title"
115
+ isOpen = { true }
116
+ visibility = { visible }
117
+ onClosed = { ( ) => {
118
+ setVisible ( Visibility . Collapsed ) ;
119
+ } }
120
+ severity = { WinUIEnums . InfoBarSeverity . Success }
121
+ horizontalAlignment = { HorizontalAlignment . Center }
122
+ />
123
+ < View >
124
+ < Text style = { { fontSize : 36 , textAlign : 'center' , padding : 42 } } >
125
+ Welcome to React Native XAML
126
+ </ Text >
127
+ </ View >
128
+ < SplitView
129
+ isPaneOpen = { isOpen }
130
+ onPaneClosed = { ( ) => {
131
+ setIsOpen ( false ) ;
132
+ } }
133
+ width = { 800 }
134
+ height = { 300 }
135
+ paneBackground = "red"
136
+ panePlacement = { SplitViewPanePlacement . Left } >
137
+ < TextBlock
138
+ text = "this is in the pane"
139
+ priority = { SplitViewPriority . Pane }
140
+ foreground = "white"
141
+ />
142
+ < Grid
143
+ background = "green"
144
+ priority = { SplitViewPriority . Content }
145
+ gridLayout = { { rows : [ 200 ] , columns : [ 200 ] } } >
146
+ < TextBlock text = "this is in the content" foreground = "white" />
147
+ </ Grid >
148
+ </ SplitView >
149
+
96
150
< View
97
151
style = { {
98
152
backgroundColor : isDarkMode ? Colors . black : Colors . white ,
99
153
} } >
100
- < TextBox
101
- text = { `x` }
102
- onBeforeTextChanging = { e => {
103
- if ( e . nativeEvent . args ) {
104
- setX ( e . nativeEvent . args . newText ) ;
105
- }
154
+ < Button
155
+ foreground = "#992222"
156
+ onTapped = { a => {
157
+ setIsOpen ( ! isOpen ) ;
106
158
} }
159
+ content = 'button'
107
160
/>
161
+ { /* <BlankUserControl onHappened={(arg) => alert(JSON.stringify(arg.nativeEvent)) } /> */ }
162
+ { /* <Button content={`Last selected option = ${option} ${count}`}
163
+ onClick={(a) => {
164
+ alert(JSON.stringify(a.nativeEvent));
165
+ setCount(count + 1);
166
+ setIsOpen(true); }}
167
+ clickMode={ClickMode.Release}
168
+ resources={{
169
+ ButtonForeground: "#00fff1",
170
+ ButtonForegroundPressed: "#2090ff",
171
+ }}
172
+ /> */ }
173
+ < TextBlock foreground = "black" padding = { 20 } margin = { 20 } >
174
+ < Run text = "hello world!" />
175
+ < LineBreak />
176
+ < Italic >
177
+ < Run text = "hi there" />
178
+ </ Italic >
179
+ < Hyperlink navigateUri = "http://bing.com" >
180
+ < Run text = "Go to bing" />
181
+ </ Hyperlink >
182
+ </ TextBlock >
183
+ < NavigationView
184
+ style = { { height : 200 , width : 120 , margin : 20 , padding : 40 } } >
185
+ < NavigationViewItem content = 'item 1' >
186
+ < FontIcon glyph = "" />
187
+ </ NavigationViewItem >
188
+ < NavigationViewItem content = 'item 2' />
189
+ </ NavigationView >
190
+ { /*<StackPanel orientation="horizontal">*/ }
191
+ { /* <HyperlinkButton content="Click me!" onClick={(args) => {*/ }
192
+ { /* alert(`clicked! Native event args: ${JSON.stringify(args.nativeEvent)}`);*/ }
193
+ { /* }} />*/ }
194
+ { /* <Border verticalAlignment="center" background="paleturquoise" >*/ }
195
+ { /* <TextBlock text="this is a text block" foreground='red' textAlignment="center" />*/ }
196
+ { /* </Border>*/ }
197
+ { /* <TextBlock text="this is another text block" foreground='green' textAlignment="center" />*/ }
198
+ { /* <Button content="this is a button" onClick={() => { alert("you clicked the button!"); }} />*/ }
199
+ { /*</StackPanel>*/ }
200
+ < ComboBox
201
+ text = "this is a combobox"
202
+ description = { { string : 'best cats' } }
203
+ onSelectionChanged = { args => {
204
+ alert (
205
+ `sel changed! Native event args: ${ JSON . stringify (
206
+ args . nativeEvent ,
207
+ ) } `,
208
+ ) ;
209
+ } } >
210
+ < ComboBoxItem content = 'garfield' foreground = "black" />
211
+ < ComboBoxItem content = 'snoopy' foreground = "black" />
212
+ </ ComboBox >
213
+ { /* <TextBox text="this is a textbox with a menuFlyout" foreground="red">
214
+ <MenuFlyout isOpen={isOpen} onClosed={() => {
215
+ setIsOpen(false);
216
+ }} >
217
+ <MenuFlyoutItem text="option 1" onClick={(x) => { alert(JSON.stringify(x.nativeEvent)); setOption("option 1"); }} />
218
+ <MenuFlyoutItem text="option 2" onClick={() => { alert("clicked 2"); setOption("option 2"); }}/>
219
+ </MenuFlyout>
220
+ </TextBox> */ }
108
221
109
- < WinUI . ColorPicker onColorChanged = { ( e ) => {
110
- console . log ( e . nativeEvent ) ;
111
- } } />
222
+ { /*<TextBox text="this is a textbox with a flyout" */ }
223
+ { /* foreground="red" >*/ }
224
+ { /* <NativeXamlControl type="flyout" >*/ }
225
+ { /* <Button content="click me" />*/ }
226
+ { /* </NativeXamlControl>*/ }
227
+ { /*</TextBox>*/ }
112
228
229
+ < Section title = "Step One" >
230
+ Edit < Text style = { styles . highlight } > App.js</ Text > to change this
231
+ screen and then come back to see your edits.
232
+ </ Section >
233
+ < Section title = "See Your Changes" >
234
+ < ReloadInstructions />
235
+ </ Section >
236
+ < Section title = "Debug" >
237
+ < DebugInstructions />
238
+ </ Section >
239
+ < Section title = "Learn More" >
240
+ Read the docs to discover what to do next:
241
+ </ Section >
242
+ < LearnMoreLinks />
113
243
</ View >
114
244
</ ScrollView >
115
245
</ SafeAreaView >
116
246
) ;
117
- } ;
247
+ }
118
248
119
249
const styles = StyleSheet . create ( {
120
250
sectionContainer : {
0 commit comments