@@ -11,10 +11,10 @@ use android_view::{
1111 * ,
1212} ;
1313use masonry:: {
14- core:: { Action , DefaultProperties , Widget , WidgetId } ,
14+ core:: { Action , Properties , Widget , WidgetId , WidgetPod } ,
1515 properties:: Padding ,
1616 theme:: default_property_set,
17- widgets:: { Button , Flex , Label , Portal , RootWidget , TextArea , Textbox } ,
17+ widgets:: { Button , Flex , Label , Portal , TextArea , TextInput } ,
1818} ;
1919use masonry_android:: { AppDriver , DriverCtx } ;
2020use std:: { ffi:: c_void, sync:: Arc } ;
@@ -31,18 +31,15 @@ impl AppDriver for Driver {
3131 match action {
3232 Action :: ButtonPressed ( _) => {
3333 ctx. render_root ( ) . edit_root_widget ( |mut root| {
34- let mut root = root. downcast :: < RootWidget > ( ) ;
35-
36- let mut portal = RootWidget :: child_mut ( & mut root) ;
37- let mut portal = portal. downcast :: < Portal < Flex > > ( ) ;
34+ let mut portal = root. downcast :: < Portal < Flex > > ( ) ;
3835 let mut flex = Portal :: child_mut ( & mut portal) ;
3936 Flex :: add_child ( & mut flex, Label :: new ( self . next_task . clone ( ) ) ) ;
4037
4138 let mut first_row = Flex :: child_mut ( & mut flex, 0 ) . unwrap ( ) ;
4239 let mut first_row = first_row. downcast :: < Flex > ( ) ;
43- let mut textbox = Flex :: child_mut ( & mut first_row, 0 ) . unwrap ( ) ;
44- let mut textbox = textbox . downcast :: < Textbox > ( ) ;
45- let mut text_area = Textbox :: text_mut ( & mut textbox ) ;
40+ let mut text_input = Flex :: child_mut ( & mut first_row, 0 ) . unwrap ( ) ;
41+ let mut text_input = text_input . downcast :: < TextInput > ( ) ;
42+ let mut text_area = TextInput :: text_mut ( & mut text_input ) ;
4643 TextArea :: reset_text ( & mut text_area, "" ) ;
4744 } ) ;
4845 }
@@ -57,22 +54,19 @@ impl AppDriver for Driver {
5754fn make_widget_tree ( ) -> impl Widget {
5855 Portal :: new (
5956 Flex :: column ( )
60- . with_child (
61- Flex :: row ( )
62- . with_flex_child ( Textbox :: new ( "" ) , 1.0 )
63- . with_child ( Button :: new ( "Add task" ) ) ,
57+ . with_child_pod (
58+ WidgetPod :: new_with_props (
59+ Flex :: row ( )
60+ . with_flex_child ( TextInput :: new ( "" ) , 1.0 )
61+ . with_child ( Button :: new ( "Add task" ) ) ,
62+ Properties :: new ( ) . with ( Padding :: all ( WIDGET_SPACING ) ) ,
63+ )
64+ . erased ( ) ,
6465 )
6566 . with_spacer ( WIDGET_SPACING ) ,
6667 )
6768}
6869
69- fn default_props ( ) -> Arc < DefaultProperties > {
70- let mut default_properties = default_property_set ( ) ;
71- default_properties. insert :: < RootWidget , _ > ( Padding :: all ( WIDGET_SPACING ) ) ;
72-
73- Arc :: new ( default_properties)
74- }
75-
7670extern "system" fn new_view_peer < ' local > (
7771 mut env : JNIEnv < ' local > ,
7872 _view : View < ' local > ,
@@ -81,11 +75,11 @@ extern "system" fn new_view_peer<'local>(
8175 masonry_android:: new_view_peer (
8276 & mut env,
8377 & context,
84- RootWidget :: new ( make_widget_tree ( ) ) ,
78+ make_widget_tree ( ) ,
8579 Driver {
8680 next_task : String :: new ( ) ,
8781 } ,
88- default_props ( ) ,
82+ Arc :: new ( default_property_set ( ) ) ,
8983 )
9084}
9185
0 commit comments