Skip to content

Commit 153ee6c

Browse files
author
surbhi
committed
improve magic numbers
1 parent 8c7f700 commit 153ee6c

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

src/bitmessagekivy/baseclass/common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@
4343
},
4444
}
4545

46+
47+
class ChipProperties:
48+
"""ChipProperties class for kivy UI"""
49+
CENTER_X_ANDROID = 0.91
50+
CENTER_X_OTHER = 0.94
51+
CENTER_Y = 0.3
52+
HEIGHT_DP = 18
53+
RADIUS = [8]
54+
TEXT_COLOR = (1, 1, 1, 1)
55+
SIZE_HINT_ANDROID = (0.16, None)
56+
SIZE_HINT_OTHER = (0.08, None)
57+
58+
59+
class BadgeProperties:
60+
"""BadgeProperties class for kivy UI"""
61+
SIZE_ANDROID = [120, 140]
62+
SIZE_OTHER = [64, 80]
63+
FONT_SIZE = "11sp"
64+
65+
4666
DIALOG_WIDTH_ANDROID = 0.8
4767
DIALOG_WIDTH_OTHER = 0.55
4868
DIALOG_HEIGHT = 0.25

src/bitmessagekivy/baseclass/maildetail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pybitmessage.bitmessagekivy.baseclass.common import (
2323
avatar_image_first_letter, kivy_state_variables, show_time_history, toast,
2424
DIALOG_WIDTH_ANDROID, DIALOG_WIDTH_OTHER, DIALOG_HEIGHT, LONG_PRESS_DURATION,
25-
DELETE_DELAY)
25+
DELETE_DELAY, ChipProperties, BadgeProperties)
2626
from pybitmessage.bitmessagekivy.baseclass.popup import SenderDetailPopup
2727
from pybitmessage.bitmessagekivy.get_platform import platform
2828
from pybitmessage.helper_sql import sqlQuery
@@ -86,6 +86,8 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
8686
time_tag = StringProperty()
8787
avatar_image = StringProperty()
8888
no_subject = '(no subject)'
89+
chipProperties = ChipProperties()
90+
badgeProperties = BadgeProperties()
8991

9092
def __init__(self, *args, **kwargs):
9193
"""Initialize MailDetail screen."""

src/bitmessagekivy/kv/maildetail.kv

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#:set color_transparent (0,0,0,0) # transparent black
2+
#:set color_black (0,0,0,1) # black
3+
14
<MailDetail>:
25
name: 'mailDetail'
36
ScrollView:
@@ -15,7 +18,7 @@
1518
font_style: 'H5'
1619
theme_text_color: 'Primary'
1720
_no_ripple_effect: True
18-
long_press_time: 1
21+
long_press_time: self.long_press_time
1922
TwoLineAvatarIconListItem:
2023
id: subaft
2124
text: app.tr._(root.from_addr)
@@ -24,20 +27,23 @@
2427
on_press: root.detailed_popup()
2528
BadgeText:
2629
size_hint:(None, None)
27-
size:[120, 140] if app.app_platform == 'android' else [64, 80]
30+
size: root.badgeProperties.SIZE_ANDROID if app.app_platform == 'android' else root.badgeProperties.SIZE_OTHER
2831
text: app.tr._(root.time_tag)
2932
halign:'center'
3033
font_style:'Caption'
3134
pos_hint: {'center_y': .8}
3235
_txt_right_pad: dp(70)
33-
font_size: '11sp'
36+
font_size: root.badgeProperties.FONT_SIZE
3437
MDChip:
35-
size_hint: (.16 if app.app_platform == 'android' else .08 , None)
38+
size_hint: root.chipProperties.SIZE_HINT_ANDROID if app.app_platform == 'android' else root.chipProperties.SIZE_HINT_OTHER
3639
text: app.tr._(root.page_type)
3740
icon: ''
38-
text_color: (1,1,1,1)
39-
pos_hint: {'center_x': .91 if app.app_platform == 'android' else .95, 'center_y': .3}
40-
radius: [8]
41+
text_color: root.chipProperties.TEXT_COLOR
42+
pos_hint: {
43+
'center_x': root.chipProperties.CENTER_X_ANDROID if app.app_platform == 'android' else root.chipProperties.CENTER_X_OTHER,
44+
'center_y': root.chipProperties.CENTER_Y
45+
}
46+
radius: root.chipProperties.RADIUS
4147
height: self.parent.height/4
4248
AvatarSampleWidget:
4349
source: root.avatar_image
@@ -54,18 +60,18 @@
5460
text: root.message
5561
multiline: True
5662
readonly: True
57-
line_color_normal: [0,0,0,0]
58-
_current_line_color: [0,0,0,0]
59-
line_color_focus: [0,0,0,0]
63+
line_color_normal: color_transparent
64+
_current_line_color: color_transparent
65+
line_color_focus: color_transparent
6066
markup: True
6167
font_size: '15sp'
6268
canvas.before:
6369
Color:
64-
rgba: (0,0,0,1)
70+
rgba: color_black
6571
Loader:
6672

6773

6874
<MyMDTextField@MDTextField>:
6975
canvas.before:
7076
Color:
71-
rgba: (0,0,0,1)
77+
rgba: color_black

0 commit comments

Comments
 (0)