@@ -8,11 +8,13 @@ use include_gif::include_gif;
8
8
use ledger_device_sdk:: io:: * ;
9
9
use ledger_device_sdk:: nbgl:: {
10
10
init_comm, CenteredInfo , CenteredInfoStyle , Field , InfoButton , InfoLongPress , InfosList ,
11
- NbglGenericReview , NbglGlyph , NbglPageContent , NbglStatus , TagValueConfirm , TagValueList ,
12
- TuneIndex ,
11
+ NbglChoice , NbglGenericReview , NbglGlyph , NbglPageContent , NbglStatus , TagValueConfirm ,
12
+ TagValueList , TuneIndex ,
13
13
} ;
14
14
use ledger_secure_sdk_sys:: * ;
15
15
16
+ use core:: ops:: Not ;
17
+
16
18
#[ panic_handler]
17
19
fn panic ( _: & core:: panic:: PanicInfo ) -> ! {
18
20
exit_app ( 1 ) ;
@@ -87,11 +89,33 @@ extern "C" fn sample_main() {
87
89
. add_content ( NbglPageContent :: TagValueConfirm ( tag_value_confirm) )
88
90
. add_content ( NbglPageContent :: InfosList ( infos_list) ) ;
89
91
90
- let success = review. show ( "Reject Example" ) ;
91
- let status_text = if success {
92
- "Example confirmed"
93
- } else {
94
- "Example rejected"
95
- } ;
96
- NbglStatus :: new ( ) . text ( status_text) . show ( success) ;
92
+ const IMPORTANT : NbglGlyph =
93
+ NbglGlyph :: from_include ( include_gif ! ( "icons/Important_Circle_64px.png" , NBGL ) ) ;
94
+
95
+ let mut show_tx = true ;
96
+ let mut status_text = "Example rejected" ;
97
+ while show_tx {
98
+ let confirm = review. show ( "Reject Example" ) ;
99
+ if confirm {
100
+ status_text = "Example confirmed" ;
101
+ show_tx = false ;
102
+ } else {
103
+ show_tx = NbglChoice :: new ( )
104
+ . glyph ( & IMPORTANT )
105
+ . show (
106
+ "Reject transaction?" ,
107
+ "" ,
108
+ "Yes, reject" ,
109
+ "Go back to transaction" ,
110
+ )
111
+ // not() is used to invert the boolean value returned
112
+ // by the choice (since we want to return to showing the
113
+ // transaction if the user selects "Go back to transaction"
114
+ // which returns false).
115
+ . not ( ) ;
116
+ }
117
+ }
118
+ NbglStatus :: new ( )
119
+ . text ( status_text)
120
+ . show ( status_text == "Example confirmed" ) ;
97
121
}
0 commit comments