22
33import mpos
44from mpos .apps import Activity
5+ from mpos .ui .keyboard import MposKeyboard
56
67"""
78SettingActivity is used to edit one setting.
@@ -28,22 +29,22 @@ def onCreate(self):
2829 print (setting )
2930
3031 settings_screen_detail = lv .obj ()
31- settings_screen_detail .set_style_pad_all (mpos . ui . pct_of_display_width ( 2 ), 0 )
32+ settings_screen_detail .set_style_pad_all (0 , lv . PART . MAIN )
3233 settings_screen_detail .set_flex_flow (lv .FLEX_FLOW .COLUMN )
3334
3435 top_cont = lv .obj (settings_screen_detail )
3536 top_cont .set_width (lv .pct (100 ))
36- top_cont .set_style_border_width (0 , 0 )
37+ top_cont .set_style_border_width (0 , lv . PART . MAIN )
3738 top_cont .set_height (lv .SIZE_CONTENT )
38- top_cont .set_style_pad_all (mpos . ui . pct_of_display_width ( 1 ), 0 )
39+ top_cont .set_style_pad_all (0 , lv . PART . MAIN )
3940 top_cont .set_flex_flow (lv .FLEX_FLOW .ROW )
40- top_cont .set_style_flex_main_place (lv .FLEX_ALIGN .SPACE_BETWEEN , 0 )
41+ top_cont .set_style_flex_main_place (lv .FLEX_ALIGN .SPACE_BETWEEN , lv . PART . MAIN )
4142 top_cont .set_scrollbar_mode (lv .SCROLLBAR_MODE .OFF )
4243
4344 setting_label = lv .label (top_cont )
4445 setting_label .set_text (setting ["title" ])
45- setting_label .align (lv .ALIGN .TOP_LEFT ,0 , 0 )
46- setting_label .set_style_text_font (lv .font_montserrat_20 , 0 )
46+ setting_label .align (lv .ALIGN .TOP_LEFT , 0 , 0 )
47+ setting_label .set_style_text_font (lv .font_montserrat_16 , lv . PART . MAIN )
4748
4849 ui = setting .get ("ui" )
4950 ui_options = setting .get ("ui_options" )
@@ -77,34 +78,29 @@ def onCreate(self):
7778 if current_setting == option_value :
7879 self .dropdown .set_selected (i )
7980 break # no need to check the rest because only one can be selected
80- else :
81- # Textarea for other settings
81+ else : # Textarea for other settings
8282 self .textarea = lv .textarea (settings_screen_detail )
8383 self .textarea .set_width (lv .pct (100 ))
84- self .textarea .set_height (lv .SIZE_CONTENT )
85- self .textarea .align_to (top_cont , lv .ALIGN .OUT_BOTTOM_MID , 0 , 0 )
84+ self .textarea .set_style_pad_all (mpos .ui .pct_of_display_width (2 ), lv .PART .MAIN )
85+ self .textarea .set_style_margin_left (mpos .ui .pct_of_display_width (2 ), lv .PART .MAIN )
86+ self .textarea .set_style_margin_right (mpos .ui .pct_of_display_width (2 ), lv .PART .MAIN )
87+ self .textarea .set_one_line (True )
8688 if current_setting :
8789 self .textarea .set_text (current_setting )
8890 placeholder = setting .get ("placeholder" )
8991 if placeholder :
9092 self .textarea .set_placeholder_text (placeholder )
91- self .textarea .add_event_cb (lambda * args : mpos .ui .anim .smooth_show (self .keyboard ), lv .EVENT .CLICKED , None ) # it might be focused, but keyboard hidden (because ready/cancel clicked)
92- self .textarea .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .DEFOCUSED , None )
93- # Initialize keyboard (hidden initially)
9493 self .keyboard = MposKeyboard (settings_screen_detail )
95- self .keyboard .align (lv .ALIGN .BOTTOM_MID , 0 , 0 )
9694 self .keyboard .add_flag (lv .obj .FLAG .HIDDEN )
97- self .keyboard .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .READY , None )
98- self .keyboard .add_event_cb (lambda * args : mpos .ui .anim .smooth_hide (self .keyboard ), lv .EVENT .CANCEL , None )
9995 self .keyboard .set_textarea (self .textarea )
10096
10197 # Button container
10298 btn_cont = lv .obj (settings_screen_detail )
10399 btn_cont .set_width (lv .pct (100 ))
104- btn_cont .set_style_border_width (0 , 0 )
100+ btn_cont .set_style_border_width (0 , lv . PART . MAIN )
105101 btn_cont .set_height (lv .SIZE_CONTENT )
106102 btn_cont .set_flex_flow (lv .FLEX_FLOW .ROW )
107- btn_cont .set_style_flex_main_place (lv .FLEX_ALIGN .SPACE_BETWEEN , 0 )
103+ btn_cont .set_style_flex_main_place (lv .FLEX_ALIGN .SPACE_BETWEEN , lv . PART . MAIN )
108104 # Save button
109105 save_btn = lv .button (btn_cont )
110106 save_btn .set_size (lv .pct (45 ), lv .SIZE_CONTENT )
@@ -126,11 +122,11 @@ def onCreate(self):
126122 cambutton .set_size (lv .pct (100 ), lv .pct (30 ))
127123 cambuttonlabel = lv .label (cambutton )
128124 cambuttonlabel .set_text ("Scan data from QR code" )
129- cambuttonlabel .set_style_text_font (lv .font_montserrat_18 , 0 )
125+ cambuttonlabel .set_style_text_font (lv .font_montserrat_18 , lv . PART . MAIN )
130126 cambuttonlabel .align (lv .ALIGN .TOP_MID , 0 , 0 )
131127 cambuttonlabel2 = lv .label (cambutton )
132128 cambuttonlabel2 .set_text ("Tip: Create your own QR code,\n using https://genqrcode.com or another tool." )
133- cambuttonlabel2 .set_style_text_font (lv .font_montserrat_10 , 0 )
129+ cambuttonlabel2 .set_style_text_font (lv .font_montserrat_10 , lv . PART . MAIN )
134130 cambuttonlabel2 .align (lv .ALIGN .BOTTOM_MID , 0 , 0 )
135131 cambutton .add_event_cb (self .cambutton_cb , lv .EVENT .CLICKED , None )
136132
0 commit comments