@@ -24,8 +24,8 @@ use super::{
24
24
component:: { Button , ButtonStyleSheet , FuelGauge } ,
25
25
constant:: SCREEN ,
26
26
firmware:: {
27
- Header , HeaderMsg , TextScreen , TextScreenMsg , VerticalMenu , VerticalMenuScreen ,
28
- VerticalMenuScreenMsg , SHORT_MENU_ITEMS ,
27
+ Header , HeaderMsg , RegulatoryMsg , RegulatoryScreen , TextScreen , TextScreenMsg ,
28
+ VerticalMenu , VerticalMenuScreen , VerticalMenuScreenMsg , SHORT_MENU_ITEMS ,
29
29
} ,
30
30
} ,
31
31
theme, ShortMenuVec ,
@@ -134,13 +134,16 @@ enum Subscreen {
134
134
135
135
// The about screen
136
136
AboutScreen ,
137
+ // A screen showing the regulatory information
138
+ RegulatoryScreen ,
137
139
}
138
140
139
141
// Used to preallocate memory for the largest enum variant
140
142
#[ allow( clippy:: large_enum_variant) ]
141
143
enum ActiveScreen < ' a > {
142
144
Menu ( VerticalMenuScreen < ShortMenuVec > ) ,
143
145
About ( TextScreen < Paragraphs < [ Paragraph < ' a > ; 2 ] > > ) ,
146
+ Regulatory ( RegulatoryScreen ) ,
144
147
145
148
// used only during `DeviceMenuScreen::new`
146
149
Empty ,
@@ -183,8 +186,9 @@ impl<'a> DeviceMenuScreen<'a> {
183
186
} ;
184
187
185
188
let about = screen. add_subscreen ( Subscreen :: AboutScreen ) ;
189
+ let regulatory = screen. add_subscreen ( Subscreen :: RegulatoryScreen ) ;
186
190
let security = screen. add_security_menu ( ) ;
187
- let device = screen. add_device_menu ( device_name, about, auto_lock_delay) ;
191
+ let device = screen. add_device_menu ( device_name, regulatory , about, auto_lock_delay) ;
188
192
let settings = screen. add_settings_menu ( security, device) ;
189
193
190
194
let is_connected = !paired_devices. is_empty ( ) ; // FIXME after BLE API has this
@@ -284,6 +288,7 @@ impl<'a> DeviceMenuScreen<'a> {
284
288
fn add_device_menu (
285
289
& mut self ,
286
290
device_name : Option < TString < ' static > > ,
291
+ regulatory_index : usize ,
287
292
about_index : usize ,
288
293
auto_lock_delay : TString < ' static > ,
289
294
) -> usize {
@@ -311,6 +316,11 @@ impl<'a> DeviceMenuScreen<'a> {
311
316
unwrap ! ( items. push( autolock_delay_item) ) ;
312
317
}
313
318
319
+ unwrap ! ( items. push( MenuItem :: new(
320
+ TR :: regulatory_certification__title. into( ) ,
321
+ Some ( Action :: GoTo ( regulatory_index) )
322
+ ) ) ) ;
323
+
314
324
unwrap ! ( items. push( MenuItem :: new(
315
325
"About" . into( ) ,
316
326
Some ( Action :: GoTo ( about_index) )
@@ -431,6 +441,9 @@ impl<'a> DeviceMenuScreen<'a> {
431
441
. with_header ( Header :: new ( "About" . into ( ) ) . with_close_button ( ) ) ,
432
442
) ;
433
443
}
444
+ Subscreen :: RegulatoryScreen => {
445
+ * self . active_screen . deref_mut ( ) = ActiveScreen :: Regulatory ( RegulatoryScreen :: new ( ) ) ;
446
+ }
434
447
}
435
448
}
436
449
@@ -490,6 +503,9 @@ impl<'a> Component for DeviceMenuScreen<'a> {
490
503
ActiveScreen :: About ( about) => {
491
504
about. place ( bounds) ;
492
505
}
506
+ ActiveScreen :: Regulatory ( regulatory) => {
507
+ regulatory. place ( bounds) ;
508
+ }
493
509
ActiveScreen :: Empty => { }
494
510
} ;
495
511
@@ -525,6 +541,11 @@ impl<'a> Component for DeviceMenuScreen<'a> {
525
541
return self . go_back ( ctx) ;
526
542
}
527
543
}
544
+ ( Subscreen :: RegulatoryScreen , ActiveScreen :: Regulatory ( regulatory) ) => {
545
+ if let Some ( RegulatoryMsg :: Cancelled ) = regulatory. event ( ctx, event) {
546
+ return self . go_back ( ctx) ;
547
+ }
548
+ }
528
549
_ => { }
529
550
}
530
551
@@ -535,6 +556,7 @@ impl<'a> Component for DeviceMenuScreen<'a> {
535
556
match self . active_screen . deref ( ) {
536
557
ActiveScreen :: Menu ( menu) => menu. render ( target) ,
537
558
ActiveScreen :: About ( about) => about. render ( target) ,
559
+ ActiveScreen :: Regulatory ( regulatory) => regulatory. render ( target) ,
538
560
ActiveScreen :: Empty => { }
539
561
} ;
540
562
}
0 commit comments