-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen.py
More file actions
50 lines (38 loc) · 1.5 KB
/
screen.py
File metadata and controls
50 lines (38 loc) · 1.5 KB
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
import platform
from .view import View
if platform.system() == "Android":
from java import jclass
class Screen(View):
native_class = jclass("android.app.Activity")
def __init__(self):
super().__init__()
self.native_instance = self.native_class()
self.layout = None
def add_view(self, view):
if self.layout is None:
raise ValueError("You must set a layout before adding views.")
self.layout.add_view(view)
def set_layout(self, layout):
self.layout = layout
self.native_instance.setContentView(layout.native_instance)
def show(self):
# This method should contain code to start the Activity
pass
elif platform.system() == "iOS":
from rubicon.objc import ObjCClass
class Screen(View):
native_class = ObjCClass("UIViewController")
def __init__(self):
super().__init__()
self.native_instance = self.native_class.alloc().init()
self.layout = None
def add_view(self, view):
if self.layout is None:
raise ValueError("You must set a layout before adding views.")
self.layout.add_view(view)
def set_layout(self, layout):
self.layout = layout
self.native_instance.view().addSubview_(layout.native_instance)
def show(self):
# This method should contain code to present the ViewController
pass