@klyftig/mobile-ui 1.3.3 → 1.3.5
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/package.json +1 -1
- package/src/components/CenterDialog.tsx +88 -0
- package/src/components/GlassList.tsx +60 -1
- package/src/index.ts +3 -1
package/package.json
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Modal,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
KeyboardAvoidingView,
|
|
8
|
+
Platform,
|
|
9
|
+
StyleProp,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { useTheme } from '../hooks/useTheme';
|
|
13
|
+
|
|
14
|
+
export interface CenterDialogProps {
|
|
15
|
+
visible: boolean;
|
|
16
|
+
/** Called on backdrop tap and hardware back. */
|
|
17
|
+
onDismiss: () => void;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
/** Wrap the overlay in a KeyboardAvoidingView — use when the dialog hosts text inputs. */
|
|
20
|
+
avoidKeyboard?: boolean;
|
|
21
|
+
/** Disable tap-outside-to-dismiss. Hardware back still calls onDismiss. */
|
|
22
|
+
dismissable?: boolean;
|
|
23
|
+
/** Accessibility label for the tap-to-dismiss backdrop. */
|
|
24
|
+
backdropAccessibilityLabel?: string;
|
|
25
|
+
/** Styles merged into the white card (e.g. `{ alignItems: 'center' }`). */
|
|
26
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Centered alert-style modal: dimmed scrim with tap-to-dismiss + a rounded white card.
|
|
31
|
+
* Callers own the card's content; this only provides the shared shell.
|
|
32
|
+
*/
|
|
33
|
+
export function CenterDialog({
|
|
34
|
+
visible,
|
|
35
|
+
onDismiss,
|
|
36
|
+
children,
|
|
37
|
+
avoidKeyboard = false,
|
|
38
|
+
dismissable = true,
|
|
39
|
+
backdropAccessibilityLabel,
|
|
40
|
+
contentStyle,
|
|
41
|
+
}: CenterDialogProps) {
|
|
42
|
+
const { colors } = useTheme();
|
|
43
|
+
const Overlay = avoidKeyboard ? KeyboardAvoidingView : View;
|
|
44
|
+
const overlayProps = avoidKeyboard
|
|
45
|
+
? { behavior: Platform.OS === 'ios' ? ('padding' as const) : undefined }
|
|
46
|
+
: {};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Modal visible={visible} transparent animationType="fade" onRequestClose={onDismiss}>
|
|
50
|
+
<Overlay style={styles.overlay} {...overlayProps}>
|
|
51
|
+
<TouchableOpacity
|
|
52
|
+
style={styles.backdrop}
|
|
53
|
+
activeOpacity={1}
|
|
54
|
+
onPress={dismissable ? onDismiss : undefined}
|
|
55
|
+
disabled={!dismissable}
|
|
56
|
+
accessibilityRole="button"
|
|
57
|
+
accessibilityLabel={backdropAccessibilityLabel}
|
|
58
|
+
/>
|
|
59
|
+
<View style={[styles.content, { backgroundColor: colors.background.card }, contentStyle]}>
|
|
60
|
+
{children}
|
|
61
|
+
</View>
|
|
62
|
+
</Overlay>
|
|
63
|
+
</Modal>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
overlay: {
|
|
69
|
+
flex: 1,
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
},
|
|
73
|
+
backdrop: {
|
|
74
|
+
...StyleSheet.absoluteFillObject,
|
|
75
|
+
backgroundColor: 'rgba(0,0,0,0.4)',
|
|
76
|
+
},
|
|
77
|
+
content: {
|
|
78
|
+
borderRadius: 20,
|
|
79
|
+
padding: 24,
|
|
80
|
+
width: '85%',
|
|
81
|
+
maxWidth: 360,
|
|
82
|
+
shadowColor: '#000',
|
|
83
|
+
shadowOffset: { width: 0, height: 4 },
|
|
84
|
+
shadowOpacity: 0.15,
|
|
85
|
+
shadowRadius: 12,
|
|
86
|
+
elevation: 8,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TouchableOpacity, Text, View, StyleSheet } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, Text, View, StyleSheet, Switch } from 'react-native';
|
|
3
3
|
import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
|
|
4
4
|
import { useTheme } from '../hooks/useTheme';
|
|
5
5
|
|
|
@@ -12,6 +12,16 @@ interface GlassListItemProps {
|
|
|
12
12
|
style?: any;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
interface GlassToggleItemProps {
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
leftIcon?: string;
|
|
19
|
+
value: boolean;
|
|
20
|
+
onValueChange: (next: boolean) => void;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
style?: any;
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
export const GlassListItem: React.FC<GlassListItemProps> = ({
|
|
16
26
|
title,
|
|
17
27
|
description,
|
|
@@ -61,6 +71,52 @@ export const GlassListItem: React.FC<GlassListItemProps> = ({
|
|
|
61
71
|
return content;
|
|
62
72
|
};
|
|
63
73
|
|
|
74
|
+
// A list row that ends in a native Switch instead of a chevron/icon. The
|
|
75
|
+
// switch turns the theme's success green when on. Use this for settings
|
|
76
|
+
// toggles so the on/off state reads clearly (GlassListItem's rightIcon is a
|
|
77
|
+
// static tertiary-gray glyph and can't convey toggle state).
|
|
78
|
+
export const GlassToggleItem: React.FC<GlassToggleItemProps> = ({
|
|
79
|
+
title,
|
|
80
|
+
description,
|
|
81
|
+
leftIcon,
|
|
82
|
+
value,
|
|
83
|
+
onValueChange,
|
|
84
|
+
disabled,
|
|
85
|
+
style,
|
|
86
|
+
}) => {
|
|
87
|
+
const { colors } = useTheme();
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View
|
|
91
|
+
style={[
|
|
92
|
+
styles.listItem,
|
|
93
|
+
{ backgroundColor: colors.background.card, borderColor: colors.border.light },
|
|
94
|
+
style,
|
|
95
|
+
]}
|
|
96
|
+
>
|
|
97
|
+
<View style={styles.listItemContent}>
|
|
98
|
+
{leftIcon && (
|
|
99
|
+
<Icon name={leftIcon} size={24} color={colors.icon.primary} style={styles.leftIcon} />
|
|
100
|
+
)}
|
|
101
|
+
<View style={styles.textContainer}>
|
|
102
|
+
<Text style={[styles.title, { color: colors.text.primary }]}>{title}</Text>
|
|
103
|
+
{description && <Text style={[styles.description, { color: colors.text.secondary }]}>{description}</Text>}
|
|
104
|
+
</View>
|
|
105
|
+
<Switch
|
|
106
|
+
value={value}
|
|
107
|
+
onValueChange={onValueChange}
|
|
108
|
+
disabled={disabled}
|
|
109
|
+
accessibilityLabel={title}
|
|
110
|
+
trackColor={{ false: '#E5E5EA', true: colors.accent.success }}
|
|
111
|
+
thumbColor="#FFFFFF"
|
|
112
|
+
ios_backgroundColor="#E5E5EA"
|
|
113
|
+
style={styles.toggleSwitch}
|
|
114
|
+
/>
|
|
115
|
+
</View>
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
64
120
|
const styles = StyleSheet.create({
|
|
65
121
|
listItem: {
|
|
66
122
|
borderRadius: 16,
|
|
@@ -94,4 +150,7 @@ const styles = StyleSheet.create({
|
|
|
94
150
|
rightIcon: {
|
|
95
151
|
marginLeft: 12,
|
|
96
152
|
},
|
|
153
|
+
toggleSwitch: {
|
|
154
|
+
marginLeft: 12,
|
|
155
|
+
},
|
|
97
156
|
});
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export { GlassCard } from './components/GlassCard';
|
|
|
20
20
|
export { GlassContainer } from './components/GlassContainer';
|
|
21
21
|
export { GlassHeaderBackground } from './components/GlassHeaderBackground';
|
|
22
22
|
export { GlassInput } from './components/GlassInput';
|
|
23
|
-
export { GlassListItem } from './components/GlassList';
|
|
23
|
+
export { GlassListItem, GlassToggleItem } from './components/GlassList';
|
|
24
24
|
export { GlassStatsCard, GlassMacroCard, GlassNutrientRow } from './components/GlassStats';
|
|
25
25
|
export { RadioOption, RadioGroup } from './components/RadioOption';
|
|
26
26
|
export type { RadioOptionProps, RadioGroupProps } from './components/RadioOption';
|
|
@@ -44,6 +44,8 @@ export { WheelPicker } from './components/WheelPicker';
|
|
|
44
44
|
export type { WheelPickerProps } from './components/WheelPicker';
|
|
45
45
|
export { DisclaimerPill } from './components/DisclaimerPill';
|
|
46
46
|
export type { DisclaimerPillProps } from './components/DisclaimerPill';
|
|
47
|
+
export { CenterDialog } from './components/CenterDialog';
|
|
48
|
+
export type { CenterDialogProps } from './components/CenterDialog';
|
|
47
49
|
|
|
48
50
|
// Progress
|
|
49
51
|
export { CircularProgress } from './components/progress/CircularProgress';
|