结构优化

This commit is contained in:
冯佳
2025-07-31 17:02:08 +08:00
parent 627aa51235
commit 54bf9f6d94
5 changed files with 176 additions and 266 deletions

246
kv/app.kv
View File

@ -1,43 +1,36 @@
ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其切换
MainScreen: # 主屏幕
name: 'main' # 屏幕名称,用于导航切换
HomeScreen: # 首页屏幕
name: 'home' # 首页,显示应用主要内容和功能入口
LoginScreen: # 登录屏幕
name: 'login' # 用户认证界面
ProfileScreen: # 个人资料屏幕
name: "profile" # 显示用户个人信息的界面
HistoryScreen: # 历史记录屏幕
name: 'history' # 显示用户操作历史
ModifyCurrentParamScreen: # 修改参数屏幕
name: 'modify_current_param' # 用于修改系统参数的界面
ModifyVoltageParamScreen: # 修改电压参数屏幕
name: 'modify_voltage_param' # 用于修改电压参数的界面
ModifyLeakageParamScreen: # 修改漏电参数屏幕
name: 'modify_leakage_param' # 用于修改漏电参数的
ModifySystemParamScreen: # 修改系统参数屏幕
name: 'modify_system_param' # 用于修改系统设置的界面
ModifyProtectionParamScreen: # 修改保护参数屏幕
name: 'modify_protection_param' # 用于修改保护参数的界面
RealTimeCurveScreen: # 实时曲线屏幕
name: 'real_time_curve' # 显示实时数据曲线的界面
ControlCommandScreen: # 控制命令屏幕
name: 'control_command' # 用于发送控制命令的界面
AboutScreen: # 关于屏幕
name: 'about' # 显示应用信息和开发者信息的界
ScreenManager:
MainScreen:
name: 'main'
HomeScreen:
name: 'home'
LoginScreen:
name: 'login'
ProfileScreen:
name: "profile"
HistoryScreen:
name: 'history'
ModifyCurrentParamScreen:
name: 'modify_current_param'
ModifyVoltageParamScreen:
name: 'modify_voltage_param'
ModifyLeakageParamScreen:
name: 'modify_leakage_param'
ModifySystemParamScreen:
name: 'modify_system_param'
ModifyProtectionParamScreen:
name: 'modify_protection_param'
RealTimeCurveScreen:
name: 'real_time_curve'
ControlCommandScreen:
name: 'control_command'
AboutScreen:
name: 'about'
<MainScreen>:
MDFloatLayout:
# Image:
# source: 'assets/logo.png'
# size_hint: None, 0.9
# width: dp(150)
# pos_hint: {'center_x': 0.1, 'center_y': 0.95}
Image:
source: 'assets/img.png'
size_hint: 1, 1
@ -83,27 +76,6 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
size: self.size
pos: self.pos
radius: [5]
# Button:
# text: "注 册"
# size_hint: None, None
# font_name: "BPoppins"
# width: dp(350)
# height: dp(59)
# pos_hint: {'center_x': 0.5, 'center_y': 0.19}
# background_color: 0,0,0,0
# color: rgba(52, 0, 231, 255)
# on_touch_down: app.change_cursor(True)
# on_touch_up: app.change_cursor(False)
# on_release:
# root.manager.transition.direction = "left"
# root.manager.current = "signup"
# canvas.before:
# Color:
# rgb: rgba(52, 0, 231, 255)
# Line:
# width: 1.2
# rounded_rectangle: self.x, self.y, self.width, self.height, 5,5,5,5,100
<DrawerClickableItem@MDNavigationDrawerItem>
<HomeScreen>:
@ -242,8 +214,8 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
id : user
title: "欢迎使用"
text: "功能总览"
title_font_style: "H5" # 使用自定义标题字体
text_font_style: "Caption" # 使用自定义正文字体
title_font_style: "H5"
text_font_style: "Caption"
text_color: "#6c7272"
text_font_size: '13sp'
title_color: "#00f0ff"
@ -560,7 +532,7 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
size_hint_y: None
height: '30dp'
MDLabel:
text: "Your Details"
text: "信息"
font_name: "BPoppins"
font_size: "14sp"
color: [0,0,0,1]
@ -581,55 +553,41 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
MDList:
spacing: "0dp"
OneLineIconListItem:
text: profile_user_name.text
id: profile_user_name
text: ""
IconLeftWidget:
icon: "account-outline"
icon: ""
OneLineIconListItem:
id : profile_user_pass
text: ""
IconLeftWidget:
icon: "email-outline"
icon: ""
OneLineIconListItem:
id : profile_modbus_ip
text: ""
IconLeftWidget:
icon: "dialpad"
icon: ""
OneLineIconListItem:
id : profile_modbus_port
text: ""
IconLeftWidget:
icon: ""
OneLineIconListItem:
id : profile_wifi_ssid
text: ""
IconLeftWidget:
icon: "phone-outline"
MDLabel:
text: "Other Details"
font_name: "BPoppins"
font_size: "14sp"
size_hint_y: None
height: self.texture_size[1]
padding: "12dp"
pos_hint: {'center_y': 0.9}
ScrollView:
MDList:
spacing: "0dp"
OneLineAvatarListItem:
id : profile_branch
icon: "wifi"
OneLineIconListItem:
id : profile_nfc_id
text: ""
ImageLeftWidget:
source:'assets/branch.png'
size_hint: 2, .68
pos: self.pos
OneLineAvatarListItem:
id : profile_semester
IconLeftWidget:
icon: "nfc"
OneLineIconListItem:
id : profile_reserve
text: ""
ImageLeftWidget:
source:'assets/semister.png'
size_hint: 2, .68
pos: self.pos
IconLeftWidget:
icon: ""
<HistoryScreen>:
MDFloatLayout:
@ -720,31 +678,6 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
spacing: "2dp"
Widget:
MDBottomAppBar:
height: "62dp"
elevation: 10
MDActionBottomAppBarButton:
icon: "home"
pos_hint:{'center_x':0.15, 'center_y': 0.5}
on_press: root.manager.current = 'home'
MDActionBottomAppBarButton:
icon: "tools"
pos_hint:{'center_x':0.38, 'center_y': 0.5}
on_press: root.manager.current = 'borrow_book'
MDActionBottomAppBarButton:
icon: "thumb-up-outline"
pos_hint:{'center_x':0.61, 'center_y': 0.5}
on_press: root.manager.current = 'recommend'
MDActionBottomAppBarButton:
icon: "history"
pos_hint:{'center_x':0.85, 'center_y': 0.5}
on_press:
root.manager.current = 'history'
# app.book_history()
MDIconButton:
icon: "arrow-left"
pos_hint: {'center_y': 0.95}
@ -810,7 +743,7 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
MDTextField:
id: edit_name
id: edit_user_name
text: ""
hint_text: "Enter Name*"
font_name: "MPoppins"
@ -833,12 +766,12 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
MDTextField:
id: edit_prn
id: edit_user_pass
text: ""
hint_text: "Provide your PRN*"
hint_text: "User_pass*"
font_name: "MPoppins"
font_size: "15sp"
helper_text: "unable to change prn directly"
helper_text: "Provide your password"
helper_text_mode: "on_focus"
readonly: True
icon_right: "dialpad"
@ -857,15 +790,15 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
width: dp(0.5)
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
MDTextField:
id: edit_email
id: edit_modbus_ip
text: ""
hint_text: "Provide Email-id*"
hint_text: "Modbus_IP*"
font_name: "MPoppins"
font_size: "15sp"
readonly: True
helper_text: "unable to change email directly"
helper_text: "Provide your Modbus_IP"
helper_text_mode: "on_focus"
icon_right: "email-arrow-left"
icon_right: "network"
min_text_length: 11
icon_color: app.theme_cls.primary_color
pos_hint: {"center_x": 0.5, "center_y": 0.6025}
@ -881,15 +814,15 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
MDTextField:
id:edit_no
id:edit_modbus_port
text: ""
hint_text: "Enter WhatsApp Number*"
hint_text: "Modbus_Port*"
font_name: "MPoppins"
font_size: "15sp"
readonly: True
helper_text: "unable to change number directly"
helper_text_mode: "on_focus"
icon_right: "whatsapp"
icon_right: "dialpad"
icon_color: app.theme_cls.primary_color
input_filter: 'int'
max_text_length: 10
@ -906,14 +839,14 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
MDTextField:
id: edit_branch
id: edit_nfc_id
text: ""
hint_text: "Branch*"
hint_text: "NFC_ID*"
font_name: "MPoppins"
font_size: "15sp"
helper_text: "Provide your Branch"
helper_text: "Provide your NFC_ID"
helper_text_mode: "on_focus"
icon_right: "source-branch"
icon_right: "nfc"
min_text_length: 11
icon_color: app.theme_cls.primary_color
pos_hint: {"center_x": 0.5, "center_y": 0.3625}
@ -929,12 +862,12 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
MDTextField:
id: edit_sem
id: edit_wifi_ssid
text: ""
hint_text: "Semester*"
hint_text: "wifi ssid*"
font_name: "MPoppins"
font_size: "15sp"
helper_text: "Provide your semester like I,II,III only*"
helper_text: "Provide your wifi ssid"
helper_text_mode: "on_focus"
icon_right: "roman-numeral-2"
min_text_length: 11
@ -950,9 +883,35 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
Line:
width: dp(0.5)
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
MDTextField:
id: edit_reserve
text: ""
hint_text: "Reserve*"
font_name: "MPoppins"
font_size: "15sp"
helper_text: "Provide your Reserve"
helper_text_mode: "on_focus"
icon_right: "nfc"
min_text_length: 11
icon_color: app.theme_cls.primary_color
pos_hint: {"center_x": 0.5, "center_y": 0.1225}
size_hint_x: None
width: dp(335)
on_touch_down: app.change_cursor(True)
on_touch_up: app.change_cursor(False)
canvas.before:
Color:
rgb: rgba(127, 127, 127, 255)
Line:
width: dp(0.5)
rounded_rectangle: self.x-5, self.y+20, self.width+10, self.height-25, 10,10,10,10,100
Button:
text: "Save Profile & Continue"
text: "保存配置"
font_name: "BPoppins"
size_hint: 0.66, 0.065
pos_hint: {'center_x': 0.5, 'center_y': 0.17}
@ -972,21 +931,6 @@ ScreenManager: # 屏幕管理器,用于管理应用中所有的屏幕及其
pos: self.pos
radius: [25]
MDTextButton:
id : edit_private_credential_butn
text: "Do you want edit prn/email/No."
pos_hint: {'center_x': 0.5, 'center_y': 0.12}
color: rgba(68,78,132,255)
font_name: "BPoppins"
font_size: '13sp'
on_touch_down: app.change_cursor(True)
on_touch_up: app.change_cursor(False)
on_release:
root.manager.transition.direction= "down"
app.send_otp(edit_no.text)
app.otp_button_fun("1")
root.manager.current="otp"
<RealTimeCurveScreen>:
MDFloatLayout: # 使用浮动布局,可以自由控制子组件的位置