Skip to content

Commit 33e6b50

Browse files
committed
feat: advanced launcher customization
1 parent 669d0ba commit 33e6b50

File tree

6 files changed

+239
-144
lines changed

6 files changed

+239
-144
lines changed

src/main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from routes import LoginPage, MainPage, ProfilePage, RegisterPage, SettingsPage
44
from settings import settings
5+
from utils import setup_theme_settings
56
from config import (
67
LAUNCHER_NAME,
78
LAUNCHER_VERSION,
@@ -17,13 +18,13 @@ async def main(page: ft.Page):
1718

1819
page.theme_mode = settings.launcher_theme
1920

20-
page.theme = ft.Theme(
21-
color_scheme_seed=settings.launcher_color,
22-
page_transitions=ft.PageTransitionsTheme(
23-
linux=ft.PageTransitionTheme.FADE_FORWARDS,
24-
windows=ft.PageTransitionTheme.FADE_FORWARDS,
25-
),
21+
setup_theme_settings(
22+
page,
23+
settings.launcher_color,
24+
settings.launcher_border_radius,
25+
settings.launcher_border_shape,
2626
)
27+
2728
page.window.visible = True
2829
page.window.prevent_close = False
2930

src/routes/index.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,12 @@ def build_ui(self):
175175
color=ft.Colors.SURFACE_CONTAINER_HIGHEST,
176176
),
177177
leading=ft.IconButton(
178-
padding=ft.Padding(12, 12, 12, 12),
179178
content=Shimmer(
180179
control=ft.Icon(ft.Icons.PERSON, size=32),
181180
color=ft.Colors.SURFACE_CONTAINER_HIGHEST,
182181
width=64,
183182
height=64,
184183
),
185-
style=ft.ButtonStyle(
186-
shape=ft.RoundedRectangleBorder(radius=8),
187-
bgcolor=ft.Colors.TRANSPARENT,
188-
),
189184
tooltip="Профіль",
190185
on_click=lambda e: self.page.go("/profile"),
191186
),
@@ -197,10 +192,6 @@ def build_ui(self):
197192
[
198193
# donate button
199194
ft.IconButton(
200-
padding=ft.Padding(12, 12, 12, 12),
201-
style=ft.ButtonStyle(
202-
shape=ft.RoundedRectangleBorder(radius=8),
203-
),
204195
icon=ft.Icons.ATTACH_MONEY,
205196
on_click=lambda e: self._open_link(
206197
"https://send.monobank.ua/jar/48bPzh2JmA"
@@ -209,10 +200,6 @@ def build_ui(self):
209200
),
210201
# github
211202
ft.IconButton(
212-
padding=ft.Padding(12, 12, 12, 12),
213-
style=ft.ButtonStyle(
214-
shape=ft.RoundedRectangleBorder(radius=8),
215-
),
216203
content=ft.Image(
217204
src="github-mark.svg",
218205
width=20,
@@ -225,10 +212,6 @@ def build_ui(self):
225212
tooltip="GitHub",
226213
),
227214
ft.IconButton(
228-
padding=ft.Padding(12, 12, 12, 12),
229-
style=ft.ButtonStyle(
230-
shape=ft.RoundedRectangleBorder(radius=8),
231-
),
232215
icon=ft.Icons.TELEGRAM,
233216
on_click=lambda e: self._open_link(
234217
"https://t.me/cube_dvij"
@@ -237,10 +220,6 @@ def build_ui(self):
237220
),
238221
# discord
239222
ft.IconButton(
240-
padding=ft.Padding(12, 12, 12, 12),
241-
style=ft.ButtonStyle(
242-
shape=ft.RoundedRectangleBorder(radius=8),
243-
),
244223
icon=ft.Icons.DISCORD,
245224
on_click=lambda e: self._open_link(
246225
"https://discord.gg/E9rZM58gqT"
@@ -249,11 +228,6 @@ def build_ui(self):
249228
),
250229
# settings
251230
ft.IconButton(
252-
padding=ft.Padding(12, 12, 12, 12),
253-
style=ft.ButtonStyle(
254-
shape=ft.RoundedRectangleBorder(radius=8),
255-
bgcolor=ft.Colors.TRANSPARENT,
256-
),
257231
icon=ft.Icons.SETTINGS,
258232
on_click=lambda e: self.page.go("/settings"),
259233
tooltip="Налаштування",
@@ -263,26 +237,26 @@ def build_ui(self):
263237
padding=ft.Padding(0, 0, 8, 0),
264238
),
265239
],
266-
shape=ft.RoundedRectangleBorder(radius=8),
240+
267241
)
268242
self._play_button = ft.FloatingActionButton(
269243
icon=ft.Icons.PLAY_ARROW,
270-
shape=ft.RoundedRectangleBorder(radius=8),
244+
271245
text="Грати",
272246
width=160,
273247
on_click=self._check_game,
274248
)
275249
self._check_game_button = ft.FloatingActionButton(
276250
icon=ft.Icons.RESTART_ALT,
277251
bgcolor=ft.Colors.SECONDARY_CONTAINER,
278-
shape=ft.RoundedRectangleBorder(radius=8),
252+
279253
tooltip="Перевстановити гру",
280254
on_click=self._force_install_game,
281255
)
282256
self._open_game_folder_button = ft.FloatingActionButton(
283257
icon=ft.Icons.FOLDER,
284258
bgcolor=ft.Colors.SECONDARY_CONTAINER,
285-
shape=ft.RoundedRectangleBorder(radius=8),
259+
286260
tooltip="Відкрити папку з грою",
287261
on_click=lambda e: self._open_link(f"file://{APPDATA_FOLDER}"),
288262
)

src/routes/profile.py

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ def build_ui(self):
4040
self._appbar = ft.AppBar(
4141
leading=ft.IconButton(
4242
icon=ft.Icons.ARROW_BACK,
43-
style=ft.ButtonStyle(
44-
shape=ft.RoundedRectangleBorder(radius=8),
45-
),
4643
on_click=self.go_index,
4744
tooltip="На головну",
4845
),
@@ -51,17 +48,13 @@ def build_ui(self):
5148
width=64,
5249
height=64,
5350
icon=ft.Icons.LOGOUT,
54-
style=ft.ButtonStyle(
55-
shape=ft.RoundedRectangleBorder(radius=8),
56-
),
5751
on_click=self.open_alert,
5852
tooltip="Вийти з аккаунта",
5953
),
6054
],
6155
title=ft.Text("Профіль", size=20),
6256
leading_width=64,
63-
center_title=False,
64-
shape=ft.RoundedRectangleBorder(radius=8),
57+
center_title=False,
6558
bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST,
6659
)
6760

@@ -71,6 +64,7 @@ def build_ui(self):
7164
width=64,
7265
height=64,
7366
fit=ft.ImageFit.CONTAIN,
67+
filter_quality=ft.FilterQuality.NONE,
7468
),
7569
title=ft.TextField(
7670
# account.user["user"]["players"][0]["name"],
@@ -89,14 +83,10 @@ def build_ui(self):
8983
size=10,
9084
selectable=True,
9185
),
92-
trailing=ft.FloatingActionButton(
86+
trailing=ft.IconButton(
9387
icon=ft.Icons.EDIT,
9488
tooltip="Редагувати",
95-
mini=True,
96-
width=32,
97-
height=32,
9889
on_click=self._edit_nickname,
99-
shape=ft.RoundedRectangleBorder(radius=8),
10090
),
10191
title_alignment=ft.ListTileTitleAlignment.TITLE_HEIGHT,
10292
content_padding=ft.Padding(8, 2, 8, 2),
@@ -124,55 +114,41 @@ def build_ui(self):
124114
vertical_alignment=ft.CrossAxisAlignment.CENTER,
125115
alignment=ft.MainAxisAlignment.CENTER,
126116
controls=[
127-
ft.FilledTonalButton(
117+
ft.OutlinedButton(
128118
"Завантажити скін",
129119
icon=ft.Icons.FACE,
130120
expand=True,
131121
on_click=lambda e: self._skin_file_picker.pick_files(
132122
dialog_title="Виберіть файл скіна",
133123
allowed_extensions=["png"],
134124
),
135-
style=ft.ButtonStyle(
136-
shape=ft.RoundedRectangleBorder(radius=8),
137-
padding=ft.Padding(0, 0, 0, 0),
138-
),
139125
),
140-
ft.FloatingActionButton(
126+
ft.IconButton(
141127
icon=ft.Icons.DELETE,
142-
scale=0.8,
143-
mini=True,
144-
bgcolor=ft.Colors.RED_400,
128+
icon_color=ft.Colors.ERROR,
145129
tooltip="Видалити скін",
146130
on_click=self.on_delete_skin,
147-
shape=ft.RoundedRectangleBorder(radius=8),
148131
),
149132
],
150133
)
151134
self._cape_settings = ft.Row(
152135
vertical_alignment=ft.CrossAxisAlignment.CENTER,
153136
alignment=ft.MainAxisAlignment.CENTER,
154137
controls=[
155-
ft.FilledTonalButton(
138+
ft.OutlinedButton(
156139
"Завантажити плащ",
157140
icon=ft.Icons.BOOKMARK,
158141
expand=True,
159142
on_click=lambda e: self._cape_file_picker.pick_files(
160143
dialog_title="Виберіть файл плаща",
161144
allowed_extensions=["png"],
162145
),
163-
style=ft.ButtonStyle(
164-
shape=ft.RoundedRectangleBorder(radius=8),
165-
padding=ft.Padding(0, 0, 0, 0),
166-
),
167146
),
168-
ft.FloatingActionButton(
147+
ft.IconButton(
169148
icon=ft.Icons.DELETE,
170-
scale=0.8,
171-
mini=True,
172-
bgcolor=ft.Colors.RED_400,
149+
icon_color=ft.Colors.ERROR,
173150
tooltip="Видалити плащ",
174151
on_click=self.on_delete_cape,
175-
shape=ft.RoundedRectangleBorder(radius=8),
176152
),
177153
],
178154
)
@@ -198,22 +174,19 @@ def build_ui(self):
198174
vertical_alignment=ft.CrossAxisAlignment.CENTER,
199175
alignment=ft.MainAxisAlignment.CENTER,
200176
controls=[
201-
ft.FilledTonalButton(
177+
ft.OutlinedButton(
202178
"Змінити пароль",
203179
icon=ft.Icons.LOCK,
204180
expand=True,
205181
on_click=self.on_change_password,
206-
style=ft.ButtonStyle(
207-
shape=ft.RoundedRectangleBorder(radius=8),
208-
padding=ft.Padding(0, 0, 0, 0),
209-
),
210182
),
211183
],
212184
),
213185
],
214186
)
215187
self._card = ft.Card(
216188
expand=True,
189+
margin=ft.Margin(0, 4, 0, 0),
217190
content=ft.Container(
218191
padding=ft.Padding(8, 0, 8, 0),
219192
content=ft.Column(
@@ -242,41 +215,45 @@ def build_ui(self):
242215
src=None,
243216
width=216,
244217
height=392,
218+
filter_quality=ft.FilterQuality.NONE,
245219
)
246220
self._skin_back_image = ft.Image(
247221
# src=f"{SKINS_CACHE_FOLDER}/{account.skin_hash}-back.png",
248222
src=None,
249223
width=216,
250224
height=392,
225+
filter_quality=ft.FilterQuality.NONE,
251226
)
252227

228+
self._skin_card = ft.Card(
229+
margin=ft.Margin(0, 4, 0, 0),
230+
231+
content=ft.Row(
232+
width=500,
233+
controls=[
234+
ft.Container(
235+
padding=ft.Padding(16, 0, 16, 0),
236+
content=self._skin_image,
237+
expand=True,
238+
),
239+
ft.VerticalDivider(),
240+
ft.Container(
241+
padding=ft.Padding(16, 0, 16, 0),
242+
content=self._skin_back_image,
243+
expand=True,
244+
),
245+
],
246+
)
247+
)
253248
self.pagelet = ft.Pagelet(
254249
expand=True,
255250
appbar=self._appbar,
256251
content=ft.Row(
257252
expand=True,
253+
spacing=4,
258254
controls=[
259255
self._card,
260-
ft.Card(
261-
content=ft.Row(
262-
width=500,
263-
controls=[
264-
ft.Container(
265-
padding=ft.Padding(16, 0, 16, 0),
266-
content=self._skin_image,
267-
expand=True,
268-
),
269-
ft.VerticalDivider(),
270-
ft.Container(
271-
padding=ft.Padding(16, 0, 16, 0),
272-
content=self._skin_back_image,
273-
expand=True,
274-
),
275-
],
276-
),
277-
),
278-
# ft.VerticalDivider(),
279-
# self._skin_back_image,
256+
self._skin_card,
280257
],
281258
),
282259
# height=200,

0 commit comments

Comments
 (0)