-
Notifications
You must be signed in to change notification settings - Fork 1
/
widgets.py
166 lines (132 loc) · 4.52 KB
/
widgets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List
import json
wrap_content = "wrap_content"
match_parent = 'match_parent'
class Widget(ABC):
@abstractmethod
def __init__(self, **kwargs):
self.type: str
self.Value: str
self.width = wrap_content
self.height = wrap_content
self.weight = 0
if kwargs:
for key, value in kwargs.items():
self.__dict__[key] = value
def to_json(self):
return json.dumps(self, default=lambda x: vars(x), indent=4)
class Picture(Widget):
def __init__(self, **kwargs):
self.Value = '@pic'
super().__init__(**kwargs)
self.type = "Picture"
class TextView(Widget):
def __init__(self, **kwargs):
self.Value = '@value'
super().__init__(**kwargs)
self.type = "TextView"
class CheckBox(Widget):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.type = 'CheckBox'
class PopupMenuButton(Widget):
def __init__(self, **kwargs):
self.Value = '@value'
super().__init__(**kwargs)
self.type = "PopupMenuButton"
self.show_by_condition = ''
self.NoRefresh = False
self.document_type = ''
self.mask = ''
class LinearLayout(Widget):
def __init__(self, *args, **kwargs):
self.type = 'LinearLayout'
self.orientation = "vertical"
super().__init__(**kwargs)
self.Elements = list(args) or []
def append(self, *widgets):
for widget in widgets:
self.Elements.append(widget)
class Options:
def __init__(self, search_enabled=True, save_position=True, override_search=False):
self.options = {
'search_enabled': search_enabled,
'save_position': save_position,
'override_search': override_search
}
class CustomCards:
def __init__(self, layout: LinearLayout, options: Options, cardsdata: List[dict] = []):
self.customcards = {
'options': options or Options(),
'layout': layout,
'cardsdata': cardsdata
}
def to_json(self):
return json.dumps(self, default=lambda x: vars(x), indent=4, ensure_ascii=False).encode('utf8').decode()
class CustomTable:
def __init__(self, layout: LinearLayout, options: Options, tabledata: List[dict]):
self.customtable = {
'options': options or Options(),
'layout': layout,
'tabledata': tabledata
}
def to_json(self):
return json.dumps(self, default=lambda x: vars(x), indent=4, ensure_ascii=False).encode('utf8').decode()
@dataclass
class ModernField:
hint: str = ''
default_text: str = ''
counter: bool = False
counter_max: int = 0
input_type: int = 0
password: bool = False
events: bool = False
"""
TYPE_NULL: 0
TYPE_CLASS_NUMBER: 2
TYPE_NUMBER_FLAG_DECIMAL: 8192
TYPE_NUMBER_FLAG_SIGNED: 4096
TYPE_NUMBER_VARIATION_NORMAL: 0
TYPE_NUMBER_VARIATION_PASSWORD: 16
TYPE_CLASS_DATETIME : 4
TYPE_DATETIME_VARIATION_DATE: 16
TYPE_DATETIME_VARIATION_NORMAL: 0
TYPE_DATETIME_VARIATION_TIME: 32
TYPE_CLASS_PHONE: 3
TYPE_MASK_CLASS: 15
TYPE_MASK_FLAGS: 16773120
TYPE_MASK_VARIATION: 4080
TYPE_CLASS_TEXT: 1
TYPE_TEXT_FLAG_AUTO_COMPLETE: 65536
TYPE_TEXT_FLAG_AUTO_CORRECT: 32768
TYPE_TEXT_FLAG_CAP_CHARACTERS: 4096
TYPE_TEXT_FLAG_CAP_SENTENCES: 16384
TYPE_TEXT_FLAG_CAP_WORDS: 8192
TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS: 1048576
TYPE_TEXT_FLAG_IME_MULTI_LINE: 262144
TYPE_TEXT_FLAG_MULTI_LINE: 131072
TYPE_TEXT_FLAG_NO_SUGGESTIONS: 524288
TYPE_TEXT_VARIATION_EMAIL_ADDRESS: 32
TYPE_TEXT_VARIATION_EMAIL_SUBJECT: 48
TYPE_TEXT_VARIATION_FILTER: 176
TYPE_TEXT_VARIATION_LONG_MESSAGE: 80
TYPE_TEXT_VARIATION_NORMAL: 0
TYPE_TEXT_VARIATION_PASSWORD: 128
TYPE_TEXT_VARIATION_PERSON_NAME: 96
TYPE_TEXT_VARIATION_PHONETIC: 192
TYPE_TEXT_VARIATION_POSTAL_ADDRESS: 112
TYPE_TEXT_VARIATION_SHORT_MESSAGE: 64
TYPE_TEXT_VARIATION_URI: 16
TYPE_TEXT_VARIATION_VISIBLE_PASSWORD: 144
TYPE_TEXT_VARIATION_WEB_EDIT_TEXT: 160
TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS: 208
TYPE_TEXT_VARIATION_WEB_PASSWORD: 224
"""
def to_json(self):
return json.dumps(
self,
default=lambda x: {k: v for k, v in vars(x).items() if v},
indent=4, ensure_ascii=False
).encode('utf8').decode()