pythonnative 0.23.0__py3-none-any.whl → 0.25.0__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 +44 -53
- pythonnative/animated.py +3 -3
- pythonnative/cli/pn.py +3 -3
- pythonnative/components.py +309 -513
- pythonnative/diagnostics.py +214 -0
- pythonnative/element.py +5 -2
- pythonnative/events.py +13 -8
- pythonnative/hooks.py +761 -114
- pythonnative/hot_reload.py +9 -1
- pythonnative/native_modules/notifications.py +36 -4
- pythonnative/native_modules/permissions.py +24 -1
- pythonnative/native_views/android.py +85 -3
- pythonnative/native_views/desktop.py +38 -1
- pythonnative/native_views/ios.py +252 -7
- pythonnative/navigation.py +41 -17
- pythonnative/preview.py +43 -7
- pythonnative/reconciler.py +1360 -457
- pythonnative/runtime.py +407 -215
- pythonnative/screen.py +377 -34
- pythonnative/storage.py +5 -5
- pythonnative/style.py +83 -0
- pythonnative/suspense.py +417 -0
- pythonnative/templates/android_template/app/src/main/java/com/pythonnative/android_template/ScreenFragment.kt +22 -0
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/METADATA +6 -4
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/RECORD +29 -27
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/WHEEL +1 -1
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/entry_points.txt +0 -0
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/licenses/LICENSE +0 -0
- {pythonnative-0.23.0.dist-info → pythonnative-0.25.0.dist-info}/top_level.txt +0 -0
pythonnative/__init__.py
CHANGED
|
@@ -54,96 +54,83 @@ Example:
|
|
|
54
54
|
count, set_count = pn.use_state(0)
|
|
55
55
|
return pn.Column(
|
|
56
56
|
pn.Text(f"Count: {count}", style=pn.style(font_size=24)),
|
|
57
|
-
pn.Button("+",
|
|
57
|
+
pn.Button("+", on_press=lambda: set_count(count + 1)),
|
|
58
58
|
style=pn.style(spacing=12),
|
|
59
59
|
)
|
|
60
60
|
```
|
|
61
61
|
"""
|
|
62
62
|
|
|
63
|
-
__version__ = "0.
|
|
63
|
+
__version__ = "0.25.0"
|
|
64
64
|
|
|
65
|
-
from . import appearance, gestures, images, runtime, sdk
|
|
65
|
+
from . import appearance, diagnostics, gestures, images, runtime, sdk
|
|
66
66
|
from .alerts import Alert
|
|
67
67
|
from .animated import Animated, AnimatedValue, use_animated_value
|
|
68
68
|
from .components import (
|
|
69
69
|
ActivityIndicator,
|
|
70
|
-
ActivityIndicatorProps,
|
|
71
70
|
Button,
|
|
72
|
-
ButtonProps,
|
|
73
71
|
Checkbox,
|
|
74
|
-
CheckboxProps,
|
|
75
72
|
Column,
|
|
76
73
|
DatePicker,
|
|
77
|
-
DatePickerProps,
|
|
78
74
|
ErrorBoundary,
|
|
79
75
|
FlatList,
|
|
80
76
|
Fragment,
|
|
81
77
|
Image,
|
|
82
78
|
ImageBackground,
|
|
83
|
-
ImageBackgroundProps,
|
|
84
|
-
ImageProps,
|
|
85
79
|
KeyboardAvoidingView,
|
|
86
|
-
|
|
80
|
+
ListController,
|
|
87
81
|
Modal,
|
|
88
|
-
ModalProps,
|
|
89
82
|
Picker,
|
|
90
|
-
|
|
83
|
+
Portal,
|
|
91
84
|
Pressable,
|
|
92
|
-
PressableProps,
|
|
93
85
|
ProgressBar,
|
|
94
|
-
ProgressBarProps,
|
|
95
86
|
RefreshControl,
|
|
96
87
|
Row,
|
|
97
88
|
SafeAreaView,
|
|
98
|
-
SafeAreaViewProps,
|
|
99
89
|
ScrollView,
|
|
100
|
-
ScrollViewProps,
|
|
101
90
|
SectionList,
|
|
102
91
|
SegmentedControl,
|
|
103
|
-
SegmentedControlProps,
|
|
104
92
|
Slider,
|
|
105
|
-
SliderProps,
|
|
106
93
|
Spacer,
|
|
107
|
-
SpacerProps,
|
|
108
94
|
StatusBar,
|
|
109
|
-
|
|
95
|
+
Suspense,
|
|
110
96
|
Switch,
|
|
111
|
-
SwitchProps,
|
|
112
97
|
Text,
|
|
113
98
|
TextInput,
|
|
114
|
-
TextInputProps,
|
|
115
|
-
TextProps,
|
|
116
99
|
TouchableOpacity,
|
|
117
|
-
TouchableOpacityProps,
|
|
118
100
|
View,
|
|
119
|
-
ViewProps,
|
|
120
101
|
WebView,
|
|
121
|
-
WebViewProps,
|
|
122
102
|
)
|
|
103
|
+
from .diagnostics import HookOrderError
|
|
123
104
|
from .element import Element
|
|
124
105
|
from .hooks import (
|
|
125
106
|
MutationCall,
|
|
126
107
|
MutationState,
|
|
127
108
|
Provider,
|
|
128
109
|
QueryResult,
|
|
110
|
+
Ref,
|
|
129
111
|
batch_updates,
|
|
130
112
|
component,
|
|
131
113
|
create_context,
|
|
132
114
|
memo,
|
|
133
|
-
|
|
115
|
+
use_back_handler,
|
|
134
116
|
use_callback,
|
|
135
117
|
use_color_scheme,
|
|
136
118
|
use_context,
|
|
119
|
+
use_deferred_value,
|
|
137
120
|
use_effect,
|
|
121
|
+
use_imperative_handle,
|
|
138
122
|
use_keyboard_height,
|
|
123
|
+
use_layout_effect,
|
|
139
124
|
use_memo,
|
|
140
125
|
use_mutation,
|
|
141
126
|
use_navigation,
|
|
142
127
|
use_query,
|
|
143
128
|
use_reducer,
|
|
144
129
|
use_ref,
|
|
130
|
+
use_resource,
|
|
145
131
|
use_safe_area_insets,
|
|
146
132
|
use_state,
|
|
133
|
+
use_transition,
|
|
147
134
|
use_window_dimensions,
|
|
148
135
|
)
|
|
149
136
|
from .native_modules import (
|
|
@@ -167,6 +154,7 @@ from .native_modules import (
|
|
|
167
154
|
)
|
|
168
155
|
from .navigation import (
|
|
169
156
|
NavigationContainer,
|
|
157
|
+
ScreenOptions,
|
|
170
158
|
create_drawer_navigator,
|
|
171
159
|
create_stack_navigator,
|
|
172
160
|
create_tab_navigator,
|
|
@@ -175,7 +163,7 @@ from .navigation import (
|
|
|
175
163
|
)
|
|
176
164
|
from .net import HTTPError, Response, fetch
|
|
177
165
|
from .platform import Platform
|
|
178
|
-
from .runtime import run_async
|
|
166
|
+
from .runtime import run_async, run_blocking
|
|
179
167
|
from .screen import create_screen
|
|
180
168
|
from .sdk import (
|
|
181
169
|
Props,
|
|
@@ -188,6 +176,8 @@ from .storage import AsyncStorage, use_persisted_state
|
|
|
188
176
|
from .style import (
|
|
189
177
|
DEFAULT_DARK_THEME,
|
|
190
178
|
DEFAULT_LIGHT_THEME,
|
|
179
|
+
AccessibilityState,
|
|
180
|
+
AlignContent,
|
|
191
181
|
AlignItems,
|
|
192
182
|
AlignSelf,
|
|
193
183
|
AutoCapitalize,
|
|
@@ -195,9 +185,11 @@ from .style import (
|
|
|
195
185
|
Dimension,
|
|
196
186
|
EdgeInsets,
|
|
197
187
|
FlexDirection,
|
|
188
|
+
FlexWrap,
|
|
198
189
|
FontWeight,
|
|
199
190
|
JustifyContent,
|
|
200
191
|
KeyboardType,
|
|
192
|
+
LayoutDirection,
|
|
201
193
|
Overflow,
|
|
202
194
|
Position,
|
|
203
195
|
ReturnKeyType,
|
|
@@ -215,6 +207,7 @@ from .style import (
|
|
|
215
207
|
style,
|
|
216
208
|
use_theme,
|
|
217
209
|
)
|
|
210
|
+
from .suspense import Resource, lazy, start_resource
|
|
218
211
|
|
|
219
212
|
__all__ = [
|
|
220
213
|
# Components
|
|
@@ -229,8 +222,10 @@ __all__ = [
|
|
|
229
222
|
"Image",
|
|
230
223
|
"ImageBackground",
|
|
231
224
|
"KeyboardAvoidingView",
|
|
225
|
+
"ListController",
|
|
232
226
|
"Modal",
|
|
233
227
|
"Picker",
|
|
228
|
+
"Portal",
|
|
234
229
|
"Pressable",
|
|
235
230
|
"ProgressBar",
|
|
236
231
|
"RefreshControl",
|
|
@@ -242,36 +237,13 @@ __all__ = [
|
|
|
242
237
|
"Slider",
|
|
243
238
|
"Spacer",
|
|
244
239
|
"StatusBar",
|
|
240
|
+
"Suspense",
|
|
245
241
|
"Switch",
|
|
246
242
|
"Text",
|
|
247
243
|
"TextInput",
|
|
248
244
|
"TouchableOpacity",
|
|
249
245
|
"View",
|
|
250
246
|
"WebView",
|
|
251
|
-
# Built-in Props dataclasses
|
|
252
|
-
"ActivityIndicatorProps",
|
|
253
|
-
"ButtonProps",
|
|
254
|
-
"CheckboxProps",
|
|
255
|
-
"DatePickerProps",
|
|
256
|
-
"ImageBackgroundProps",
|
|
257
|
-
"ImageProps",
|
|
258
|
-
"KeyboardAvoidingViewProps",
|
|
259
|
-
"ModalProps",
|
|
260
|
-
"PickerProps",
|
|
261
|
-
"PressableProps",
|
|
262
|
-
"ProgressBarProps",
|
|
263
|
-
"SafeAreaViewProps",
|
|
264
|
-
"ScrollViewProps",
|
|
265
|
-
"SegmentedControlProps",
|
|
266
|
-
"SliderProps",
|
|
267
|
-
"SpacerProps",
|
|
268
|
-
"StatusBarProps",
|
|
269
|
-
"SwitchProps",
|
|
270
|
-
"TextInputProps",
|
|
271
|
-
"TextProps",
|
|
272
|
-
"TouchableOpacityProps",
|
|
273
|
-
"ViewProps",
|
|
274
|
-
"WebViewProps",
|
|
275
247
|
# Core
|
|
276
248
|
"Element",
|
|
277
249
|
"create_screen",
|
|
@@ -283,13 +255,17 @@ __all__ = [
|
|
|
283
255
|
"MutationCall",
|
|
284
256
|
"MutationState",
|
|
285
257
|
"QueryResult",
|
|
286
|
-
"
|
|
258
|
+
"Ref",
|
|
259
|
+
"use_back_handler",
|
|
287
260
|
"use_callback",
|
|
288
261
|
"use_color_scheme",
|
|
289
262
|
"use_context",
|
|
263
|
+
"use_deferred_value",
|
|
290
264
|
"use_effect",
|
|
291
265
|
"use_focus_effect",
|
|
266
|
+
"use_imperative_handle",
|
|
292
267
|
"use_keyboard_height",
|
|
268
|
+
"use_layout_effect",
|
|
293
269
|
"use_memo",
|
|
294
270
|
"use_mutation",
|
|
295
271
|
"use_navigation",
|
|
@@ -297,17 +273,26 @@ __all__ = [
|
|
|
297
273
|
"use_query",
|
|
298
274
|
"use_reducer",
|
|
299
275
|
"use_ref",
|
|
276
|
+
"use_resource",
|
|
300
277
|
"use_route",
|
|
301
278
|
"use_safe_area_insets",
|
|
302
279
|
"use_state",
|
|
280
|
+
"use_transition",
|
|
303
281
|
"use_window_dimensions",
|
|
304
282
|
"Provider",
|
|
283
|
+
# Suspense and async rendering
|
|
284
|
+
"Resource",
|
|
285
|
+
"lazy",
|
|
286
|
+
"start_resource",
|
|
305
287
|
# Navigation
|
|
306
288
|
"NavigationContainer",
|
|
289
|
+
"ScreenOptions",
|
|
307
290
|
"create_drawer_navigator",
|
|
308
291
|
"create_stack_navigator",
|
|
309
292
|
"create_tab_navigator",
|
|
310
293
|
# Styling - typed primitives
|
|
294
|
+
"AccessibilityState",
|
|
295
|
+
"AlignContent",
|
|
311
296
|
"AlignItems",
|
|
312
297
|
"AlignSelf",
|
|
313
298
|
"AutoCapitalize",
|
|
@@ -317,9 +302,11 @@ __all__ = [
|
|
|
317
302
|
"Dimension",
|
|
318
303
|
"EdgeInsets",
|
|
319
304
|
"FlexDirection",
|
|
305
|
+
"FlexWrap",
|
|
320
306
|
"FontWeight",
|
|
321
307
|
"JustifyContent",
|
|
322
308
|
"KeyboardType",
|
|
309
|
+
"LayoutDirection",
|
|
323
310
|
"Overflow",
|
|
324
311
|
"Position",
|
|
325
312
|
"ReturnKeyType",
|
|
@@ -373,7 +360,11 @@ __all__ = [
|
|
|
373
360
|
"Response",
|
|
374
361
|
# Runtime
|
|
375
362
|
"run_async",
|
|
363
|
+
"run_blocking",
|
|
376
364
|
"runtime",
|
|
365
|
+
# Diagnostics
|
|
366
|
+
"HookOrderError",
|
|
367
|
+
"diagnostics",
|
|
377
368
|
# Platform
|
|
378
369
|
"Platform",
|
|
379
370
|
# Custom-component SDK
|
pythonnative/animated.py
CHANGED
|
@@ -47,7 +47,7 @@ Example:
|
|
|
47
47
|
await pn.Animated.timing(opacity, to=1.0, duration=400)
|
|
48
48
|
await pn.Animated.timing(opacity, to=0.5, duration=200)
|
|
49
49
|
|
|
50
|
-
pn.
|
|
50
|
+
pn.use_effect(fade_in, [])
|
|
51
51
|
|
|
52
52
|
return pn.Animated.View(
|
|
53
53
|
pn.Text("Hello!"),
|
|
@@ -834,7 +834,7 @@ def _make_animated_factory(
|
|
|
834
834
|
ref = use_ref(None)
|
|
835
835
|
|
|
836
836
|
def _attach_bindings() -> Callable[[], None]:
|
|
837
|
-
tag = ref.
|
|
837
|
+
tag = ref._pn_tag
|
|
838
838
|
if tag is None:
|
|
839
839
|
return lambda: None
|
|
840
840
|
detachers = [value.attach(tag, _animated_prop_name(prop)) for prop, value in bindings.items()]
|
|
@@ -1014,7 +1014,7 @@ def use_animated_value(initial: float = 0.0) -> AnimatedValue:
|
|
|
1014
1014
|
async def fade_in():
|
|
1015
1015
|
await pn.Animated.timing(opacity, to=1.0, duration=300)
|
|
1016
1016
|
|
|
1017
|
-
pn.
|
|
1017
|
+
pn.use_effect(fade_in, [])
|
|
1018
1018
|
return pn.Animated.View(
|
|
1019
1019
|
pn.Text("Hello"),
|
|
1020
1020
|
style=pn.style(opacity=opacity),
|
pythonnative/cli/pn.py
CHANGED
|
@@ -59,8 +59,8 @@ def HomeScreen():
|
|
|
59
59
|
pn.Column(
|
|
60
60
|
pn.Text("Hello from PythonNative!", style={"font_size": 24, "bold": True}),
|
|
61
61
|
pn.Text(f"Tapped {count} times"),
|
|
62
|
-
pn.Button("Tap me",
|
|
63
|
-
pn.Button("Open detail",
|
|
62
|
+
pn.Button("Tap me", on_press=lambda: set_count(count + 1)),
|
|
63
|
+
pn.Button("Open detail", on_press=lambda: nav.navigate("Detail", {"count": count})),
|
|
64
64
|
style={"spacing": 12, "padding": 16, "align_items": "stretch"},
|
|
65
65
|
)
|
|
66
66
|
)
|
|
@@ -72,7 +72,7 @@ def DetailScreen():
|
|
|
72
72
|
params = pn.use_route()
|
|
73
73
|
return pn.Column(
|
|
74
74
|
pn.Text(f"Detail: count was {params.get('count', 0)}", style={"font_size": 20}),
|
|
75
|
-
pn.Button("Back",
|
|
75
|
+
pn.Button("Back", on_press=nav.go_back),
|
|
76
76
|
style={"spacing": 12, "padding": 16},
|
|
77
77
|
)
|
|
78
78
|
|