atlas-design-system 1.2.0
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/.eslintrc.js +33 -0
- package/README.md +5 -0
- package/example/README.md +50 -0
- package/example/app/_layout.tsx +32 -0
- package/example/app/buttonGallery.tsx +49 -0
- package/example/app/dateTimeInputGallery.tsx +28 -0
- package/example/app/index.tsx +58 -0
- package/example/app/selectInputGallery.tsx +45 -0
- package/example/app/sheetGallery.tsx +36 -0
- package/example/app/switchToggleInputGallery.tsx +28 -0
- package/example/app/textGallery.tsx +68 -0
- package/example/app/textInputGallery.tsx +28 -0
- package/example/app.json +37 -0
- package/example/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/example/assets/images/adaptive-icon.png +0 -0
- package/example/assets/images/favicon.png +0 -0
- package/example/assets/images/icon.png +0 -0
- package/example/assets/images/partial-react-logo.png +0 -0
- package/example/assets/images/react-logo.png +0 -0
- package/example/assets/images/react-logo@2x.png +0 -0
- package/example/assets/images/react-logo@3x.png +0 -0
- package/example/assets/images/splash.png +0 -0
- package/example/babel.config.js +6 -0
- package/example/components/Collapsible.tsx +41 -0
- package/example/components/ExternalLink.tsx +24 -0
- package/example/components/ParallaxScrollView.tsx +76 -0
- package/example/components/ThemedText.tsx +60 -0
- package/example/components/ThemedView.tsx +14 -0
- package/example/components/__tests__/ThemedText-test.tsx +10 -0
- package/example/components/__tests__/__snapshots__/ThemedText-test.tsx.snap +24 -0
- package/example/components/navigation/TabBarIcon.js +24 -0
- package/example/components/navigation/TabBarIcon.tsx +9 -0
- package/example/constants/Colors.ts +26 -0
- package/example/hooks/useColorScheme.ts +1 -0
- package/example/hooks/useThemeColor.ts +22 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/Podfile +58 -0
- package/example/ios/Podfile.lock +1603 -0
- package/example/ios/Podfile.properties.json +4 -0
- package/example/ios/example/AppDelegate.h +7 -0
- package/example/ios/example/AppDelegate.mm +62 -0
- package/example/ios/example/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json +14 -0
- package/example/ios/example/Images.xcassets/Contents.json +6 -0
- package/example/ios/example/Images.xcassets/SplashScreen.imageset/Contents.json +21 -0
- package/example/ios/example/Images.xcassets/SplashScreen.imageset/image.png +0 -0
- package/example/ios/example/Images.xcassets/SplashScreenBackground.imageset/Contents.json +21 -0
- package/example/ios/example/Images.xcassets/SplashScreenBackground.imageset/image.png +0 -0
- package/example/ios/example/Info.plist +81 -0
- package/example/ios/example/PrivacyInfo.xcprivacy +48 -0
- package/example/ios/example/SplashScreen.storyboard +51 -0
- package/example/ios/example/Supporting/Expo.plist +12 -0
- package/example/ios/example/example-Bridging-Header.h +3 -0
- package/example/ios/example/example.entitlements +5 -0
- package/example/ios/example/main.m +10 -0
- package/example/ios/example/noop-file.swift +4 -0
- package/example/ios/example.xcodeproj/project.pbxproj +555 -0
- package/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme +88 -0
- package/example/ios/example.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/metro.config.js +34 -0
- package/example/package.json +53 -0
- package/example/react-native.config.js +9 -0
- package/example/scripts/reset-project.js +73 -0
- package/example/tsconfig.json +17 -0
- package/example/yarn.lock +8571 -0
- package/package.json +49 -0
- package/src/components/Button/Button.tsx +110 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Button/styles/ButtonStyle.ts +47 -0
- package/src/components/DateTimeInput/index.tsx +172 -0
- package/src/components/DragHandle/index.tsx +49 -0
- package/src/components/MenuItemDescription/MenuItemDescription.tsx +34 -0
- package/src/components/MenuItemDescription/index.ts +1 -0
- package/src/components/NavigationListRow/index.tsx +68 -0
- package/src/components/SelectInput/SelectInput.tsx +191 -0
- package/src/components/SelectInput/index.ts +2 -0
- package/src/components/SelectInput/types.ts +5 -0
- package/src/components/Sheet/index.tsx +189 -0
- package/src/components/SwitchToggle/index.tsx +31 -0
- package/src/components/Text/Text.tsx +74 -0
- package/src/components/Text/index.tsx +2 -0
- package/src/components/TextInput/TextInput.tsx +241 -0
- package/src/components/TextInput/index.tsx +2 -0
- package/src/components/TitleBar/TitleBar.tsx +150 -0
- package/src/components/TitleBar/index.ts +2 -0
- package/src/components/index.ts +11 -0
- package/src/context/index.ts +6 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTheme.ts +7 -0
- package/src/hooks/useThemedStyle.ts +18 -0
- package/src/index.ts +5 -0
- package/src/shared/styles/index.ts +33 -0
- package/src/themes/AtlasLightTheme.ts +90 -0
- package/src/themes/index.ts +1 -0
- package/src/types/index.ts +3 -0
- package/src/types/theme.ts +45 -0
- package/src/types/typography.ts +14 -0
- package/tsconfig.json +111 -0
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "atlas-design-system",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "A react native design system for the Atlas workout app",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"repository": "https://github.com/juancstlm/AtlasDesignSystem",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint 'src/**/*.{ts,tsx}' && tsc --noEmit",
|
|
9
|
+
"test": "test",
|
|
10
|
+
"example": "yarn --cwd example",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"patch": "npm version patch",
|
|
13
|
+
"minor": "npm version minor",
|
|
14
|
+
"watch": "tsc --watch"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"native"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@react-native-community/datetimepicker": "~8.0.1",
|
|
22
|
+
"moment": "^2.29.0",
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-native": "0.74.3",
|
|
25
|
+
"react-native-reanimated": "~3.10.1",
|
|
26
|
+
"react-native-safe-area-context": "^4.10.9",
|
|
27
|
+
"react-native-vector-icons": "^10.1.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@react-native-community/datetimepicker": ">=3.5.2",
|
|
31
|
+
"react": ">=17.0.1",
|
|
32
|
+
"react-native": ">=0.64.1",
|
|
33
|
+
"react-native-reanimated": ">=3.0.0",
|
|
34
|
+
"react-native-safe-area-context": ">=4.0.0",
|
|
35
|
+
"react-native-vector-icons": ">=10.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "^18.2.0",
|
|
39
|
+
"@types/react-native-vector-icons": "^6.4.18",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
41
|
+
"@typescript-eslint/parser": "^8.4.0",
|
|
42
|
+
"eslint": "^8.19.0",
|
|
43
|
+
"eslint-plugin-react": "^7.35.2",
|
|
44
|
+
"eslint-plugin-react-native": "^4.1.0",
|
|
45
|
+
"typescript": "^5.5.4"
|
|
46
|
+
},
|
|
47
|
+
"author": "Juan Castillo",
|
|
48
|
+
"license": "ISC"
|
|
49
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
|
|
9
|
+
import { useButtonStyles } from "./styles/ButtonStyle";
|
|
10
|
+
import Text from "../Text";
|
|
11
|
+
|
|
12
|
+
export enum ButtonType {
|
|
13
|
+
Primary,
|
|
14
|
+
Destructive,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ButtonProps {
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
// Deprecated use appearance
|
|
20
|
+
type?: ButtonType;
|
|
21
|
+
onPress?: () => void;
|
|
22
|
+
text: string;
|
|
23
|
+
loading?: boolean;
|
|
24
|
+
testID?: string;
|
|
25
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
26
|
+
appearance?: "primary" | "secondary" | "destructive";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getButtonStyle = (
|
|
30
|
+
styles: {
|
|
31
|
+
disabled: StyleProp<ViewStyle>;
|
|
32
|
+
primary: StyleProp<ViewStyle>;
|
|
33
|
+
secondary: StyleProp<ViewStyle>;
|
|
34
|
+
destructive: StyleProp<ViewStyle>;
|
|
35
|
+
},
|
|
36
|
+
appearance: ButtonProps["appearance"],
|
|
37
|
+
disabled: boolean
|
|
38
|
+
) => {
|
|
39
|
+
const style = [styles.primary];
|
|
40
|
+
|
|
41
|
+
if (appearance === "secondary") {
|
|
42
|
+
style.push(styles.secondary);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (appearance === "destructive") {
|
|
46
|
+
style.push(styles.destructive);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (disabled) {
|
|
50
|
+
style.push(styles.disabled);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return style;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Button = ({
|
|
57
|
+
testID,
|
|
58
|
+
disabled = false,
|
|
59
|
+
onPress,
|
|
60
|
+
text,
|
|
61
|
+
loading,
|
|
62
|
+
containerStyle = {},
|
|
63
|
+
appearance = "primary",
|
|
64
|
+
type,
|
|
65
|
+
}: ButtonProps) => {
|
|
66
|
+
const { styles, theme } = useButtonStyles();
|
|
67
|
+
const buttonStyle = useMemo(() => {
|
|
68
|
+
let _apperance = appearance;
|
|
69
|
+
|
|
70
|
+
if (type) {
|
|
71
|
+
_apperance = type === ButtonType.Destructive ? "destructive" : "primary";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return getButtonStyle(
|
|
75
|
+
{
|
|
76
|
+
disabled: styles.disabled,
|
|
77
|
+
primary: styles.default,
|
|
78
|
+
destructive: styles.destructiveContainer,
|
|
79
|
+
secondary: styles.secondary,
|
|
80
|
+
},
|
|
81
|
+
_apperance,
|
|
82
|
+
disabled
|
|
83
|
+
);
|
|
84
|
+
}, [styles, appearance, disabled, type]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<TouchableOpacity
|
|
88
|
+
testID={testID}
|
|
89
|
+
style={[buttonStyle, disabled && styles.disabled, containerStyle]}
|
|
90
|
+
onPress={onPress}
|
|
91
|
+
disabled={disabled || loading}
|
|
92
|
+
>
|
|
93
|
+
{loading ? (
|
|
94
|
+
<ActivityIndicator
|
|
95
|
+
size="small"
|
|
96
|
+
color={theme.colors.foregroundOnPrimary}
|
|
97
|
+
/>
|
|
98
|
+
) : (
|
|
99
|
+
<Text
|
|
100
|
+
category="h3"
|
|
101
|
+
style={[styles.defaultText, disabled && styles.disabledText]}
|
|
102
|
+
>
|
|
103
|
+
{text}
|
|
104
|
+
</Text>
|
|
105
|
+
)}
|
|
106
|
+
</TouchableOpacity>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default Button;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useThemedStyle } from '../../../hooks';
|
|
5
|
+
|
|
6
|
+
export const useButtonStyles = () =>
|
|
7
|
+
useThemedStyle(
|
|
8
|
+
useCallback(
|
|
9
|
+
theme =>
|
|
10
|
+
StyleSheet.create({
|
|
11
|
+
default: {
|
|
12
|
+
borderRadius: theme.borderRadius,
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
backgroundColor: theme.colors.primary,
|
|
15
|
+
paddingHorizontal: theme.size.baseSize * 4,
|
|
16
|
+
paddingVertical: theme.size.baseSize * 2,
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
},
|
|
19
|
+
secondary: {
|
|
20
|
+
backgroundColor: theme.colors.foregroundLowContrast,
|
|
21
|
+
},
|
|
22
|
+
destructiveContainer: {
|
|
23
|
+
borderRadius: theme.borderRadius,
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
paddingHorizontal: theme.size.baseSize * 4,
|
|
26
|
+
paddingVertical: theme.size.baseSize * 2,
|
|
27
|
+
textAlign: 'center',
|
|
28
|
+
backgroundColor: theme.colors.secondaryNegative,
|
|
29
|
+
},
|
|
30
|
+
destructiveText: {
|
|
31
|
+
textAlign: 'center',
|
|
32
|
+
color: theme.colors.backgroundPrimary,
|
|
33
|
+
},
|
|
34
|
+
defaultText: {
|
|
35
|
+
textAlign: 'center',
|
|
36
|
+
color: theme.colors.foregroundOnPrimary,
|
|
37
|
+
},
|
|
38
|
+
disabled: {
|
|
39
|
+
backgroundColor: theme.colors.primaryLowContrast,
|
|
40
|
+
},
|
|
41
|
+
disabledText: {
|
|
42
|
+
color: theme.colors.foregroundOnPrimary,
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
[]
|
|
46
|
+
)
|
|
47
|
+
);
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import DateTimePicker, { IOSNativeProps, AndroidNativeProps } from '@react-native-community/datetimepicker';
|
|
3
|
+
import { View, TouchableOpacity, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import Animated, { interpolate, interpolateColor, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
5
|
+
// import IonIcons from 'react-native-vector-icons/Ionicons';
|
|
6
|
+
import moment from 'moment';
|
|
7
|
+
|
|
8
|
+
import Sheet from '../Sheet';
|
|
9
|
+
import Text from '../Text';
|
|
10
|
+
import { MenuItemDescription } from '../MenuItemDescription';
|
|
11
|
+
import { useThemedStyle } from '../../hooks';
|
|
12
|
+
import Button from '../Button';
|
|
13
|
+
|
|
14
|
+
export type DateTimeInputProps = {
|
|
15
|
+
label: string;
|
|
16
|
+
caption?: string;
|
|
17
|
+
value: Date;
|
|
18
|
+
onChange?: (date: Date) => void;
|
|
19
|
+
onSave?: (date: Date) => void;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
testID?: string;
|
|
22
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
23
|
+
mode?: IOSNativeProps['mode'] | AndroidNativeProps['mode'];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getFormat = (mode?: DateTimeInputProps['mode']) => {
|
|
27
|
+
switch (mode) {
|
|
28
|
+
case 'date': {
|
|
29
|
+
return 'MMM D, YYYY';
|
|
30
|
+
}
|
|
31
|
+
case 'time': {
|
|
32
|
+
return 'h:mm A';
|
|
33
|
+
}
|
|
34
|
+
case 'datetime':
|
|
35
|
+
default: {
|
|
36
|
+
return 'MMM D, YYYY h:mm A';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const DateTimeInput = ({
|
|
42
|
+
value,
|
|
43
|
+
onChange,
|
|
44
|
+
testID,
|
|
45
|
+
containerStyle,
|
|
46
|
+
label,
|
|
47
|
+
caption,
|
|
48
|
+
mode = 'date',
|
|
49
|
+
disabled = false,
|
|
50
|
+
onSave,
|
|
51
|
+
}: DateTimeInputProps) => {
|
|
52
|
+
const { styles, theme } = useStyles(disabled);
|
|
53
|
+
const [dateSheetOpen, setDateSheetOpen] = useState(false);
|
|
54
|
+
const [date, setDate] = useState(value);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (dateSheetOpen) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setDate(value);
|
|
62
|
+
}, [dateSheetOpen, value]);
|
|
63
|
+
|
|
64
|
+
const animatedValue = useSharedValue(value ? 1 : 0);
|
|
65
|
+
|
|
66
|
+
const animatedLabelStyles = useAnimatedStyle(() => {
|
|
67
|
+
return {
|
|
68
|
+
transform: [{ translateY: interpolate(animatedValue.value, [0, 1], [1, -8]) }],
|
|
69
|
+
fontSize: interpolate(animatedValue.value, [0, 1], [14, 10]),
|
|
70
|
+
};
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const animatedContainerStyles = useAnimatedStyle(() => {
|
|
74
|
+
return {
|
|
75
|
+
borderColor: interpolateColor(animatedValue.value, [0, 1], ['#ffffff00', theme.colors.border]),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const animatedValueStyle = useAnimatedStyle(() => {
|
|
80
|
+
return {
|
|
81
|
+
flex: 1,
|
|
82
|
+
transform: [{ translateY: animatedValue.value * 6 }],
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<View testID={testID} style={[styles.container, containerStyle]}>
|
|
89
|
+
<TouchableOpacity onPress={() => setDateSheetOpen(true)} disabled={disabled}>
|
|
90
|
+
<Animated.View style={[styles.itemContainer, animatedContainerStyles]}>
|
|
91
|
+
<View pointerEvents="none" style={styles.labelContainer}>
|
|
92
|
+
<Animated.Text style={[styles.label, animatedLabelStyles]}>{label}</Animated.Text>
|
|
93
|
+
</View>
|
|
94
|
+
<Animated.View style={animatedValueStyle}>
|
|
95
|
+
<Text contrast="low" style={styles.value}>
|
|
96
|
+
{moment(value).format(getFormat(mode)).toString()}
|
|
97
|
+
</Text>
|
|
98
|
+
</Animated.View>
|
|
99
|
+
{/*<IonIcons
|
|
100
|
+
style={styles.iconRight}
|
|
101
|
+
color={!disabled ? theme.colors.foreground : theme.colors.foregroundLowContrast}
|
|
102
|
+
name={mode === 'time' ? 'time-outline' : 'calendar-outline'}
|
|
103
|
+
size={20}
|
|
104
|
+
/>*/}
|
|
105
|
+
</Animated.View>
|
|
106
|
+
</TouchableOpacity>
|
|
107
|
+
{!!caption && <MenuItemDescription description={caption} />}
|
|
108
|
+
</View>
|
|
109
|
+
<Sheet disableScroll header={label} open={dateSheetOpen} setOpen={setDateSheetOpen}>
|
|
110
|
+
<DateTimePicker
|
|
111
|
+
value={date}
|
|
112
|
+
mode={mode}
|
|
113
|
+
themeVariant={theme.isDarkTheme ? 'dark' : 'light'}
|
|
114
|
+
display="spinner"
|
|
115
|
+
onChange={(_, newDate) => {
|
|
116
|
+
if (!newDate) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
setDate(newDate);
|
|
120
|
+
onChange?.(newDate);
|
|
121
|
+
}}
|
|
122
|
+
/>
|
|
123
|
+
<Button
|
|
124
|
+
disabled={value.getTime() === date.getTime()}
|
|
125
|
+
text="Save"
|
|
126
|
+
onPress={() => {
|
|
127
|
+
onSave?.(date);
|
|
128
|
+
}}
|
|
129
|
+
/>
|
|
130
|
+
</Sheet>
|
|
131
|
+
</>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default DateTimeInput;
|
|
136
|
+
|
|
137
|
+
const useStyles = (disabled: boolean) =>
|
|
138
|
+
useThemedStyle(
|
|
139
|
+
useCallback(
|
|
140
|
+
t =>
|
|
141
|
+
StyleSheet.create({
|
|
142
|
+
container: {
|
|
143
|
+
marginBottom: t.size.baseSize * 3,
|
|
144
|
+
},
|
|
145
|
+
itemContainer: {
|
|
146
|
+
backgroundColor: t.colors.backgroundOnPrimary,
|
|
147
|
+
borderRadius: t.borderRadius,
|
|
148
|
+
paddingHorizontal: t.size.baseSize * 2,
|
|
149
|
+
minHeight: t.size.baseSize * 8,
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
justifyContent: 'space-between',
|
|
152
|
+
alignItems: 'center',
|
|
153
|
+
},
|
|
154
|
+
itemLabel: {
|
|
155
|
+
color: t.textPrimary,
|
|
156
|
+
},
|
|
157
|
+
labelContainer: {
|
|
158
|
+
left: t.size.baseSize * 2,
|
|
159
|
+
position: 'absolute',
|
|
160
|
+
},
|
|
161
|
+
label: {
|
|
162
|
+
color: !disabled ? t.colors.foreground : t.colors.foregroundLowContrast,
|
|
163
|
+
...t.typography.p1,
|
|
164
|
+
},
|
|
165
|
+
iconRight: {},
|
|
166
|
+
value: {
|
|
167
|
+
paddingHorizontal: t.size.baseSize * 0,
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
[disabled]
|
|
171
|
+
)
|
|
172
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { useThemedStyle } from "../../hooks";
|
|
5
|
+
|
|
6
|
+
const SIZE_MAP = {
|
|
7
|
+
small: 5,
|
|
8
|
+
medium: 10,
|
|
9
|
+
large: 20,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type DragHandleSize = "small" | "medium" | "large";
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
size?: DragHandleSize;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const DragHandle = ({ size = "medium" }: Props) => {
|
|
19
|
+
const styles = useStyles(size).styles;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<View style={styles.container}>
|
|
23
|
+
<View style={styles.handle}></View>
|
|
24
|
+
</View>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default DragHandle;
|
|
29
|
+
|
|
30
|
+
const useStyles = (size: DragHandleSize) =>
|
|
31
|
+
useThemedStyle(
|
|
32
|
+
useCallback(
|
|
33
|
+
(t) =>
|
|
34
|
+
StyleSheet.create({
|
|
35
|
+
container: {
|
|
36
|
+
width: "100%",
|
|
37
|
+
paddingVertical: t.size.baseSize * 2,
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
},
|
|
40
|
+
handle: {
|
|
41
|
+
width: t.size.baseSize * (SIZE_MAP[size] || t.size.baseSize),
|
|
42
|
+
height: t.size.baseSize,
|
|
43
|
+
borderRadius: t.borderRadius,
|
|
44
|
+
backgroundColor: t.colors.backgroundOnPrimary,
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
[size]
|
|
48
|
+
)
|
|
49
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import Text from '../Text';
|
|
5
|
+
import { useThemedStyle } from '../../hooks';
|
|
6
|
+
|
|
7
|
+
export type MenuItemDescriptionProps = {
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const MenuItemDescription = ({ description }: MenuItemDescriptionProps) => {
|
|
12
|
+
const styles = useStyles().styles;
|
|
13
|
+
return (
|
|
14
|
+
<View style={styles.descriptionContainer}>
|
|
15
|
+
<Text category="p2" contrast="low">
|
|
16
|
+
{description}
|
|
17
|
+
</Text>
|
|
18
|
+
</View>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const useStyles = () =>
|
|
23
|
+
useThemedStyle(
|
|
24
|
+
useCallback(
|
|
25
|
+
theme =>
|
|
26
|
+
StyleSheet.create({
|
|
27
|
+
descriptionContainer: {
|
|
28
|
+
marginHorizontal: theme.size.baseSize * 2,
|
|
29
|
+
marginTop: theme.size.baseSize,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
[]
|
|
33
|
+
)
|
|
34
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MenuItemDescription';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
|
+
import { StyleSheet, View, TouchableOpacity } from "react-native";
|
|
3
|
+
import IonIcons from "react-native-vector-icons/Ionicons";
|
|
4
|
+
|
|
5
|
+
import Text from "../Text";
|
|
6
|
+
import { useThemedStyle } from "../../hooks/useThemedStyle";
|
|
7
|
+
|
|
8
|
+
export type NavigationListRowProps = {
|
|
9
|
+
label: string;
|
|
10
|
+
caption?: string;
|
|
11
|
+
onPress?: () => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const NavigationListRow = ({
|
|
16
|
+
label,
|
|
17
|
+
caption,
|
|
18
|
+
onPress,
|
|
19
|
+
disabled,
|
|
20
|
+
}: NavigationListRowProps) => {
|
|
21
|
+
const styles = useStyles().styles;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<TouchableOpacity
|
|
25
|
+
disabled={disabled}
|
|
26
|
+
style={styles.container}
|
|
27
|
+
onPress={onPress}
|
|
28
|
+
>
|
|
29
|
+
<View style={styles.content}>
|
|
30
|
+
<Text category="h3">{label}</Text>
|
|
31
|
+
{caption && <Text contrast="low">{caption}</Text>}
|
|
32
|
+
</View>
|
|
33
|
+
<IonIcons
|
|
34
|
+
style={styles.chevronRight}
|
|
35
|
+
size={18}
|
|
36
|
+
name="chevron-forward-outline"
|
|
37
|
+
/>
|
|
38
|
+
</TouchableOpacity>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default NavigationListRow;
|
|
43
|
+
|
|
44
|
+
const useStyles = () =>
|
|
45
|
+
useThemedStyle(
|
|
46
|
+
useCallback(
|
|
47
|
+
(t) =>
|
|
48
|
+
StyleSheet.create({
|
|
49
|
+
content: {
|
|
50
|
+
flexGrow: 1,
|
|
51
|
+
},
|
|
52
|
+
container: {
|
|
53
|
+
width: "100%",
|
|
54
|
+
flexDirection: "row",
|
|
55
|
+
paddingVertical: t.size.baseSize * 2,
|
|
56
|
+
paddingHorizontal: t.size.baseSize * 4,
|
|
57
|
+
},
|
|
58
|
+
chevronRight: {
|
|
59
|
+
height: "100%",
|
|
60
|
+
flexGrow: 0,
|
|
61
|
+
},
|
|
62
|
+
chevronRightTint: {
|
|
63
|
+
color: t.colors.foregroundLowContrast,
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
[]
|
|
67
|
+
)
|
|
68
|
+
);
|