|
| 1 | +<template> |
| 2 | + <Page> |
| 3 | + <ActionBar :title="title"> |
| 4 | + <NavigationButton text="Back" android.systemIcon="ic_menu_back" @tap="onNavigationButtonTap"></NavigationButton> |
| 5 | + </ActionBar> |
| 6 | + <StackLayout> |
| 7 | + <MDButton id="bottomsheet" text="bottomsheet" @tap="onTap" /> |
| 8 | + <MDButton id="dont_ignore_top_safe_area" text="dont_ignore_top_safe_area" @tap="onTap" /> |
| 9 | + <MDButton id="ignore_bottom_safe_area" text="ignore_bottom_safe_area" @tap="onTap" /> |
| 10 | + <MDButton id="dont_ignore_top_ignore_bottom_safe_area" text="dont_ignore_top_ignore_bottom_safe_area" @tap="onTap" /> |
| 11 | + <MDButton id="bottomsheet-keyboard" text="bottomsheet-keyboard" @tap="onTap" /> |
| 12 | + <MDButton id="bottomsheet-peekheight" text="bottomsheet-peekheight" @tap="onTap" /> |
| 13 | + </StackLayout> |
| 14 | + </Page> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script lang="ts"> |
| 18 | +import { EventData, View } from '@nativescript/core'; |
| 19 | +import * as frameModule from '@nativescript/core/ui/frame'; |
| 20 | +import { NativeScriptVue } from 'nativescript-vue'; |
| 21 | +import Vue from 'vue'; |
| 22 | +import BottomSheetInner from './BottomSheetInner.vue'; |
| 23 | +import BottomSheetInnerKeyboard from './BottomSheetInnerKeyboard.vue'; |
| 24 | +
|
| 25 | +export const title = 'BottomSheet sample'; |
| 26 | +
|
| 27 | +export default Vue.extend({ |
| 28 | + data() { |
| 29 | + return { |
| 30 | + name: 'BottomSheet', |
| 31 | + title |
| 32 | + }; |
| 33 | + }, |
| 34 | + methods: { |
| 35 | + onNavigationButtonTap() { |
| 36 | + frameModule.Frame.topmost().goBack(); |
| 37 | + }, |
| 38 | + onTap(args: EventData) { |
| 39 | + const obj = args.object as View; |
| 40 | + const objId = obj.id; |
| 41 | + console.log('onTap', objId, obj); |
| 42 | + switch (objId) { |
| 43 | + case 'bottomsheet': { |
| 44 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInner, { |
| 45 | + // transparent: true, |
| 46 | + closeCallback: (...args) => { |
| 47 | + console.log('bottom sheet closed', args); |
| 48 | + } |
| 49 | + }); |
| 50 | + break; |
| 51 | + } |
| 52 | + case 'dont_ignore_top_safe_area': { |
| 53 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInner, { |
| 54 | + ignoreTopSafeArea: false, |
| 55 | + // transparent:true, |
| 56 | + closeCallback: (...args) => { |
| 57 | + console.log('bottom sheet closed', args); |
| 58 | + } |
| 59 | + }); |
| 60 | + break; |
| 61 | + } |
| 62 | + case 'ignore_bottom_safe_area': { |
| 63 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInner, { |
| 64 | + // transparent:true, |
| 65 | + ignoreBottomSafeArea: true, |
| 66 | + closeCallback: (...args) => { |
| 67 | + console.log('bottom sheet closed', args); |
| 68 | + } |
| 69 | + }); |
| 70 | + break; |
| 71 | + } |
| 72 | + case 'dont_ignore_top_ignore_bottom_safe_area': { |
| 73 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInner, { |
| 74 | + // transparent:true, |
| 75 | + ignoreTopSafeArea: false, |
| 76 | + ignoreBottomSafeArea: true, |
| 77 | + closeCallback: (...args) => { |
| 78 | + console.log('bottom sheet closed', args); |
| 79 | + } |
| 80 | + }); |
| 81 | + break; |
| 82 | + } |
| 83 | + case 'bottomsheet-keyboard': { |
| 84 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInnerKeyboard, { |
| 85 | + closeCallback: (...args) => { |
| 86 | + console.log('bottom sheet closed', args); |
| 87 | + } |
| 88 | + }); |
| 89 | + break; |
| 90 | + } |
| 91 | + case 'bottomsheet-peekheight': { |
| 92 | + (this as NativeScriptVue).$showBottomSheet(BottomSheetInner, { |
| 93 | + peekHeight: 100, |
| 94 | + trackingScrollView: 'scrollView', |
| 95 | + // transparent: true, |
| 96 | + closeCallback: (...args) => { |
| 97 | + console.log('bottom sheet closed', args); |
| 98 | + } |
| 99 | + }); |
| 100 | + break; |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | +}); |
| 106 | +</script> |
0 commit comments