Helper method to create a row for each setting.
(self, label, control)
| 1190 | self.focused_control = control |
| 1191 | |
| 1192 | def create_setting_row(self, label, control): |
| 1193 | """Helper method to create a row for each setting.""" |
| 1194 | if hasattr(control, "on_focus"): |
| 1195 | control.on_focus = lambda e: self.set_focused_control(e.control) |
| 1196 | |
| 1197 | if self.app.is_mobile: |
| 1198 | if isinstance(control, (ft.Switch, ft.Checkbox, ft.IconButton)): |
| 1199 | return ft.Row( |
| 1200 | [ft.Text(label), ft.Container(expand=True), control], |
| 1201 | alignment=ft.MainAxisAlignment.SPACE_BETWEEN, |
| 1202 | vertical_alignment=ft.CrossAxisAlignment.CENTER, |
| 1203 | width=float("inf"), |
| 1204 | ) |
| 1205 | |
| 1206 | if hasattr(control, "width") and control.width and control.width > 250: |
| 1207 | control.width = 250 |
| 1208 | |
| 1209 | if isinstance(control, (ft.TextField, ft.Dropdown)): |
| 1210 | control.width = float("inf") |
| 1211 | control.expand = True |
| 1212 | |
| 1213 | return ft.Column( |
| 1214 | [ |
| 1215 | ft.Text(label, text_align=ft.TextAlign.LEFT), |
| 1216 | ft.Container( |
| 1217 | content=control, |
| 1218 | margin=ft.Margin.only(top=5, bottom=10), |
| 1219 | expand=True, |
| 1220 | width=float("inf"), |
| 1221 | ), |
| 1222 | ], |
| 1223 | spacing=0, |
| 1224 | alignment=ft.MainAxisAlignment.START, |
| 1225 | horizontal_alignment=ft.CrossAxisAlignment.START, |
| 1226 | width=float("inf"), |
| 1227 | ) |
| 1228 | else: |
| 1229 | return ft.Row( |
| 1230 | [ft.Text(label, width=200, text_align=ft.TextAlign.RIGHT), control], |
| 1231 | alignment=ft.MainAxisAlignment.START, |
| 1232 | vertical_alignment=ft.CrossAxisAlignment.CENTER, |
| 1233 | ) |
| 1234 | |
| 1235 | def pick_folder(self, label, control): |
| 1236 | async def pick_folder_click(_): |
no test coverage detected