Skip to content

Commit dc9a68b

Browse files
committed
fix bugs
1 parent e931941 commit dc9a68b

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

GUI-ver/src/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def os_det():
1616
OS_SYS = os_det()
1717

1818
XRAY_PATH=f"./core/{OS_SYS}/xray"
19-
APP_VERSION = "4.3-10"
19+
APP_VERSION = "4.3-11"
2020
ROOT = "./"
2121
CORE_PATH = "./core"
2222
SAVE_PATH = "./core.zip"

GUI-ver/src/main.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, page: ft.Page):
1818
self.page.title = "XC (Xray-Client)"
1919
self.page.theme_mode = self.read_settinng("theme")
2020
self.debug_mod = self.read_settinng("debug")
21+
self.theme_color = self.change_theme_color(self.read_settinng("theme_color"))
2122
self.backend.log_callback = self.log
2223
self.page.padding = 20 # padding of all page
2324
self.page.window.min_width = 600
@@ -91,20 +92,23 @@ def read_settinng (type) :
9192
data = json.loads(f)
9293
ping = data.get("ping", default_settings["ping"])
9394
theme = data.get("theme", default_settings["theme"])
95+
theme_color = data.get("theme_color" , default_settings["theme_color"])
9496
debug = data.get("debug", default_settings["debug"])
9597
useragent = data.get("useragent", default_settings["useragent"])
9698
except json.JSONDecodeError:
9799

98100
print("Error decoding JSON, using default settings.")
99101
ping = default_settings["ping"]
100102
theme = default_settings["theme"]
103+
theme_color = default_settings["theme_color"]
101104
debug = default_settings["debug"]
102105
useragent = default_settings["useragent"]
103106
else:
104107

105108
print("File is empty, using default settings.")
106109
ping = default_settings["ping"]
107110
theme = default_settings["theme"]
111+
theme_color = default_settings["theme_color"]
108112
debug = default_settings["debug"]
109113
useragent = default_settings["useragent"]
110114
with open("./setting.json" , "w") as file :
@@ -114,6 +118,7 @@ def read_settinng (type) :
114118
print("File not found, using default settings.")
115119
ping = default_settings["ping"]
116120
theme = default_settings["theme"]
121+
theme_color = default_settings["theme_color"]
117122
debug = default_settings["debug"]
118123
useragent = default_settings["useragent"]
119124
with open("./setting.json" , "w") as file :
@@ -127,8 +132,8 @@ def read_settinng (type) :
127132
return ft.ThemeMode.DARK
128133
elif theme_mode == "light" :
129134
return ft.ThemeMode.LIGHT
130-
elif type == "theme_color": # اضافه کردن خواندن رنگ تم
131-
return data.get("theme_color", default_settings["theme_color"])
135+
elif type == "theme_color":
136+
return theme_color
132137
elif type == "debug" :
133138
return debug
134139
elif type == "useragent" :
@@ -212,8 +217,8 @@ def create_ui(self):
212217
ft.ControlState.HOVERED: ft.Colors.WHITE,
213218
},
214219
bgcolor={
215-
ft.ControlState.DEFAULT: ft.Colors.BLUE,
216-
ft.ControlState.HOVERED: ft.Colors.BLUE_700,
220+
ft.ControlState.DEFAULT: ft.Colors.PRIMARY,
221+
ft.ControlState.HOVERED: ft.Colors.SECONDARY,
217222
},
218223
),
219224
on_click=self.show_import_dialog,
@@ -288,7 +293,7 @@ def create_ui(self):
288293
label="Proxy",
289294
value=True,
290295
active_color=ft.Colors.GREY_400,
291-
inactive_thumb_color=ft.Colors.BLUE,
296+
inactive_thumb_color=ft.Colors.PRIMARY,
292297
on_change=self.toggle_mode,
293298
)
294299

