Skip to content

Commit d7ac93b

Browse files
committed
fix(components,templates): restore hello-world on iOS and Android
1 parent 593fee4 commit d7ac93b

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

src/pythonnative/button.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class _PNButtonHandler(NSObject): # type: ignore[valid-type]
7979
_callback: Optional[Callable[[], None]] = None
8080

8181
@objc_method
82-
def onTap_(self, sender: Any) -> None:
82+
def onTap_(self, sender: object) -> None:
8383
try:
8484
callback = self._callback
8585
if callback is not None:

src/pythonnative/scroll_view.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,26 @@ def __init__(self) -> None:
7272

7373
def add_view(self, view: Any) -> None:
7474
self.views.append(view)
75-
# Ensure view is a subview of scrollview
76-
if view.native_instance not in self.native_instance.subviews:
75+
# Add as subview and size child to fill scroll view by default so content is visible
76+
try:
7777
self.native_instance.addSubview_(view.native_instance)
78+
except Exception:
79+
pass
80+
# Default layout: if the child has no size yet, size it to fill the scroll view
81+
# and enable flexible width/height. If the child is already sized explicitly,
82+
# leave it unchanged.
83+
try:
84+
frame = getattr(view.native_instance, "frame")
85+
size = getattr(frame, "size", None)
86+
width = getattr(size, "width", 0) if size is not None else 0
87+
height = getattr(size, "height", 0) if size is not None else 0
88+
if width <= 0 or height <= 0:
89+
bounds = self.native_instance.bounds
90+
view.native_instance.setFrame_(bounds)
91+
# UIViewAutoresizingFlexibleWidth (2) | UIViewAutoresizingFlexibleHeight (16)
92+
view.native_instance.setAutoresizingMask_(2 | 16)
93+
except Exception:
94+
pass
7895

7996
@staticmethod
8097
def wrap(view: Any) -> "ScrollView":

src/pythonnative/templates/android_template/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ plugins {
66

77
android {
88
namespace 'com.pythonnative.android_template'
9-
compileSdk 33
9+
compileSdk 34
1010

1111
defaultConfig {
1212
applicationId "com.pythonnative.android_template"
1313
minSdk 24
14-
targetSdk 33
14+
targetSdk 34
1515
versionCode 1
1616
versionName "1.0"
1717

src/pythonnative/templates/android_template/app/src/main/res/navigation/nav_graph.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<argument
1717
android:name="args_json"
1818
app:argType="string"
19-
android:nullable="true" />
19+
app:nullable="true" />
2020
</fragment>
2121

2222
</navigation>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id 'com.android.application' version '8.0.2' apply false
4-
id 'com.android.library' version '8.0.2' apply false
5-
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
3+
id 'com.android.application' version '8.2.2' apply false
4+
id 'com.android.library' version '8.2.2' apply false
5+
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
66
id 'com.chaquo.python' version '14.0.2' apply false
77
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Mon Jun 19 11:09:16 PDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)