Refactor: Move UI definitions to KV file and modularize edit popup
- Created src/edit_popup.py module for EditPopup and DrawingLayer classes - Moved EditPopup UI definition to signage_player.kv (reduced main.py by 533 lines) - Moved CardSwipePopup UI definition to signage_player.kv (reduced main.py by 41 lines) - Improved code organization with better separation of concerns - main.py reduced from 2,384 to 1,811 lines (24% reduction) - All functionality preserved, no breaking changes
This commit is contained in:
+277
-1
@@ -634,4 +634,280 @@
|
||||
Button:
|
||||
text: 'Cancel'
|
||||
background_color: 0.6, 0.2, 0.2, 1
|
||||
on_press: root.dismiss()
|
||||
on_press: root.dismiss()
|
||||
|
||||
|
||||
# Card Swipe Popup
|
||||
<CardSwipePopup>:
|
||||
title: 'Card Authentication Required'
|
||||
size_hint: 0.5, 0.4
|
||||
auto_dismiss: False
|
||||
separator_height: 2
|
||||
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
padding: dp(20)
|
||||
spacing: dp(20)
|
||||
|
||||
# Card swipe icon
|
||||
AsyncImage:
|
||||
id: icon_image
|
||||
size_hint: 1, 0.4
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
|
||||
# Message label
|
||||
Label:
|
||||
id: message_label
|
||||
text: 'Please swipe your card...'
|
||||
font_size: sp(20)
|
||||
size_hint: 1, 0.2
|
||||
|
||||
# Countdown timer
|
||||
Label:
|
||||
id: countdown_label
|
||||
text: '5'
|
||||
font_size: sp(48)
|
||||
color: 0.9, 0.6, 0.2, 1
|
||||
size_hint: 1, 0.2
|
||||
|
||||
# Cancel button
|
||||
Button:
|
||||
text: 'Cancel'
|
||||
size_hint: 1, 0.2
|
||||
background_color: 0.9, 0.3, 0.2, 1
|
||||
on_press: root.cancel(self)
|
||||
|
||||
|
||||
# Edit Popup (Drawing on Images)
|
||||
<EditPopup>:
|
||||
title: ''
|
||||
size_hint: 1, 1
|
||||
auto_dismiss: False
|
||||
separator_height: 0
|
||||
|
||||
FloatLayout:
|
||||
# Background image (full screen)
|
||||
Image:
|
||||
id: image_widget
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
size_hint: 1, 1
|
||||
pos_hint: {'x': 0, 'y': 0}
|
||||
|
||||
# Drawing layer (will be added programmatically due to custom class)
|
||||
# Placeholder widget for drawing layer positioning
|
||||
Widget:
|
||||
id: drawing_layer_placeholder
|
||||
size_hint: 1, 1
|
||||
pos_hint: {'x': 0, 'y': 0}
|
||||
|
||||
# Top toolbar
|
||||
BoxLayout:
|
||||
id: top_toolbar
|
||||
orientation: 'horizontal'
|
||||
size_hint: 1, None
|
||||
height: dp(56)
|
||||
pos_hint: {'top': 1, 'x': 0}
|
||||
spacing: dp(10)
|
||||
padding: [dp(10), dp(8)]
|
||||
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0.1, 0.1, 0.1, 0.5
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
|
||||
Widget: # Spacer
|
||||
|
||||
Button:
|
||||
id: undo_btn
|
||||
text: 'Undo'
|
||||
font_size: sp(16)
|
||||
size_hint: None, 1
|
||||
width: dp(100)
|
||||
background_normal: ''
|
||||
background_color: 0.9, 0.6, 0.2, 0.9
|
||||
|
||||
Button:
|
||||
id: clear_btn
|
||||
text: 'Clear'
|
||||
font_size: sp(16)
|
||||
size_hint: None, 1
|
||||
width: dp(100)
|
||||
background_normal: ''
|
||||
background_color: 0.9, 0.3, 0.2, 0.9
|
||||
|
||||
Button:
|
||||
id: save_btn
|
||||
text: 'Save'
|
||||
font_size: sp(16)
|
||||
size_hint: None, 1
|
||||
width: dp(100)
|
||||
background_normal: ''
|
||||
background_color: 0.2, 0.8, 0.2, 0.9
|
||||
|
||||
Button:
|
||||
id: cancel_btn
|
||||
text: 'Cancel'
|
||||
font_size: sp(16)
|
||||
size_hint: None, 1
|
||||
width: dp(100)
|
||||
background_normal: ''
|
||||
background_color: 0.6, 0.2, 0.2, 0.9
|
||||
|
||||
Label:
|
||||
id: countdown_label
|
||||
text: '5:00'
|
||||
font_size: sp(20)
|
||||
size_hint: None, 1
|
||||
width: dp(80)
|
||||
color: 1, 1, 1, 1
|
||||
bold: True
|
||||
|
||||
Widget: # Small spacer
|
||||
size_hint: None, 1
|
||||
width: dp(10)
|
||||
|
||||
# Right sidebar
|
||||
BoxLayout:
|
||||
id: right_sidebar
|
||||
orientation: 'vertical'
|
||||
size_hint: None, 1
|
||||
width: dp(56)
|
||||
pos_hint: {'right': 1, 'y': 0}
|
||||
spacing: dp(10)
|
||||
padding: [dp(8), dp(66), dp(8), dp(10)]
|
||||
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 0.1, 0.1, 0.1, 0.5
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
|
||||
# Color section header
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
size_hint_y: None
|
||||
height: dp(55)
|
||||
spacing: dp(2)
|
||||
|
||||
Image:
|
||||
id: color_icon
|
||||
size_hint_y: None
|
||||
height: dp(28)
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
|
||||
Label:
|
||||
text: 'Color'
|
||||
font_size: sp(11)
|
||||
bold: True
|
||||
size_hint_y: None
|
||||
height: dp(25)
|
||||
|
||||
# Color buttons
|
||||
Button:
|
||||
id: red_btn
|
||||
text: 'R'
|
||||
font_size: sp(18)
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 1, 0, 0, 1
|
||||
|
||||
Button:
|
||||
id: blue_btn
|
||||
text: 'B'
|
||||
font_size: sp(18)
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0, 0, 1, 1
|
||||
|
||||
Button:
|
||||
id: green_btn
|
||||
text: 'G'
|
||||
font_size: sp(18)
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0, 1, 0, 1
|
||||
|
||||
Button:
|
||||
id: black_btn
|
||||
text: 'K'
|
||||
font_size: sp(18)
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0, 0, 0, 1
|
||||
|
||||
Button:
|
||||
id: white_btn
|
||||
text: 'W'
|
||||
font_size: sp(18)
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 1, 1, 1, 1
|
||||
|
||||
# Spacer
|
||||
Widget:
|
||||
size_hint_y: 0.2
|
||||
|
||||
# Thickness section header
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
size_hint_y: None
|
||||
height: dp(55)
|
||||
spacing: dp(2)
|
||||
|
||||
Image:
|
||||
id: thickness_icon
|
||||
size_hint_y: None
|
||||
height: dp(28)
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
|
||||
Label:
|
||||
text: 'Size'
|
||||
font_size: sp(11)
|
||||
bold: True
|
||||
size_hint_y: None
|
||||
height: dp(25)
|
||||
|
||||
# Thickness buttons
|
||||
Button:
|
||||
id: small_btn
|
||||
text: 'S'
|
||||
font_size: sp(20)
|
||||
bold: True
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0.3, 0.3, 0.3, 0.9
|
||||
|
||||
Button:
|
||||
id: medium_btn
|
||||
text: 'M'
|
||||
font_size: sp(20)
|
||||
bold: True
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0.3, 0.3, 0.3, 0.9
|
||||
|
||||
Button:
|
||||
id: large_btn
|
||||
text: 'L'
|
||||
font_size: sp(20)
|
||||
bold: True
|
||||
size_hint: 1, None
|
||||
height: dp(50)
|
||||
background_normal: ''
|
||||
background_color: 0.3, 0.3, 0.3, 0.9
|
||||
|
||||
Widget: # Bottom spacer
|
||||
Reference in New Issue
Block a user