DEx-Framework 0.0.39__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of DEx-Framework might be problematic. Click here for more details.

Files changed (83) hide show
  1. dex_framework-0.0.39/DEx_Framework/__init__.py +11 -0
  2. dex_framework-0.0.39/DEx_Framework/foundations/__init__.py +11 -0
  3. dex_framework-0.0.39/DEx_Framework/foundations/components/__init__.py +76 -0
  4. dex_framework-0.0.39/DEx_Framework/foundations/components/actions_commands/__init__.py +11 -0
  5. dex_framework-0.0.39/DEx_Framework/foundations/components/actions_commands/ds_button.py +160 -0
  6. dex_framework-0.0.39/DEx_Framework/foundations/components/actions_commands/ds_text_link.py +122 -0
  7. dex_framework-0.0.39/DEx_Framework/foundations/components/actions_commands/ds_theme_action.py +114 -0
  8. dex_framework-0.0.39/DEx_Framework/foundations/components/actions_commands/ds_user_login_action.py +206 -0
  9. dex_framework-0.0.39/DEx_Framework/foundations/components/authentication_session/__init__.py +0 -0
  10. dex_framework-0.0.39/DEx_Framework/foundations/components/authentication_session/ds_login.py +589 -0
  11. dex_framework-0.0.39/DEx_Framework/foundations/components/authentication_session/ds_login_modal.py +225 -0
  12. dex_framework-0.0.39/DEx_Framework/foundations/components/authentication_session/ds_login_screen.py +234 -0
  13. dex_framework-0.0.39/DEx_Framework/foundations/components/data_display_visualization/__init__.py +0 -0
  14. dex_framework-0.0.39/DEx_Framework/foundations/components/data_display_visualization/ds_kpi_card.py +167 -0
  15. dex_framework-0.0.39/DEx_Framework/foundations/components/data_display_visualization/ds_line_chart.py +408 -0
  16. dex_framework-0.0.39/DEx_Framework/foundations/components/data_display_visualization/ds_progressbar.py +178 -0
  17. dex_framework-0.0.39/DEx_Framework/foundations/components/data_display_visualization/ds_table.py +264 -0
  18. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/__init__.py +0 -0
  19. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_checkbox.py +93 -0
  20. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_dropdown.py +124 -0
  21. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_file_picker.py +257 -0
  22. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_radio.py +101 -0
  23. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_search.py +115 -0
  24. dex_framework-0.0.39/DEx_Framework/foundations/components/data_input_controls/ds_text_field.py +118 -0
  25. dex_framework-0.0.39/DEx_Framework/foundations/components/feedback_status/__init__.py +0 -0
  26. dex_framework-0.0.39/DEx_Framework/foundations/components/feedback_status/ds_alert.py +156 -0
  27. dex_framework-0.0.39/DEx_Framework/foundations/components/feedback_status/ds_status_chip.py +130 -0
  28. dex_framework-0.0.39/DEx_Framework/foundations/components/feedback_status/ds_toast.py +135 -0
  29. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/__init__.py +0 -0
  30. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_app_shell.py +500 -0
  31. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_card.py +187 -0
  32. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_container.py +114 -0
  33. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_header.py +348 -0
  34. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_menu_nr.py +247 -0
  35. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_sidebar.py +486 -0
  36. dex_framework-0.0.39/DEx_Framework/foundations/components/layout_structure/ds_version_bar.py +221 -0
  37. dex_framework-0.0.39/DEx_Framework/foundations/components/navigation_components/__init__.py +0 -0
  38. dex_framework-0.0.39/DEx_Framework/foundations/components/navigation_components/ds_stepper.py +282 -0
  39. dex_framework-0.0.39/DEx_Framework/foundations/components/navigation_components/ds_tabs.py +222 -0
  40. dex_framework-0.0.39/DEx_Framework/foundations/components/navigation_components/ds_timeline.py +197 -0
  41. dex_framework-0.0.39/DEx_Framework/foundations/components/overlays_dialogs/__init__.py +0 -0
  42. dex_framework-0.0.39/DEx_Framework/foundations/components/overlays_dialogs/ds_modal.py +225 -0
  43. dex_framework-0.0.39/DEx_Framework/foundations/components/theming_styling/__init__.py +0 -0
  44. dex_framework-0.0.39/DEx_Framework/foundations/components/theming_styling/ds_theme_list.py +133 -0
  45. dex_framework-0.0.39/DEx_Framework/foundations/components/theming_styling/ds_theme_manager.py +113 -0
  46. dex_framework-0.0.39/DEx_Framework/foundations/components/visual_foundations/__init__.py +0 -0
  47. dex_framework-0.0.39/DEx_Framework/foundations/components/visual_foundations/ds_text.py +66 -0
  48. dex_framework-0.0.39/DEx_Framework/foundations/tokens/__init__.py +51 -0
  49. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_alert.py +98 -0
  50. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_app_shell.py +45 -0
  51. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_button.py +96 -0
  52. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_card.py +106 -0
  53. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_checkbox.py +45 -0
  54. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_dropdown.py +82 -0
  55. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_header.py +167 -0
  56. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_input.py +77 -0
  57. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_kpi_card.py +120 -0
  58. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_line_chart.py +105 -0
  59. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_modal.py +85 -0
  60. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_progressbar.py +29 -0
  61. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_radio.py +41 -0
  62. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_search.py +86 -0
  63. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_sidebar.py +192 -0
  64. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_status_chip.py +113 -0
  65. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_stepper.py +80 -0
  66. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_table.py +101 -0
  67. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_tabs.py +89 -0
  68. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_theme.py +931 -0
  69. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_timeline.py +95 -0
  70. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_toast.py +110 -0
  71. dex_framework-0.0.39/DEx_Framework/foundations/tokens/tk_typography.py +34 -0
  72. dex_framework-0.0.39/DEx_Framework/py.typed +0 -0
  73. dex_framework-0.0.39/DEx_Framework.egg-info/PKG-INFO +167 -0
  74. dex_framework-0.0.39/DEx_Framework.egg-info/SOURCES.txt +81 -0
  75. dex_framework-0.0.39/DEx_Framework.egg-info/dependency_links.txt +1 -0
  76. dex_framework-0.0.39/DEx_Framework.egg-info/requires.txt +7 -0
  77. dex_framework-0.0.39/DEx_Framework.egg-info/top_level.txt +1 -0
  78. dex_framework-0.0.39/LICENSE +22 -0
  79. dex_framework-0.0.39/MANIFEST.in +6 -0
  80. dex_framework-0.0.39/PKG-INFO +167 -0
  81. dex_framework-0.0.39/README.md +136 -0
  82. dex_framework-0.0.39/pyproject.toml +56 -0
  83. dex_framework-0.0.39/setup.cfg +4 -0
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from DEx_Framework import foundations as _foundations
4
+ from DEx_Framework.foundations import * # noqa: F401,F403
5
+
6
+ __version__ = "0.0.39"
7
+
8
+ __all__ = [
9
+ *_foundations.__all__,
10
+ "__version__",
11
+ ]
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ from DEx_Framework.foundations import components as _components
4
+ from DEx_Framework.foundations import tokens as _tokens
5
+ from DEx_Framework.foundations.components import * # noqa: F401,F403
6
+ from DEx_Framework.foundations.tokens import * # noqa: F401,F403
7
+
8
+ __all__ = [
9
+ *_components.__all__,
10
+ *_tokens.__all__,
11
+ ]
@@ -0,0 +1,76 @@
1
+ from DEx_Framework.foundations.components.visual_foundations.ds_text import DS_Text
2
+ from DEx_Framework.foundations.components.actions_commands.ds_text_link import DS_TextLink
3
+ from DEx_Framework.foundations.components.actions_commands.ds_theme_action import DS_Theme_Action
4
+ from DEx_Framework.foundations.components.actions_commands.ds_user_login_action import DS_User_Login_Action
5
+ from DEx_Framework.foundations.components.authentication_session.ds_login import DS_Login
6
+ from DEx_Framework.foundations.components.authentication_session.ds_login_modal import DS_Login_Modal
7
+ from DEx_Framework.foundations.components.authentication_session.ds_login_screen import DS_Login_Screen
8
+ from DEx_Framework.foundations.components.data_input_controls.ds_text_field import DS_TextField
9
+ from DEx_Framework.foundations.components.data_input_controls.ds_dropdown import DS_Dropdown, DropdownOption
10
+ from DEx_Framework.foundations.components.actions_commands.ds_button import DS_Button
11
+ from DEx_Framework.foundations.components.data_input_controls.ds_checkbox import DS_Checkbox
12
+ from DEx_Framework.foundations.components.data_input_controls.ds_radio import DS_RadioGroup, RadioOption
13
+ from DEx_Framework.foundations.components.layout_structure.ds_header import DS_Header, HeaderAction
14
+ from DEx_Framework.foundations.components.data_input_controls.ds_search import DS_Search
15
+ from DEx_Framework.foundations.components.layout_structure.ds_card import DS_Card
16
+ from DEx_Framework.foundations.components.overlays_dialogs.ds_modal import DS_Modal, ModalAction
17
+ from DEx_Framework.foundations.components.data_input_controls.ds_file_picker import DS_FilePicker
18
+ from DEx_Framework.foundations.components.data_display_visualization.ds_table import DS_Table, TableColumn, TableRow
19
+ from DEx_Framework.foundations.components.layout_structure.ds_sidebar import DS_Sidebar, SidebarItem, SidebarAction
20
+ from DEx_Framework.foundations.components.layout_structure.ds_app_shell import DS_AppShell
21
+ from DEx_Framework.foundations.components.layout_structure.ds_menu_nr import DS_Menu_NR
22
+ from DEx_Framework.foundations.components.theming_styling.ds_theme_manager import DS_ThemeManager
23
+ from DEx_Framework.foundations.components.theming_styling.ds_theme_list import DS_ThemeList
24
+ from DEx_Framework.foundations.components.data_display_visualization.ds_kpi_card import DS_KPICard
25
+ from DEx_Framework.foundations.components.feedback_status.ds_alert import DS_Alert
26
+ from DEx_Framework.foundations.components.navigation_components.ds_stepper import DS_Stepper, StepItem
27
+ from DEx_Framework.foundations.components.feedback_status.ds_toast import DS_Toast
28
+ from DEx_Framework.foundations.components.navigation_components.ds_tabs import DS_Tabs, TabItem
29
+ from DEx_Framework.foundations.components.feedback_status.ds_status_chip import DS_StatusChip
30
+ from DEx_Framework.foundations.components.navigation_components.ds_timeline import DS_Timeline, TimelineEvent
31
+ from DEx_Framework.foundations.components.data_display_visualization.ds_line_chart import DS_LineChart, LineChartSeries, LineChartPoint
32
+ from DEx_Framework.foundations.components.data_display_visualization.ds_progressbar import DS_ProgressBar
33
+ from DEx_Framework.foundations.components.layout_structure.ds_container import DS_Container
34
+ from DEx_Framework.foundations.components.layout_structure.ds_version_bar import DS_VersionBar
35
+
36
+ __all__ = [
37
+ "DS_Text",
38
+ "DS_TextLink",
39
+ "DS_Theme_Action",
40
+ "DS_User_Login_Action",
41
+ "DS_Login",
42
+ "DS_Login_Modal",
43
+ "DS_Login_Screen",
44
+ "DS_TextField",
45
+ "DS_Dropdown", "DropdownOption",
46
+ "DS_Button",
47
+ "DS_Checkbox",
48
+ "DS_RadioGroup", "RadioOption",
49
+ "DS_Header", "HeaderAction",
50
+ "DS_Search",
51
+ "DS_Card",
52
+ "DS_Modal", "ModalAction",
53
+ "DS_FilePicker",
54
+ "DS_Table", "TableColumn", "TableRow",
55
+ "DS_Sidebar", "SidebarItem", "SidebarAction",
56
+ "DS_AppShell",
57
+ "DS_Menu_NR",
58
+ "DS_ThemeManager",
59
+ "DS_ThemeList",
60
+ "DS_KPICard",
61
+ "DS_Alert",
62
+ "DS_Stepper", "StepItem",
63
+ "DS_Toast",
64
+ "DS_Tabs", "TabItem",
65
+ "DS_StatusChip",
66
+ "DS_Timeline", "TimelineEvent",
67
+ "DS_LineChart", "LineChartSeries", "LineChartPoint",
68
+ "DS_ProgressBar",
69
+ "DS_Container",
70
+ "DS_VersionBar",
71
+ ]
72
+
73
+
74
+
75
+
76
+
@@ -0,0 +1,11 @@
1
+ from DEx_Framework.foundations.components.actions_commands.ds_button import DS_Button
2
+ from DEx_Framework.foundations.components.actions_commands.ds_text_link import DS_TextLink
3
+ from DEx_Framework.foundations.components.actions_commands.ds_theme_action import DS_Theme_Action
4
+ from DEx_Framework.foundations.components.actions_commands.ds_user_login_action import DS_User_Login_Action
5
+
6
+ __all__ = [
7
+ "DS_Button",
8
+ "DS_TextLink",
9
+ "DS_Theme_Action",
10
+ "DS_User_Login_Action",
11
+ ]
@@ -0,0 +1,160 @@
1
+ from __future__ import annotations
2
+ from typing import Optional
3
+
4
+ import flet as ft
5
+
6
+ from DEx_Framework.foundations.components.theming_styling.ds_theme_manager import DS_ThemeManager
7
+ from DEx_Framework.foundations.tokens.tk_button import TK_ButtonToken as ButtonToken, TK_ButtonTokens as ButtonTokens
8
+ from DEx_Framework.foundations.tokens.tk_theme import TK_Theme
9
+
10
+
11
+ class DS_Button(ft.ElevatedButton):
12
+
13
+ def __init__(
14
+ self,
15
+
16
+ # Parâmetros do botão
17
+ # -------------------
18
+ label: str = "",
19
+
20
+ # Tokens e tema
21
+ # -------------
22
+ token: ButtonToken = ButtonTokens.filled,
23
+ icon: Optional[str] = None,
24
+
25
+ # Dimensões e layout
26
+ # ------------------
27
+ radius: Optional[float] = None,
28
+ icon_only: bool = False,
29
+ disabled: bool = False,
30
+
31
+ # Callbacks
32
+ # ---------
33
+ on_click=None,
34
+ theme_manager: Optional[DS_ThemeManager] = None,
35
+ auto_apply_theme: bool = True,
36
+
37
+ # Outros
38
+ # ------
39
+ **kwargs,
40
+ ):
41
+ __version__ = "0.0.1"
42
+ # -------------------
43
+ self._theme_manager = theme_manager if theme_manager is not None else (DS_ThemeManager.get() if auto_apply_theme else None)
44
+ self._disabled = disabled
45
+ self._radius_override = radius
46
+ self._icon_only = icon_only
47
+ self._icon_control = None
48
+ self._token_variant = self._resolve_variant(token)
49
+ self._use_theme_token = self._token_variant is not None and self._theme_manager is not None
50
+ self._token = token
51
+
52
+ if self._use_theme_token:
53
+ token = self._get_theme_token(self._theme_manager.theme)
54
+
55
+ self._token = token
56
+ bgcolor = token.bgcolor_disabled if disabled else token.bgcolor
57
+ color = "transparent" if icon_only else (token.color_disabled if disabled else token.color)
58
+
59
+ border = (
60
+ ft.BorderSide(width=token.border_width, color=token.border_color)
61
+ if token.border_color
62
+ else None
63
+ )
64
+
65
+ icon_color = token.icon_color if not disabled else token.color_disabled
66
+ if icon_only:
67
+ self._icon_control = ft.Icon(name=icon, size=token.icon_size, color=icon_color)
68
+ super().__init__(
69
+ content=self._icon_control,
70
+ disabled=disabled,
71
+ on_click=on_click,
72
+ style=ft.ButtonStyle(
73
+ bgcolor=bgcolor,
74
+ color=color,
75
+ shape=ft.RoundedRectangleBorder(radius=self._effective_radius(token)),
76
+ padding=ft.padding.all(0),
77
+ side=border,
78
+ alignment=ft.alignment.center,
79
+ ),
80
+ **kwargs,
81
+ )
82
+ else:
83
+ super().__init__(
84
+ text=label,
85
+ icon=icon,
86
+ icon_color=icon_color,
87
+ disabled=disabled,
88
+ on_click=on_click,
89
+ style=ft.ButtonStyle(
90
+ bgcolor=bgcolor,
91
+ color=color,
92
+ shape=ft.RoundedRectangleBorder(radius=self._effective_radius(token)),
93
+ padding=ft.padding.symmetric(
94
+ horizontal=token.padding_horizontal,
95
+ vertical=token.padding_vertical,
96
+ ),
97
+ side=border,
98
+ text_style=ft.TextStyle(size=token.text_size),
99
+ icon_size=token.icon_size,
100
+ ),
101
+ **kwargs,
102
+ )
103
+
104
+ if self._theme_manager is not None:
105
+ self._theme_manager.subscribe(self._on_theme_change)
106
+
107
+ @staticmethod
108
+ def _resolve_variant(token: ButtonToken) -> Optional[str]:
109
+ if token is ButtonTokens.filled:
110
+ return "button_filled"
111
+ if token is ButtonTokens.outlined:
112
+ return "button_outlined"
113
+ if token is ButtonTokens.tonal:
114
+ return "button_tonal"
115
+ return None
116
+
117
+ def _get_theme_token(self, theme: TK_Theme) -> ButtonToken:
118
+ return getattr(theme, self._token_variant, self._token)
119
+
120
+ def _apply_theme(self, theme: TK_Theme):
121
+ if not self._use_theme_token:
122
+ return
123
+ self._token = self._get_theme_token(theme)
124
+ token = self._token
125
+ disabled = self._disabled
126
+ bgcolor = token.bgcolor_disabled if disabled else token.bgcolor
127
+ color = "transparent" if self._icon_only else (token.color_disabled if disabled else token.color)
128
+ border = (
129
+ ft.BorderSide(width=token.border_width, color=token.border_color)
130
+ if token.border_color
131
+ else None
132
+ )
133
+ self.style = ft.ButtonStyle(
134
+ bgcolor=bgcolor,
135
+ color=color,
136
+ shape=ft.RoundedRectangleBorder(radius=self._effective_radius(token)),
137
+ padding=ft.padding.all(0) if self._icon_only else ft.padding.symmetric(
138
+ horizontal=token.padding_horizontal,
139
+ vertical=token.padding_vertical,
140
+ ),
141
+ side=border,
142
+ text_style=ft.TextStyle(size=0 if self._icon_only else token.text_size),
143
+ icon_size=token.icon_size,
144
+ alignment=ft.alignment.center if self._icon_only else None,
145
+ )
146
+ if self._icon_only and self._icon_control is not None:
147
+ self._icon_control.color = token.icon_color if not disabled else token.color_disabled
148
+ self._icon_control.size = token.icon_size
149
+ else:
150
+ self.icon_color = token.icon_color if not disabled else token.color_disabled
151
+ try:
152
+ self.update()
153
+ except Exception:
154
+ pass
155
+
156
+ def _effective_radius(self, token: ButtonToken) -> float:
157
+ return token.border_radius if self._radius_override is None else self._radius_override
158
+
159
+ def _on_theme_change(self, theme: TK_Theme):
160
+ self._apply_theme(theme)
@@ -0,0 +1,122 @@
1
+ from __future__ import annotations
2
+ from typing import Optional
3
+
4
+ import flet as ft
5
+
6
+ from DEx_Framework.foundations.components.theming_styling.ds_theme_manager import DS_ThemeManager
7
+ from DEx_Framework.foundations.tokens.tk_theme import TK_Theme
8
+ from DEx_Framework.foundations.tokens.tk_typography import TK_TextToken as TextToken, TK_TypographyTokens as TypographyTokens
9
+
10
+
11
+ class DS_TextLink(ft.Text):
12
+
13
+ def __init__(
14
+ self,
15
+
16
+ # Geral
17
+ # -----
18
+ text: str = "",
19
+
20
+ # Textos e rótulos
21
+ # ----------------
22
+ link_text: str = "",
23
+ url: Optional[str] = None,
24
+
25
+ # Tokens e tema
26
+ # -------------
27
+ token: TextToken = TypographyTokens.body_medium,
28
+ color: Optional[str] = None,
29
+ link_color: Optional[str] = None,
30
+ underline: bool = True,
31
+
32
+ # Callbacks
33
+ # ---------
34
+ on_click=None,
35
+ suffix: str = "",
36
+ theme_manager: Optional[DS_ThemeManager] = None,
37
+
38
+ # Parâmetros do botão
39
+ # -------------------
40
+ auto_apply_theme: bool = True,
41
+
42
+ # Outros
43
+ # ------
44
+ **kwargs,
45
+ ):
46
+ __version__ = "0.0.1"
47
+ # -------------------
48
+ self._theme_manager = theme_manager if theme_manager is not None else (DS_ThemeManager.get() if auto_apply_theme else None)
49
+ self._token = token
50
+ self._color_override = color
51
+ self._link_color_override = link_color
52
+ self._underline = underline
53
+ self._text = text
54
+ self._link_text = link_text
55
+ self._suffix = suffix
56
+ self._url = url
57
+ self._on_click = on_click
58
+ self._use_theme_colors = (color is None or link_color is None) and self._theme_manager is not None
59
+
60
+ base_color = self._resolve_base_color()
61
+ link_color_resolved = self._resolve_link_color(base_color)
62
+
63
+ spans = self._build_spans(base_color, link_color_resolved)
64
+ super().__init__(spans=spans, **kwargs)
65
+
66
+ if self._theme_manager is not None:
67
+ self._theme_manager.subscribe(self._on_theme_change)
68
+
69
+ def _resolve_base_color(self) -> str:
70
+ if self._color_override is not None:
71
+ return self._color_override
72
+ if self._theme_manager is not None and self._use_theme_colors:
73
+ return self._theme_manager.theme.text_secondary
74
+ return self._token.color
75
+
76
+ def _resolve_link_color(self, base_color: str) -> str:
77
+ if self._link_color_override is not None:
78
+ return self._link_color_override
79
+ if self._theme_manager is not None and self._use_theme_colors:
80
+ return self._theme_manager.theme.text_accent
81
+ return base_color
82
+
83
+ def _build_spans(self, base_color: str, link_color: str) -> list:
84
+ base_style = ft.TextStyle(
85
+ size=self._token.size,
86
+ weight=self._token.weight,
87
+ color=base_color,
88
+ font_family=self._token.font_family,
89
+ italic=self._token.italic,
90
+ )
91
+
92
+ link_style = ft.TextStyle(
93
+ size=self._token.size,
94
+ weight=self._token.weight,
95
+ color=link_color,
96
+ font_family=self._token.font_family,
97
+ italic=self._token.italic,
98
+ decoration=ft.TextDecoration.UNDERLINE if self._underline else None,
99
+ )
100
+
101
+ spans = []
102
+ if self._text:
103
+ spans.append(ft.TextSpan(text=self._text, style=base_style))
104
+ if self._link_text:
105
+ spans.append(ft.TextSpan(text=self._link_text, url=self._url, on_click=self._on_click, style=link_style))
106
+ if self._suffix:
107
+ spans.append(ft.TextSpan(text=self._suffix, style=base_style))
108
+ return spans
109
+
110
+ def _apply_theme(self, theme: TK_Theme):
111
+ if not self._use_theme_colors:
112
+ return
113
+ base_color = self._resolve_base_color()
114
+ link_color = self._resolve_link_color(base_color)
115
+ self.spans = self._build_spans(base_color, link_color)
116
+ try:
117
+ self.update()
118
+ except Exception:
119
+ pass
120
+
121
+ def _on_theme_change(self, theme: TK_Theme):
122
+ self._apply_theme(theme)
@@ -0,0 +1,114 @@
1
+ from __future__ import annotations
2
+ from dataclasses import replace
3
+ from typing import Optional
4
+
5
+ import flet as ft
6
+
7
+ from DEx_Framework.foundations.components.actions_commands.ds_button import DS_Button
8
+ from DEx_Framework.foundations.components.theming_styling.ds_theme_manager import DS_ThemeManager
9
+ from DEx_Framework.foundations.tokens.tk_button import TK_ButtonToken as ButtonToken, TK_ButtonTokens as ButtonTokens
10
+
11
+
12
+ class DS_Theme_Action(DS_Button):
13
+
14
+ def __init__(
15
+ self,
16
+
17
+ # Parâmetros do botão
18
+ # -------------------
19
+ label: str = "",
20
+
21
+ # Geral
22
+ # -----
23
+ page: Optional[ft.Page] = None,
24
+
25
+ # Tokens e tema
26
+ # -------------
27
+ token: ButtonToken = ButtonTokens.filled,
28
+ icon: Optional[str] = ft.Icons.PALETTE,
29
+ shape: str = "rounded",
30
+
31
+ # Dimensões e layout
32
+ # ------------------
33
+ radius: Optional[float] = 24,
34
+ height: Optional[float] = 32,
35
+ width: Optional[float] = 32,
36
+ icon_only: bool = True,
37
+ disabled: bool = False,
38
+ theme_manager: Optional[DS_ThemeManager] = None,
39
+ auto_apply_theme: bool = True,
40
+ use_header_style: bool = True,
41
+
42
+ # Outros
43
+ # ------
44
+ **kwargs,
45
+ ):
46
+ __version__ = "0.0.1"
47
+ # -------------------
48
+ self._page = page
49
+ self._shape = shape
50
+ self._theme_manager = theme_manager if theme_manager is not None else (DS_ThemeManager.get() if auto_apply_theme else None)
51
+ self._use_header_style = use_header_style
52
+ if self._use_header_style:
53
+ icon_only = True
54
+ if self._shape == "square":
55
+ radius = 0
56
+
57
+ super().__init__(
58
+ label=label,
59
+ token=token,
60
+ icon=icon,
61
+ radius=radius,
62
+ icon_only=icon_only,
63
+ disabled=disabled,
64
+ on_click=self._handle_click,
65
+ theme_manager=self._theme_manager,
66
+ auto_apply_theme=auto_apply_theme,
67
+ height=height,
68
+ width=width,
69
+ **kwargs,
70
+ )
71
+
72
+ if self._use_header_style and self._theme_manager is not None:
73
+ self._apply_header_style(self._theme_manager.theme)
74
+
75
+ def _handle_click(self, e):
76
+ if self._theme_manager is None or self._page is None:
77
+ return
78
+ self._theme_manager.cycle(self._page)
79
+
80
+ def _apply_header_style(self, theme):
81
+ header_token = theme.app_shell.header_token
82
+ self.style = ft.ButtonStyle(
83
+ bgcolor=header_token.action_btn_bgcolor,
84
+ shape=ft.CircleBorder(),
85
+ padding=ft.padding.all(8),
86
+ alignment=ft.alignment.center,
87
+ )
88
+ self.height = header_token.action_btn_size
89
+ self.width = header_token.action_btn_size
90
+ if self._icon_only and self._icon_control is not None:
91
+ self._icon_control.color = header_token.action_btn_icon_color
92
+ self._icon_control.size = header_token.action_btn_icon_size
93
+ else:
94
+ self.icon_color = header_token.action_btn_icon_color
95
+ self.icon_size = header_token.action_btn_icon_size
96
+ try:
97
+ self.update()
98
+ except Exception:
99
+ pass
100
+
101
+ def _apply_theme(self, theme):
102
+ if self._use_header_style:
103
+ self._apply_header_style(theme)
104
+ return
105
+ super()._apply_theme(theme)
106
+
107
+ def _apply_shape(self, token: ButtonToken) -> ButtonToken:
108
+ if self._shape == "square":
109
+ return replace(token, border_radius=0)
110
+ return token
111
+
112
+ def _get_theme_token(self, theme):
113
+ token = super()._get_theme_token(theme)
114
+ return self._apply_shape(token)