@klyftig/mobile-ui 1.3.5 → 1.3.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klyftig/mobile-ui",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "scripts": {
5
5
  "pack-install": "npm pack && mv klyftig-ui-*.tgz /tmp/klyftig-ui-local.tgz && cd ../../mobile && npm install /tmp/klyftig-ui-local.tgz"
6
6
  },
@@ -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
+ });
@@ -54,19 +54,27 @@ 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;
62
+ /** Diameter of the main button. Defaults to FAB_SIZE (50). */
63
+ size?: number;
59
64
  }
60
65
 
61
66
  export const FAB_SIZE = 50;
62
67
  const SUB_BUTTON_SIZE = 44;
63
68
  const SUB_BUTTON_SPACING = 58;
69
+ // Main icon ≈ 48% of the button diameter (24 at the default 50px).
70
+ const ICON_RATIO = 0.48;
64
71
 
65
72
  // Fallback colors for sub-buttons when no color is specified
66
73
  const ACTION_COLORS = ['#10b981', '#f59e0b', '#0ea5e9', '#8b5cf6', '#ec4899'];
67
74
 
68
- export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress }) => {
75
+ export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, collapsedIcon, overrideOnPress, size = FAB_SIZE }) => {
69
76
  const insets = useSafeAreaInsets();
77
+ const iconSize = Math.round(size * ICON_RATIO);
70
78
  const [isExpanded, setIsExpanded] = useState(false);
71
79
  const expandAnim = useRef(new Animated.Value(0)).current;
72
80
 
@@ -124,8 +132,8 @@ export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress
124
132
  style={[
125
133
  styles.subButtonRow,
126
134
  {
127
- bottom: fabBottom + (FAB_SIZE - SUB_BUTTON_SIZE) / 2,
128
- right: 16 + (FAB_SIZE - SUB_BUTTON_SIZE) / 2,
135
+ bottom: fabBottom + (size - SUB_BUTTON_SIZE) / 2,
136
+ right: 16 + (size - SUB_BUTTON_SIZE) / 2,
129
137
  transform: [{ translateY }, { scale: subButtonScale }],
130
138
  opacity: subButtonOpacity,
131
139
  },
@@ -157,11 +165,11 @@ export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress
157
165
  <AdaptiveGlassView
158
166
  variant="clear"
159
167
  interactive={true}
160
- style={[styles.fabGlass, { bottom: fabBottom, right: 16 }]}
168
+ style={[styles.fabGlass, { bottom: fabBottom, right: 16, width: size, height: size, borderRadius: size / 2 }]}
161
169
  fallbackStyle={styles.fabFallback}
162
170
  >
163
171
  <TouchableOpacity
164
- style={styles.fabTouchable}
172
+ style={[styles.fabTouchable, { borderRadius: size / 2 }]}
165
173
  onPress={overrideOnPress ?? toggle}
166
174
  activeOpacity={0.85}
167
175
  accessibilityRole="button"
@@ -169,8 +177,8 @@ export const FAB: React.FC<FABProps> = ({ actions, overrideIcon, overrideOnPress
169
177
  accessibilityState={{ expanded: overrideOnPress ? undefined : isExpanded }}
170
178
  >
171
179
  <Icon
172
- name={overrideIcon ?? (isExpanded ? 'close' : 'plus')}
173
- size={24}
180
+ name={overrideIcon ?? (isExpanded ? 'close' : (collapsedIcon ?? 'plus'))}
181
+ size={iconSize}
174
182
  color={GLASS_AVAILABLE ? '#1A1A1A' : '#FFFFFF'}
175
183
  />
176
184
  </TouchableOpacity>
@@ -46,7 +46,8 @@ export function ScreenHeader({
46
46
  onPress={onLeftPress}
47
47
  accessibilityLabel={leftAccessibilityLabel}
48
48
  accessibilityRole="button"
49
- hitSlop={8}
49
+ style={styles.leftButton}
50
+ hitSlop={12}
50
51
  >
51
52
  <Icon name={leftIcon as any} size={26} color={colors.icon.primary} />
52
53
  </TouchableOpacity>
@@ -86,10 +87,17 @@ const styles = StyleSheet.create({
86
87
  marginBottom: 8,
87
88
  },
88
89
  side: {
89
- width: 40,
90
+ width: 44,
90
91
  alignItems: 'center',
91
92
  justifyContent: 'center',
92
93
  },
94
+ leftButton: {
95
+ width: 44,
96
+ height: 44,
97
+ alignItems: 'center',
98
+ justifyContent: 'center',
99
+ marginLeft: -9,
100
+ },
93
101
  center: {
94
102
  flex: 1,
95
103
  alignItems: 'center',
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';