pythonnative 0.4.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonnative/__init__.py +94 -66
- pythonnative/cli/pn.py +153 -24
- pythonnative/components.py +563 -0
- pythonnative/element.py +53 -0
- pythonnative/hooks.py +287 -0
- pythonnative/hot_reload.py +143 -0
- pythonnative/native_modules/__init__.py +19 -0
- pythonnative/native_modules/camera.py +105 -0
- pythonnative/native_modules/file_system.py +131 -0
- pythonnative/native_modules/location.py +61 -0
- pythonnative/native_modules/notifications.py +151 -0
- pythonnative/native_views.py +1334 -0
- pythonnative/page.py +320 -247
- pythonnative/reconciler.py +262 -0
- pythonnative/style.py +115 -0
- pythonnative/templates/android_template/app/build.gradle +2 -7
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt +2 -1
- pythonnative/templates/android_template/build.gradle +1 -1
- pythonnative/utils.py +21 -29
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/METADATA +20 -19
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/RECORD +25 -40
- pythonnative/activity_indicator_view.py +0 -71
- pythonnative/button.py +0 -113
- pythonnative/collection_view.py +0 -0
- pythonnative/date_picker.py +0 -76
- pythonnative/image_view.py +0 -78
- pythonnative/label.py +0 -133
- pythonnative/list_view.py +0 -76
- pythonnative/material_activity_indicator_view.py +0 -71
- pythonnative/material_bottom_navigation_view.py +0 -0
- pythonnative/material_button.py +0 -69
- pythonnative/material_date_picker.py +0 -87
- pythonnative/material_progress_view.py +0 -70
- pythonnative/material_search_bar.py +0 -69
- pythonnative/material_switch.py +0 -69
- pythonnative/material_time_picker.py +0 -76
- pythonnative/material_toolbar.py +0 -0
- pythonnative/picker_view.py +0 -69
- pythonnative/progress_view.py +0 -70
- pythonnative/scroll_view.py +0 -101
- pythonnative/search_bar.py +0 -69
- pythonnative/stack_view.py +0 -199
- pythonnative/switch.py +0 -68
- pythonnative/text_field.py +0 -132
- pythonnative/text_view.py +0 -135
- pythonnative/time_picker.py +0 -77
- pythonnative/view.py +0 -173
- pythonnative/web_view.py +0 -60
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/WHEEL +0 -0
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/entry_points.txt +0 -0
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {pythonnative-0.4.0.dist-info → pythonnative-0.6.0.dist-info}/top_level.txt +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialActivityIndicatorViewBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def start_animating(self) -> None:
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def stop_animating(self) -> None:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicator
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialActivityIndicatorView(MaterialActivityIndicatorViewBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any) -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.progressindicator.CircularProgressIndicator")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.native_instance.setIndeterminate(True)
|
|
41
|
-
|
|
42
|
-
def start_animating(self) -> None:
|
|
43
|
-
# self.native_instance.setVisibility(android.view.View.VISIBLE)
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
def stop_animating(self) -> None:
|
|
47
|
-
# self.native_instance.setVisibility(android.view.View.GONE)
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
else:
|
|
51
|
-
# ========================================
|
|
52
|
-
# iOS class
|
|
53
|
-
# https://developer.apple.com/documentation/uikit/uiactivityindicatorview
|
|
54
|
-
# ========================================
|
|
55
|
-
|
|
56
|
-
from rubicon.objc import ObjCClass
|
|
57
|
-
|
|
58
|
-
class MaterialActivityIndicatorView(MaterialActivityIndicatorViewBase, ViewBase):
|
|
59
|
-
def __init__(self) -> None:
|
|
60
|
-
super().__init__()
|
|
61
|
-
self.native_class = ObjCClass("UIActivityIndicatorView")
|
|
62
|
-
self.native_instance = self.native_class.alloc().initWithActivityIndicatorStyle_(
|
|
63
|
-
0
|
|
64
|
-
) # 0: UIActivityIndicatorViewStyleLarge
|
|
65
|
-
self.native_instance.hidesWhenStopped = True
|
|
66
|
-
|
|
67
|
-
def start_animating(self) -> None:
|
|
68
|
-
self.native_instance.startAnimating()
|
|
69
|
-
|
|
70
|
-
def stop_animating(self) -> None:
|
|
71
|
-
self.native_instance.stopAnimating()
|
|
File without changes
|
pythonnative/material_button.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialButtonBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_title(self, title: str) -> "MaterialButtonBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_title(self) -> str:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/button/MaterialButton
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialButton(MaterialButtonBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any, title: str = "") -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.button.MaterialButton")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.set_title(title)
|
|
41
|
-
|
|
42
|
-
def set_title(self, title: str) -> "MaterialButton":
|
|
43
|
-
self.native_instance.setText(title)
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_title(self) -> str:
|
|
47
|
-
return self.native_instance.getText().toString()
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uibutton
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class MaterialButton(MaterialButtonBase, ViewBase):
|
|
58
|
-
def __init__(self, title: str = "") -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UIButton") # Apple does not have a direct equivalent for MaterialButton
|
|
61
|
-
self.native_instance = self.native_class.alloc().init()
|
|
62
|
-
self.set_title(title)
|
|
63
|
-
|
|
64
|
-
def set_title(self, title: str) -> "MaterialButton":
|
|
65
|
-
self.native_instance.setTitle_forState_(title, 0)
|
|
66
|
-
return self
|
|
67
|
-
|
|
68
|
-
def get_title(self) -> str:
|
|
69
|
-
return self.native_instance.titleForState_(0)
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialDatePickerBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_date(self, year: int, month: int, day: int) -> "MaterialDatePickerBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_date(self) -> tuple:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from java import jclass
|
|
32
|
-
|
|
33
|
-
class MaterialDatePicker(MaterialDatePickerBase, ViewBase):
|
|
34
|
-
def __init__(self, year: int = 0, month: int = 0, day: int = 0) -> None:
|
|
35
|
-
super().__init__()
|
|
36
|
-
self.native_class = jclass("com.google.android.material.datepicker.MaterialDatePicker")
|
|
37
|
-
self.builder = self.native_class.Builder.datePicker()
|
|
38
|
-
self.set_date(year, month, day)
|
|
39
|
-
self.native_instance = self.builder.build()
|
|
40
|
-
|
|
41
|
-
def set_date(self, year: int, month: int, day: int) -> "MaterialDatePicker":
|
|
42
|
-
# MaterialDatePicker uses milliseconds since epoch to set date
|
|
43
|
-
from java.util import Calendar
|
|
44
|
-
|
|
45
|
-
cal = Calendar.getInstance()
|
|
46
|
-
cal.set(year, month, day)
|
|
47
|
-
milliseconds = cal.getTimeInMillis()
|
|
48
|
-
self.builder.setSelection(milliseconds)
|
|
49
|
-
return self
|
|
50
|
-
|
|
51
|
-
def get_date(self) -> tuple:
|
|
52
|
-
# Convert selection (milliseconds since epoch) back to a date
|
|
53
|
-
from java.util import Calendar
|
|
54
|
-
|
|
55
|
-
cal = Calendar.getInstance()
|
|
56
|
-
cal.setTimeInMillis(self.native_instance.getSelection())
|
|
57
|
-
return (
|
|
58
|
-
cal.get(Calendar.YEAR),
|
|
59
|
-
cal.get(Calendar.MONTH),
|
|
60
|
-
cal.get(Calendar.DAY_OF_MONTH),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
else:
|
|
64
|
-
# ========================================
|
|
65
|
-
# iOS class
|
|
66
|
-
# https://developer.apple.com/documentation/uikit/uidatepicker
|
|
67
|
-
# ========================================
|
|
68
|
-
|
|
69
|
-
from datetime import datetime
|
|
70
|
-
|
|
71
|
-
from rubicon.objc import ObjCClass
|
|
72
|
-
|
|
73
|
-
class MaterialDatePicker(MaterialDatePickerBase, ViewBase):
|
|
74
|
-
def __init__(self, year: int = 0, month: int = 0, day: int = 0) -> None:
|
|
75
|
-
super().__init__()
|
|
76
|
-
self.native_class = ObjCClass("UIDatePicker")
|
|
77
|
-
self.native_instance = self.native_class.alloc().init()
|
|
78
|
-
self.set_date(year, month, day)
|
|
79
|
-
|
|
80
|
-
def set_date(self, year: int, month: int, day: int) -> "MaterialDatePicker":
|
|
81
|
-
date = datetime(year, month, day)
|
|
82
|
-
self.native_instance.setDate_(date)
|
|
83
|
-
return self
|
|
84
|
-
|
|
85
|
-
def get_date(self) -> tuple:
|
|
86
|
-
date = self.native_instance.date()
|
|
87
|
-
return date.year, date.month, date.day
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialProgressViewBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_progress(self, progress: float) -> "MaterialProgressViewBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_progress(self) -> float:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicator
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialProgressView(MaterialProgressViewBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any) -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.progressindicator.LinearProgressIndicator")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.native_instance.setIndeterminate(False)
|
|
41
|
-
|
|
42
|
-
def set_progress(self, progress: float) -> "MaterialProgressView":
|
|
43
|
-
self.native_instance.setProgress(int(progress * 100))
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_progress(self) -> float:
|
|
47
|
-
return self.native_instance.getProgress() / 100.0
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uiprogressview
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class MaterialProgressView(MaterialProgressViewBase, ViewBase):
|
|
58
|
-
def __init__(self) -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UIProgressView")
|
|
61
|
-
self.native_instance = self.native_class.alloc().initWithProgressViewStyle_(
|
|
62
|
-
0
|
|
63
|
-
) # 0: UIProgressViewStyleDefault
|
|
64
|
-
|
|
65
|
-
def set_progress(self, progress: float) -> "MaterialProgressView":
|
|
66
|
-
self.native_instance.setProgress_animated_(progress, False)
|
|
67
|
-
return self
|
|
68
|
-
|
|
69
|
-
def get_progress(self) -> float:
|
|
70
|
-
return self.native_instance.progress()
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialSearchBarBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_query(self, query: str) -> "MaterialSearchBarBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_query(self) -> str:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/search/SearchBar
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialSearchBar(MaterialSearchBarBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any, query: str = "") -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.search.SearchBar")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.set_query(query)
|
|
41
|
-
|
|
42
|
-
def set_query(self, query: str) -> "MaterialSearchBar":
|
|
43
|
-
self.native_instance.setQuery(query, False)
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_query(self) -> str:
|
|
47
|
-
return self.native_instance.getQuery().toString()
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uisearchbar
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class MaterialSearchBar(MaterialSearchBarBase, ViewBase):
|
|
58
|
-
def __init__(self, query: str = "") -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UISearchBar")
|
|
61
|
-
self.native_instance = self.native_class.alloc().init()
|
|
62
|
-
self.set_query(query)
|
|
63
|
-
|
|
64
|
-
def set_query(self, query: str) -> "MaterialSearchBar":
|
|
65
|
-
self.native_instance.set_searchText_(query)
|
|
66
|
-
return self
|
|
67
|
-
|
|
68
|
-
def get_query(self) -> str:
|
|
69
|
-
return self.native_instance.searchText()
|
pythonnative/material_switch.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialSwitchBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_on(self, value: bool) -> "MaterialSwitchBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def is_on(self) -> bool:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/materialswitch/MaterialSwitch
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialSwitch(MaterialSwitchBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any, value: bool = False) -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.switch.MaterialSwitch")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.set_on(value)
|
|
41
|
-
|
|
42
|
-
def set_on(self, value: bool) -> "MaterialSwitch":
|
|
43
|
-
self.native_instance.setChecked(value)
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def is_on(self) -> bool:
|
|
47
|
-
return self.native_instance.isChecked()
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uiswitch
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class MaterialSwitch(MaterialSwitchBase, ViewBase):
|
|
58
|
-
def __init__(self, value: bool = False) -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UISwitch")
|
|
61
|
-
self.native_instance = self.native_class.alloc().init()
|
|
62
|
-
self.set_on(value)
|
|
63
|
-
|
|
64
|
-
def set_on(self, value: bool) -> "MaterialSwitch":
|
|
65
|
-
self.native_instance.setOn_animated_(value, False)
|
|
66
|
-
return self
|
|
67
|
-
|
|
68
|
-
def is_on(self) -> bool:
|
|
69
|
-
return self.native_instance.isOn()
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaterialTimePickerBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_time(self, hour: int, minute: int) -> "MaterialTimePickerBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_time(self) -> tuple:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/com/google/android/material/timepicker/MaterialTimePicker
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class MaterialTimePicker(MaterialTimePickerBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any, hour: int = 0, minute: int = 0) -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("com.google.android.material.timepicker.MaterialTimePicker")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.set_time(hour, minute)
|
|
41
|
-
|
|
42
|
-
def set_time(self, hour: int, minute: int) -> "MaterialTimePicker":
|
|
43
|
-
self.native_instance.setTime(hour, minute)
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_time(self) -> tuple:
|
|
47
|
-
hour = self.native_instance.getHour()
|
|
48
|
-
minute = self.native_instance.getMinute()
|
|
49
|
-
return hour, minute
|
|
50
|
-
|
|
51
|
-
else:
|
|
52
|
-
# ========================================
|
|
53
|
-
# iOS class
|
|
54
|
-
# https://developer.apple.com/documentation/uikit/uidatepicker
|
|
55
|
-
# ========================================
|
|
56
|
-
|
|
57
|
-
from datetime import time
|
|
58
|
-
|
|
59
|
-
from rubicon.objc import ObjCClass
|
|
60
|
-
|
|
61
|
-
class MaterialTimePicker(MaterialTimePickerBase, ViewBase):
|
|
62
|
-
def __init__(self, hour: int = 0, minute: int = 0) -> None:
|
|
63
|
-
super().__init__()
|
|
64
|
-
self.native_class = ObjCClass("UIDatePicker")
|
|
65
|
-
self.native_instance = self.native_class.alloc().init()
|
|
66
|
-
self.native_instance.setDatePickerMode_(1) # Setting mode to Time
|
|
67
|
-
self.set_time(hour, minute)
|
|
68
|
-
|
|
69
|
-
def set_time(self, hour: int, minute: int) -> "MaterialTimePicker":
|
|
70
|
-
t = time(hour, minute)
|
|
71
|
-
self.native_instance.setTime_(t)
|
|
72
|
-
return self
|
|
73
|
-
|
|
74
|
-
def get_time(self) -> tuple:
|
|
75
|
-
t = self.native_instance.time()
|
|
76
|
-
return t.hour, t.minute
|
pythonnative/material_toolbar.py
DELETED
|
File without changes
|
pythonnative/picker_view.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class PickerViewBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_selected(self, index: int) -> "PickerViewBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_selected(self) -> int:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/android/widget/Spinner
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from typing import Any
|
|
32
|
-
|
|
33
|
-
from java import jclass
|
|
34
|
-
|
|
35
|
-
class PickerView(PickerViewBase, ViewBase):
|
|
36
|
-
def __init__(self, context: Any, index: int = 0) -> None:
|
|
37
|
-
super().__init__()
|
|
38
|
-
self.native_class = jclass("android.widget.Spinner")
|
|
39
|
-
self.native_instance = self.native_class(context)
|
|
40
|
-
self.set_selected(index)
|
|
41
|
-
|
|
42
|
-
def set_selected(self, index: int) -> "PickerView":
|
|
43
|
-
self.native_instance.setSelection(index)
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_selected(self) -> int:
|
|
47
|
-
return self.native_instance.getSelectedItemPosition()
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uipickerview
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class PickerView(PickerViewBase, ViewBase):
|
|
58
|
-
def __init__(self, index: int = 0) -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UIPickerView")
|
|
61
|
-
self.native_instance = self.native_class.alloc().init()
|
|
62
|
-
self.set_selected(index)
|
|
63
|
-
|
|
64
|
-
def set_selected(self, index: int) -> "PickerView":
|
|
65
|
-
self.native_instance.selectRow_inComponent_animated_(index, 0, False)
|
|
66
|
-
return self
|
|
67
|
-
|
|
68
|
-
def get_selected(self) -> int:
|
|
69
|
-
return self.native_instance.selectedRowInComponent_(0)
|
pythonnative/progress_view.py
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
from .utils import IS_ANDROID, get_android_context
|
|
4
|
-
from .view import ViewBase
|
|
5
|
-
|
|
6
|
-
# ========================================
|
|
7
|
-
# Base class
|
|
8
|
-
# ========================================
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class ProgressViewBase(ABC):
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def __init__(self) -> None:
|
|
14
|
-
super().__init__()
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def set_progress(self, progress: float) -> "ProgressViewBase":
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
@abstractmethod
|
|
21
|
-
def get_progress(self) -> float:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if IS_ANDROID:
|
|
26
|
-
# ========================================
|
|
27
|
-
# Android class
|
|
28
|
-
# https://developer.android.com/reference/android/widget/ProgressBar
|
|
29
|
-
# ========================================
|
|
30
|
-
|
|
31
|
-
from java import jclass
|
|
32
|
-
|
|
33
|
-
class ProgressView(ProgressViewBase, ViewBase):
|
|
34
|
-
def __init__(self) -> None:
|
|
35
|
-
super().__init__()
|
|
36
|
-
self.native_class = jclass("android.widget.ProgressBar")
|
|
37
|
-
# self.native_instance = self.native_class(context, None, android.R.attr.progressBarStyleHorizontal)
|
|
38
|
-
context = get_android_context()
|
|
39
|
-
self.native_instance = self.native_class(context, None, jclass("android.R$attr").progressBarStyleHorizontal)
|
|
40
|
-
self.native_instance.setIndeterminate(False)
|
|
41
|
-
|
|
42
|
-
def set_progress(self, progress: float) -> "ProgressView":
|
|
43
|
-
self.native_instance.setProgress(int(progress * 100))
|
|
44
|
-
return self
|
|
45
|
-
|
|
46
|
-
def get_progress(self) -> float:
|
|
47
|
-
return self.native_instance.getProgress() / 100.0
|
|
48
|
-
|
|
49
|
-
else:
|
|
50
|
-
# ========================================
|
|
51
|
-
# iOS class
|
|
52
|
-
# https://developer.apple.com/documentation/uikit/uiprogressview
|
|
53
|
-
# ========================================
|
|
54
|
-
|
|
55
|
-
from rubicon.objc import ObjCClass
|
|
56
|
-
|
|
57
|
-
class ProgressView(ProgressViewBase, ViewBase):
|
|
58
|
-
def __init__(self) -> None:
|
|
59
|
-
super().__init__()
|
|
60
|
-
self.native_class = ObjCClass("UIProgressView")
|
|
61
|
-
self.native_instance = self.native_class.alloc().initWithProgressViewStyle_(
|
|
62
|
-
0
|
|
63
|
-
) # 0: UIProgressViewStyleDefault
|
|
64
|
-
|
|
65
|
-
def set_progress(self, progress: float) -> "ProgressView":
|
|
66
|
-
self.native_instance.setProgress_animated_(progress, False)
|
|
67
|
-
return self
|
|
68
|
-
|
|
69
|
-
def get_progress(self) -> float:
|
|
70
|
-
return self.native_instance.progress()
|