react-native-timer-picker 1.0.0 → 1.1.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/README.md +386 -2
- package/package.json +41 -8
- package/dist/components/DurationPicker/DurationPicker.styles.d.ts +0 -26
- package/dist/components/DurationPicker/DurationPicker.styles.js +0 -39
- package/dist/components/DurationPicker/DurationScroll.d.ts +0 -16
- package/dist/components/DurationPicker/DurationScroll.js +0 -121
- package/dist/components/DurationPicker/index.d.ts +0 -27
- package/dist/components/DurationPicker/index.js +0 -55
- package/dist/components/DurationPickerModal.styles.d.ts +0 -23
- package/dist/components/DurationPickerModal.styles.js +0 -40
- package/dist/components/Modal/Modal.styles.d.ts +0 -22
- package/dist/components/Modal/Modal.styles.js +0 -26
- package/dist/components/Modal/index.d.ts +0 -14
- package/dist/components/Modal/index.js +0 -121
- package/dist/components/TimerPicker/DurationScroll.d.ts +0 -16
- package/dist/components/TimerPicker/DurationScroll.js +0 -121
- package/dist/components/TimerPicker/TimerPicker.styles.d.ts +0 -26
- package/dist/components/TimerPicker/TimerPicker.styles.js +0 -40
- package/dist/components/TimerPicker/index.d.ts +0 -27
- package/dist/components/TimerPicker/index.js +0 -56
- package/dist/components/TimerPickerModal.styles.d.ts +0 -23
- package/dist/components/TimerPickerModal.styles.js +0 -41
- package/dist/components/index.d.ts +0 -28
- package/dist/components/index.js +0 -87
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -10
- package/dist/utils/colorToRgba.d.ts +0 -4
- package/dist/utils/colorToRgba.js +0 -48
- package/dist/utils/generateNumbers.d.ts +0 -7
- package/dist/utils/generateNumbers.js +0 -27
- package/dist/utils/padWithZero.d.ts +0 -1
- package/dist/utils/padWithZero.js +0 -12
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
-
if (ar || !(i in from)) {
|
|
28
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
-
ar[i] = from[i];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
var react_1 = __importStar(require("react"));
|
|
36
|
-
var react_native_1 = require("react-native");
|
|
37
|
-
var expo_linear_gradient_1 = require("expo-linear-gradient");
|
|
38
|
-
var generateNumbers_1 = require("../../utils/generateNumbers");
|
|
39
|
-
var colorToRgba_1 = require("../../utils/colorToRgba");
|
|
40
|
-
var DurationScroll = function (_a) {
|
|
41
|
-
var _b, _c, _d, _e;
|
|
42
|
-
var numberOfItems = _a.numberOfItems, label = _a.label, _f = _a.initialIndex, initialIndex = _f === void 0 ? 0 : _f, onDurationChange = _a.onDurationChange, _g = _a.padNumbersWithZero, padNumbersWithZero = _g === void 0 ? false : _g, _h = _a.disableInfiniteScroll, disableInfiniteScroll = _h === void 0 ? false : _h, padWithNItems = _a.padWithNItems, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, styles = _a.styles;
|
|
43
|
-
var flatListRef = (0, react_1.useRef)(null);
|
|
44
|
-
var data = (0, generateNumbers_1.generateNumbers)(numberOfItems, {
|
|
45
|
-
padWithZero: padNumbersWithZero,
|
|
46
|
-
repeatNTimes: 3,
|
|
47
|
-
disableInfiniteScroll: disableInfiniteScroll,
|
|
48
|
-
padWithNItems: padWithNItems,
|
|
49
|
-
});
|
|
50
|
-
var numberOfItemsToShow = 1 + padWithNItems * 2;
|
|
51
|
-
var renderItem = function (_a) {
|
|
52
|
-
var item = _a.item;
|
|
53
|
-
return (<react_native_1.View key={item} style={styles.pickerItemContainer}>
|
|
54
|
-
<react_native_1.Text style={styles.pickerItem}>{item}</react_native_1.Text>
|
|
55
|
-
</react_native_1.View>);
|
|
56
|
-
};
|
|
57
|
-
var onViewableItemsChanged = (0, react_1.useCallback)(function (_a) {
|
|
58
|
-
var _b, _c, _d, _e;
|
|
59
|
-
var viewableItems = _a.viewableItems;
|
|
60
|
-
if (((_b = viewableItems[0]) === null || _b === void 0 ? void 0 : _b.index) &&
|
|
61
|
-
viewableItems[0].index < numberOfItems * 0.5) {
|
|
62
|
-
(_c = flatListRef.current) === null || _c === void 0 ? void 0 : _c.scrollToIndex({
|
|
63
|
-
animated: false,
|
|
64
|
-
index: viewableItems[0].index + numberOfItems,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else if (((_d = viewableItems[0]) === null || _d === void 0 ? void 0 : _d.index) &&
|
|
68
|
-
viewableItems[0].index >= numberOfItems * 2.5) {
|
|
69
|
-
(_e = flatListRef.current) === null || _e === void 0 ? void 0 : _e.scrollToIndex({
|
|
70
|
-
animated: false,
|
|
71
|
-
index: viewableItems[0].index - numberOfItems,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}, []);
|
|
75
|
-
var viewabilityConfigCallbackPairs = (0, react_1.useRef)([
|
|
76
|
-
{
|
|
77
|
-
viewabilityConfig: { viewAreaCoveragePercentThreshold: 25 },
|
|
78
|
-
onViewableItemsChanged: onViewableItemsChanged,
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
return (<react_native_1.View style={{
|
|
82
|
-
height: styles.pickerItemContainer.height * numberOfItemsToShow,
|
|
83
|
-
overflow: "hidden",
|
|
84
|
-
}}>
|
|
85
|
-
<react_native_1.FlatList ref={flatListRef} data={data} getItemLayout={function (_, index) { return ({
|
|
86
|
-
length: styles.pickerItemContainer.height,
|
|
87
|
-
offset: styles.pickerItemContainer.height * index,
|
|
88
|
-
index: index,
|
|
89
|
-
}); }} initialScrollIndex={(initialIndex % numberOfItems) +
|
|
90
|
-
numberOfItems +
|
|
91
|
-
(disableInfiniteScroll ? padWithNItems : 0) -
|
|
92
|
-
(padWithNItems - 1)} windowSize={numberOfItemsToShow} renderItem={renderItem} keyExtractor={function (_, index) { return index.toString(); }} showsVerticalScrollIndicator={false} decelerationRate="fast" scrollEventThrottle={10} snapToAlignment="start"
|
|
93
|
-
// used in place of snapToOffset due to bug on Android
|
|
94
|
-
snapToOffsets={__spreadArray([], Array(data.length), true).map(function (_, i) { return i * styles.pickerItemContainer.height; })} viewabilityConfigCallbackPairs={!disableInfiniteScroll
|
|
95
|
-
? viewabilityConfigCallbackPairs === null || viewabilityConfigCallbackPairs === void 0 ? void 0 : viewabilityConfigCallbackPairs.current
|
|
96
|
-
: undefined} onMomentumScrollEnd={function (e) {
|
|
97
|
-
var newIndex = Math.round(e.nativeEvent.contentOffset.y /
|
|
98
|
-
styles.pickerItemContainer.height);
|
|
99
|
-
onDurationChange((disableInfiniteScroll ? newIndex : newIndex) %
|
|
100
|
-
(numberOfItems + 1));
|
|
101
|
-
}}/>
|
|
102
|
-
<react_native_1.View style={styles.pickerLabelContainer}>
|
|
103
|
-
<react_native_1.Text style={styles.pickerLabel}>{label}</react_native_1.Text>
|
|
104
|
-
</react_native_1.View>
|
|
105
|
-
<expo_linear_gradient_1.LinearGradient colors={[
|
|
106
|
-
(_b = styles.pickerContainer.backgroundColor) !== null && _b !== void 0 ? _b : "white",
|
|
107
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
108
|
-
color: (_c = styles.pickerContainer.backgroundColor) !== null && _c !== void 0 ? _c : "white",
|
|
109
|
-
opacity: 0,
|
|
110
|
-
}),
|
|
111
|
-
]} start={{ x: 1, y: 0.3 }} end={{ x: 1, y: 1 }} {...pickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { top: 0 }]}/>
|
|
112
|
-
<expo_linear_gradient_1.LinearGradient colors={[
|
|
113
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
114
|
-
color: (_d = styles.pickerContainer.backgroundColor) !== null && _d !== void 0 ? _d : "white",
|
|
115
|
-
opacity: 0,
|
|
116
|
-
}),
|
|
117
|
-
(_e = styles.pickerContainer.backgroundColor) !== null && _e !== void 0 ? _e : "white",
|
|
118
|
-
]} start={{ x: 1, y: 0 }} end={{ x: 1, y: 0.7 }} {...pickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { bottom: -1 }]}/>
|
|
119
|
-
</react_native_1.View>);
|
|
120
|
-
};
|
|
121
|
-
exports.default = DurationScroll;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import { LinearGradient } from "expo-linear-gradient";
|
|
4
|
-
import { CustomDurationPickerStyles } from "./DurationPicker.styles";
|
|
5
|
-
export interface DurationPickerProps {
|
|
6
|
-
onDurationChange?: (duration: {
|
|
7
|
-
hours: number;
|
|
8
|
-
minutes: number;
|
|
9
|
-
seconds: number;
|
|
10
|
-
}) => void;
|
|
11
|
-
initialHours?: number;
|
|
12
|
-
initialMinutes?: number;
|
|
13
|
-
initialSeconds?: number;
|
|
14
|
-
hideHours?: boolean;
|
|
15
|
-
hideMinutes?: boolean;
|
|
16
|
-
hideSeconds?: boolean;
|
|
17
|
-
hourLabel?: string;
|
|
18
|
-
minuteLabel?: string;
|
|
19
|
-
secondLabel?: string;
|
|
20
|
-
padWithNItems?: number;
|
|
21
|
-
disableInfiniteScroll?: boolean;
|
|
22
|
-
pickerContainerProps?: React.ComponentProps<typeof View>;
|
|
23
|
-
pickerGradientOverlayProps?: React.ComponentProps<typeof LinearGradient>;
|
|
24
|
-
styles?: CustomDurationPickerStyles;
|
|
25
|
-
}
|
|
26
|
-
declare const DurationPicker: ({ onDurationChange, initialHours, initialMinutes, initialSeconds, hideHours, hideMinutes, hideSeconds, hourLabel, minuteLabel, secondLabel, padWithNItems, disableInfiniteScroll, pickerContainerProps, pickerGradientOverlayProps, styles: customStyles, }: DurationPickerProps) => React.ReactElement;
|
|
27
|
-
export default DurationPicker;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
var react_1 = __importStar(require("react"));
|
|
30
|
-
var react_native_1 = require("react-native");
|
|
31
|
-
var DurationScroll_1 = __importDefault(require("./DurationScroll"));
|
|
32
|
-
var DurationPicker_styles_1 = require("./DurationPicker.styles");
|
|
33
|
-
var DurationPicker = function (_a) {
|
|
34
|
-
var onDurationChange = _a.onDurationChange, _b = _a.initialHours, initialHours = _b === void 0 ? 0 : _b, _c = _a.initialMinutes, initialMinutes = _c === void 0 ? 0 : _c, _d = _a.initialSeconds, initialSeconds = _d === void 0 ? 0 : _d, _e = _a.hideHours, hideHours = _e === void 0 ? false : _e, _f = _a.hideMinutes, hideMinutes = _f === void 0 ? false : _f, _g = _a.hideSeconds, hideSeconds = _g === void 0 ? false : _g, _h = _a.hourLabel, hourLabel = _h === void 0 ? "h" : _h, _j = _a.minuteLabel, minuteLabel = _j === void 0 ? "m" : _j, _k = _a.secondLabel, secondLabel = _k === void 0 ? "s" : _k, _l = _a.padWithNItems, padWithNItems = _l === void 0 ? 1 : _l, _m = _a.disableInfiniteScroll, disableInfiniteScroll = _m === void 0 ? false : _m, pickerContainerProps = _a.pickerContainerProps, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, customStyles = _a.styles;
|
|
35
|
-
var checkedPadWithNItems = padWithNItems >= 0 ? Math.round(padWithNItems) : 0;
|
|
36
|
-
var styles = (0, DurationPicker_styles_1.generateStyles)(customStyles, {
|
|
37
|
-
padWithNItems: checkedPadWithNItems,
|
|
38
|
-
});
|
|
39
|
-
var _o = (0, react_1.useState)(initialHours), selectedHours = _o[0], setSelectedHours = _o[1];
|
|
40
|
-
var _p = (0, react_1.useState)(initialMinutes), selectedMinutes = _p[0], setSelectedMinutes = _p[1];
|
|
41
|
-
var _q = (0, react_1.useState)(initialSeconds), selectedSeconds = _q[0], setSelectedSeconds = _q[1];
|
|
42
|
-
(0, react_1.useEffect)(function () {
|
|
43
|
-
onDurationChange === null || onDurationChange === void 0 ? void 0 : onDurationChange({
|
|
44
|
-
hours: selectedHours,
|
|
45
|
-
minutes: selectedMinutes,
|
|
46
|
-
seconds: selectedSeconds,
|
|
47
|
-
});
|
|
48
|
-
}, [selectedHours, selectedMinutes, selectedSeconds]);
|
|
49
|
-
return (<react_native_1.View {...pickerContainerProps} style={styles.pickerContainer}>
|
|
50
|
-
{!hideHours ? (<DurationScroll_1.default numberOfItems={23} label={hourLabel} initialIndex={initialHours} onDurationChange={setSelectedHours} pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
51
|
-
{!hideMinutes ? (<DurationScroll_1.default numberOfItems={59} label={minuteLabel} initialIndex={initialMinutes} onDurationChange={setSelectedMinutes} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
52
|
-
{!hideSeconds ? (<DurationScroll_1.default numberOfItems={59} label={secondLabel} initialIndex={initialSeconds} onDurationChange={setSelectedSeconds} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
53
|
-
</react_native_1.View>);
|
|
54
|
-
};
|
|
55
|
-
exports.default = DurationPicker;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CustomDurationPickerStyles } from "./DurationPicker/DurationPicker.styles";
|
|
2
|
-
export interface CustomDurationPickerModalStyles extends CustomDurationPickerStyles {
|
|
3
|
-
container?: any;
|
|
4
|
-
contentContainer?: any;
|
|
5
|
-
pickerContainer?: any;
|
|
6
|
-
pickerLabel?: any;
|
|
7
|
-
pickerItemContainer?: any;
|
|
8
|
-
pickerItem?: any;
|
|
9
|
-
buttonContainer?: any;
|
|
10
|
-
button?: any;
|
|
11
|
-
cancelButton?: any;
|
|
12
|
-
confirmButton?: any;
|
|
13
|
-
modalTitle?: any;
|
|
14
|
-
}
|
|
15
|
-
export declare const generateStyles: (customStyles: CustomDurationPickerModalStyles | undefined) => {
|
|
16
|
-
container: any;
|
|
17
|
-
contentContainer: any;
|
|
18
|
-
buttonContainer: any;
|
|
19
|
-
button: any;
|
|
20
|
-
cancelButton: any;
|
|
21
|
-
confirmButton: any;
|
|
22
|
-
modalTitle: any;
|
|
23
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.generateStyles = void 0;
|
|
15
|
-
var react_native_1 = require("react-native");
|
|
16
|
-
var DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
17
|
-
var DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
18
|
-
var LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
19
|
-
var LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
20
|
-
var generateStyles = function (customStyles) {
|
|
21
|
-
var _a, _b, _c, _d;
|
|
22
|
-
return react_native_1.StyleSheet.create({
|
|
23
|
-
container: __assign({ flex: 1, justifyContent: "center", alignItems: "center" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.container),
|
|
24
|
-
contentContainer: __assign({ backgroundColor: ((_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.backgroundColor) !== null && _a !== void 0 ? _a : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
25
|
-
? DARK_MODE_BACKGROUND_COLOR
|
|
26
|
-
: LIGHT_MODE_BACKGROUND_COLOR, justifyContent: "center", alignItems: "center", borderRadius: 20, padding: 20 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.contentContainer),
|
|
27
|
-
buttonContainer: __assign({ flexDirection: "row", marginTop: 25 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.buttonContainer),
|
|
28
|
-
button: __assign({ marginHorizontal: 12, paddingVertical: 10, paddingHorizontal: 20, borderWidth: 1, borderRadius: 10, fontSize: 16, overflow: "hidden" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.button),
|
|
29
|
-
cancelButton: __assign({ borderColor: "gray", color: ((_b = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _b !== void 0 ? _b : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
30
|
-
? DARK_MODE_TEXT_COLOR
|
|
31
|
-
: "gray", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "gray" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.cancelButton),
|
|
32
|
-
confirmButton: __assign({ borderColor: "green", color: ((_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _c !== void 0 ? _c : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
33
|
-
? DARK_MODE_TEXT_COLOR
|
|
34
|
-
: "green", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "green" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.confirmButton),
|
|
35
|
-
modalTitle: __assign({ fontSize: 24, fontWeight: "bold", marginBottom: 15, color: ((_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _d !== void 0 ? _d : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
36
|
-
? DARK_MODE_TEXT_COLOR
|
|
37
|
-
: LIGHT_MODE_TEXT_COLOR }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.modalTitle),
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.generateStyles = generateStyles;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const styles: {
|
|
2
|
-
container: {
|
|
3
|
-
position: "absolute";
|
|
4
|
-
top: number;
|
|
5
|
-
left: number;
|
|
6
|
-
right: number;
|
|
7
|
-
bottom: number;
|
|
8
|
-
};
|
|
9
|
-
backdrop: {
|
|
10
|
-
position: "absolute";
|
|
11
|
-
top: number;
|
|
12
|
-
bottom: number;
|
|
13
|
-
left: number;
|
|
14
|
-
right: number;
|
|
15
|
-
backgroundColor: string;
|
|
16
|
-
opacity: number;
|
|
17
|
-
};
|
|
18
|
-
content: {
|
|
19
|
-
flex: number;
|
|
20
|
-
justifyContent: "flex-end";
|
|
21
|
-
};
|
|
22
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.styles = void 0;
|
|
4
|
-
var react_native_1 = require("react-native");
|
|
5
|
-
exports.styles = react_native_1.StyleSheet.create({
|
|
6
|
-
container: {
|
|
7
|
-
position: "absolute",
|
|
8
|
-
top: 0,
|
|
9
|
-
left: 0,
|
|
10
|
-
right: 0,
|
|
11
|
-
bottom: 0,
|
|
12
|
-
},
|
|
13
|
-
backdrop: {
|
|
14
|
-
position: "absolute",
|
|
15
|
-
top: 0,
|
|
16
|
-
bottom: 0,
|
|
17
|
-
left: 0,
|
|
18
|
-
right: 0,
|
|
19
|
-
backgroundColor: "black",
|
|
20
|
-
opacity: 0,
|
|
21
|
-
},
|
|
22
|
-
content: {
|
|
23
|
-
flex: 1,
|
|
24
|
-
justifyContent: "flex-end",
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface ModalProps {
|
|
3
|
-
children?: React.ReactElement;
|
|
4
|
-
onOverlayPress?: () => void;
|
|
5
|
-
onHide?: () => void;
|
|
6
|
-
isVisible?: boolean;
|
|
7
|
-
animationDuration?: number;
|
|
8
|
-
overlayOpacity?: number;
|
|
9
|
-
modalProps?: any;
|
|
10
|
-
contentStyle?: any;
|
|
11
|
-
overlayStyle?: any;
|
|
12
|
-
}
|
|
13
|
-
export declare const Modal: ({ children, onOverlayPress, onHide, isVisible, animationDuration, overlayOpacity, modalProps, contentStyle, overlayStyle, }: ModalProps) => React.ReactElement;
|
|
14
|
-
export default Modal;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Modal = void 0;
|
|
27
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
-
var react_1 = __importStar(require("react"));
|
|
29
|
-
var react_native_1 = require("react-native");
|
|
30
|
-
var Modal_styles_1 = require("./Modal.styles");
|
|
31
|
-
var Modal = function (_a) {
|
|
32
|
-
var children = _a.children, onOverlayPress = _a.onOverlayPress, onHide = _a.onHide, _b = _a.isVisible, isVisible = _b === void 0 ? false : _b, _c = _a.animationDuration, animationDuration = _c === void 0 ? 300 : _c, _d = _a.overlayOpacity, overlayOpacity = _d === void 0 ? 0.4 : _d, modalProps = _a.modalProps, contentStyle = _a.contentStyle, overlayStyle = _a.overlayStyle;
|
|
33
|
-
var _e = (0, react_1.useState)(react_native_1.Dimensions.get("window").height), screenHeight = _e[0], setScreenHeight = _e[1];
|
|
34
|
-
var _f = (0, react_1.useState)(react_native_1.Dimensions.get("window").width), screenWidth = _f[0], setScreenWidth = _f[1];
|
|
35
|
-
var isMounted = (0, react_1.useRef)(false);
|
|
36
|
-
var animatedOpacity = (0, react_1.useRef)(new react_native_1.Animated.Value(0));
|
|
37
|
-
var handleDimensionsUpdate = function (dimensionsUpdate) {
|
|
38
|
-
var updatedScreenWidth = dimensionsUpdate.window.width;
|
|
39
|
-
var updateadScreenHeight = dimensionsUpdate.window.height;
|
|
40
|
-
if (updatedScreenWidth !== screenWidth ||
|
|
41
|
-
updateadScreenHeight !== screenHeight) {
|
|
42
|
-
setScreenHeight(updateadScreenHeight);
|
|
43
|
-
setScreenWidth(updatedScreenWidth);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
(0, react_1.useEffect)(function () {
|
|
47
|
-
isMounted.current = true;
|
|
48
|
-
if (isVisible) {
|
|
49
|
-
show();
|
|
50
|
-
}
|
|
51
|
-
var deviceEventEmitter = react_native_1.DeviceEventEmitter.addListener("didUpdateDimensions", handleDimensionsUpdate);
|
|
52
|
-
return function () {
|
|
53
|
-
deviceEventEmitter.remove();
|
|
54
|
-
isMounted.current = false;
|
|
55
|
-
};
|
|
56
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
-
}, []);
|
|
58
|
-
var backdropAnimatedStyle = {
|
|
59
|
-
opacity: animatedOpacity.current.interpolate({
|
|
60
|
-
inputRange: [0, 1],
|
|
61
|
-
outputRange: [0, overlayOpacity],
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
var contentAnimatedStyle = {
|
|
65
|
-
transform: [
|
|
66
|
-
{
|
|
67
|
-
translateY: animatedOpacity.current.interpolate({
|
|
68
|
-
inputRange: [0, 1],
|
|
69
|
-
outputRange: [screenHeight, 0],
|
|
70
|
-
extrapolate: "clamp",
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
var show = (0, react_1.useCallback)(function () {
|
|
76
|
-
react_native_1.Animated.timing(animatedOpacity.current, {
|
|
77
|
-
easing: react_native_1.Easing.inOut(react_native_1.Easing.quad),
|
|
78
|
-
// Using native driver in the modal makes the content flash
|
|
79
|
-
useNativeDriver: false,
|
|
80
|
-
duration: animationDuration,
|
|
81
|
-
toValue: 1,
|
|
82
|
-
}).start();
|
|
83
|
-
}, [animationDuration]);
|
|
84
|
-
var hide = (0, react_1.useCallback)(function () {
|
|
85
|
-
react_native_1.Animated.timing(animatedOpacity.current, {
|
|
86
|
-
easing: react_native_1.Easing.inOut(react_native_1.Easing.quad),
|
|
87
|
-
// Using native driver in the modal makes the content flash
|
|
88
|
-
useNativeDriver: false,
|
|
89
|
-
duration: animationDuration,
|
|
90
|
-
toValue: 0,
|
|
91
|
-
}).start(function () {
|
|
92
|
-
if (isMounted.current) {
|
|
93
|
-
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}, [animationDuration, onHide]);
|
|
97
|
-
(0, react_1.useEffect)(function () {
|
|
98
|
-
if (isVisible) {
|
|
99
|
-
show();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
hide();
|
|
103
|
-
}
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
}, [isVisible]);
|
|
106
|
-
return (<react_native_1.Modal transparent animationType="fade" visible={isVisible} {...modalProps}>
|
|
107
|
-
<react_native_1.TouchableWithoutFeedback onPress={onOverlayPress}>
|
|
108
|
-
<react_native_1.Animated.View style={[
|
|
109
|
-
Modal_styles_1.styles.backdrop,
|
|
110
|
-
backdropAnimatedStyle,
|
|
111
|
-
{ width: screenWidth, height: screenHeight },
|
|
112
|
-
overlayStyle,
|
|
113
|
-
]}/>
|
|
114
|
-
</react_native_1.TouchableWithoutFeedback>
|
|
115
|
-
<react_native_1.Animated.View style={[Modal_styles_1.styles.content, contentAnimatedStyle, contentStyle]} pointerEvents="box-none">
|
|
116
|
-
{children}
|
|
117
|
-
</react_native_1.Animated.View>
|
|
118
|
-
</react_native_1.Modal>);
|
|
119
|
-
};
|
|
120
|
-
exports.Modal = Modal;
|
|
121
|
-
exports.default = exports.Modal;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { LinearGradient } from "expo-linear-gradient";
|
|
3
|
-
import { generateStyles } from "./TimerPicker.styles";
|
|
4
|
-
interface DurationScrollProps {
|
|
5
|
-
numberOfItems: number;
|
|
6
|
-
label?: string;
|
|
7
|
-
initialIndex?: number;
|
|
8
|
-
onDurationChange: (duration: number) => void;
|
|
9
|
-
padNumbersWithZero?: boolean;
|
|
10
|
-
disableInfiniteScroll?: boolean;
|
|
11
|
-
padWithNItems: number;
|
|
12
|
-
pickerGradientOverlayProps?: React.ComponentProps<typeof LinearGradient>;
|
|
13
|
-
styles: ReturnType<typeof generateStyles>;
|
|
14
|
-
}
|
|
15
|
-
declare const DurationScroll: ({ numberOfItems, label, initialIndex, onDurationChange, padNumbersWithZero, disableInfiniteScroll, padWithNItems, pickerGradientOverlayProps, styles, }: DurationScrollProps) => React.ReactElement;
|
|
16
|
-
export default DurationScroll;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
-
if (ar || !(i in from)) {
|
|
28
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
-
ar[i] = from[i];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
var react_1 = __importStar(require("react"));
|
|
36
|
-
var react_native_1 = require("react-native");
|
|
37
|
-
var expo_linear_gradient_1 = require("expo-linear-gradient");
|
|
38
|
-
var generateNumbers_1 = require("../../utils/generateNumbers");
|
|
39
|
-
var colorToRgba_1 = require("../../utils/colorToRgba");
|
|
40
|
-
var DurationScroll = function (_a) {
|
|
41
|
-
var _b, _c, _d, _e;
|
|
42
|
-
var numberOfItems = _a.numberOfItems, label = _a.label, _f = _a.initialIndex, initialIndex = _f === void 0 ? 0 : _f, onDurationChange = _a.onDurationChange, _g = _a.padNumbersWithZero, padNumbersWithZero = _g === void 0 ? false : _g, _h = _a.disableInfiniteScroll, disableInfiniteScroll = _h === void 0 ? false : _h, padWithNItems = _a.padWithNItems, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, styles = _a.styles;
|
|
43
|
-
var flatListRef = (0, react_1.useRef)(null);
|
|
44
|
-
var data = (0, generateNumbers_1.generateNumbers)(numberOfItems, {
|
|
45
|
-
padWithZero: padNumbersWithZero,
|
|
46
|
-
repeatNTimes: 3,
|
|
47
|
-
disableInfiniteScroll: disableInfiniteScroll,
|
|
48
|
-
padWithNItems: padWithNItems,
|
|
49
|
-
});
|
|
50
|
-
var numberOfItemsToShow = 1 + padWithNItems * 2;
|
|
51
|
-
var renderItem = function (_a) {
|
|
52
|
-
var item = _a.item;
|
|
53
|
-
return (<react_native_1.View key={item} style={styles.pickerItemContainer}>
|
|
54
|
-
<react_native_1.Text style={styles.pickerItem}>{item}</react_native_1.Text>
|
|
55
|
-
</react_native_1.View>);
|
|
56
|
-
};
|
|
57
|
-
var onViewableItemsChanged = (0, react_1.useCallback)(function (_a) {
|
|
58
|
-
var _b, _c, _d, _e;
|
|
59
|
-
var viewableItems = _a.viewableItems;
|
|
60
|
-
if (((_b = viewableItems[0]) === null || _b === void 0 ? void 0 : _b.index) &&
|
|
61
|
-
viewableItems[0].index < numberOfItems * 0.5) {
|
|
62
|
-
(_c = flatListRef.current) === null || _c === void 0 ? void 0 : _c.scrollToIndex({
|
|
63
|
-
animated: false,
|
|
64
|
-
index: viewableItems[0].index + numberOfItems,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else if (((_d = viewableItems[0]) === null || _d === void 0 ? void 0 : _d.index) &&
|
|
68
|
-
viewableItems[0].index >= numberOfItems * 2.5) {
|
|
69
|
-
(_e = flatListRef.current) === null || _e === void 0 ? void 0 : _e.scrollToIndex({
|
|
70
|
-
animated: false,
|
|
71
|
-
index: viewableItems[0].index - numberOfItems,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}, [numberOfItems]);
|
|
75
|
-
var viewabilityConfigCallbackPairs = (0, react_1.useRef)([
|
|
76
|
-
{
|
|
77
|
-
viewabilityConfig: { viewAreaCoveragePercentThreshold: 25 },
|
|
78
|
-
onViewableItemsChanged: onViewableItemsChanged,
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
return (<react_native_1.View style={{
|
|
82
|
-
height: styles.pickerItemContainer.height * numberOfItemsToShow,
|
|
83
|
-
overflow: "hidden",
|
|
84
|
-
}}>
|
|
85
|
-
<react_native_1.FlatList ref={flatListRef} data={data} getItemLayout={function (_, index) { return ({
|
|
86
|
-
length: styles.pickerItemContainer.height,
|
|
87
|
-
offset: styles.pickerItemContainer.height * index,
|
|
88
|
-
index: index,
|
|
89
|
-
}); }} initialScrollIndex={(initialIndex % numberOfItems) +
|
|
90
|
-
numberOfItems +
|
|
91
|
-
(disableInfiniteScroll ? padWithNItems : 0) -
|
|
92
|
-
(padWithNItems - 1)} windowSize={numberOfItemsToShow} renderItem={renderItem} keyExtractor={function (_, index) { return index.toString(); }} showsVerticalScrollIndicator={false} decelerationRate="fast" scrollEventThrottle={10} snapToAlignment="start"
|
|
93
|
-
// used in place of snapToOffset due to bug on Android
|
|
94
|
-
snapToOffsets={__spreadArray([], Array(data.length), true).map(function (_, i) { return i * styles.pickerItemContainer.height; })} viewabilityConfigCallbackPairs={!disableInfiniteScroll
|
|
95
|
-
? viewabilityConfigCallbackPairs === null || viewabilityConfigCallbackPairs === void 0 ? void 0 : viewabilityConfigCallbackPairs.current
|
|
96
|
-
: undefined} onMomentumScrollEnd={function (e) {
|
|
97
|
-
var newIndex = Math.round(e.nativeEvent.contentOffset.y /
|
|
98
|
-
styles.pickerItemContainer.height);
|
|
99
|
-
onDurationChange((disableInfiniteScroll ? newIndex : newIndex) %
|
|
100
|
-
(numberOfItems + 1));
|
|
101
|
-
}}/>
|
|
102
|
-
<react_native_1.View style={styles.pickerLabelContainer}>
|
|
103
|
-
<react_native_1.Text style={styles.pickerLabel}>{label}</react_native_1.Text>
|
|
104
|
-
</react_native_1.View>
|
|
105
|
-
<expo_linear_gradient_1.LinearGradient colors={[
|
|
106
|
-
(_b = styles.pickerContainer.backgroundColor) !== null && _b !== void 0 ? _b : "white",
|
|
107
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
108
|
-
color: (_c = styles.pickerContainer.backgroundColor) !== null && _c !== void 0 ? _c : "white",
|
|
109
|
-
opacity: 0,
|
|
110
|
-
}),
|
|
111
|
-
]} start={{ x: 1, y: 0.3 }} end={{ x: 1, y: 1 }} {...pickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { top: 0 }]}/>
|
|
112
|
-
<expo_linear_gradient_1.LinearGradient colors={[
|
|
113
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
114
|
-
color: (_d = styles.pickerContainer.backgroundColor) !== null && _d !== void 0 ? _d : "white",
|
|
115
|
-
opacity: 0,
|
|
116
|
-
}),
|
|
117
|
-
(_e = styles.pickerContainer.backgroundColor) !== null && _e !== void 0 ? _e : "white",
|
|
118
|
-
]} start={{ x: 1, y: 0 }} end={{ x: 1, y: 0.7 }} {...pickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { bottom: -1 }]}/>
|
|
119
|
-
</react_native_1.View>);
|
|
120
|
-
};
|
|
121
|
-
exports.default = DurationScroll;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface CustomTimerPickerStyles {
|
|
2
|
-
theme?: "light" | "dark";
|
|
3
|
-
backgroundColor?: string;
|
|
4
|
-
textColor?: string;
|
|
5
|
-
pickerContainer?: any;
|
|
6
|
-
pickerLabelContainer?: any;
|
|
7
|
-
pickerLabel?: any;
|
|
8
|
-
pickerItemContainer?: any;
|
|
9
|
-
pickerItem?: any;
|
|
10
|
-
buttonContainer?: any;
|
|
11
|
-
button?: any;
|
|
12
|
-
cancelButton?: any;
|
|
13
|
-
confirmButton?: any;
|
|
14
|
-
modalTitle?: any;
|
|
15
|
-
pickerGradientOverlay?: any;
|
|
16
|
-
}
|
|
17
|
-
export declare const generateStyles: (customStyles: CustomTimerPickerStyles | undefined, options: {
|
|
18
|
-
padWithNItems: number;
|
|
19
|
-
}) => {
|
|
20
|
-
pickerContainer: any;
|
|
21
|
-
pickerLabelContainer: any;
|
|
22
|
-
pickerLabel: any;
|
|
23
|
-
pickerItemContainer: any;
|
|
24
|
-
pickerItem: any;
|
|
25
|
-
pickerGradientOverlay: any;
|
|
26
|
-
};
|