@klyftig/mobile-ui 1.3.6 → 1.3.8
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
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, TouchableOpacity, ActivityIndicator, StyleSheet } from 'react-native';
|
|
3
|
+
import { MaterialCommunityIcons as Icon } from '@expo/vector-icons';
|
|
4
|
+
import { useTheme } from '../hooks/useTheme';
|
|
5
|
+
|
|
6
|
+
export type CircleIconButtonVariant = 'secondary' | 'primary';
|
|
7
|
+
|
|
8
|
+
export interface CircleIconButtonProps {
|
|
9
|
+
icon: string;
|
|
10
|
+
onPress: () => void;
|
|
11
|
+
/** `secondary` (default) = flat iOS-style translucent-grey dismiss circle.
|
|
12
|
+
* `primary` = solid brand-dark circle with a white glyph. */
|
|
13
|
+
variant?: CircleIconButtonVariant;
|
|
14
|
+
/** Diameter. Defaults to 40. */
|
|
15
|
+
size?: number;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
accessibilityLabel?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Circular icon button for modal chrome (close, save, etc.). The `secondary`
|
|
23
|
+
* variant renders the iOS-standard dismiss affordance — a flat translucent-grey
|
|
24
|
+
* circle with a soft grey glyph, no border or shadow.
|
|
25
|
+
*/
|
|
26
|
+
export const CircleIconButton: React.FC<CircleIconButtonProps> = ({
|
|
27
|
+
icon,
|
|
28
|
+
onPress,
|
|
29
|
+
variant = 'secondary',
|
|
30
|
+
size = 40,
|
|
31
|
+
loading = false,
|
|
32
|
+
disabled = false,
|
|
33
|
+
accessibilityLabel,
|
|
34
|
+
}) => {
|
|
35
|
+
const { colors } = useTheme();
|
|
36
|
+
const isPrimary = variant === 'primary';
|
|
37
|
+
const iconSize = Math.round(size * 0.5);
|
|
38
|
+
return (
|
|
39
|
+
<TouchableOpacity
|
|
40
|
+
onPress={onPress}
|
|
41
|
+
disabled={disabled || loading}
|
|
42
|
+
activeOpacity={0.7}
|
|
43
|
+
accessibilityRole="button"
|
|
44
|
+
accessibilityLabel={accessibilityLabel}
|
|
45
|
+
>
|
|
46
|
+
<View
|
|
47
|
+
style={[
|
|
48
|
+
styles.base,
|
|
49
|
+
{ width: size, height: size, borderRadius: size / 2 },
|
|
50
|
+
isPrimary ? { backgroundColor: colors.text.primary } : styles.secondary,
|
|
51
|
+
]}
|
|
52
|
+
>
|
|
53
|
+
{loading ? (
|
|
54
|
+
<ActivityIndicator size="small" color={isPrimary ? '#FFFFFF' : colors.text.primary} />
|
|
55
|
+
) : (
|
|
56
|
+
<Icon name={icon as any} size={iconSize} color={isPrimary ? '#FFFFFF' : 'rgba(60, 60, 67, 0.6)'} />
|
|
57
|
+
)}
|
|
58
|
+
</View>
|
|
59
|
+
</TouchableOpacity>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const styles = StyleSheet.create({
|
|
64
|
+
base: {
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
overflow: 'hidden',
|
|
68
|
+
},
|
|
69
|
+
secondary: {
|
|
70
|
+
backgroundColor: 'rgba(120, 120, 128, 0.16)',
|
|
71
|
+
},
|
|
72
|
+
});
|
package/src/components/FAB.tsx
CHANGED
|
@@ -54,6 +54,9 @@ interface FABProps {
|
|
|
54
54
|
actions: FABAction[];
|
|
55
55
|
/** Override main button icon (e.g. 'camera' when input is focused) */
|
|
56
56
|
overrideIcon?: string;
|
|
57
|
+
/** Icon for the collapsed (menu-closed) state. Defaults to 'plus'. Unlike
|
|
58
|
+
* `overrideIcon`, this still morphs to 'close' when the menu is expanded. */
|
|
59
|
+
collapsedIcon?: string;
|
|
57
60
|
/** If set, tapping the main button calls this directly instead of toggling the menu */
|
|
58
61
|
overrideOnPress?: () => void;
|
|
59
62
|
/** Diameter of the main button. Defaults to FAB_SIZE (50). */
|
|
@@ -69,7 +72,7 @@ const ICON_RATIO = 0.48;
|
|
|
69
72
|
// Fallback colors for sub-buttons when no color is specified
|
|
70
73
|
const ACTION_COLORS = ['#10b981', '#f59e0b', '#0ea5e9', '#8b5cf6', '#ec4899'];
|
|
71
74
|
|
|
72
|
-
export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress, size = FAB_SIZE }) => {
|
|
75
|
+
export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, collapsedIcon, overrideOnPress, size = FAB_SIZE }) => {
|
|
73
76
|
const insets = useSafeAreaInsets();
|
|
74
77
|
const iconSize = Math.round(size * ICON_RATIO);
|
|
75
78
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
@@ -174,7 +177,7 @@ export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress
|
|
|
174
177
|
accessibilityState={{ expanded: overrideOnPress ? undefined : isExpanded }}
|
|
175
178
|
>
|
|
176
179
|
<Icon
|
|
177
|
-
name={overrideIcon ?? (isExpanded ? 'close' : 'plus')}
|
|
180
|
+
name={overrideIcon ?? (isExpanded ? 'close' : (collapsedIcon ?? 'plus'))}
|
|
178
181
|
size={iconSize}
|
|
179
182
|
color={GLASS_AVAILABLE ? '#1A1A1A' : '#FFFFFF'}
|
|
180
183
|
/>
|
|
@@ -28,6 +28,13 @@ interface GlassInputProps {
|
|
|
28
28
|
selectTextOnFocus?: boolean;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// When a single-line input is not focused, anchor the selection to the start so
|
|
32
|
+
// iOS/Android scroll a value longer than the field to reveal its BEGINNING
|
|
33
|
+
// ("Carrot - Cream Sauce…") instead of its tail ("…Sauce - pistachio nuts").
|
|
34
|
+
// Only applied while unfocused — during editing the selection stays uncontrolled
|
|
35
|
+
// so the caret follows taps and typing normally.
|
|
36
|
+
const SELECTION_START = { start: 0, end: 0 } as const;
|
|
37
|
+
|
|
31
38
|
const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
32
39
|
label,
|
|
33
40
|
value,
|
|
@@ -98,6 +105,7 @@ const GlassInputComponent: React.FC<GlassInputProps> = ({
|
|
|
98
105
|
onFocus={handleFocus}
|
|
99
106
|
onBlur={handleBlur}
|
|
100
107
|
selectTextOnFocus={selectTextOnFocus}
|
|
108
|
+
selection={!isFocused && !multiline ? SELECTION_START : undefined}
|
|
101
109
|
multiline={multiline}
|
|
102
110
|
numberOfLines={numberOfLines}
|
|
103
111
|
textAlignVertical={multiline ? 'top' : undefined}
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { AdaptiveGlassView } from './components/AdaptiveGlassView';
|
|
|
16
16
|
export { ErrorBoundary } from './components/ErrorBoundary';
|
|
17
17
|
export { FAB, FAB_SIZE } from './components/FAB';
|
|
18
18
|
export { GlassButton } from './components/GlassButton';
|
|
19
|
+
export { CircleIconButton } from './components/CircleIconButton';
|
|
20
|
+
export type { CircleIconButtonProps, CircleIconButtonVariant } from './components/CircleIconButton';
|
|
19
21
|
export { GlassCard } from './components/GlassCard';
|
|
20
22
|
export { GlassContainer } from './components/GlassContainer';
|
|
21
23
|
export { GlassHeaderBackground } from './components/GlassHeaderBackground';
|