@klyftig/mobile-ui 1.3.3 → 1.3.4
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/GlassList.tsx +60 -1
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -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';
|