@@ -21,6 +21,8 @@ const LARGE_APPLICATION_WIDTH: u16 = 75;
21
21
/// Application result type.
22
22
pub type AppResult < T > = Result < T , Box < dyn error:: Error > > ;
23
23
24
+ const DEFAULT_QRCODE_LABEL : & str = "Press enter to copy the OTP URI code" ;
25
+
24
26
/// Application.
25
27
pub struct App < ' a > {
26
28
/// Is the application running?
@@ -36,6 +38,9 @@ pub struct App<'a> {
36
38
pub ( crate ) search_query : String ,
37
39
pub ( crate ) focus : Focus ,
38
40
pub ( crate ) popup : Popup ,
41
+
42
+ /// Info text in the QRCode page
43
+ pub ( crate ) qr_code_page_label : & ' static str ,
39
44
}
40
45
41
46
pub struct Popup {
@@ -60,7 +65,7 @@ impl<'a> App<'a> {
60
65
progress : percentage ( ) ,
61
66
label_text : String :: from ( "" ) ,
62
67
print_percentage : true ,
63
- current_page : Main ,
68
+ current_page : Page :: default ( ) ,
64
69
search_query : String :: from ( "" ) ,
65
70
focus : Focus :: MainPage ,
66
71
popup : Popup {
@@ -69,9 +74,16 @@ impl<'a> App<'a> {
69
74
percent_x : 60 ,
70
75
percent_y : 20 ,
71
76
} ,
77
+ qr_code_page_label : DEFAULT_QRCODE_LABEL ,
72
78
}
73
79
}
74
80
81
+ pub ( crate ) fn reset ( & mut self ) {
82
+ self . current_page = Page :: default ( ) ;
83
+ self . print_percentage = true ;
84
+ self . qr_code_page_label = DEFAULT_QRCODE_LABEL ;
85
+ }
86
+
75
87
/// Handles the tick event of the terminal.
76
88
pub fn tick ( & mut self , force_update : bool ) {
77
89
// Update progress bar
@@ -105,11 +117,15 @@ impl<'a> App<'a> {
105
117
} else {
106
118
format ! ( "{} - {}" , & element. issuer, & element. label)
107
119
} ;
108
- Paragraph :: new ( element. get_qrcode ( ) )
109
- . block ( Block :: default ( ) . title ( title) . borders ( Borders :: ALL ) )
110
- . style ( Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: Reset ) )
111
- . alignment ( Alignment :: Center )
112
- . wrap ( Wrap { trim : true } )
120
+ Paragraph :: new ( format ! (
121
+ "{}\n {}" ,
122
+ element. get_qrcode( ) ,
123
+ self . qr_code_page_label
124
+ ) )
125
+ . block ( Block :: default ( ) . title ( title) . borders ( Borders :: ALL ) )
126
+ . style ( Style :: default ( ) . fg ( Color :: White ) . bg ( Color :: Reset ) )
127
+ . alignment ( Alignment :: Center )
128
+ . wrap ( Wrap { trim : true } )
113
129
} )
114
130
. unwrap_or_else ( || {
115
131
Paragraph :: new ( "No element is selected" )
0 commit comments