Skip to content

Commit 0b4e85c

Browse files
committed
feat: BottomSheet add default collapsed sheet height for android
1 parent 1ec0b28 commit 0b4e85c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/bottomsheet/bottomsheet-common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface BottomSheetOptions {
3131
ignoreBottomSafeArea?: boolean; // optional ios parameter to bottom safe area. Default is false
3232
disableDimBackground?: boolean; // optional parameter to remove the dim background
3333
skipCollapsedState?: boolean; // optional Android parameter to skip midway state when view is greater than 50%. Default is false
34+
peekHeight?: number // optional Android parameter to set the collapsed sheet height.
3435
}
3536

3637
export abstract class ViewWithBottomSheetBase extends View {

src/bottomsheet/bottomsheet.android.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { applyMixins } from '@nativescript-community/ui-material-core';
2-
import { AndroidActivityBackPressedEventData, Application, View, fromObject } from '@nativescript/core';
2+
import { AndroidActivityBackPressedEventData, Application, View, fromObject, Utils } from '@nativescript/core';
33
import { BottomSheetOptions, ViewWithBottomSheetBase } from './bottomsheet-common';
44

55
export { ViewWithBottomSheetBase } from './bottomsheet-common';
@@ -133,6 +133,12 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
133133
// disable peek/collapsed state
134134
behavior.setSkipCollapsed(true);
135135
}
136+
137+
const peekHeight = bottomSheetOptions.options?.peekHeight;
138+
if(peekHeight){
139+
behavior.setState(com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED);
140+
behavior.setPeekHeight(Utils.layout.toDevicePixels(peekHeight));
141+
}
136142

137143
if (owner && !owner.isLoaded) {
138144
owner.callLoaded();

0 commit comments

Comments
 (0)