@@ -5,6 +5,8 @@ use core::str::from_utf8;
55
66use nanos_sdk:: buttons:: * ;
77use nanos_ui:: bagls:: * ;
8+ use nanos_ui:: layout:: * ;
9+ use nanos_ui:: ui:: clear_screen;
810
911#[ derive( Clone , Debug ) ]
1012pub struct PromptQueue {
@@ -116,45 +118,44 @@ impl PromptQueue {
116118 let mut buttons = Default :: default ( ) ;
117119
118120 loop {
121+ clear_screen ( ) ;
119122 // Display
120123 let ( current_title, current_body) = title_and_body;
121124 match state {
122125 PromptingState :: Prompts => {
123- Bagl :: LABELLINE ( LabelLine :: new ( ) . pos ( 0 , 10 ) . text ( current_title. as_str ( ) ) )
124- . display ( ) ;
126+ current_title. as_str ( ) . place ( Location :: Top , Layout :: Centered , false ) ;
125127 #[ cfg( target_os = "nanos" ) ]
126128 {
127- Bagl :: LABELLINE ( LabelLine :: new ( ) . pos ( 0 , 25 ) . text ( current_body. as_str ( ) ) )
128- . paint ( ) ;
129+ current_body. as_str ( ) . place ( Location :: Custom ( 15 ) , Layout :: Centered , false ) ;
129130 }
130131 #[ cfg( not( target_os = "nanos" ) ) ]
131132 {
132133 let mut iter = current_body. as_bytes ( ) . chunks ( 16 ) ;
133134 if let Some ( body) = iter. next ( ) . map ( |s| from_utf8 ( s) . ok ( ) ) . flatten ( ) {
134- Bagl :: LABELLINE ( LabelLine :: new ( ) . pos ( 0 , 25 ) . text ( body ) ) . paint ( )
135+ body . place ( Location :: Custom ( 16 ) , Layout :: Centered , false ) ;
135136 } ;
136137 if let Some ( body) = iter. next ( ) . map ( |s| from_utf8 ( s) . ok ( ) ) . flatten ( ) {
137- Bagl :: LABELLINE ( LabelLine :: new ( ) . pos ( 0 , 40 ) . text ( body ) ) . paint ( )
138+ body . place ( Location :: Custom ( 31 ) , Layout :: Centered , false ) ;
138139 } ;
139140 if let Some ( body) = iter. next ( ) . map ( |s| from_utf8 ( s) . ok ( ) ) . flatten ( ) {
140- Bagl :: LABELLINE ( LabelLine :: new ( ) . pos ( 0 , 55 ) . text ( body ) ) . paint ( )
141+ body . place ( Location :: Custom ( 46 ) , Layout :: Centered , false ) ;
141142 } ;
142143 }
143144 if backward. prev != [ 0 ; HASH_LENGTH ] {
144- LEFT_ARROW . paint ( ) ;
145+ LEFT_ARROW . instant_display ( ) ;
145146 }
146- RIGHT_ARROW . paint ( ) ;
147+ RIGHT_ARROW . instant_display ( ) ;
147148 }
148149 PromptingState :: Confirm => {
149- Bagl :: ICON ( Icon :: new ( Icons :: CheckBadge ) . pos ( 18 , 12 ) ) . display ( ) ;
150- Bagl :: LABELLINE ( LabelLine :: new ( ) . text ( "Confirm" ) . pos ( 0 , 20 ) ) . paint ( ) ;
151- LEFT_ARROW . paint ( ) ;
152- RIGHT_ARROW . paint ( ) ;
150+ CHECKMARK_ICON . set_x ( 18 ) . display ( ) ;
151+ "Confirm" . place ( Location :: Middle , Layout :: Centered , false ) ;
152+ LEFT_ARROW . instant_display ( ) ;
153+ RIGHT_ARROW . instant_display ( ) ;
153154 }
154155 PromptingState :: Cancel => {
155- Bagl :: ICON ( Icon :: new ( Icons :: CrossBadge ) . pos ( 18 , 12 ) ) . display ( ) ;
156- Bagl :: LABELLINE ( LabelLine :: new ( ) . text ( "Cancel" ) . pos ( 0 , 20 ) ) . paint ( ) ;
157- LEFT_ARROW . paint ( ) ;
156+ CROSS_ICON . set_x ( 18 ) . display ( ) ;
157+ "Reject" . place ( Location :: Middle , Layout :: Centered , false ) ;
158+ LEFT_ARROW . instant_display ( ) ;
158159 }
159160 }
160161 // Handle buttons
0 commit comments