@umituz/react-native-design-system 1.15.0 → 2.0.1
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 +26 -19
- package/src/atoms/AtomicAvatar.tsx +161 -0
- package/src/atoms/AtomicButton.tsx +241 -0
- package/src/atoms/AtomicCard.tsx +84 -0
- package/src/atoms/AtomicChip.tsx +226 -0
- package/src/atoms/AtomicDatePicker.tsx +255 -0
- package/src/atoms/AtomicFab.tsx +99 -0
- package/src/atoms/AtomicIcon.tsx +149 -0
- package/src/atoms/AtomicInput.tsx +308 -0
- package/src/atoms/AtomicPicker.tsx +310 -0
- package/src/atoms/AtomicProgress.tsx +149 -0
- package/src/atoms/AtomicText.tsx +55 -0
- package/src/atoms/__tests__/AtomicButton.test.tsx +107 -0
- package/src/atoms/__tests__/AtomicIcon.test.tsx +110 -0
- package/src/atoms/__tests__/AtomicInput.test.tsx +195 -0
- package/src/atoms/datepicker/components/DatePickerButton.tsx +112 -0
- package/src/atoms/datepicker/components/DatePickerModal.tsx +143 -0
- package/src/atoms/fab/styles/fabStyles.ts +98 -0
- package/src/atoms/fab/types/index.ts +88 -0
- package/src/atoms/index.ts +70 -0
- package/src/atoms/input/hooks/useInputState.ts +63 -0
- package/src/atoms/input/styles/inputStylesHelper.ts +120 -0
- package/src/atoms/picker/components/PickerChips.tsx +57 -0
- package/src/atoms/picker/components/PickerModal.tsx +214 -0
- package/src/atoms/picker/styles/pickerStyles.ts +223 -0
- package/src/atoms/picker/types/index.ts +42 -0
- package/src/index.ts +133 -52
- package/src/molecules/ConfirmationModal.tsx +42 -0
- package/src/molecules/ConfirmationModalContent.tsx +87 -0
- package/src/molecules/ConfirmationModalMain.tsx +91 -0
- package/src/molecules/FormField.tsx +155 -0
- package/src/molecules/IconContainer.tsx +79 -0
- package/src/molecules/ListItem.tsx +35 -0
- package/src/molecules/ScreenHeader.tsx +171 -0
- package/src/molecules/SearchBar.tsx +198 -0
- package/src/molecules/confirmation-modal/components.tsx +94 -0
- package/src/molecules/confirmation-modal/index.ts +7 -0
- package/src/molecules/confirmation-modal/styles/confirmationModalStyles.ts +133 -0
- package/src/molecules/confirmation-modal/types/index.ts +41 -0
- package/src/molecules/confirmation-modal/useConfirmationModal.ts +50 -0
- package/src/molecules/index.ts +19 -0
- package/src/molecules/listitem/index.ts +6 -0
- package/src/molecules/listitem/styles/listItemStyles.ts +37 -0
- package/src/molecules/listitem/types/index.ts +21 -0
- package/src/organisms/AppHeader.tsx +136 -0
- package/src/organisms/FormContainer.tsx +169 -0
- package/src/organisms/ScreenLayout.tsx +183 -0
- package/src/organisms/index.ts +31 -0
- package/src/responsive/config.ts +139 -0
- package/src/responsive/deviceDetection.ts +155 -0
- package/src/responsive/gridUtils.ts +79 -0
- package/src/responsive/index.ts +52 -0
- package/src/responsive/platformConstants.ts +98 -0
- package/src/responsive/responsive.ts +61 -0
- package/src/responsive/responsiveLayout.ts +137 -0
- package/src/responsive/responsiveSizing.ts +134 -0
- package/src/responsive/useResponsive.ts +140 -0
- package/src/responsive/validation.ts +158 -0
- package/src/theme/core/BaseTokens.ts +42 -0
- package/src/theme/core/ColorPalette.ts +29 -0
- package/src/theme/core/CustomColors.ts +122 -0
- package/src/theme/core/NavigationTheme.ts +72 -0
- package/src/theme/core/TokenFactory.ts +103 -0
- package/src/theme/core/colors/ColorUtils.ts +53 -0
- package/src/theme/core/colors/DarkColors.ts +146 -0
- package/src/theme/core/colors/LightColors.ts +146 -0
- package/src/theme/core/constants/DesignConstants.ts +31 -0
- package/src/theme/core/themes.ts +118 -0
- package/src/theme/core/tokens/BaseTokens.ts +144 -0
- package/src/theme/core/tokens/Borders.ts +43 -0
- package/src/theme/core/tokens/Sizes.ts +51 -0
- package/src/theme/core/tokens/Spacing.ts +38 -0
- package/src/theme/core/tokens/Typography.ts +143 -0
- package/src/theme/hooks/useAppDesignTokens.ts +45 -0
- package/src/theme/hooks/useCommonStyles.ts +248 -0
- package/src/theme/hooks/useThemedStyles.ts +68 -0
- package/src/theme/index.ts +94 -0
- package/src/theme/infrastructure/globalThemeStore.ts +69 -0
- package/src/theme/infrastructure/storage/ThemeStorage.ts +93 -0
- package/src/theme/infrastructure/stores/themeStore.ts +109 -0
- package/src/typography/__tests__/colorValidationUtils.test.ts +180 -0
- package/src/typography/__tests__/textColorUtils.test.ts +185 -0
- package/src/typography/__tests__/textStyleUtils.test.ts +168 -0
- package/src/typography/domain/entities/TypographyTypes.ts +88 -0
- package/src/typography/index.ts +53 -0
- package/src/typography/presentation/utils/colorValidationUtils.ts +133 -0
- package/src/typography/presentation/utils/textColorUtils.ts +205 -0
- package/src/typography/presentation/utils/textStyleUtils.ts +159 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmationModal Subcomponents
|
|
3
|
+
*
|
|
4
|
+
* Smaller components for the confirmation modal
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { View, ViewStyle, StyleProp } from 'react-native';
|
|
9
|
+
import { AtomicText, AtomicButton, AtomicIcon } from '../../atoms';
|
|
10
|
+
import type { DesignTokens } from '../../theme';
|
|
11
|
+
import {
|
|
12
|
+
getButtonContainerStyle,
|
|
13
|
+
getButtonStyle,
|
|
14
|
+
} from './styles/confirmationModalStyles';
|
|
15
|
+
|
|
16
|
+
export const ConfirmationModalIcon: React.FC<{
|
|
17
|
+
icon: string;
|
|
18
|
+
iconColor: string;
|
|
19
|
+
testID: string;
|
|
20
|
+
}> = ({ icon, iconColor, testID }) => (
|
|
21
|
+
<AtomicIcon
|
|
22
|
+
name={icon}
|
|
23
|
+
size="xl"
|
|
24
|
+
color={iconColor as 'primary' | 'secondary' | 'error' | 'warning' | 'success' | 'surfaceVariant'}
|
|
25
|
+
testID={`${testID}-icon`}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const ConfirmationModalTitle: React.FC<{
|
|
30
|
+
title: string;
|
|
31
|
+
tokens: DesignTokens;
|
|
32
|
+
testID: string;
|
|
33
|
+
}> = ({ title, tokens, testID }) => (
|
|
34
|
+
<AtomicText
|
|
35
|
+
type="titleLarge"
|
|
36
|
+
style={{
|
|
37
|
+
color: tokens.colors.textPrimary,
|
|
38
|
+
textAlign: 'center',
|
|
39
|
+
fontWeight: tokens.typography.bold,
|
|
40
|
+
}}
|
|
41
|
+
testID={`${testID}-title`}
|
|
42
|
+
>
|
|
43
|
+
{title}
|
|
44
|
+
</AtomicText>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const ConfirmationModalMessage: React.FC<{
|
|
48
|
+
message: string;
|
|
49
|
+
tokens: DesignTokens;
|
|
50
|
+
testID: string;
|
|
51
|
+
}> = ({ message, tokens, testID }) => (
|
|
52
|
+
<AtomicText
|
|
53
|
+
type="bodyMedium"
|
|
54
|
+
style={{
|
|
55
|
+
color: tokens.colors.textSecondary,
|
|
56
|
+
textAlign: 'center',
|
|
57
|
+
lineHeight: tokens.typography.bodyMedium.lineHeight,
|
|
58
|
+
}}
|
|
59
|
+
testID={`${testID}-message`}
|
|
60
|
+
>
|
|
61
|
+
{message}
|
|
62
|
+
</AtomicText>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const ConfirmationModalButtons: React.FC<{
|
|
66
|
+
confirmText: string;
|
|
67
|
+
cancelText: string;
|
|
68
|
+
onConfirm: () => void;
|
|
69
|
+
onCancel: () => void;
|
|
70
|
+
confirmButtonStyle: StyleProp<ViewStyle>;
|
|
71
|
+
testID: string;
|
|
72
|
+
}> = ({ confirmText, cancelText, onConfirm, onCancel, confirmButtonStyle, testID }) => (
|
|
73
|
+
<View style={getButtonContainerStyle({} as DesignTokens)}>
|
|
74
|
+
<AtomicButton
|
|
75
|
+
variant="outline"
|
|
76
|
+
size="md"
|
|
77
|
+
onPress={onCancel}
|
|
78
|
+
style={getButtonStyle()}
|
|
79
|
+
testID={`${testID}-cancel-button`}
|
|
80
|
+
>
|
|
81
|
+
{cancelText}
|
|
82
|
+
</AtomicButton>
|
|
83
|
+
|
|
84
|
+
<AtomicButton
|
|
85
|
+
variant="primary"
|
|
86
|
+
size="md"
|
|
87
|
+
onPress={onConfirm}
|
|
88
|
+
style={confirmButtonStyle}
|
|
89
|
+
testID={`${testID}-confirm-button`}
|
|
90
|
+
>
|
|
91
|
+
{confirmText}
|
|
92
|
+
</AtomicButton>
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmationModal Style Utilities
|
|
3
|
+
*
|
|
4
|
+
* Styling functions for confirmation modal component
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ViewStyle } from 'react-native';
|
|
8
|
+
import { ConfirmationModalVariant, ConfirmationModalVariantConfig } from '../types/';
|
|
9
|
+
import type { DesignTokens } from '../../../theme';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get variant configuration (icon and color only)
|
|
13
|
+
* Note: Confirm text is handled in component with translations
|
|
14
|
+
*/
|
|
15
|
+
export const getVariantConfig = (
|
|
16
|
+
variant: ConfirmationModalVariant,
|
|
17
|
+
_tokens: DesignTokens
|
|
18
|
+
): Omit<ConfirmationModalVariantConfig, 'confirmText'> => {
|
|
19
|
+
switch (variant) {
|
|
20
|
+
case 'destructive':
|
|
21
|
+
return {
|
|
22
|
+
icon: 'warning',
|
|
23
|
+
iconColor: 'error',
|
|
24
|
+
};
|
|
25
|
+
case 'warning':
|
|
26
|
+
return {
|
|
27
|
+
icon: 'warning',
|
|
28
|
+
iconColor: 'warning',
|
|
29
|
+
};
|
|
30
|
+
case 'success':
|
|
31
|
+
return {
|
|
32
|
+
icon: 'check-circle',
|
|
33
|
+
iconColor: 'success',
|
|
34
|
+
};
|
|
35
|
+
case 'default':
|
|
36
|
+
default:
|
|
37
|
+
return {
|
|
38
|
+
icon: 'help-circle',
|
|
39
|
+
iconColor: 'primary',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get modal overlay style
|
|
46
|
+
*/
|
|
47
|
+
export const getModalOverlayStyle = (_tokens: DesignTokens): ViewStyle => ({
|
|
48
|
+
flex: 1,
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get backdrop style (invisible layer for dismissing)
|
|
56
|
+
*/
|
|
57
|
+
export const getBackdropStyle = (): ViewStyle => ({
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
top: 0,
|
|
60
|
+
left: 0,
|
|
61
|
+
right: 0,
|
|
62
|
+
bottom: 0,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get modal container style
|
|
67
|
+
*/
|
|
68
|
+
export const getModalContainerStyle = (tokens: DesignTokens): ViewStyle => ({
|
|
69
|
+
width: '85%',
|
|
70
|
+
maxWidth: 400,
|
|
71
|
+
backgroundColor: tokens.colors.surface,
|
|
72
|
+
borderRadius: 16,
|
|
73
|
+
padding: 24,
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
borderWidth: 1,
|
|
76
|
+
borderColor: tokens.colors.outline,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get icon container style
|
|
81
|
+
*/
|
|
82
|
+
export const getIconContainerStyle = (_tokens: DesignTokens): ViewStyle => ({
|
|
83
|
+
marginBottom: 16,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get title container style
|
|
88
|
+
*/
|
|
89
|
+
export const getTitleContainerStyle = (_tokens: DesignTokens): ViewStyle => ({
|
|
90
|
+
marginBottom: 8,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get message container style
|
|
95
|
+
*/
|
|
96
|
+
export const getMessageContainerStyle = (_tokens: DesignTokens): ViewStyle => ({
|
|
97
|
+
marginBottom: 24,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get button container style
|
|
102
|
+
*/
|
|
103
|
+
export const getButtonContainerStyle = (_tokens: DesignTokens): ViewStyle => ({
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
gap: 12,
|
|
106
|
+
width: '100%',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Get button style
|
|
111
|
+
*/
|
|
112
|
+
export const getButtonStyle = (): ViewStyle => ({
|
|
113
|
+
flex: 1,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get confirm button variant based on modal variant
|
|
118
|
+
*/
|
|
119
|
+
export const getConfirmButtonVariant = (
|
|
120
|
+
variant: ConfirmationModalVariant
|
|
121
|
+
): 'primary' | 'secondary' | 'tertiary' | 'outline' | 'ghost' => {
|
|
122
|
+
switch (variant) {
|
|
123
|
+
case 'destructive':
|
|
124
|
+
return 'primary'; // Will use error color
|
|
125
|
+
case 'warning':
|
|
126
|
+
return 'primary'; // Will use warning color
|
|
127
|
+
case 'success':
|
|
128
|
+
return 'primary'; // Will use success color
|
|
129
|
+
case 'default':
|
|
130
|
+
default:
|
|
131
|
+
return 'primary';
|
|
132
|
+
}
|
|
133
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmationModal Types
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewStyle, StyleProp } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export type ConfirmationModalVariant = 'default' | 'destructive' | 'warning' | 'success';
|
|
7
|
+
|
|
8
|
+
export interface ConfirmationModalVariantConfig {
|
|
9
|
+
icon: string;
|
|
10
|
+
iconColor: string;
|
|
11
|
+
confirmText?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ConfirmationModalProps {
|
|
15
|
+
/** Modal visibility */
|
|
16
|
+
visible: boolean;
|
|
17
|
+
/** Modal title */
|
|
18
|
+
title: string;
|
|
19
|
+
/** Modal message */
|
|
20
|
+
message: string;
|
|
21
|
+
/** Confirm button text */
|
|
22
|
+
confirmText?: string;
|
|
23
|
+
/** Cancel button text */
|
|
24
|
+
cancelText?: string;
|
|
25
|
+
/** Confirm callback */
|
|
26
|
+
onConfirm: () => void;
|
|
27
|
+
/** Cancel/Close callback */
|
|
28
|
+
onCancel: () => void;
|
|
29
|
+
/** Modal variant for styling */
|
|
30
|
+
variant?: ConfirmationModalVariant;
|
|
31
|
+
/** Optional icon */
|
|
32
|
+
icon?: string;
|
|
33
|
+
/** Test ID */
|
|
34
|
+
testID?: string;
|
|
35
|
+
/** Show backdrop */
|
|
36
|
+
showBackdrop?: boolean;
|
|
37
|
+
/** Allow backdrop dismiss */
|
|
38
|
+
backdropDismissible?: boolean;
|
|
39
|
+
/** Custom style */
|
|
40
|
+
style?: StyleProp<ViewStyle>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmationModal Hook
|
|
3
|
+
*
|
|
4
|
+
* Hook for managing confirmation modal state
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ConfirmationModalProps, ConfirmationModalVariant } from './types';
|
|
9
|
+
|
|
10
|
+
const useConfirmationModalState = () => {
|
|
11
|
+
const [visible, setVisible] = React.useState(false);
|
|
12
|
+
|
|
13
|
+
const showConfirmation = React.useCallback(() => setVisible(true), []);
|
|
14
|
+
const hideConfirmation = React.useCallback(() => setVisible(false), []);
|
|
15
|
+
|
|
16
|
+
return { visible, showConfirmation, hideConfirmation };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const useConfirmationModal = (config: {
|
|
20
|
+
title: string;
|
|
21
|
+
message: string;
|
|
22
|
+
variant?: ConfirmationModalVariant;
|
|
23
|
+
confirmText: string;
|
|
24
|
+
cancelText: string;
|
|
25
|
+
onConfirm: () => void;
|
|
26
|
+
}) => {
|
|
27
|
+
const { visible, showConfirmation, hideConfirmation } = useConfirmationModalState();
|
|
28
|
+
|
|
29
|
+
const handleConfirm = React.useCallback(() => {
|
|
30
|
+
config.onConfirm();
|
|
31
|
+
hideConfirmation();
|
|
32
|
+
}, [config, hideConfirmation]);
|
|
33
|
+
|
|
34
|
+
const confirmationProps: ConfirmationModalProps = React.useMemo(() => ({
|
|
35
|
+
visible,
|
|
36
|
+
title: config.title,
|
|
37
|
+
message: config.message,
|
|
38
|
+
variant: config.variant || 'default',
|
|
39
|
+
confirmText: config.confirmText,
|
|
40
|
+
cancelText: config.cancelText,
|
|
41
|
+
onConfirm: handleConfirm,
|
|
42
|
+
onCancel: hideConfirmation,
|
|
43
|
+
}), [visible, config.title, config.message, config.variant, config.confirmText, config.cancelText, handleConfirm, hideConfirmation]);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
showConfirmation,
|
|
47
|
+
hideConfirmation,
|
|
48
|
+
confirmationProps,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Molecules - Composite UI components
|
|
3
|
+
* Built from atoms following atomic design principles
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Component exports
|
|
7
|
+
export { FormField, type FormFieldProps } from './FormField';
|
|
8
|
+
export { ListItem, type ListItemProps } from './ListItem';
|
|
9
|
+
export { SearchBar, type SearchBarProps } from './SearchBar';
|
|
10
|
+
export { IconContainer } from './IconContainer';
|
|
11
|
+
export { ScreenHeader, type ScreenHeaderProps } from './ScreenHeader';
|
|
12
|
+
export { ConfirmationModal } from './ConfirmationModalMain';
|
|
13
|
+
export { useConfirmationModal } from './confirmation-modal/useConfirmationModal';
|
|
14
|
+
|
|
15
|
+
// Type exports
|
|
16
|
+
export type {
|
|
17
|
+
ConfirmationModalProps,
|
|
18
|
+
ConfirmationModalVariant,
|
|
19
|
+
} from './confirmation-modal/types/';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ListItem Styles
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
5
|
+
import type { DesignTokens } from '../../../theme';
|
|
6
|
+
|
|
7
|
+
export interface ListItemStyles {
|
|
8
|
+
container: ViewStyle;
|
|
9
|
+
disabled: ViewStyle;
|
|
10
|
+
iconContainer: ViewStyle;
|
|
11
|
+
content: ViewStyle;
|
|
12
|
+
subtitle: TextStyle;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getListItemStyles = (tokens: DesignTokens): ListItemStyles => ({
|
|
16
|
+
container: {
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
paddingVertical: tokens.spacing.md,
|
|
20
|
+
paddingHorizontal: tokens.spacing.md,
|
|
21
|
+
backgroundColor: tokens.colors.surface,
|
|
22
|
+
borderRadius: tokens.borders.radius.md,
|
|
23
|
+
minHeight: 56,
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
opacity: tokens.opacity.disabled,
|
|
27
|
+
},
|
|
28
|
+
iconContainer: {
|
|
29
|
+
marginRight: tokens.spacing.md,
|
|
30
|
+
},
|
|
31
|
+
content: {
|
|
32
|
+
flex: 1,
|
|
33
|
+
},
|
|
34
|
+
subtitle: {
|
|
35
|
+
marginTop: tokens.spacing.xs,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ListItem Types
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewStyle } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export interface ListItemProps {
|
|
7
|
+
/** Main title text */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Optional subtitle text */
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
/** Left icon name */
|
|
12
|
+
leftIcon?: string;
|
|
13
|
+
/** Right icon name */
|
|
14
|
+
rightIcon?: string;
|
|
15
|
+
/** Press handler */
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
/** Disabled state */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Custom container style */
|
|
20
|
+
style?: ViewStyle;
|
|
21
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AppHeader Organism - Application Header Component
|
|
3
|
+
*
|
|
4
|
+
* Complex header combining atoms and molecules
|
|
5
|
+
* Generic component suitable for any application
|
|
6
|
+
*
|
|
7
|
+
* Atomic Design Level: ORGANISM
|
|
8
|
+
* Composition: AtomicIcon + AtomicText + AtomicButton
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { View, type ViewStyle } from 'react-native';
|
|
13
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
14
|
+
import { useAppDesignTokens } from '../theme';
|
|
15
|
+
import { AtomicText, AtomicButton, type IconName } from '../atoms';
|
|
16
|
+
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// TYPE DEFINITIONS
|
|
19
|
+
// =============================================================================
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* AppHeader component props
|
|
23
|
+
*
|
|
24
|
+
* leftIcon/rightIcon: Any MaterialIcons name
|
|
25
|
+
* @see https://fonts.google.com/icons
|
|
26
|
+
*/
|
|
27
|
+
export interface AppHeaderProps {
|
|
28
|
+
title: string;
|
|
29
|
+
subtitle?: string;
|
|
30
|
+
leftIcon?: IconName;
|
|
31
|
+
onLeftPress?: () => void;
|
|
32
|
+
rightIcon?: IconName;
|
|
33
|
+
onRightPress?: () => void;
|
|
34
|
+
backgroundColor?: string;
|
|
35
|
+
style?: ViewStyle;
|
|
36
|
+
accessibilityLabel?: string;
|
|
37
|
+
accessibilityHint?: string;
|
|
38
|
+
accessible?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// COMPONENT IMPLEMENTATION
|
|
43
|
+
// =============================================================================
|
|
44
|
+
|
|
45
|
+
export const AppHeader: React.FC<AppHeaderProps> = ({
|
|
46
|
+
title,
|
|
47
|
+
subtitle,
|
|
48
|
+
leftIcon,
|
|
49
|
+
onLeftPress,
|
|
50
|
+
rightIcon,
|
|
51
|
+
onRightPress,
|
|
52
|
+
backgroundColor,
|
|
53
|
+
style,
|
|
54
|
+
}) => {
|
|
55
|
+
const tokens = useAppDesignTokens();
|
|
56
|
+
const bgColor = backgroundColor || tokens.colors.surface;
|
|
57
|
+
const styles = createAppHeaderStyles(tokens);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<SafeAreaView style={[styles.safeArea, { backgroundColor: bgColor }]}>
|
|
61
|
+
<View style={[styles.container, { backgroundColor: bgColor }, style]}>
|
|
62
|
+
{/* Left Action */}
|
|
63
|
+
<View style={styles.leftContainer}>
|
|
64
|
+
{leftIcon && onLeftPress && (
|
|
65
|
+
<AtomicButton
|
|
66
|
+
variant="text"
|
|
67
|
+
size="sm"
|
|
68
|
+
onPress={onLeftPress}
|
|
69
|
+
icon={leftIcon}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
</View>
|
|
73
|
+
|
|
74
|
+
{/* Title Section */}
|
|
75
|
+
<View style={styles.titleContainer}>
|
|
76
|
+
<AtomicText type="titleLarge" color="primary" numberOfLines={1}>
|
|
77
|
+
{title}
|
|
78
|
+
</AtomicText>
|
|
79
|
+
{subtitle && (
|
|
80
|
+
<AtomicText type="bodySmall" color="secondary" numberOfLines={1}>
|
|
81
|
+
{subtitle}
|
|
82
|
+
</AtomicText>
|
|
83
|
+
)}
|
|
84
|
+
</View>
|
|
85
|
+
|
|
86
|
+
{/* Right Action */}
|
|
87
|
+
<View style={styles.rightContainer}>
|
|
88
|
+
{rightIcon && onRightPress && (
|
|
89
|
+
<AtomicButton
|
|
90
|
+
variant="text"
|
|
91
|
+
size="sm"
|
|
92
|
+
onPress={onRightPress}
|
|
93
|
+
icon={rightIcon}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
</SafeAreaView>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// =============================================================================
|
|
103
|
+
// STYLES
|
|
104
|
+
// =============================================================================
|
|
105
|
+
|
|
106
|
+
const createAppHeaderStyles = (tokens: ReturnType<typeof useAppDesignTokens>) => ({
|
|
107
|
+
safeArea: {
|
|
108
|
+
backgroundColor: tokens.colors.surface,
|
|
109
|
+
} as ViewStyle,
|
|
110
|
+
container: {
|
|
111
|
+
flexDirection: 'row' as const,
|
|
112
|
+
alignItems: 'center' as const,
|
|
113
|
+
justifyContent: 'space-between' as const,
|
|
114
|
+
paddingHorizontal: tokens.spacing.md,
|
|
115
|
+
paddingVertical: tokens.spacing.sm,
|
|
116
|
+
minHeight: tokens.iconSizes.xl + tokens.spacing.md,
|
|
117
|
+
} as ViewStyle,
|
|
118
|
+
leftContainer: {
|
|
119
|
+
width: tokens.iconSizes.xl + tokens.spacing.sm,
|
|
120
|
+
alignItems: 'flex-start' as const,
|
|
121
|
+
} as ViewStyle,
|
|
122
|
+
titleContainer: {
|
|
123
|
+
flex: 1,
|
|
124
|
+
alignItems: 'center' as const,
|
|
125
|
+
paddingHorizontal: tokens.spacing.sm,
|
|
126
|
+
} as ViewStyle,
|
|
127
|
+
rightContainer: {
|
|
128
|
+
width: tokens.iconSizes.xl + tokens.spacing.sm,
|
|
129
|
+
alignItems: 'flex-start' as const,
|
|
130
|
+
} as ViewStyle,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// =============================================================================
|
|
134
|
+
// EXPORTS
|
|
135
|
+
// =============================================================================
|
|
136
|
+
|