@bigbinary/neetoui-rn 3.1.4 → 3.2.0
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.
|
@@ -7,7 +7,7 @@ export type AlertButton = {
|
|
|
7
7
|
export type AlertParams = {
|
|
8
8
|
title: string;
|
|
9
9
|
description?: string;
|
|
10
|
-
/** When true (default), backdrop tap
|
|
10
|
+
/** When true (default), backdrop tap, swipe-down and Android back dismiss the sheet. */
|
|
11
11
|
isCancelable?: boolean;
|
|
12
12
|
/**
|
|
13
13
|
* First button is the full-width primary action; the rest render as
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../../../src/components/Alert/Alert.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAQF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;;iBAsII,WAAW;CAHhC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Pressable, View } from "react-native";
|
|
2
|
+
import { BackHandler, Pressable, View } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
BottomSheetBackdrop,
|
|
5
5
|
BottomSheetModal,
|
|
@@ -21,7 +21,7 @@ export type AlertButton = {
|
|
|
21
21
|
export type AlertParams = {
|
|
22
22
|
title: string;
|
|
23
23
|
description?: string;
|
|
24
|
-
/** When true (default), backdrop tap
|
|
24
|
+
/** When true (default), backdrop tap, swipe-down and Android back dismiss the sheet. */
|
|
25
25
|
isCancelable?: boolean;
|
|
26
26
|
/**
|
|
27
27
|
* First button is the full-width primary action; the rest render as
|
|
@@ -88,6 +88,23 @@ export const Alert = () => {
|
|
|
88
88
|
}
|
|
89
89
|
}, [isVisible]);
|
|
90
90
|
|
|
91
|
+
// gorhom leaves Android back alone, so without this the press falls
|
|
92
|
+
// through to the navigator and pops the screen underneath the sheet.
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!isVisible) return undefined;
|
|
95
|
+
|
|
96
|
+
const subscription = BackHandler.addEventListener(
|
|
97
|
+
"hardwareBackPress",
|
|
98
|
+
() => {
|
|
99
|
+
if (isCancelable) setIsVisible(false);
|
|
100
|
+
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return () => subscription.remove();
|
|
106
|
+
}, [isVisible, isCancelable]);
|
|
107
|
+
|
|
91
108
|
const hide = () => setIsVisible(false);
|
|
92
109
|
|
|
93
110
|
// Fires for every close path — button press, backdrop tap, swipe down and
|