Skip to content

Commit 0b02a11

Browse files
authored
fix: Fix actions sizing (#2)
* fix: Fix actions height * bump version
1 parent 7beb85f commit 0b02a11

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

demo/app/main-page.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
</sv:SwipeView.leftActionsTemplate>
1212

1313
<sv:SwipeView.rightActionsTemplate>
14-
<StackLayout backgroundColor="red" color="white" tap="onDelete">
15-
<Label text="Delete" />
16-
</StackLayout>
14+
<GridLayout rows="*, auto, *" backgroundColor="red" color="white" tap="onDelete">
15+
<Label row="1" text="Delete" />
16+
</GridLayout>
1717
</sv:SwipeView.rightActionsTemplate>
1818

19-
<GridLayout backgroundColor="white">
19+
<StackLayout backgroundColor="white">
20+
<Label text="{{ value }}" verticalAlignment="center"/>
21+
<Label text="{{ value }}" verticalAlignment="center"/>
2022
<Label text="{{ value }}" verticalAlignment="center"/>
21-
</GridLayout>
23+
</StackLayout>
2224
</sv:SwipeView>
2325
</ListView.itemTemplate>
2426
</ListView>

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-swipe-view",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "NativeScript plugin to connect with Azure Notification Hubs",
55
"main": "dist/swipe-view",
66
"typings": "swipe-view.d.ts",

src/swipe-view.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,24 @@ export class SwipeView extends GridLayout implements definition.SwipeView {
128128
return;
129129
}
130130

131-
if (this._prevPanState !== e.state) {
131+
// Swipe start
132+
if (e.state === 2
133+
&& this._prevPanState !== e.state) {
132134
this.parent?.notify({
133135
eventName: SwipeView.swipeViewSwipeStartedEvent,
134136
object: this,
135137
});
138+
139+
// Set the height of the swipe view to the max from all. Otherwise it is not resized correctly.
140+
const itemViewHeight = this.getChildAt(1)?.getMeasuredHeight();
141+
const leftActionsHeight = this._leftActionsTemplateView?.getMeasuredHeight();
142+
const rightActionsHeight = this._rightActionsTemplateView?.getMeasuredHeight();
143+
const finalHeight = Math.max(
144+
itemViewHeight || 0,
145+
leftActionsHeight || 0,
146+
rightActionsHeight || 0,
147+
);
148+
this._swipeView.height = Utils.layout.toDeviceIndependentPixels(finalHeight);
136149
}
137150

138151
this._prevPanState = e.state;

0 commit comments

Comments
 (0)