@@ -298,7 +303,7 @@ def create_ui(self):
298303
expand=True,
299304
min_lines=12,
300305
max_lines=20,
301-
border_color=ft.Colors.BLUE_200,
306+
border_color=ft.Colors.SECONDARY,
302307
border_radius=8,
303308
text_size=14,
304309
visible=True, # Initially visible
@@ -378,7 +383,7 @@ def create_ui(self):
378383
], alignment=ft.MainAxisAlignment.CENTER),
379384
ft.Container(height=5),
380385
ft.Row([
381-
ft.Icon(ft.Icons.TERMINAL, color=ft.Colors.BLUE),
386+
ft.Icon(ft.Icons.TERMINAL, color=ft.Colors.PRIMARY),
382387
ft.Text("Xray Status:", size=18, weight=ft.FontWeight.BOLD),
383388
], alignment=ft.MainAxisAlignment.CENTER),
384389
self.log_view,
@@ -402,7 +407,7 @@ def add_profile_tab(self, profile):
402407
# Create search field
403408
search_field = ft.TextField(
404409
label="Search configs",
405-
prefix_icon=ft.icons.SEARCH,
410+
prefix_icon=ft.Icons.SEARCH,
406411
expand=True,
407412
on_change=lambda e, lst=config_list, p=profile: self.filter_configs(e.control.value, lst, p),
408413
height=40,
@@ -758,7 +763,7 @@ def ping_selected_config(e):
758763
return ft.ListTile(
759764
leading=ft.Icon(
760765
ft.Icons.CLOUD,
761-
color=ft.Colors.BLUE if is_selected else ft.Colors.GREY,
766+
color=ft.Colors.PRIMARY if is_selected else ft.Colors.GREY,
762767
size=24,
763768
),
764769
title=ft.Container(
@@ -769,7 +774,7 @@ def ping_selected_config(e):
769774
),
770775
bgcolor=ft.Colors.TRANSPARENT, # Remove background color from container
771776
padding=ft.padding.all(12),
772-
animate=ft.animation.Animation(duration=300, curve=ft.AnimationCurve.EASE_IN_OUT),
777+
animate=ft.Animation(duration=300, curve=ft.AnimationCurve.EASE_IN_OUT),
773778
border_radius=8,
774779
),
775780
trailing=ft.Container(
@@ -784,7 +789,7 @@ def ping_selected_config(e):
784789
on_click=lambda _, c=config, p=profile: self.select_config(c, p),
785790
on_long_press=ping_selected_config,
786791
tooltip="Hold to Ping",
787-
bgcolor=ft.Colors.BLUE_100 if is_selected else ft.Colors.TRANSPARENT, # Move background color to ListTile
792+
bgcolor=ft.Colors.SECONDARY if is_selected else ft.Colors.TRANSPARENT, # Move background color to ListTile
788793
)
789794

790795
# "0" = cancel does not exist
@@ -1215,30 +1220,41 @@ def change_ping_type(self, e):
12151220
print(f"Ping type changed to: {self.ping_type}")
12161221

12171222
def change_theme_color(self, e):
1218-
color = e.control.value
1223+
color = getattr(e, "control", None)
1224+
if color:
1225+
color = color.value
1226+
else:
1227+
color = e
1228+
12191229
self.write_setting("theme_color", color)
12201230

12211231
# تنظیم رنگ‌های مختلف برنامه
12221232
if color == "blue":
1223-
primary_color = ft.colors.BLUE
1224-
primary_container = ft.colors.BLUE_100
1233+
primary_color = ft.Colors.BLUE
1234+
primary_container = ft.Colors.BLUE_100
1235+
secondary_color = ft.Colors.BLUE_700
12251236
elif color == "red":
1226-
primary_color = ft.colors.RED
1227-
primary_container = ft.colors.RED_100
1237+
primary_color = ft.Colors.RED
1238+
primary_container = ft.Colors.RED_100
1239+
secondary_color = ft.Colors.RED_700
12281240
elif color == "green":
1229-
primary_color = ft.colors.GREEN
1230-
primary_container = ft.colors.GREEN_100
1241+
primary_color = ft.Colors.GREEN
1242+
primary_container = ft.Colors.GREEN_100
1243+
secondary_color = ft.Colors.GREEN_700
12311244
elif color == "purple":
1232-
primary_color = ft.colors.PURPLE
1233-
primary_container = ft.colors.PURPLE_100
1245+
primary_color = ft.Colors.PURPLE
1246+
primary_container = ft.Colors.PURPLE_100
1247+
secondary_color = ft.Colors.PURPLE_700
12341248
elif color == "orange":
1235-
primary_color = ft.colors.ORANGE
1236-
primary_container = ft.colors.ORANGE_100
1249+
primary_color = ft.Colors.ORANGE
1250+
primary_container = ft.Colors.ORANGE_100
1251+
secondary_color = ft.Colors.ORANGE_700
12371252

12381253
self.page.theme = ft.Theme(
12391254
color_scheme=ft.ColorScheme(
12401255
primary=primary_color,
12411256
primary_container=primary_container,
1257+
secondary=secondary_color
12421258
)
12431259
)
12441260
self.page.update()

setting.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ping": "Real-delay",
3-
"theme": "light",
3+
"theme": "dark",
4+
"theme_color": "red",
45
"debug": "off",
5-
"useragent": "v2rayNG/1.9.16",
6-
"theme_color": "green"
6+
"useragent": "XC(Xray-Client)"
77
}

0 commit comments

Comments
 (0)