| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a7ef3d5 commit d0068fd
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,7 +103,7 @@ Recommended scopes (choose the smallest, most accurate unit; prefer module/direc | |||
| 103 | 103 | - `hooks` – function components and hooks (`hooks.py`) | |
| 104 | 104 | - `hot_reload` – file watcher and module reloader (`hot_reload.py`) | |
| 105 | 105 | - `native_modules` – native API modules for device capabilities (`native_modules/`) | |
| 106 | - - `native_views` – platform-specific native view creation and updates (`native_views.py`) | ||
| 106 | + - `native_views` – platform-specific native view creation and updates (`native_views/`) | ||
| 107 | 107 | - `package` – `src/pythonnative/__init__.py` exports and package boundary | |
| 108 | 108 | - `page` – Page component, lifecycle, and reactive state (`page.py`) | |
| 109 | 109 | - `reconciler` – virtual view tree diffing and reconciliation (`reconciler.py`) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,3 +64,9 @@ Function component primitives: | |||
| 64 | 64 | ## Native view registry | |
| 65 | 65 | ||
| 66 | 66 | `pythonnative.native_views.NativeViewRegistry` — maps element type names to platform-specific handlers. Use `set_registry()` to inject a mock for testing. | |
| 67 | + | ||
| 68 | + The `native_views` package is organised into submodules: | ||
| 69 | + | ||
| 70 | + - `pythonnative.native_views.base` — shared `ViewHandler` protocol and utilities (`parse_color_int`, `resolve_padding`, `LAYOUT_KEYS`) | ||
| 71 | + - `pythonnative.native_views.android` — Android handlers (only imported at runtime on Android via Chaquopy) | ||
| 72 | + - `pythonnative.native_views.ios` — iOS handlers (only imported at runtime on iOS via rubicon-objc) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,6 +56,16 @@ The entry point `create_page()` is called internally by native templates to boot | |||
| 56 | 56 | ||
| 57 | 57 | All components support layout properties inside the `style` dict: `width`, `height`, `flex`, `margin`, `min_width`, `max_width`, `min_height`, `max_height`, `align_self`. Containers (`Column`, `Row`) support `spacing`, `padding`, `alignment`, `align_items`, and `justify_content`. | |
| 58 | 58 | ||
| 59 | + ## Native view handlers | ||
| 60 | + | ||
| 61 | + Platform-specific rendering logic lives in the `native_views` package, organised into dedicated submodules: | ||
| 62 | + | ||
| 63 | + - `native_views.base` — shared `ViewHandler` protocol and common utilities (colour parsing, padding resolution, layout keys) | ||
| 64 | + - `native_views.android` — Android handlers using Chaquopy's Java bridge (`jclass`, `dynamic_proxy`) | ||
| 65 | + - `native_views.ios` — iOS handlers using rubicon-objc (`ObjCClass`, `objc_method`) | ||
| 66 | + | ||
| 67 | + Each handler class maps an element type name (e.g. `"Text"`, `"Button"`) to platform-native widget creation, property updates, and child management. The `NativeViewRegistry` lazily imports only the relevant platform module at runtime, so the package can be imported on any platform for testing. | ||
| 68 | + | ||
| 59 | 69 | ## Comparison | |
| 60 | 70 | ||
| 61 | 71 | - **Versus React Native:** RN uses JSX + a JavaScript bridge + Yoga layout. PythonNative uses Python + direct native calls + platform layout managers. No JS bridge, no serialisation overhead. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | [mypy] | |
| 2 | - python_version = 3.9 | ||
| 2 | + python_version = 3.10 | ||
| 3 | 3 | ignore_missing_imports = True | |
| 4 | 4 | warn_redundant_casts = True | |
| 5 | 5 | warn_unused_ignores = True | |
@@ -17,3 +17,6 @@ disable_error_code = attr-defined,no-redef | |||
| 17 | 17 | ||
| 18 | 18 | [mypy-pythonnative.native_views] | |
| 19 | 19 | disable_error_code = misc | |
| 20 | + | ||
| 21 | + [mypy-pythonnative.native_views.*] | ||
| 22 | + disable_error_code = misc | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments