pythonnative 0.12.0__tar.gz → 0.13.1__tar.gz
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-0.12.0/src/pythonnative.egg-info → pythonnative-0.13.1}/PKG-INFO +4 -3
- {pythonnative-0.12.0 → pythonnative-0.13.1}/README.md +3 -2
- {pythonnative-0.12.0 → pythonnative-0.13.1}/pyproject.toml +3 -1
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/__init__.py +3 -3
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/cli/pn.py +34 -9
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/hooks.py +22 -13
- pythonnative-0.13.1/src/pythonnative/hot_reload.py +645 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_views/__init__.py +72 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_views/ios.py +49 -5
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/navigation.py +178 -35
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/platform_metrics.py +9 -9
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/reconciler.py +7 -7
- pythonnative-0.12.0/src/pythonnative/page.py → pythonnative-0.13.1/src/pythonnative/screen.py +294 -75
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/MainActivity.kt +4 -4
- pythonnative-0.13.1/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/Navigator.kt +43 -0
- pythonnative-0.12.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PageFragment.kt → pythonnative-0.13.1/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt +23 -18
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml +6 -6
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/ViewController.swift +31 -26
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/utils.py +5 -5
- {pythonnative-0.12.0 → pythonnative-0.13.1/src/pythonnative.egg-info}/PKG-INFO +4 -3
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative.egg-info/SOURCES.txt +3 -3
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_cli.py +12 -10
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_hooks.py +2 -2
- pythonnative-0.13.1/tests/test_hot_reload.py +536 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_metric_hooks.py +3 -3
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_native_views.py +95 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_navigation.py +266 -12
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_reconciler.py +1 -1
- pythonnative-0.12.0/tests/test_page.py → pythonnative-0.13.1/tests/test_screen.py +28 -28
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_smoke.py +1 -1
- pythonnative-0.12.0/src/pythonnative/hot_reload.py +0 -329
- pythonnative-0.12.0/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/Navigator.kt +0 -26
- pythonnative-0.12.0/tests/test_hot_reload.py +0 -97
- {pythonnative-0.12.0 → pythonnative-0.13.1}/LICENSE +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/setup.cfg +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/_ios_log.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/alerts.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/animated.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/cli/__init__.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/components.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/element.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/layout.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_modules/__init__.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_modules/camera.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_modules/file_system.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_modules/location.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_modules/notifications.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_views/android.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/native_views/base.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/platform.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/style.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/build.gradle +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/proguard-rules.pro +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/androidTest/java/com/pythonnative/android_template/ExampleInstrumentedTest.kt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/AndroidManifest.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/PNVirtualListView.java +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/drawable/ic_launcher_background.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/layout/activity_main.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/values/colors.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/values/strings.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/values/themes.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/values-night/themes.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/xml/backup_rules.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/main/res/xml/data_extraction_rules.xml +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/app/src/test/java/com/pythonnative/android_template/ExampleUnitTest.kt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/build.gradle +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.jar +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/gradle/wrapper/gradle-wrapper.properties +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/gradle.properties +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/gradlew +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/gradlew.bat +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/android_template/settings.gradle +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/AppDelegate.swift +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AccentColor.colorset/Contents.json +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Assets.xcassets/Contents.json +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/LaunchScreen.storyboard +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Base.lproj/Main.storyboard +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/Info.plist +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template/SceneDelegate.swift +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_template.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_templateTests/ios_templateTests.swift +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITestsLaunchTests.swift +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative.egg-info/dependency_links.txt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative.egg-info/entry_points.txt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative.egg-info/requires.txt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/src/pythonnative.egg-info/top_level.txt +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_alert.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_animated.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_components.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_element.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_ios_log.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_layout.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_new_components.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_platform.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_platform_metrics.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_ref.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_style.py +0 -0
- {pythonnative-0.12.0 → pythonnative-0.13.1}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonnative
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.1
|
|
4
4
|
Summary: Cross-platform native UI toolkit for Android and iOS
|
|
5
5
|
Author: Owen Carey
|
|
6
6
|
License: MIT License
|
|
@@ -101,7 +101,8 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
|
|
|
101
101
|
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
|
|
102
102
|
- **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
|
|
103
103
|
- **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
|
|
104
|
-
- **
|
|
104
|
+
- **Native-backed navigation:** Declarative `Stack`, `Tab`, and `Drawer` navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (`UINavigationController` on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect.
|
|
105
|
+
- **Fast Refresh hot reload:** `pn run --hot-reload` watches `app/` and patches edits into the running app on save, preserving component state across most changes.
|
|
105
106
|
- **Bundled templates:** Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
|
|
106
107
|
|
|
107
108
|
## Quick Start
|
|
@@ -119,7 +120,7 @@ import pythonnative as pn
|
|
|
119
120
|
|
|
120
121
|
|
|
121
122
|
@pn.component
|
|
122
|
-
def
|
|
123
|
+
def App():
|
|
123
124
|
count, set_count = pn.use_state(0)
|
|
124
125
|
return pn.Column(
|
|
125
126
|
pn.Text(f"Count: {count}", style={"font_size": 24}),
|
|
@@ -37,7 +37,8 @@ PythonNative is a cross-platform toolkit for building native Android and iOS app
|
|
|
37
37
|
- **Virtual view tree + reconciler:** Element trees are diffed and patched with minimal native mutations, similar to React's reconciliation.
|
|
38
38
|
- **Direct native bindings:** Python calls platform APIs directly through Chaquopy and rubicon-objc, with no JavaScript bridge.
|
|
39
39
|
- **CLI scaffolding:** `pn init` creates a ready-to-run project; `pn run android` and `pn run ios` build and launch your app.
|
|
40
|
-
- **
|
|
40
|
+
- **Native-backed navigation:** Declarative `Stack`, `Tab`, and `Drawer` navigators inspired by React Navigation. The root stack drives the platform's native navigation controller (`UINavigationController` on iOS, AndroidX Navigation Component on Android), so transitions, back gestures, and the hardware back button match what users expect.
|
|
41
|
+
- **Fast Refresh hot reload:** `pn run --hot-reload` watches `app/` and patches edits into the running app on save, preserving component state across most changes.
|
|
41
42
|
- **Bundled templates:** Android Gradle and iOS Xcode templates are included, so scaffolding requires no network access.
|
|
42
43
|
|
|
43
44
|
## Quick Start
|
|
@@ -55,7 +56,7 @@ import pythonnative as pn
|
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
@pn.component
|
|
58
|
-
def
|
|
59
|
+
def App():
|
|
59
60
|
count, set_count = pn.use_state(0)
|
|
60
61
|
return pn.Column(
|
|
61
62
|
pn.Text(f"Count: {count}", style={"font_size": 24}),
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pythonnative"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.1"
|
|
8
8
|
description = "Cross-platform native UI toolkit for Android and iOS"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Owen Carey" }
|
|
@@ -61,6 +61,8 @@ Issues = "https://github.com/pythonnative/pythonnative/issues"
|
|
|
61
61
|
Documentation = "https://docs.pythonnative.com/"
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
|
|
65
|
+
|
|
64
66
|
[tool.setuptools.packages.find]
|
|
65
67
|
where = ["src"]
|
|
66
68
|
|
|
@@ -41,7 +41,7 @@ Example:
|
|
|
41
41
|
```
|
|
42
42
|
"""
|
|
43
43
|
|
|
44
|
-
__version__ = "0.
|
|
44
|
+
__version__ = "0.13.1"
|
|
45
45
|
|
|
46
46
|
from .alerts import Alert
|
|
47
47
|
from .animated import Animated, AnimatedValue
|
|
@@ -98,8 +98,8 @@ from .navigation import (
|
|
|
98
98
|
use_focus_effect,
|
|
99
99
|
use_route,
|
|
100
100
|
)
|
|
101
|
-
from .page import create_page
|
|
102
101
|
from .platform import Platform
|
|
102
|
+
from .screen import create_screen
|
|
103
103
|
from .style import StyleSheet, ThemeContext
|
|
104
104
|
|
|
105
105
|
__all__ = [
|
|
@@ -130,7 +130,7 @@ __all__ = [
|
|
|
130
130
|
"WebView",
|
|
131
131
|
# Core
|
|
132
132
|
"Element",
|
|
133
|
-
"
|
|
133
|
+
"create_screen",
|
|
134
134
|
# Hooks
|
|
135
135
|
"batch_updates",
|
|
136
136
|
"component",
|
|
@@ -32,9 +32,9 @@ from typing import Any, Dict, List, Optional
|
|
|
32
32
|
def init_project(args: argparse.Namespace) -> None:
|
|
33
33
|
"""Scaffold a new PythonNative project in the current directory.
|
|
34
34
|
|
|
35
|
-
Creates `app/
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
Creates `app/main.py`, `pythonnative.json`, `requirements.txt`,
|
|
36
|
+
and `.gitignore`. Refuses to overwrite existing files unless
|
|
37
|
+
`--force` is passed.
|
|
38
38
|
|
|
39
39
|
Args:
|
|
40
40
|
args: The parsed argparse namespace. Recognized attributes:
|
|
@@ -68,30 +68,55 @@ def init_project(args: argparse.Namespace) -> None:
|
|
|
68
68
|
|
|
69
69
|
os.makedirs(app_dir, exist_ok=True)
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
if not os.path.exists(
|
|
73
|
-
with open(
|
|
71
|
+
main_py = os.path.join(app_dir, "main.py")
|
|
72
|
+
if not os.path.exists(main_py) or args.force:
|
|
73
|
+
with open(main_py, "w", encoding="utf-8") as f:
|
|
74
74
|
f.write("""import pythonnative as pn
|
|
75
75
|
|
|
76
|
+
Stack = pn.create_stack_navigator()
|
|
77
|
+
|
|
76
78
|
|
|
77
79
|
@pn.component
|
|
78
|
-
def
|
|
80
|
+
def HomeScreen():
|
|
79
81
|
count, set_count = pn.use_state(0)
|
|
82
|
+
nav = pn.use_navigation()
|
|
80
83
|
return pn.ScrollView(
|
|
81
84
|
pn.Column(
|
|
82
85
|
pn.Text("Hello from PythonNative!", style={"font_size": 24, "bold": True}),
|
|
83
86
|
pn.Text(f"Tapped {count} times"),
|
|
84
87
|
pn.Button("Tap me", on_click=lambda: set_count(count + 1)),
|
|
88
|
+
pn.Button("Open detail", on_click=lambda: nav.navigate("Detail", {"count": count})),
|
|
85
89
|
style={"spacing": 12, "padding": 16, "align_items": "stretch"},
|
|
86
90
|
)
|
|
87
91
|
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@pn.component
|
|
95
|
+
def DetailScreen():
|
|
96
|
+
nav = pn.use_navigation()
|
|
97
|
+
params = pn.use_route()
|
|
98
|
+
return pn.Column(
|
|
99
|
+
pn.Text(f"Detail: count was {params.get('count', 0)}", style={"font_size": 20}),
|
|
100
|
+
pn.Button("Back", on_click=nav.go_back),
|
|
101
|
+
style={"spacing": 12, "padding": 16},
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@pn.component
|
|
106
|
+
def App():
|
|
107
|
+
return pn.NavigationContainer(
|
|
108
|
+
Stack.Navigator(
|
|
109
|
+
Stack.Screen("Home", component=HomeScreen, options={"title": "Home"}),
|
|
110
|
+
Stack.Screen("Detail", component=DetailScreen, options={"title": "Detail"}),
|
|
111
|
+
)
|
|
112
|
+
)
|
|
88
113
|
""")
|
|
89
114
|
|
|
90
115
|
# Create config
|
|
91
116
|
config = {
|
|
92
117
|
"name": project_name,
|
|
93
118
|
"appId": "com.example." + project_name.replace(" ", "").lower(),
|
|
94
|
-
"entryPoint": "app/
|
|
119
|
+
"entryPoint": "app/main.py",
|
|
95
120
|
"pythonVersion": "3.11",
|
|
96
121
|
"ios": {},
|
|
97
122
|
"android": {},
|
|
@@ -319,7 +344,7 @@ ANDROID_LOGCAT_FILTERS: list[str] = [
|
|
|
319
344
|
"python.stdout:V",
|
|
320
345
|
"python.stderr:V",
|
|
321
346
|
"MainActivity:V",
|
|
322
|
-
"
|
|
347
|
+
"ScreenFragment:V",
|
|
323
348
|
"Navigator:V",
|
|
324
349
|
"PythonNative:V",
|
|
325
350
|
"AndroidRuntime:E",
|
|
@@ -511,13 +511,13 @@ def use_window_dimensions() -> Dict[str, float]:
|
|
|
511
511
|
"""Return the current viewport size and re-render when it changes.
|
|
512
512
|
|
|
513
513
|
Equivalent to React Native's ``useWindowDimensions``. The values
|
|
514
|
-
are pushed by the
|
|
514
|
+
are pushed by the screen host whenever the platform reports a new
|
|
515
515
|
size (initial layout, rotation, multitasking split-view).
|
|
516
516
|
|
|
517
517
|
Returns:
|
|
518
518
|
A dict with ``"width"`` and ``"height"`` floats in layout
|
|
519
519
|
units (pt on iOS, dp on Android). Both are ``0.0`` until the
|
|
520
|
-
|
|
520
|
+
screen host has run its first layout pass.
|
|
521
521
|
|
|
522
522
|
Raises:
|
|
523
523
|
RuntimeError: If called outside a `@component` function.
|
|
@@ -717,8 +717,13 @@ _NavigationContext: Context = create_context(None)
|
|
|
717
717
|
class NavigationHandle:
|
|
718
718
|
"""Handle returned by [`use_navigation`][pythonnative.use_navigation].
|
|
719
719
|
|
|
720
|
-
Wraps the host's push/pop primitives so screens can navigate
|
|
721
|
-
knowing the underlying native navigation stack.
|
|
720
|
+
Wraps the host's push/pop primitives so screens can navigate
|
|
721
|
+
without knowing the underlying native navigation stack. The
|
|
722
|
+
typical user-facing surface is the declarative handle returned by
|
|
723
|
+
a [`Stack`][pythonnative.create_stack_navigator] — this class is
|
|
724
|
+
the lower-level fallback used when no navigator is rendered (and
|
|
725
|
+
as the bridge that declarative navigators delegate to when they
|
|
726
|
+
need to push real native screens).
|
|
722
727
|
|
|
723
728
|
Example:
|
|
724
729
|
```python
|
|
@@ -729,7 +734,7 @@ class NavigationHandle:
|
|
|
729
734
|
nav = pn.use_navigation()
|
|
730
735
|
return pn.Button(
|
|
731
736
|
"Open Detail",
|
|
732
|
-
on_click=lambda: nav.navigate(
|
|
737
|
+
on_click=lambda: nav.navigate("Detail", {"id": 42}),
|
|
733
738
|
)
|
|
734
739
|
```
|
|
735
740
|
"""
|
|
@@ -737,16 +742,20 @@ class NavigationHandle:
|
|
|
737
742
|
def __init__(self, host: Any) -> None:
|
|
738
743
|
self._host = host
|
|
739
744
|
|
|
740
|
-
def navigate(self,
|
|
741
|
-
"""Push
|
|
745
|
+
def navigate(self, component: Any, params: Optional[Dict[str, Any]] = None) -> None:
|
|
746
|
+
"""Push ``component`` onto the navigation stack.
|
|
742
747
|
|
|
743
748
|
Args:
|
|
744
|
-
|
|
745
|
-
path (e.g
|
|
749
|
+
component: A ``@component`` function or a dotted Python
|
|
750
|
+
path (e.g. ``"app.detail.DetailScreen"``). When a
|
|
751
|
+
Stack navigator is the root of the app, prefer the
|
|
752
|
+
declarative ``nav.navigate("Detail", params)`` form
|
|
753
|
+
returned by ``use_navigation()`` (it pushes by route
|
|
754
|
+
name and the host re-uses its own ``App`` component).
|
|
746
755
|
params: Optional dict of arguments serialized into the
|
|
747
756
|
target screen.
|
|
748
757
|
"""
|
|
749
|
-
self._host._push(
|
|
758
|
+
self._host._push(component, params)
|
|
750
759
|
|
|
751
760
|
def go_back(self) -> None:
|
|
752
761
|
"""Pop the current screen and return to the previous one."""
|
|
@@ -771,13 +780,13 @@ def use_navigation() -> NavigationHandle:
|
|
|
771
780
|
|
|
772
781
|
Raises:
|
|
773
782
|
RuntimeError: If called outside a component rendered via
|
|
774
|
-
[`
|
|
783
|
+
[`create_screen`][pythonnative.create_screen].
|
|
775
784
|
"""
|
|
776
785
|
handle = use_context(_NavigationContext)
|
|
777
786
|
if handle is None:
|
|
778
787
|
raise RuntimeError(
|
|
779
|
-
"use_navigation() called outside a PythonNative
|
|
780
|
-
"Ensure your component is rendered via
|
|
788
|
+
"use_navigation() called outside a PythonNative screen. "
|
|
789
|
+
"Ensure your component is rendered via create_screen()."
|
|
781
790
|
)
|
|
782
791
|
return handle
|
|
783
792
|
|