native-pytech 1.0.57 → 1.0.58
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Button, Text } from '@expo/ui/swift-ui';
|
|
2
2
|
import { frame, font, foregroundStyle, buttonStyle, controlSize, disabled } from '@expo/ui/swift-ui/modifiers';
|
|
3
|
-
import React, { memo, useMemo } from 'react';
|
|
3
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
4
4
|
import { useWindowDimensions } from 'react-native';
|
|
5
5
|
export default memo(({ text, onPress, onSubmit, backgroundColorPage, enabled = true, themeColor = 'default' }) => {
|
|
6
6
|
const { width } = useWindowDimensions();
|
|
@@ -14,7 +14,15 @@ export default memo(({ text, onPress, onSubmit, backgroundColorPage, enabled = t
|
|
|
14
14
|
font({ weight: 'semibold' }),
|
|
15
15
|
...(enabled ? [foregroundStyle('#85fffd')] : []), // colors.especiales.celeste
|
|
16
16
|
], [width, enabled]);
|
|
17
|
-
|
|
17
|
+
const _onPress = useCallback(async () => {
|
|
18
|
+
if (onPress) {
|
|
19
|
+
const result = await onPress();
|
|
20
|
+
if (!result)
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
onSubmit?.();
|
|
24
|
+
}, [onPress, onSubmit]);
|
|
25
|
+
return (<Button onPress={_onPress} modifiers={modifiers}>
|
|
18
26
|
<Text modifiers={modifiersText}>
|
|
19
27
|
{text}
|
|
20
28
|
</Text>
|
package/package.json
CHANGED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import colors from '../../constants';
|
|
2
|
-
import { GlassView } from 'expo-glass-effect';
|
|
3
|
-
import { useApp } from "../../../../../libs/providers/App";
|
|
4
|
-
import { memo, useCallback, useMemo, useState } from 'react';
|
|
5
|
-
import { ActivityIndicator, Pressable, StyleSheet } from 'react-native';
|
|
6
|
-
import Utils from '../../../../../libs/constants/utils';
|
|
7
|
-
import Text from './Text';
|
|
8
|
-
export default memo(({ text, onPress, onSubmit, backgroundColorPage, enabled = true, themeColor = 'default' }) => {
|
|
9
|
-
const { colorScheme } = useApp();
|
|
10
|
-
const Theme = colors.theme[colorScheme];
|
|
11
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
12
|
-
const _onPress = useCallback(async () => {
|
|
13
|
-
if (isLoading)
|
|
14
|
-
return;
|
|
15
|
-
if (onPress) {
|
|
16
|
-
setIsLoading(true);
|
|
17
|
-
const result = await onPress();
|
|
18
|
-
setIsLoading(false);
|
|
19
|
-
if (!result)
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
onSubmit?.();
|
|
23
|
-
}, [onPress, onSubmit]);
|
|
24
|
-
const backgroundColor = useCallback((pressed) => {
|
|
25
|
-
return enabled ?
|
|
26
|
-
(themeColor === 'default' ? Utils.adjustLightness(colors.especiales.azul, -10) : undefined)
|
|
27
|
-
: Theme.colorButtonFooterDisabled;
|
|
28
|
-
}, [enabled, themeColor]);
|
|
29
|
-
const color = useMemo(() => themeColor === 'default' ? colors.especiales.celeste : Theme.text2, [themeColor]);
|
|
30
|
-
return (<Pressable disabled={!enabled} onPress={_onPress} style={{ width: '100%' }}>
|
|
31
|
-
<GlassView glassEffectStyle={themeColor === 'default' ? "clear" : "regular"} isInteractive={enabled} style={[
|
|
32
|
-
styles.button,
|
|
33
|
-
{ backgroundColor: backgroundColor(true) }
|
|
34
|
-
]}>
|
|
35
|
-
{!isLoading ? (<Text text={text} enabled={enabled} themeColor={themeColor}/>) : (<ActivityIndicator size='small' style={{ margin: 'auto' }} color={color}/>)}
|
|
36
|
-
</GlassView>
|
|
37
|
-
</Pressable>);
|
|
38
|
-
});
|
|
39
|
-
const styles = StyleSheet.create({
|
|
40
|
-
button: {
|
|
41
|
-
borderRadius: 99,
|
|
42
|
-
paddingHorizontal: 20,
|
|
43
|
-
paddingVertical: 15.5,
|
|
44
|
-
alignItems: 'center',
|
|
45
|
-
justifyContent: 'center',
|
|
46
|
-
width: '100%',
|
|
47
|
-
},
|
|
48
|
-
text: {
|
|
49
|
-
fontSize: 17,
|
|
50
|
-
fontWeight: '600',
|
|
51
|
-
}
|
|
52
|
-
});
|