MCPcopy Create free account
hub / github.com/Bbalduzz/fletmint / __init__

Method __init__

fletmint/toggle_switch.py:35–69  ·  view source on GitHub ↗
(
        self, on_switch=None, initial_value=0, theme=ft.ThemeMode.DARK, **kwargs
    )

Source from the content-addressed store, hash-verified

33
34class ToggleSwitch(ft.Container):
35 def __init__(
36 self, on_switch=None, initial_value=0, theme=ft.ThemeMode.DARK, **kwargs
37 ):
38 # Set initial toggle state and callback
39 self.colors = (
40 ToggleSwitchColors.dark()
41 if theme == ft.ThemeMode.DARK
42 else ToggleSwitchColors.light()
43 )
44 self.on_switch = on_switch
45 self.value = initial_value
46
47 # Icons for moon and sun
48 self.moon_icon = ft.icons.DARK_MODE
49 self.sun_icon = ft.icons.LIGHT_MODE
50
51 # Initialize the parent container with appearance settings
52 super().__init__(
53 width=133,
54 height=45,
55 bgcolor=self.colors.container_background_color,
56 padding=ft.padding.all(5),
57 border=ft.border.all(1, self.colors.container_border_color),
58 border_radius=10,
59 **kwargs,
60 )
61
62 # Set up the initial UI elements
63 self.dark_container = self.get_container(self.moon_icon, self.value == 0)
64 self.light_container = self.get_container(self.sun_icon, self.value == 1)
65
66 # Create the main row to hold the toggles
67 self.content = ft.Row(
68 controls=[self.dark_container, self.light_container],
69 )
70
71 def did_mount(self):
72 self.colors = (

Callers

nothing calls this directly

Calls 3

get_containerMethod · 0.95
darkMethod · 0.45
lightMethod · 0.45

Tested by

no test coverage detected