Update tabs for current Flet API

This commit is contained in:
SNW 2026-09-23 20:25:29 +00:00
parent 5eb38dcf5e
commit e8ec5fcad3
3 changed files with 54 additions and 8 deletions

View file

@ -88,12 +88,22 @@ def main(page: ft.Page) -> None:
actions=[ft.IconButton(ft.Icons.SETTINGS_OUTLINED, on_click=open_settings)], actions=[ft.IconButton(ft.Icons.SETTINGS_OUTLINED, on_click=open_settings)],
) )
tabs = ft.Tabs( tabs = ft.Tabs(
content=ft.Column(
[
ft.TabBar(
tabs=[ft.Tab(label="VPN"), ft.Tab(label="Белые списки")],
scrollable=False,
),
ft.TabBarView(
controls=[vpn_screen, white_lists_screen],
expand=True,
),
],
expand=True,
),
length=2,
expand=True, expand=True,
selected_index=0, selected_index=0,
tabs=[
ft.Tab(text="VPN", content=vpn_screen),
ft.Tab(text="Белые списки", content=white_lists_screen),
],
on_change=tab_changed, on_change=tab_changed,
) )
page.add( page.add(

View file

@ -106,11 +106,15 @@ def build_vpn_screen(
content.controls = [ content.controls = [
section_title("VPN", "Выберите стратегию и потяните слайдер вправо"), section_title("VPN", "Выберите стратегию и потяните слайдер вправо"),
ft.Tabs( ft.Tabs(
selected_index=0 if controller.strategy is Strategy.BASIC else 1, content=ft.TabBar(
tabs=[ tabs=[
ft.Tab(text="Основная", icon=ft.Icons.LIGHT_MODE), ft.Tab(label="Основная", icon=ft.Icons.LIGHT_MODE),
ft.Tab(text="Усиленная", icon=ft.Icons.SHIELD), ft.Tab(label="Усиленная", icon=ft.Icons.SHIELD),
], ],
scrollable=False,
),
length=2,
selected_index=0 if controller.strategy is Strategy.BASIC else 1,
on_change=strategy_changed, on_change=strategy_changed,
), ),
ft.SegmentedButton( ft.SegmentedButton(

32
tests/test_ui_startup.py Normal file
View file

@ -0,0 +1,32 @@
import flet as ft
from app.main import main
class FakePage:
platform = ft.PagePlatform.LINUX
def add(self, *controls: ft.Control) -> None:
self.controls = controls
def update(self) -> None:
pass
def open(self, control: ft.Control) -> None:
pass
def close(self, control: ft.Control) -> None:
pass
def launch_url(self, url: str) -> None:
pass
def run_task(self, handler) -> None:
pass
def test_ui_control_tree_builds_with_current_flet_api() -> None:
page = FakePage()
main(page) # type: ignore[arg-type]
assert len(page.controls) == 1
assert isinstance(page.controls[0], ft.SafeArea)