2121from typing import Callable , Optional
2222
2323import flet
24- from flet import (AlertDialog , AppBar , Banner , Checkbox , Column , Container ,
25- Divider , ElevatedButton , FilePicker , FilePickerResultEvent ,
26- FilledButton , Icon , Image , Page , ProgressBar , ProgressRing ,
27- Row , Text , TextButton , TextField , UserControl ,
28- VerticalDivider , colors , icons )
24+ from flet import (
25+ AlertDialog ,
26+ AppBar ,
27+ Banner ,
28+ Checkbox ,
29+ Column ,
30+ Container ,
31+ Divider ,
32+ ElevatedButton ,
33+ FilePicker ,
34+ FilePickerResultEvent ,
35+ FilledButton ,
36+ Icon ,
37+ Image ,
38+ Page ,
39+ ProgressBar ,
40+ ProgressRing ,
41+ Row ,
42+ Text ,
43+ TextButton ,
44+ TextField ,
45+ UserControl ,
46+ VerticalDivider ,
47+ colors ,
48+ icons ,
49+ )
2950from installer_config import InstallerConfig , Step
3051from loguru import logger
3152from tool_utils import call_tool_with_command , search_device
3253from widgets import call_button , confirm_button , get_title
3354
3455# Toggle to True for development purposes
3556DEVELOPMENT = False
36- DEVELOPMENT_CONFIG = "a3y17lte" # "sargo"
57+ DEVELOPMENT_CONFIG = "sargo" # " a3y17lte" # "sargo"
3758
3859
3960PLATFORM = sys .platform
@@ -212,9 +233,7 @@ def __init__(
212233 self .selected_recovery = selected_recovery
213234
214235 def build (self ):
215- self .confirm_button = confirm_button (
216- "If you selected both files you can continue." , self .on_confirm
217- )
236+ self .confirm_button = confirm_button (self .on_confirm )
218237 self .confirm_button .disabled = True
219238
220239 self .pick_recovery_dialog .on_result = self .enable_button_if_ready
@@ -257,7 +276,8 @@ def build(self):
257276 ),
258277 self .selected_recovery ,
259278 Divider (),
260- self .confirm_button ,
279+ Text ("If you selected both files you can continue." ),
280+ Row ([self .confirm_button ]),
261281 ]
262282 )
263283 return self .view
@@ -423,36 +443,50 @@ def __init__(
423443
424444 def build (self ):
425445 """Create the content of a view from step."""
426- self .right_view .controls = [get_title (f"{ self .step .title } " ), self .progressbar ]
446+ self .right_view .controls = [
447+ get_title (f"{ self .step .title } " ),
448+ self .progressbar ,
449+ Text (f"{ self .step .content } " ),
450+ ]
427451 # basic view depending on step.type
428452 if self .step .type == "confirm_button" :
429- self .right_view .controls .append (
430- confirm_button (self .step .content , self .on_confirm )
431- )
453+ self .confirm_button = confirm_button (self .on_confirm )
454+ self .right_view .controls .append (Row ([self .confirm_button ]))
432455 elif self .step .type == "call_button" :
456+ self .confirm_button = confirm_button (self .on_confirm )
457+ self .confirm_button .disabled = True
458+ self .call_button = call_button (
459+ self .call_to_phone , command = self .step .command
460+ )
433461 self .right_view .controls .append (
434- call_button (
435- self .step .content , self .call_to_phone , command = self .step .command
436- )
462+ Row ([self .call_button , self .confirm_button ])
437463 )
438464 elif self .step .type == "call_button_with_input" :
465+ self .confirm_button = confirm_button (self .on_confirm )
466+ self .confirm_button .disabled = True
467+ self .call_button = call_button (
468+ self .call_to_phone , command = self .step .command
469+ )
439470 self .right_view .controls .extend (
440- [
441- self .inputtext ,
442- call_button (
443- self .step .content , self .call_to_phone , command = self .step .command
444- ),
445- ]
471+ [self .inputtext , Row ([self .call_button , self .confirm_button ])]
446472 )
447- elif self .step .type == "text" :
448- self .right_view .controls .append (Text (self .step .content ))
449- else :
473+ elif self .step .type != "text" :
450474 raise Exception (f"Unknown step type: { self .step .type } " )
451475
452476 # if skipping is allowed add a button to the view
453477 if self .step .allow_skip or DEVELOPMENT :
454478 self .right_view .controls .append (
455- confirm_button ("Already done?" , self .on_confirm , confirm_text = "Skip" )
479+ Row (
480+ [
481+ Text ("Do you want to skip?" ),
482+ ElevatedButton (
483+ "Skip" ,
484+ on_click = self .on_confirm ,
485+ icon = icons .NEXT_PLAN_OUTLINED ,
486+ expand = True ,
487+ ),
488+ ]
489+ )
456490 )
457491 return self .view
458492
@@ -477,14 +511,19 @@ def call_to_phone(self, e, command: str):
477511 success = call_tool_with_command (command = command , bin_path = BIN_PATH )
478512 # update the view accordingly
479513 if success :
514+ # pop the progress ring
480515 self .right_view .controls .pop ()
481- self .right_view .controls .append (Text (f"Command { command } failed!" ))
482- else :
483- sleep (5 ) # wait to make sure everything is fine
484- self .right_view .controls .pop () # pop the progress ring
485516 self .right_view .controls .append (
486- ElevatedButton ("Confirm and continue" , on_click = self .on_confirm )
517+ Text (
518+ f"Command { command } failed! Try again or make sure everything is setup correctly."
519+ )
487520 )
521+ else :
522+ sleep (5 ) # wait to make sure everything is fine
523+ # pop the progress ring
524+ self .right_view .controls .pop ()
525+ self .confirm_button .disabled = False
526+ self .call_button .disabled = True
488527 self .view .update ()
489528
490529
0 commit comments