pythonnative 0.22.0__py3-none-any.whl → 0.22.1__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 +1 -1
- pythonnative/animated.py +6 -6
- pythonnative/cli/pn.py +1 -1
- pythonnative/components.py +12 -12
- pythonnative/events.py +5 -5
- pythonnative/gestures.py +3 -3
- pythonnative/hooks.py +3 -3
- pythonnative/hot_reload.py +4 -4
- pythonnative/layout.py +3 -3
- pythonnative/mutations.py +1 -1
- pythonnative/native_modules/camera.py +1 -1
- pythonnative/native_modules/haptics.py +2 -2
- pythonnative/native_modules/location.py +1 -1
- pythonnative/native_modules/permissions.py +2 -2
- pythonnative/native_modules/secure_store.py +1 -1
- pythonnative/native_views/android.py +20 -20
- pythonnative/native_views/base.py +3 -3
- pythonnative/native_views/desktop.py +7 -7
- pythonnative/native_views/ios.py +23 -23
- pythonnative/navigation.py +4 -4
- pythonnative/net.py +3 -3
- pythonnative/platform.py +1 -1
- pythonnative/platform_metrics.py +5 -5
- pythonnative/preview.py +3 -3
- pythonnative/project/builder.py +1 -1
- pythonnative/project/config.py +3 -3
- pythonnative/project/doctor.py +2 -2
- pythonnative/project/icons.py +1 -1
- pythonnative/project/ios.py +1 -1
- pythonnative/project/permissions.py +2 -2
- pythonnative/project/runtime_assets.py +3 -3
- pythonnative/reconciler.py +9 -9
- pythonnative/runtime.py +8 -8
- pythonnative/screen.py +5 -5
- pythonnative/sdk/_components.py +1 -1
- pythonnative/storage.py +3 -3
- pythonnative/style.py +1 -1
- pythonnative/templates/ios_template/ios_template.xcodeproj/project.pbxproj +2 -2
- pythonnative/templates/ios_template/ios_templateUITests/ios_templateUITests.swift +1 -1
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/METADATA +13 -13
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/RECORD +45 -45
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/WHEEL +0 -0
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/entry_points.txt +0 -0
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/licenses/LICENSE +0 -0
- {pythonnative-0.22.0.dist-info → pythonnative-0.22.1.dist-info}/top_level.txt +0 -0
pythonnative/__init__.py
CHANGED
pythonnative/animated.py
CHANGED
|
@@ -24,7 +24,7 @@ native view the value is attached to
|
|
|
24
24
|
|
|
25
25
|
- **Accepted** (iOS Core Animation, Android ``ViewPropertyAnimator`` /
|
|
26
26
|
``DynamicAnimation``): the platform animates the property entirely
|
|
27
|
-
natively
|
|
27
|
+
natively; no Python code runs per frame. Python receives exactly one
|
|
28
28
|
callback when the animation settles, updates the
|
|
29
29
|
[`AnimatedValue`][pythonnative.animated.AnimatedValue], and resolves
|
|
30
30
|
any awaiting tasks.
|
|
@@ -135,7 +135,7 @@ class AnimatedValue:
|
|
|
135
135
|
Animated components (``Animated.View`` et al.) **attach** the value
|
|
136
136
|
to ``(tag, prop)`` bindings after mount. Setting the value pushes
|
|
137
137
|
the new number to every attached native view through the registry's
|
|
138
|
-
``set_animated_property
|
|
138
|
+
``set_animated_property``, and when an animation can be driven
|
|
139
139
|
natively, the platform animates those same bindings directly.
|
|
140
140
|
|
|
141
141
|
Python-side listeners registered via
|
|
@@ -217,7 +217,7 @@ class AnimatedValue:
|
|
|
217
217
|
def add_listener(self, prop: str, callback: Callable[[float], None]) -> Callable[[], None]:
|
|
218
218
|
"""Register ``callback`` for Python-driven changes to this value.
|
|
219
219
|
|
|
220
|
-
Returns an unsubscribe callable. ``prop`` is metadata only
|
|
220
|
+
Returns an unsubscribe callable. ``prop`` is metadata only; it
|
|
221
221
|
lets the subscriber differentiate this binding from others on
|
|
222
222
|
the same ``AnimatedValue``.
|
|
223
223
|
"""
|
|
@@ -686,7 +686,7 @@ class _AnimationHandle(_AwaitableAnimation):
|
|
|
686
686
|
|
|
687
687
|
Each ``.start()`` call snapshots the value's current state, prefers
|
|
688
688
|
the native driver, and falls back to a fresh Python-ticked
|
|
689
|
-
animation otherwise (matches React Native
|
|
689
|
+
animation otherwise (matches React Native: the ``Animated.timing``
|
|
690
690
|
return value is reusable).
|
|
691
691
|
"""
|
|
692
692
|
|
|
@@ -780,7 +780,7 @@ class _CompositeAnimation(_AwaitableAnimation):
|
|
|
780
780
|
if item is None:
|
|
781
781
|
return
|
|
782
782
|
# ``_AwaitableAnimation`` and plain awaitables/coroutines are
|
|
783
|
-
# both supported
|
|
783
|
+
# both supported: lets users mix in ``asyncio.sleep``.
|
|
784
784
|
await item
|
|
785
785
|
|
|
786
786
|
|
|
@@ -824,7 +824,7 @@ def _make_animated_factory(
|
|
|
824
824
|
|
|
825
825
|
# ``@component`` packs positional children into the ``children``
|
|
826
826
|
# prop (this function declares ``*args``), and the reconciler
|
|
827
|
-
# re-invokes it with keyword props only
|
|
827
|
+
# re-invokes it with keyword props only, so at render time the
|
|
828
828
|
# payload arrives in ``kwargs``, never in ``args``.
|
|
829
829
|
children = list(args) or list(kwargs.pop("children", ()) or ())
|
|
830
830
|
|
pythonnative/cli/pn.py
CHANGED
|
@@ -5,7 +5,7 @@ The console script `pn` (declared in `pyproject.toml`) dispatches to:
|
|
|
5
5
|
- `pn init [name]`: scaffold a new project (``pythonnative.toml`` + ``app/``).
|
|
6
6
|
- `pn doctor [platform]`: diagnose the local toolchain and config.
|
|
7
7
|
- `pn preview [component]`: render the app in a desktop (Tkinter) window
|
|
8
|
-
with Fast Refresh
|
|
8
|
+
with Fast Refresh, the fast inner dev loop, no device required.
|
|
9
9
|
- `pn run android|ios`: stage + build + install + launch on a device or
|
|
10
10
|
simulator, with optional on-device hot reload.
|
|
11
11
|
- `pn build android|ios`: produce standalone artifacts (signed APK/AAB,
|
pythonnative/components.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Built-in element factories and the typed prop schemas they share.
|
|
2
2
|
|
|
3
|
-
Each ``@dataclass(frozen=True)`` class in this module
|
|
4
|
-
``ButtonProps``, etc.
|
|
3
|
+
Each ``@dataclass(frozen=True)`` class in this module (``TextProps``,
|
|
4
|
+
``ButtonProps``, etc.) is the canonical schema for one built-in
|
|
5
5
|
component. Each factory function (``Text``, ``Button``, …) is a thin
|
|
6
6
|
ergonomic wrapper that builds an [`Element`][pythonnative.Element]
|
|
7
7
|
through the shared :func:`_make_element` helper, so style resolution,
|
|
@@ -827,7 +827,7 @@ def Spacer(
|
|
|
827
827
|
|
|
828
828
|
Args:
|
|
829
829
|
size: Fixed gap in dp/pt along the parent's main axis. Mirrored
|
|
830
|
-
on both axes
|
|
830
|
+
on both axes: whichever axis the parent's
|
|
831
831
|
``flex_direction`` chooses as main becomes the actual gap.
|
|
832
832
|
flex: Flex-grow weight; useful for pushing siblings to the
|
|
833
833
|
opposite end of a [`Row`][pythonnative.Row] or
|
|
@@ -912,14 +912,14 @@ def View(
|
|
|
912
912
|
- ``flex_direction``: ``"column"`` (default), ``"row"``,
|
|
913
913
|
``"column_reverse"``, ``"row_reverse"``.
|
|
914
914
|
- ``flex_wrap``: ``"nowrap"`` (default), ``"wrap"``,
|
|
915
|
-
``"wrap_reverse"
|
|
915
|
+
``"wrap_reverse"``, with ``align_content`` controlling how
|
|
916
916
|
wrapped lines share leftover cross-axis space.
|
|
917
917
|
- ``justify_content``: main-axis distribution. Accepts
|
|
918
918
|
``"flex_start"`` (default), ``"center"``, ``"flex_end"``,
|
|
919
919
|
``"space_between"``, ``"space_around"``, ``"space_evenly"``.
|
|
920
920
|
- ``align_items``: cross-axis alignment. Accepts ``"stretch"``
|
|
921
921
|
(default), ``"flex_start"``, ``"center"``, ``"flex_end"``.
|
|
922
|
-
- ``direction``: ``"ltr"`` (default) or ``"rtl"
|
|
922
|
+
- ``direction``: ``"ltr"`` (default) or ``"rtl"``. Flips rows and
|
|
923
923
|
resolves ``margin_start`` / ``padding_end`` / absolute ``start``
|
|
924
924
|
/ ``end`` insets.
|
|
925
925
|
- ``overflow``: ``"visible"`` (default) or ``"hidden"``.
|
|
@@ -1061,7 +1061,7 @@ def ScrollView(
|
|
|
1061
1061
|
wrapper (padding, alignment, spacing of the scrollable
|
|
1062
1062
|
content), distinct from ``style`` (the scroll view frame).
|
|
1063
1063
|
keyboard_dismiss_mode: ``"none"`` (default), ``"on_drag"``, or
|
|
1064
|
-
``"interactive"
|
|
1064
|
+
``"interactive"``. Controls whether scrolling dismisses
|
|
1065
1065
|
the keyboard.
|
|
1066
1066
|
style: Style dict (or list of dicts).
|
|
1067
1067
|
ref: Optional ``use_ref()`` dict.
|
|
@@ -1145,7 +1145,7 @@ def Modal(
|
|
|
1145
1145
|
animation_type: ``"slide"`` (default), ``"fade"``, or ``"none"``.
|
|
1146
1146
|
transparent: When ``True``, the underlying view is dimmed
|
|
1147
1147
|
instead of fully covered.
|
|
1148
|
-
presentation_style: iOS presentation style
|
|
1148
|
+
presentation_style: iOS presentation style,
|
|
1149
1149
|
``"page_sheet"`` (default), ``"form_sheet"``,
|
|
1150
1150
|
``"full_screen"``, or ``"overlay"`` (custom dimmed
|
|
1151
1151
|
overlay). On Android, ``"overlay"`` keeps the dialog
|
|
@@ -1604,8 +1604,8 @@ def ErrorBoundary(
|
|
|
1604
1604
|
# ======================================================================
|
|
1605
1605
|
#
|
|
1606
1606
|
# FlatList and SectionList are pure Python components, not native
|
|
1607
|
-
# elements. They render a windowed slice of rows into a ScrollView
|
|
1608
|
-
# leading spacer, visible rows, trailing spacer
|
|
1607
|
+
# elements. They render a windowed slice of rows into a ScrollView
|
|
1608
|
+
# (leading spacer, visible rows, trailing spacer) and shift the window
|
|
1609
1609
|
# from scroll events (the same architecture as React Native's
|
|
1610
1610
|
# VirtualizedList). Because every windowed row lives in the *main*
|
|
1611
1611
|
# layout tree, rows may be any height: estimates only steer the spacer
|
|
@@ -1872,7 +1872,7 @@ def FlatList(
|
|
|
1872
1872
|
leading and trailing spacers stand in for everything else, and the
|
|
1873
1873
|
window shifts as the user scrolls. Rows may have **variable
|
|
1874
1874
|
heights**: pass ``item_height`` when rows are uniform,
|
|
1875
|
-
``get_item_height`` for exact per-item extents, or nothing at all
|
|
1875
|
+
``get_item_height`` for exact per-item extents, or nothing at all;
|
|
1876
1876
|
unknown rows start at ``estimated_item_height`` and are corrected
|
|
1877
1877
|
with their measured extent once they've been on screen.
|
|
1878
1878
|
|
|
@@ -2040,7 +2040,7 @@ def SectionList(
|
|
|
2040
2040
|
|
|
2041
2041
|
Flattens ``sections`` into a single virtualized sequence where each
|
|
2042
2042
|
entry is either a header or an item, then reuses the same windowing
|
|
2043
|
-
engine as [`FlatList`][pythonnative.FlatList]
|
|
2043
|
+
engine as [`FlatList`][pythonnative.FlatList]; headers and items
|
|
2044
2044
|
may have different (and variable) heights.
|
|
2045
2045
|
|
|
2046
2046
|
Args:
|
|
@@ -2177,7 +2177,7 @@ def StatusBar(
|
|
|
2177
2177
|
``"dark"`` (dark icons over light backgrounds), or
|
|
2178
2178
|
``"default"`` (system default).
|
|
2179
2179
|
background_color: Color of the status-bar background (Android
|
|
2180
|
-
only
|
|
2180
|
+
only; iOS draws the bar transparent over your content).
|
|
2181
2181
|
hidden: When ``True``, the status bar is hidden.
|
|
2182
2182
|
key: Stable identity for keyed reconciliation.
|
|
2183
2183
|
|
pythonnative/events.py
CHANGED
|
@@ -10,7 +10,7 @@ the bridge. This module replaces that with a single dispatch channel:
|
|
|
10
10
|
- Handlers wire their platform listener **once** at view creation; the
|
|
11
11
|
listener calls [`dispatch_event`][pythonnative.events.dispatch_event]
|
|
12
12
|
with the view's tag and the event name.
|
|
13
|
-
- Re-renders only mutate this Python-side registry
|
|
13
|
+
- Re-renders only mutate this Python-side registry; no native call is
|
|
14
14
|
made when just a callback identity changes.
|
|
15
15
|
|
|
16
16
|
The set of event names present on an element is forwarded to handlers
|
|
@@ -78,7 +78,7 @@ class EventRegistry:
|
|
|
78
78
|
|
|
79
79
|
Returns:
|
|
80
80
|
``True`` when a callback existed and was invoked (even if
|
|
81
|
-
it raised
|
|
81
|
+
it raised: exceptions are swallowed so a buggy app
|
|
82
82
|
callback can't crash the platform's UI thread), ``False``
|
|
83
83
|
when nothing is registered.
|
|
84
84
|
"""
|
|
@@ -115,7 +115,7 @@ def dispatch_event(tag: int, name: str, *args: Any) -> bool:
|
|
|
115
115
|
|
|
116
116
|
Args:
|
|
117
117
|
tag: The view's reconciler-assigned tag.
|
|
118
|
-
name: Event name
|
|
118
|
+
name: Event name, the original prop name (``"on_click"``,
|
|
119
119
|
``"on_change"``, …) or a gesture channel (``"gesture:0"``).
|
|
120
120
|
*args: Positional arguments forwarded to the user callback,
|
|
121
121
|
preserving each prop's documented signature.
|
|
@@ -144,8 +144,8 @@ def extract_events(props: Dict[str, Any]) -> Tuple[Dict[str, Any], Dict[str, Cal
|
|
|
144
144
|
- ``gestures`` lists of gesture descriptors are serialized to plain
|
|
145
145
|
dicts (handlers wire recognizers from them) while their callbacks
|
|
146
146
|
are folded into per-gesture ``"gesture:<i>"`` routers.
|
|
147
|
-
- The resulting payload carries ``_pn_events``
|
|
148
|
-
event names present
|
|
147
|
+
- The resulting payload carries ``_pn_events`` (a frozenset of the
|
|
148
|
+
event names present), so handlers can wire listeners
|
|
149
149
|
conditionally and the prop differ can detect listener
|
|
150
150
|
addition/removal without comparing closures.
|
|
151
151
|
|
pythonnative/gestures.py
CHANGED
|
@@ -351,7 +351,7 @@ def serialize_gestures(
|
|
|
351
351
|
# guarantees identical semantics on both backends.
|
|
352
352
|
|
|
353
353
|
EmitFn = Callable[[int, Dict[str, Any]], None]
|
|
354
|
-
"""``emit(gesture_index, payload)
|
|
354
|
+
"""``emit(gesture_index, payload)``: the arbiter's output channel."""
|
|
355
355
|
|
|
356
356
|
|
|
357
357
|
class _VelocityTracker:
|
|
@@ -400,7 +400,7 @@ class _Recognizer:
|
|
|
400
400
|
def kind(self) -> str:
|
|
401
401
|
return str(self.config.get("kind", ""))
|
|
402
402
|
|
|
403
|
-
# Event hooks
|
|
403
|
+
# Event hooks: ``pointers`` maps pointer id -> (x, y).
|
|
404
404
|
def down(self, pointers: Dict[int, Tuple[float, float]], t: float) -> None:
|
|
405
405
|
pass
|
|
406
406
|
|
|
@@ -805,7 +805,7 @@ class GestureArbiter:
|
|
|
805
805
|
|
|
806
806
|
One arbiter serves one view. The host backend feeds it normalized
|
|
807
807
|
pointer events (positions in the view's coordinate space, times in
|
|
808
|
-
seconds
|
|
808
|
+
seconds, any monotonic clock) and provides an ``emit`` callback
|
|
809
809
|
that forwards ``(gesture_index, payload)`` pairs to
|
|
810
810
|
[`dispatch_event`][pythonnative.events.dispatch_event].
|
|
811
811
|
|
pythonnative/hooks.py
CHANGED
|
@@ -613,7 +613,7 @@ def use_query(
|
|
|
613
613
|
Args:
|
|
614
614
|
fetcher: Zero-arg ``async`` callable that resolves to the
|
|
615
615
|
current data.
|
|
616
|
-
deps: Dependency list
|
|
616
|
+
deps: Dependency list. Refetches whenever any entry changes.
|
|
617
617
|
initial: Optional starting value for ``data`` before the
|
|
618
618
|
first fetch completes.
|
|
619
619
|
|
|
@@ -698,7 +698,7 @@ class MutationCall(Generic[T]):
|
|
|
698
698
|
Returned by the second element of the
|
|
699
699
|
[`use_mutation`][pythonnative.use_mutation] tuple. Awaiting the
|
|
700
700
|
handle resolves to the mutator's return value (or re-raises its
|
|
701
|
-
exception); discarding the handle is safe
|
|
701
|
+
exception); discarding the handle is safe. Python won't warn
|
|
702
702
|
about an unawaited coroutine because this is a plain object.
|
|
703
703
|
|
|
704
704
|
Example:
|
|
@@ -1068,7 +1068,7 @@ class NavigationHandle:
|
|
|
1068
1068
|
Wraps the host's push/pop primitives so screens can navigate
|
|
1069
1069
|
without knowing the underlying native navigation stack. The
|
|
1070
1070
|
typical user-facing surface is the declarative handle returned by
|
|
1071
|
-
a [`Stack`][pythonnative.create_stack_navigator]
|
|
1071
|
+
a [`Stack`][pythonnative.create_stack_navigator]; this class is
|
|
1072
1072
|
the lower-level fallback used when no navigator is rendered (and
|
|
1073
1073
|
as the bridge that declarative navigators delegate to when they
|
|
1074
1074
|
need to push real native screens).
|
pythonnative/hot_reload.py
CHANGED
|
@@ -17,7 +17,7 @@ Two strategies share the device-side surface:
|
|
|
17
17
|
the reconciler tree is walked and every component function whose
|
|
18
18
|
module was reloaded is swapped in place. Hook state, navigation
|
|
19
19
|
state, and even scroll positions survive because the underlying
|
|
20
|
-
``VNode`` objects are reused
|
|
20
|
+
``VNode`` objects are reused; the next render simply calls the
|
|
21
21
|
new function bodies through the old slots.
|
|
22
22
|
- **Full remount**: when the in-place swap fails (e.g. the new
|
|
23
23
|
module raised at import time, or a render exception bubbled out
|
|
@@ -197,8 +197,8 @@ class ModuleReloader:
|
|
|
197
197
|
|
|
198
198
|
Designed to be invoked from device-side glue when a hot-reload
|
|
199
199
|
push completes. All public methods are static; the class holds a
|
|
200
|
-
single piece of process-wide state
|
|
201
|
-
has most recently been applied to ``sys.modules``
|
|
200
|
+
single piece of process-wide state (the manifest version that
|
|
201
|
+
has most recently been applied to ``sys.modules``) so that
|
|
202
202
|
multiple screen hosts polling the same manifest do not each
|
|
203
203
|
re-execute the user-app modules. The first host to see a new
|
|
204
204
|
version pays the ``reload_modules`` cost; subsequent hosts on the
|
|
@@ -302,7 +302,7 @@ class ModuleReloader:
|
|
|
302
302
|
|
|
303
303
|
Returns:
|
|
304
304
|
The list of module names that are currently fresh in
|
|
305
|
-
``sys.modules
|
|
305
|
+
``sys.modules``, either freshly reloaded by this call, or
|
|
306
306
|
already reloaded by an earlier host for the same version.
|
|
307
307
|
"""
|
|
308
308
|
with ModuleReloader._reload_lock:
|
pythonnative/layout.py
CHANGED
|
@@ -9,7 +9,7 @@ The engine is invoked by the reconciler after each commit pass:
|
|
|
9
9
|
|
|
10
10
|
1. The reconciler maintains a parallel
|
|
11
11
|
[`LayoutNode`][pythonnative.layout.LayoutNode] tree (cached across
|
|
12
|
-
passes
|
|
12
|
+
passes: clean subtrees keep their nodes, dirty ones are rebuilt).
|
|
13
13
|
2. [`calculate_layout`][pythonnative.layout.calculate_layout] is called
|
|
14
14
|
with the viewport size; it recursively determines each node's
|
|
15
15
|
``(x, y, width, height)`` relative to its parent's coordinate space.
|
|
@@ -618,7 +618,7 @@ def _measure_node(
|
|
|
618
618
|
resolved_direction = _resolve_direction(style, direction)
|
|
619
619
|
|
|
620
620
|
# Incremental-layout memo: a clean node measured under identical
|
|
621
|
-
# inputs reuses its previous result without recursing
|
|
621
|
+
# inputs reuses its previous result without recursing; its whole
|
|
622
622
|
# subtree keeps the sizes from the prior pass.
|
|
623
623
|
memo = node._measure_memo
|
|
624
624
|
if (
|
|
@@ -863,7 +863,7 @@ def _layout_flex_children(
|
|
|
863
863
|
their line's cross size. The computed line structure is stored on
|
|
864
864
|
``parent._lines`` for the positioning pass.
|
|
865
865
|
|
|
866
|
-
Returns ``(used_main, used_cross)
|
|
866
|
+
Returns ``(used_main, used_cross)``, the total content size used
|
|
867
867
|
by the in-flow children, including inter-child gaps but excluding
|
|
868
868
|
the parent's own padding. The caller adds padding back in for the
|
|
869
869
|
container's outer size.
|
pythonnative/mutations.py
CHANGED
|
@@ -49,7 +49,7 @@ class CreateOp:
|
|
|
49
49
|
Attributes:
|
|
50
50
|
tag: Unique integer identity assigned by the reconciler.
|
|
51
51
|
type_name: Element type name (e.g. ``"Text"``).
|
|
52
|
-
props: Initial *clean* props
|
|
52
|
+
props: Initial *clean* props; callables have already been
|
|
53
53
|
routed to the [`EventRegistry`][pythonnative.events.EventRegistry]
|
|
54
54
|
and replaced by the ``_pn_events`` name set.
|
|
55
55
|
"""
|
|
@@ -152,7 +152,7 @@ def _ios_launch_picker(on_result: Callable[[Optional[str]], None], source: str)
|
|
|
152
152
|
_pending_delegates.pop(id(delegate), None)
|
|
153
153
|
on_result(None)
|
|
154
154
|
|
|
155
|
-
# Reference SEL/objc_method so the lint pass keeps the import
|
|
155
|
+
# Reference SEL/objc_method so the lint pass keeps the import;
|
|
156
156
|
# they're needed for the delegate class above.
|
|
157
157
|
_ = (SEL, objc_method)
|
|
158
158
|
except Exception:
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Two interfaces live here:
|
|
4
4
|
|
|
5
|
-
- [`Haptics`][pythonnative.Haptics]
|
|
5
|
+
- [`Haptics`][pythonnative.Haptics]: semantic, iOS-style feedback
|
|
6
6
|
(impact / notification / selection) backed by
|
|
7
7
|
``UIFeedbackGenerator`` on iOS and ``VibrationEffect`` patterns on
|
|
8
8
|
Android.
|
|
9
|
-
- [`Vibration`][pythonnative.Vibration]
|
|
9
|
+
- [`Vibration`][pythonnative.Vibration]: a blunt "buzz for N
|
|
10
10
|
milliseconds" interface for cases where you want an explicit
|
|
11
11
|
duration.
|
|
12
12
|
|
|
@@ -167,7 +167,7 @@ def _android_get(on_result: Callable[[Optional[Coords]], None]) -> None:
|
|
|
167
167
|
Context = jclass("android.content.Context")
|
|
168
168
|
lm = ctx.getSystemService(Context.LOCATION_SERVICE)
|
|
169
169
|
|
|
170
|
-
# Try the most recent known fix first
|
|
170
|
+
# Try the most recent known fix first; it's instant and avoids
|
|
171
171
|
# the GPS warm-up delay.
|
|
172
172
|
try:
|
|
173
173
|
for provider in ("gps", "network", "passive"):
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[`Permissions`][pythonnative.Permissions] normalizes the very different
|
|
4
4
|
iOS and Android permission models behind two calls:
|
|
5
5
|
|
|
6
|
-
- ``check(permission)
|
|
6
|
+
- ``check(permission)``: synchronous, returns a status string without
|
|
7
7
|
prompting.
|
|
8
|
-
- ``request(permission)
|
|
8
|
+
- ``request(permission)``: a coroutine that shows the system prompt
|
|
9
9
|
(if needed) and resolves to the resulting status.
|
|
10
10
|
|
|
11
11
|
Statuses are ``"granted"``, ``"denied"``, ``"blocked"`` (denied with
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Encrypted key/value storage for secrets (tokens, credentials).
|
|
2
2
|
|
|
3
3
|
[`SecureStore`][pythonnative.SecureStore] persists small string values
|
|
4
|
-
in the iOS Keychain and Android ``EncryptedSharedPreferences
|
|
4
|
+
in the iOS Keychain and Android ``EncryptedSharedPreferences``, the
|
|
5
5
|
right place for auth tokens and other secrets that
|
|
6
6
|
[`AsyncStorage`][pythonnative.AsyncStorage] (plain, unencrypted) should
|
|
7
7
|
never hold.
|
|
@@ -8,7 +8,7 @@ and frame application. Handlers are registered with the
|
|
|
8
8
|
|
|
9
9
|
**Batched protocol**: the registry applies the reconciler's mutation
|
|
10
10
|
ops; handlers receive callable-free props. User callbacks never reach
|
|
11
|
-
this module
|
|
11
|
+
this module; every interaction (clicks, text changes, scrolls,
|
|
12
12
|
gestures) is forwarded through
|
|
13
13
|
[`dispatch_event`][pythonnative.events.dispatch_event] keyed by the
|
|
14
14
|
view's reconciler-assigned tag.
|
|
@@ -244,7 +244,7 @@ def _apply_accessibility(view: Any, props: Dict[str, Any]) -> None:
|
|
|
244
244
|
except Exception:
|
|
245
245
|
pass
|
|
246
246
|
# Android's accessibility role / hint mostly comes through
|
|
247
|
-
# AccessibilityNodeInfo
|
|
247
|
+
# AccessibilityNodeInfo; full plumbing is non-trivial. We keep
|
|
248
248
|
# the API surface symmetrical with iOS but apply only the label
|
|
249
249
|
# for now.
|
|
250
250
|
|
|
@@ -689,7 +689,7 @@ class AndroidViewHandler(ViewHandler):
|
|
|
689
689
|
|
|
690
690
|
|
|
691
691
|
class FlexContainerHandler(AndroidViewHandler):
|
|
692
|
-
"""Container for flex layout
|
|
692
|
+
"""Container for flex layout, a bare `FrameLayout`.
|
|
693
693
|
|
|
694
694
|
All flex semantics (direction, alignment, distribution, padding)
|
|
695
695
|
are computed by the layout engine and applied via
|
|
@@ -844,7 +844,7 @@ class ButtonHandler(AndroidViewHandler):
|
|
|
844
844
|
|
|
845
845
|
|
|
846
846
|
class ScrollViewHandler(AndroidViewHandler):
|
|
847
|
-
"""Scroll container
|
|
847
|
+
"""Scroll container: wraps a single child whose height is unbounded.
|
|
848
848
|
|
|
849
849
|
Uses ``androidx.core.widget.NestedScrollView`` (vertical) or
|
|
850
850
|
``android.widget.HorizontalScrollView`` so nested scroll views
|
|
@@ -871,7 +871,7 @@ class ScrollViewHandler(AndroidViewHandler):
|
|
|
871
871
|
sv = jclass("android.widget.ScrollView")(_ctx())
|
|
872
872
|
|
|
873
873
|
# Vertical scroll views are *always* wrapped in a (disabled)
|
|
874
|
-
# SwipeRefreshLayout. Wrapping later is impossible
|
|
874
|
+
# SwipeRefreshLayout. Wrapping later is impossible; the
|
|
875
875
|
# reconciler may reuse this view for a screen that adds a
|
|
876
876
|
# ``refresh_control`` prop afterwards (e.g. navigation swapping
|
|
877
877
|
# screens of the same shape), and re-parenting a mounted view
|
|
@@ -1214,7 +1214,7 @@ class TextInputHandler(AndroidViewHandler):
|
|
|
1214
1214
|
# Map the cross-platform ``return_key_type`` to Android's
|
|
1215
1215
|
# ``EditorInfo.IME_ACTION_*`` so the soft keyboard renders the
|
|
1216
1216
|
# right action key. iOS has a richer set (Google / Yahoo /
|
|
1217
|
-
# Join / Route) with no direct AOSP equivalents
|
|
1217
|
+
# Join / Route) with no direct AOSP equivalents; fall back
|
|
1218
1218
|
# to ``IME_ACTION_DONE`` for those.
|
|
1219
1219
|
try:
|
|
1220
1220
|
EditorInfo = jclass("android.view.inputmethod.EditorInfo")
|
|
@@ -1244,7 +1244,7 @@ class TextInputHandler(AndroidViewHandler):
|
|
|
1244
1244
|
Single-line inputs always dismiss the keyboard on the action
|
|
1245
1245
|
key (matching React Native's Android default) and fire
|
|
1246
1246
|
``on_submit`` first. Multi-line inputs only consume the action
|
|
1247
|
-
when an ``on_submit`` handler exists
|
|
1247
|
+
when an ``on_submit`` handler exists; otherwise Enter inserts
|
|
1248
1248
|
a newline.
|
|
1249
1249
|
"""
|
|
1250
1250
|
try:
|
|
@@ -1616,7 +1616,7 @@ class WebViewHandler(AndroidViewHandler):
|
|
|
1616
1616
|
class SpacerHandler(AndroidViewHandler):
|
|
1617
1617
|
"""Empty layout placeholder used as a flexible gap.
|
|
1618
1618
|
|
|
1619
|
-
All sizing semantics live in the layout engine
|
|
1619
|
+
All sizing semantics live in the layout engine; ``Spacer``
|
|
1620
1620
|
behaves identically to a `View` with the same style props (e.g.,
|
|
1621
1621
|
``flex: 1`` for an expanding spacer, ``size`` for a fixed gap).
|
|
1622
1622
|
"""
|
|
@@ -1638,7 +1638,7 @@ class SafeAreaViewHandler(FlexContainerHandler):
|
|
|
1638
1638
|
|
|
1639
1639
|
|
|
1640
1640
|
# ======================================================================
|
|
1641
|
-
# Modal
|
|
1641
|
+
# Modal: actually presents a Dialog with the children inside
|
|
1642
1642
|
# ======================================================================
|
|
1643
1643
|
|
|
1644
1644
|
|
|
@@ -1959,7 +1959,7 @@ class TabBarHandler(AndroidViewHandler):
|
|
|
1959
1959
|
|
|
1960
1960
|
|
|
1961
1961
|
# ======================================================================
|
|
1962
|
-
# Pressable
|
|
1962
|
+
# Pressable: visual feedback + tap callbacks + gestures
|
|
1963
1963
|
# ======================================================================
|
|
1964
1964
|
|
|
1965
1965
|
|
|
@@ -2073,7 +2073,7 @@ class PressableHandler(FlexContainerHandler):
|
|
|
2073
2073
|
|
|
2074
2074
|
|
|
2075
2075
|
# ======================================================================
|
|
2076
|
-
# StatusBar
|
|
2076
|
+
# StatusBar: global side effect
|
|
2077
2077
|
# ======================================================================
|
|
2078
2078
|
|
|
2079
2079
|
|
|
@@ -2131,7 +2131,7 @@ def _present_alert(
|
|
|
2131
2131
|
) -> None:
|
|
2132
2132
|
"""Present an AlertDialog or BottomSheet (``style='action_sheet'``).
|
|
2133
2133
|
|
|
2134
|
-
Safe to call from any thread
|
|
2134
|
+
Safe to call from any thread; the AlertDialog work is automatically
|
|
2135
2135
|
marshalled to the main looper via
|
|
2136
2136
|
[`pythonnative.runtime.call_on_main_thread`][pythonnative.runtime.call_on_main_thread].
|
|
2137
2137
|
Returns immediately; the dialog appears on the next main-loop tick.
|
|
@@ -2227,12 +2227,12 @@ def _present_alert(
|
|
|
2227
2227
|
|
|
2228
2228
|
|
|
2229
2229
|
# ======================================================================
|
|
2230
|
-
# Picker
|
|
2230
|
+
# Picker: native dropdown / select widget
|
|
2231
2231
|
# ======================================================================
|
|
2232
2232
|
|
|
2233
2233
|
|
|
2234
2234
|
class PickerHandler(AndroidViewHandler):
|
|
2235
|
-
"""``Picker`` element handler
|
|
2235
|
+
"""``Picker`` element handler, native ``Spinner`` dropdown."""
|
|
2236
2236
|
|
|
2237
2237
|
def _build(self, props: Dict[str, Any]) -> Any:
|
|
2238
2238
|
sp = jclass("android.widget.Spinner")(_ctx())
|
|
@@ -2300,12 +2300,12 @@ class PickerHandler(AndroidViewHandler):
|
|
|
2300
2300
|
|
|
2301
2301
|
|
|
2302
2302
|
# ======================================================================
|
|
2303
|
-
# Checkbox
|
|
2303
|
+
# Checkbox: native CheckBox with an optional inline label
|
|
2304
2304
|
# ======================================================================
|
|
2305
2305
|
|
|
2306
2306
|
|
|
2307
2307
|
class CheckboxHandler(AndroidViewHandler):
|
|
2308
|
-
"""``Checkbox`` element handler
|
|
2308
|
+
"""``Checkbox`` element handler, native ``CheckBox`` widget.
|
|
2309
2309
|
|
|
2310
2310
|
Programmatic ``value`` updates are wrapped in a per-view
|
|
2311
2311
|
"suppress" guard so pushing a new state via ``setChecked`` never
|
|
@@ -2348,12 +2348,12 @@ class CheckboxHandler(AndroidViewHandler):
|
|
|
2348
2348
|
|
|
2349
2349
|
|
|
2350
2350
|
# ======================================================================
|
|
2351
|
-
# SegmentedControl
|
|
2351
|
+
# SegmentedControl: horizontal toggle row (no UISegmentedControl on AOSP)
|
|
2352
2352
|
# ======================================================================
|
|
2353
2353
|
|
|
2354
2354
|
|
|
2355
2355
|
class SegmentedControlHandler(AndroidViewHandler):
|
|
2356
|
-
"""``SegmentedControl`` element
|
|
2356
|
+
"""``SegmentedControl`` element, a horizontal row of toggle buttons.
|
|
2357
2357
|
|
|
2358
2358
|
Android has no ``UISegmentedControl`` equivalent, so the control is
|
|
2359
2359
|
built from a horizontal ``LinearLayout`` holding one ``Button`` per
|
|
@@ -2492,12 +2492,12 @@ class SegmentedControlHandler(AndroidViewHandler):
|
|
|
2492
2492
|
|
|
2493
2493
|
|
|
2494
2494
|
# ======================================================================
|
|
2495
|
-
# DatePicker
|
|
2495
|
+
# DatePicker: trigger button opening native date/time dialogs
|
|
2496
2496
|
# ======================================================================
|
|
2497
2497
|
|
|
2498
2498
|
|
|
2499
2499
|
class DatePickerHandler(AndroidViewHandler):
|
|
2500
|
-
"""``DatePicker`` element
|
|
2500
|
+
"""``DatePicker`` element, a trigger ``Button`` opening native dialogs.
|
|
2501
2501
|
|
|
2502
2502
|
The button text reflects the current ISO ``value`` (or a
|
|
2503
2503
|
placeholder). Tapping it opens a ``DatePickerDialog`` (``mode``
|
|
@@ -23,7 +23,7 @@ class ViewHandler:
|
|
|
23
23
|
|
|
24
24
|
A `ViewHandler` knows how to create, update, re-parent, and destroy
|
|
25
25
|
native views of one element type. The reconciler never calls a
|
|
26
|
-
handler directly
|
|
26
|
+
handler directly; it emits a batch of mutation ops
|
|
27
27
|
(`pythonnative.mutations`) that the
|
|
28
28
|
[`NativeViewRegistry`][pythonnative.native_views.NativeViewRegistry]
|
|
29
29
|
applies by dispatching to handlers. Handlers never need to know
|
|
@@ -132,7 +132,7 @@ class ViewHandler:
|
|
|
132
132
|
|
|
133
133
|
The default implementation returns ``(0, 0)``; override for
|
|
134
134
|
leaves whose size depends on their content. Container handlers
|
|
135
|
-
leave this alone
|
|
135
|
+
leave this alone; the engine sizes containers by laying out
|
|
136
136
|
their children.
|
|
137
137
|
|
|
138
138
|
Args:
|
|
@@ -149,7 +149,7 @@ class ViewHandler:
|
|
|
149
149
|
"""Execute an imperative command (e.g. ``"scroll_to_offset"``).
|
|
150
150
|
|
|
151
151
|
Commands are the escape hatch for one-shot imperative actions
|
|
152
|
-
that don't fit declarative props
|
|
152
|
+
that don't fit declarative props: scrolling, focusing,
|
|
153
153
|
flashing indicators. Unknown commands should be ignored.
|
|
154
154
|
|
|
155
155
|
Args:
|
|
@@ -74,7 +74,7 @@ from .base import ViewHandler
|
|
|
74
74
|
# ``pn preview`` installs it before mounting the app; the placement
|
|
75
75
|
# logic (``_place``) positions widgets *inside* their logical parent via
|
|
76
76
|
# Tk's ``-in`` option, which only works when both windows share a
|
|
77
|
-
# top-level
|
|
77
|
+
# top-level, guaranteed by the single-stage design.
|
|
78
78
|
|
|
79
79
|
_ROOT_CONTAINER: Any = None
|
|
80
80
|
_DEFAULT_FONT_SIZE = 15
|
|
@@ -125,7 +125,7 @@ def _tk_color(value: Any) -> Optional[str]:
|
|
|
125
125
|
"""Convert a PythonNative color into a Tk color string.
|
|
126
126
|
|
|
127
127
|
Accepts ``#rgb`` / ``#rrggbb`` / ``#aarrggbb`` hex (alpha is
|
|
128
|
-
dropped
|
|
128
|
+
dropped; Tk has no per-color alpha), ``rgb()`` / ``rgba()``
|
|
129
129
|
functional notation, ``(r, g, b)`` tuples, packed integers, and
|
|
130
130
|
named colors (passed through for Tk to resolve). Returns ``None``
|
|
131
131
|
for ``transparent`` / unparseable values so callers can leave the
|
|
@@ -686,8 +686,8 @@ class ScrollViewHandler(FlexContainerHandler):
|
|
|
686
686
|
|
|
687
687
|
The layout engine lets the content grow past the viewport on the
|
|
688
688
|
scroll axis; this handler offsets its children's placement by the
|
|
689
|
-
current scroll offset (overflow outside the frame is *not* clipped
|
|
690
|
-
|
|
689
|
+
current scroll offset (overflow outside the frame is *not* clipped,
|
|
690
|
+
a documented preview limitation of the single-stage design).
|
|
691
691
|
|
|
692
692
|
Commands:
|
|
693
693
|
``scroll_to_offset(x=…, y=…)``: jump to an offset.
|
|
@@ -1232,7 +1232,7 @@ class PressableHandler(DesktopViewHandler):
|
|
|
1232
1232
|
|
|
1233
1233
|
|
|
1234
1234
|
class ModalHandler(DesktopViewHandler):
|
|
1235
|
-
"""Overlay modal
|
|
1235
|
+
"""Overlay modal, a frame that fills the stage when ``visible``.
|
|
1236
1236
|
|
|
1237
1237
|
The reconciler lays the modal's content out against the full
|
|
1238
1238
|
viewport (see ``Reconciler._layout_visible_modals``) and applies
|
|
@@ -1275,7 +1275,7 @@ class ModalHandler(DesktopViewHandler):
|
|
|
1275
1275
|
|
|
1276
1276
|
|
|
1277
1277
|
class TabBarHandler(DesktopViewHandler):
|
|
1278
|
-
"""Bottom tab bar
|
|
1278
|
+
"""Bottom tab bar, a row of buttons laid out across its width."""
|
|
1279
1279
|
|
|
1280
1280
|
def build(self, props: Dict[str, Any]) -> Any:
|
|
1281
1281
|
frame = tk.Frame(_master(), highlightthickness=1, bd=0, background="#f2f2f7")
|
|
@@ -1454,7 +1454,7 @@ class SegmentedControlHandler(DesktopViewHandler):
|
|
|
1454
1454
|
|
|
1455
1455
|
|
|
1456
1456
|
class DatePickerHandler(DesktopViewHandler):
|
|
1457
|
-
"""Preview DatePicker
|
|
1457
|
+
"""Preview DatePicker, a text entry for the ISO date/time string."""
|
|
1458
1458
|
|
|
1459
1459
|
def build(self, props: Dict[str, Any]) -> Any:
|
|
1460
1460
|
entry = tk.Entry(_master(), highlightthickness=1, bd=0)
|