@nativescript-community/ui-bottomsheet 0.0.0-stage → 1.0.1
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.
- package/CHANGELOG.md +22 -0
- package/LICENSE +201 -0
- package/README.md +213 -2
- package/index-common.d.ts +93 -0
- package/index-common.js +140 -0
- package/index-common.js.map +1 -0
- package/index.android.d.ts +44 -0
- package/index.android.js +475 -0
- package/index.android.js.map +1 -0
- package/index.d.ts +100 -0
- package/index.ios.d.ts +114 -0
- package/index.ios.js +678 -0
- package/index.ios.js.map +1 -0
- package/ios-layout.d.ts +64 -0
- package/ios-layout.js +356 -0
- package/ios-layout.js.map +1 -0
- package/package.json +49 -5
- package/platforms/android/include.gradle +6 -0
- package/platforms/android/java/com/nativescript/ui/bottomsheet/BottomSheetDialog.java +38 -0
- package/platforms/android/java/com/nativescript/ui/bottomsheet/BottomSheetDialogFragment.java +73 -0
- package/platforms/android/native-api-usage.json +36 -0
- package/platforms/ios/native-api-usage.json +11 -0
- package/svelte/index.d.ts +24 -0
- package/svelte/index.js +48 -0
- package/svelte/index.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
package com.nativescript.ui.bottomsheet;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.ViewGroup;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
|
|
7
|
+
public class BottomSheetDialogFragment extends com.google.android.material.bottomsheet.BottomSheetDialogFragment {
|
|
8
|
+
public interface BottomSheetDialogFragmentListener {
|
|
9
|
+
android.app.Dialog onCreateDialog(BottomSheetDialogFragment fragment, android.os.Bundle savedInstanceState);
|
|
10
|
+
|
|
11
|
+
android.view.View onCreateView(BottomSheetDialogFragment fragment, android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
|
12
|
+
android.os.Bundle savedInstanceState);
|
|
13
|
+
|
|
14
|
+
void onStart(BottomSheetDialogFragment fragment);
|
|
15
|
+
|
|
16
|
+
void onDismiss(BottomSheetDialogFragment fragment, android.content.DialogInterface dialog);
|
|
17
|
+
|
|
18
|
+
void onDestroy(BottomSheetDialogFragment fragment);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BottomSheetDialogFragmentListener listener;
|
|
22
|
+
|
|
23
|
+
public BottomSheetDialogFragment() {
|
|
24
|
+
super();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public void setListener(BottomSheetDialogFragmentListener listener) {
|
|
28
|
+
this.listener = listener;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
|
|
33
|
+
if (listener != null) {
|
|
34
|
+
return listener.onCreateDialog(this, savedInstanceState);
|
|
35
|
+
}
|
|
36
|
+
return super.onCreateDialog(savedInstanceState);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
|
41
|
+
android.os.Bundle savedInstanceState) {
|
|
42
|
+
if (listener != null) {
|
|
43
|
+
return listener.onCreateView(this, inflater, container, savedInstanceState);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return super.onCreateView(inflater, container, savedInstanceState);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public void onStart() {
|
|
51
|
+
super.onStart();
|
|
52
|
+
if (listener != null) {
|
|
53
|
+
listener.onStart(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
public void onDismiss(android.content.DialogInterface dialog) {
|
|
59
|
+
super.onDismiss(dialog);
|
|
60
|
+
if (listener != null) {
|
|
61
|
+
listener.onDismiss(this, dialog);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Override
|
|
66
|
+
public void onDestroy() {
|
|
67
|
+
super.onDestroy();
|
|
68
|
+
if (listener != null) {
|
|
69
|
+
listener.onDestroy(this);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uses": [
|
|
3
|
+
"android.app:Dialog",
|
|
4
|
+
"android.content:Context",
|
|
5
|
+
"android.content:DialogInterface",
|
|
6
|
+
"android.os:Bundle",
|
|
7
|
+
"android.view:Gravity",
|
|
8
|
+
"android.view:LayoutInflater",
|
|
9
|
+
"android.view:MotionEvent",
|
|
10
|
+
"android.view:View",
|
|
11
|
+
"android.view:View.OnClickListener",
|
|
12
|
+
"android.view:View.OnTouchListener",
|
|
13
|
+
"android.view:ViewGroup",
|
|
14
|
+
"android.view:ViewGroup.LayoutParams",
|
|
15
|
+
"android.view:ViewGroup.MarginLayoutParams",
|
|
16
|
+
"android.view:Window",
|
|
17
|
+
"android.view:WindowManager",
|
|
18
|
+
"android.view:WindowManager.LayoutParams",
|
|
19
|
+
"android.webkit:WebView",
|
|
20
|
+
"android.widget:AbsListView",
|
|
21
|
+
"android.widget:FrameLayout",
|
|
22
|
+
"android.widget:FrameLayout.LayoutParams",
|
|
23
|
+
"android.widget:ScrollView",
|
|
24
|
+
"androidx.appcompat.app:AppCompatActivity",
|
|
25
|
+
"androidx.core.view:ViewCompat",
|
|
26
|
+
"com.google.android.material.bottomsheet:BottomSheetBehavior",
|
|
27
|
+
"com.google.android.material.bottomsheet:BottomSheetBehavior.BottomSheetCallback",
|
|
28
|
+
"com.google.android.material.bottomsheet:BottomSheetDialogFragment",
|
|
29
|
+
"com.google.android.material.bottomsheet:BottomSheetDragHandleView",
|
|
30
|
+
"com.google.android.material.shape:MaterialShapeDrawable",
|
|
31
|
+
"com.nativescript.ui.bottomsheet:BottomSheetDialog",
|
|
32
|
+
"com.nativescript.ui.bottomsheet:BottomSheetDialog.BottomSheetDialogListener",
|
|
33
|
+
"com.nativescript.ui.bottomsheet:BottomSheetDialogFragment",
|
|
34
|
+
"com.nativescript.ui.bottomsheet:BottomSheetDialogFragment.BottomSheetDialogFragmentListener"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BottomSheetOptions } from '../index';
|
|
2
|
+
import { View } from '@nativescript/core';
|
|
3
|
+
import { NativeViewElementNode } from '@nativescript-community/svelte-native/dom';
|
|
4
|
+
import { PageSpec } from '@nativescript-community/svelte-native/dom/navigation';
|
|
5
|
+
declare module '@nativescript/core/ui/core/view' {
|
|
6
|
+
interface View {
|
|
7
|
+
closeBottomSheet(...args: any): void;
|
|
8
|
+
showBottomSheet(options: BottomSheetOptions): View;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export interface SvelteShowBottomSheetOptions<U> extends Omit<BottomSheetOptions, 'view'> {
|
|
12
|
+
view: PageSpec<U>;
|
|
13
|
+
parent?: NativeViewElementNode<View> | View;
|
|
14
|
+
props?: U;
|
|
15
|
+
}
|
|
16
|
+
interface ComponentInstanceInfo {
|
|
17
|
+
element: NativeViewElementNode<View>;
|
|
18
|
+
viewInstance: SvelteComponent;
|
|
19
|
+
}
|
|
20
|
+
export declare function resolveComponentElement<T>(viewSpec: typeof SvelteComponent<T>, props?: any): ComponentInstanceInfo;
|
|
21
|
+
export declare function showBottomSheet<T = any, U = any>(modalOptions: SvelteShowBottomSheetOptions<U>): Promise<T>;
|
|
22
|
+
export declare function closeBottomSheet(result?: any): void;
|
|
23
|
+
export declare function isBottomSheetOpened(): boolean;
|
|
24
|
+
export {};
|
package/svelte/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Frame, View } from '@nativescript/core';
|
|
2
|
+
import { createElement } from '@nativescript-community/svelte-native/dom';
|
|
3
|
+
const modalStack = [];
|
|
4
|
+
export function resolveComponentElement(viewSpec, props) {
|
|
5
|
+
const dummy = createElement('fragment', window.document);
|
|
6
|
+
const viewInstance = new viewSpec({ target: dummy, props });
|
|
7
|
+
const element = dummy.firstElement();
|
|
8
|
+
return { element, viewInstance };
|
|
9
|
+
}
|
|
10
|
+
export function showBottomSheet(modalOptions) {
|
|
11
|
+
const { view, parent, props = {}, ...options } = modalOptions;
|
|
12
|
+
// Get this before any potential new frames are created by component below
|
|
13
|
+
const modalLauncher = (parent && (parent instanceof View ? parent : parent.nativeView)) || Frame.topmost().currentPage;
|
|
14
|
+
const componentInstanceInfo = resolveComponentElement(view, props);
|
|
15
|
+
let modalView = componentInstanceInfo.element.nativeView;
|
|
16
|
+
return new Promise(async (resolve, reject) => {
|
|
17
|
+
let resolved = false;
|
|
18
|
+
const closeCallback = (result) => {
|
|
19
|
+
if (resolved)
|
|
20
|
+
return;
|
|
21
|
+
resolved = true;
|
|
22
|
+
if (options.closeCallback) {
|
|
23
|
+
options.closeCallback(result, componentInstanceInfo.viewInstance);
|
|
24
|
+
}
|
|
25
|
+
modalStack.pop();
|
|
26
|
+
resolve(result);
|
|
27
|
+
modalView._tearDownUI();
|
|
28
|
+
componentInstanceInfo.viewInstance.$destroy(); // don't let an exception in destroy kill the promise callback
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
modalLauncher.showBottomSheet({ view: modalView, ...options, context: {}, closeCallback });
|
|
32
|
+
modalStack.push(componentInstanceInfo);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
reject(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function closeBottomSheet(result) {
|
|
40
|
+
const modalPageInstanceInfo = modalStack[modalStack.length - 1];
|
|
41
|
+
if (modalPageInstanceInfo) {
|
|
42
|
+
modalPageInstanceInfo.element.nativeView.closeBottomSheet(result);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function isBottomSheetOpened() {
|
|
46
|
+
return modalStack.length > 0;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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O;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBACxB,OAAO,CAAC,aAAa,CAAC,MAAM,EAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;YACrE,CAAC;YACD,UAAU,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,MAAM,CAAC,CAAC;YAChB,SAAS,CAAC,WAAW,EAAE,CAAC;YACxB,qBAAqB,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,8DAA8D;QACjH,CAAC,CAAC;QACF,IAAI,CAAC;YACD,aAAa,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;YAC3F,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAY;IACzC,MAAM,qBAAqB,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAChE,IAAI,qBAAqB,EAAE,CAAC;QACvB,qBAAqB,CAAC,OAAO,CAAC,UAAkB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/E,CAAC;AACL,CAAC;AACD,MAAM,UAAU,mBAAmB;IAC/B,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/ui-bottomsheet/index-common.ts","../../src/ui-bottomsheet/index.android.ts","../../src/ui-bottomsheet/index.d.ts","../../src/ui-bottomsheet/index.ios.ts","../../src/ui-bottomsheet/ios-layout.ts","../../src/ui-bottomsheet/svelte/index.ts","../../references.d.ts","../../tools/references.d.ts","../../src/references.d.ts"],"version":"5.8.3"}
|