-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecond_page.py
More file actions
74 lines (58 loc) · 2.28 KB
/
second_page.py
File metadata and controls
74 lines (58 loc) · 2.28 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from typing import Any
import pythonnative as pn
try:
# Optional: iOS styling support (safe if rubicon isn't available)
from rubicon.objc import ObjCClass
UIColor = ObjCClass("UIColor")
except Exception: # pragma: no cover
UIColor = None
class SecondPage(pn.Page):
def __init__(self, native_instance: Any) -> None:
super().__init__(native_instance)
def on_create(self) -> None:
super().on_create()
stack_view = pn.StackView()
# Read args passed from MainPage
args = self.get_args()
message = args.get("message", "Second page!")
stack_view.add_view(pn.Label(message))
# Navigate to Third Page
to_third_btn = pn.Button("Go to Third Page")
# Style button on iOS similar to MainPage
try:
if UIColor is not None:
to_third_btn.native_instance.setBackgroundColor_(UIColor.systemBlueColor())
to_third_btn.native_instance.setTitleColor_forState_(UIColor.whiteColor(), 0)
except Exception:
pass
def on_next() -> None:
# Visual confirmation that tap worked (iOS only)
try:
if UIColor is not None:
to_third_btn.native_instance.setBackgroundColor_(UIColor.systemGreenColor())
to_third_btn.native_instance.setTitleColor_forState_(UIColor.whiteColor(), 0)
except Exception:
pass
self.push("app.third_page.ThirdPage", args={"from": "Second"})
to_third_btn.set_on_click(on_next)
stack_view.add_view(to_third_btn)
back_btn = pn.Button("Back")
back_btn.set_on_click(lambda: self.pop())
stack_view.add_view(back_btn)
self.set_root_view(stack_view)
def on_start(self) -> None:
super().on_start()
def on_resume(self) -> None:
super().on_resume()
def on_pause(self) -> None:
super().on_pause()
def on_stop(self) -> None:
super().on_stop()
def on_destroy(self) -> None:
super().on_destroy()
def on_restart(self) -> None:
super().on_restart()
def on_save_instance_state(self) -> None:
super().on_save_instance_state()
def on_restore_instance_state(self) -> None:
super().on_restore_instance_state()