@klyftig/mobile-ui 1.3.4 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klyftig/mobile-ui",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
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,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
+ });
package/src/index.ts CHANGED
@@ -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';