1
1
use super :: * ;
2
2
3
- const WARNING_64PX_BITMAP : [ u8 ; 359 ] = [
4
- 0x40 , 0x00 , 0x40 , 0x00 , 0x21 , 0x5f , 0x01 , 0x00 , 0x5d , 0x01 , 0x1f , 0x8b , 0x08 , 0x00 , 0x00 , 0x00 ,
5
- 0x00 , 0x00 , 0x02 , 0xff , 0x85 , 0xd5 , 0x31 , 0x4e , 0xc3 , 0x40 , 0x10 , 0x05 , 0xd0 , 0x8d , 0x85 , 0x08 ,
6
- 0x4a , 0x45 , 0x49 , 0x91 , 0xc2 , 0x25 , 0xb2 , 0x52 , 0xe4 , 0x08 , 0x39 , 0x40 , 0xc4 , 0x19 , 0x72 , 0x82 ,
7
- 0x5c , 0x81 , 0x84 , 0x03 , 0x80 , 0xb8 , 0x41 , 0xc4 , 0x05 , 0x72 , 0x04 , 0x0a , 0xd2 , 0xe7 , 0x08 , 0x69 ,
8
- 0x02 , 0xa2 , 0x0b , 0xa5 , 0x13 , 0xa1 , 0x1d , 0xec , 0x99 , 0x5d , 0xb3 , 0xf6 , 0xee , 0x1f , 0x6f , 0xfb ,
9
- 0xc6 , 0x96 , 0xbc , 0xfe , 0x33 , 0x43 , 0x84 , 0x4f , 0xb9 , 0x27 , 0xed , 0x5c , 0xf2 , 0xeb , 0x93 , 0xc2 ,
10
- 0xbf , 0x53 , 0x63 , 0x26 , 0x0a , 0xcf , 0x8c , 0x31 , 0x23 , 0x9d , 0xb1 , 0x5b , 0x66 , 0xe8 , 0x76 , 0x51 ,
11
- 0xe1 , 0x60 , 0x06 , 0x7d , 0x5d , 0x3f , 0xfc , 0xb8 , 0x41 , 0xce , 0xbc , 0x24 , 0xe4 , 0xcc , 0x73 , 0x42 ,
12
- 0xfe , 0xea , 0x18 , 0xf8 , 0x9b , 0xe7 , 0xb4 , 0xef , 0x6a , 0x96 , 0x7b , 0x4b , 0x39 , 0x73 , 0x41 , 0xc8 ,
13
- 0x99 , 0xef , 0x08 , 0xf9 , 0x31 , 0xe4 , 0xd8 , 0xbf , 0x5a , 0x1c , 0x79 , 0x79 , 0x5b , 0xf1 , 0x90 , 0x90 ,
14
- 0x33 , 0x87 , 0x91 , 0x68 , 0x3b , 0xf3 , 0x55 , 0x18 , 0xa9 , 0x96 , 0x9f , 0x23 , 0x6e , 0xf9 , 0x25 , 0x8f ,
15
- 0x38 , 0x74 , 0x8e , 0x4b , 0xd6 , 0xc9 , 0xeb , 0xbf , 0x0b , 0x6f , 0x09 , 0x38 , 0xf3 , 0xe0 , 0x85 , 0x80 ,
16
- 0xdb , 0x34 , 0x7b , 0x97 , 0xb0 , 0xc5 , 0xec , 0x5d , 0xc2 , 0x46 , 0xc8 , 0x5d , 0xd8 , 0x90 , 0xaf , 0x9b ,
17
- 0xb8 , 0x94 , 0xc6 , 0x9f , 0x1b , 0xfa , 0x31 , 0x46 , 0xdc , 0x36 , 0x8c , 0x7d , 0x4e , 0xba , 0x17 , 0x3d ,
18
- 0xae , 0xbd , 0x5f , 0xe2 , 0xbc , 0xc4 , 0x6e , 0x9f , 0xf4 , 0xef , 0x93 , 0xeb , 0x4b , 0x16 , 0x84 , 0xf7 ,
19
- 0x9b , 0x2a , 0x68 , 0xfe , 0x4f , 0x5d , 0x90 , 0x3d , 0x43 , 0x77 , 0x05 , 0x5b , 0xe8 , 0x7d , 0xf9 , 0x70 ,
20
- 0xf1 , 0xeb , 0x16 , 0x44 , 0xf9 , 0xcc , 0xde , 0xa1 , 0xbb , 0x00 , 0x1f , 0xa0 , 0xd3 , 0x39 , 0xef , 0xb4 ,
21
- 0x4f , 0xb7 , 0xbf , 0xbe , 0xf5 , 0xfe , 0x72 , 0xed , 0x1b , 0x14 , 0xa4 , 0xfb , 0x7b , 0x78 , 0x82 , 0x2e ,
22
- 0x05 , 0xf7 , 0xd8 , 0xe9 , 0x33 , 0x18 , 0x3f , 0xc9 , 0xf9 , 0xf4 , 0xa1 , 0xcf , 0x27 , 0x97 , 0x97 , 0x02 ,
23
- 0xbb , 0x14 , 0x4c , 0xb0 , 0x4b , 0xc1 , 0x03 , 0x76 , 0xf2 , 0x89 , 0x43 , 0x6e , 0x57 , 0xfa , 0x7c , 0xf7 ,
24
- 0x89 , 0xdb , 0xe8 , 0xfb , 0xc5 , 0x4c , 0x95 , 0xfd , 0xb4 , 0x50 , 0xf7 , 0x93 , 0x5f , 0x60 , 0x23 , 0x65 ,
25
- 0x3f , 0xe6 , 0xba , 0x73 , 0xa0 , 0xc6 , 0x3d , 0xfb , 0x99 , 0xf4 , 0x05 , 0x5e , 0xcd , 0xcb , 0x3f , 0xe4 ,
26
- 0x2a , 0x7b , 0x24 , 0x00 , 0x08 , 0x00 , 0x00 ,
27
- ] ;
28
-
29
3
/// A wrapper around the asynchronous NBGL nbgl_useCaseChoice C API binding.
30
4
/// Draws a generic choice page, described in a centered info (with configurable icon),
31
5
/// thanks to a button and a footer at the bottom of the page.
@@ -57,13 +31,7 @@ impl<'a> NbglChoice<'a> {
57
31
unsafe {
58
32
let icon: nbgl_icon_details_t = match self . glyph {
59
33
Some ( g) => g. into ( ) ,
60
- None => nbgl_icon_details_t {
61
- width : 64 ,
62
- height : 64 ,
63
- bpp : NBGL_BPP_4 ,
64
- isFile : true ,
65
- bitmap : & WARNING_64PX_BITMAP as * const u8 ,
66
- } ,
34
+ None => nbgl_icon_details_t:: default ( ) ,
67
35
} ;
68
36
let message = CString :: new ( message) . unwrap ( ) ;
69
37
let sub_message = CString :: new ( sub_message) . unwrap ( ) ;
@@ -73,10 +41,22 @@ impl<'a> NbglChoice<'a> {
73
41
self . ux_sync_init ( ) ;
74
42
nbgl_useCaseChoice (
75
43
& icon as * const nbgl_icon_details_t ,
76
- message. as_ptr ( ) as * const c_char ,
77
- sub_message. as_ptr ( ) as * const c_char ,
78
- confirm_text. as_ptr ( ) as * const c_char ,
79
- cancel_text. as_ptr ( ) as * const c_char ,
44
+ match message. is_empty ( ) {
45
+ true => core:: ptr:: null ( ) ,
46
+ false => message. as_ptr ( ) as * const c_char ,
47
+ } ,
48
+ match sub_message. is_empty ( ) {
49
+ true => core:: ptr:: null ( ) ,
50
+ false => sub_message. as_ptr ( ) as * const c_char ,
51
+ } ,
52
+ match confirm_text. is_empty ( ) {
53
+ true => core:: ptr:: null ( ) ,
54
+ false => confirm_text. as_ptr ( ) as * const c_char ,
55
+ } ,
56
+ match cancel_text. is_empty ( ) {
57
+ true => core:: ptr:: null ( ) ,
58
+ false => cancel_text. as_ptr ( ) as * const c_char ,
59
+ } ,
80
60
Some ( choice_callback) ,
81
61
) ;
82
62
let sync_ret = self . ux_sync_wait ( false ) ;
0 commit comments