react95-native-rabbl 0.1.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/LICENSE +21 -0
- package/README.md +24 -0
- package/package.json +154 -0
- package/src/assets/fonts/src/ms-sans-serif/MS Sans Serif.ttf +0 -0
- package/src/assets/fonts/src/ms-sans-serif/license.txt +4 -0
- package/src/assets/fonts/src/ms-sans-serif/readme.txt +26 -0
- package/src/assets/fonts/src/ms-sans-serif-bold/MS Sans Serif Bold.ttf +0 -0
- package/src/assets/fonts/src/ms-sans-serif-bold/license.txt +4 -0
- package/src/assets/fonts/src/ms-sans-serif-bold/readme.txt +26 -0
- package/src/components/AppBar/AppBar.spec.tsx +140 -0
- package/src/components/AppBar/AppBar.tsx +43 -0
- package/src/components/AppBar/AppBarBackAction.tsx +20 -0
- package/src/components/AppBar/AppBarContent.tsx +84 -0
- package/src/components/AppBar/index.ts +1 -0
- package/src/components/Button/Button.spec.tsx +59 -0
- package/src/components/Button/Button.tsx +236 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/Card.spec.tsx +54 -0
- package/src/components/Card/Card.tsx +88 -0
- package/src/components/Card/CardContent.tsx +23 -0
- package/src/components/Card/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.tsx +10 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/ColorButton/ColorButton.tsx +69 -0
- package/src/components/ColorButton/index.ts +1 -0
- package/src/components/ColorPicker/ColorPicker.tsx +109 -0
- package/src/components/ColorPicker/index.ts +1 -0
- package/src/components/Desktop/Desktop.spec.tsx +32 -0
- package/src/components/Desktop/Desktop.tsx +132 -0
- package/src/components/Desktop/index.tsx +1 -0
- package/src/components/Divider/Divider.spec.tsx +47 -0
- package/src/components/Divider/Divider.tsx +52 -0
- package/src/components/Divider/index.tsx +1 -0
- package/src/components/FAB/FAB.tsx +288 -0
- package/src/components/FAB/FABGroup.tsx +385 -0
- package/src/components/FAB/index.ts +1 -0
- package/src/components/Fieldset/Fieldset.spec.tsx +48 -0
- package/src/components/Fieldset/Fieldset.tsx +107 -0
- package/src/components/Fieldset/index.ts +1 -0
- package/src/components/Hourglass/Hourglass.spec.tsx +24 -0
- package/src/components/Hourglass/Hourglass.tsx +43 -0
- package/src/components/Hourglass/base64hourglass.ts +3 -0
- package/src/components/Hourglass/index.ts +1 -0
- package/src/components/Icons/ArrowIcon.tsx +85 -0
- package/src/components/Icons/CheckmarkIcon.tsx +55 -0
- package/src/components/Icons/ChevronIcon.tsx +93 -0
- package/src/components/Icons/CloseIcon.tsx +48 -0
- package/src/components/Icons/index.ts +4 -0
- package/src/components/Label/Label.tsx +77 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/List/List.tsx +3 -0
- package/src/components/List/ListAccordion.tsx +154 -0
- package/src/components/List/ListItem.tsx +74 -0
- package/src/components/List/ListSection.tsx +51 -0
- package/src/components/List/index.ts +3 -0
- package/src/components/Menu/Menu.tsx +100 -0
- package/src/components/Menu/MenuItem.tsx +100 -0
- package/src/components/Menu/index.ts +1 -0
- package/src/components/NumberInput/NumberInput.spec.tsx +119 -0
- package/src/components/NumberInput/NumberInput.tsx +144 -0
- package/src/components/NumberInput/index.ts +1 -0
- package/src/components/Panel/Panel.spec.tsx +29 -0
- package/src/components/Panel/Panel.tsx +75 -0
- package/src/components/Panel/index.ts +1 -0
- package/src/components/Portal/Portal.tsx +52 -0
- package/src/components/Portal/PortalConsumer.tsx +48 -0
- package/src/components/Portal/PortalHost.tsx +150 -0
- package/src/components/Portal/PortalManager.tsx +57 -0
- package/src/components/Portal/index.ts +1 -0
- package/src/components/Progress/Progress.tsx +125 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Radio/Radio.tsx +14 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/ScrollPanel/ScrollPanel.tsx +72 -0
- package/src/components/ScrollPanel/index.ts +1 -0
- package/src/components/ScrollView/ScrollView.tsx +284 -0
- package/src/components/ScrollView/index.ts +1 -0
- package/src/components/Select/Select.tsx +229 -0
- package/src/components/Select/SelectBase.tsx +119 -0
- package/src/components/Select/SelectBox.tsx +66 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Slider/Slider.tsx +301 -0
- package/src/components/Slider/index.ts +1 -0
- package/src/components/Snackbar/Snackbar.tsx +260 -0
- package/src/components/Snackbar/SnackbarContent.tsx +23 -0
- package/src/components/Snackbar/index.ts +1 -0
- package/src/components/SwitchBase/SwitchBase.tsx +193 -0
- package/src/components/SwitchBase/index.ts +1 -0
- package/src/components/Tabs/Tabs.tsx +208 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/TextInput/TextInput.tsx +82 -0
- package/src/components/TextInput/index.ts +1 -0
- package/src/components/Toolbar/Toolbar.tsx +113 -0
- package/src/components/Toolbar/index.ts +1 -0
- package/src/components/Typography/Anchor.tsx +38 -0
- package/src/components/Typography/Text.spec.tsx +30 -0
- package/src/components/Typography/Text.tsx +55 -0
- package/src/components/Typography/Title.tsx +58 -0
- package/src/components/Typography/index.ts +3 -0
- package/src/components/Window/Window.tsx +132 -0
- package/src/components/Window/index.ts +1 -0
- package/src/core/Provider.tsx +52 -0
- package/src/core/theming.tsx +8 -0
- package/src/hooks/useAsyncReference.ts +22 -0
- package/src/hooks/useControlledOrUncontrolled.ts +23 -0
- package/src/index.ts +38 -0
- package/src/styles/shadow.tsx +36 -0
- package/src/styles/styleElements.tsx +105 -0
- package/src/styles/styles.ts +129 -0
- package/src/styles/themes/aiee.ts +36 -0
- package/src/styles/themes/ash.ts +35 -0
- package/src/styles/themes/azureOrange.ts +33 -0
- package/src/styles/themes/bee.ts +33 -0
- package/src/styles/themes/blackAndWhite.ts +33 -0
- package/src/styles/themes/blue.ts +36 -0
- package/src/styles/themes/brick.ts +33 -0
- package/src/styles/themes/candy.ts +33 -0
- package/src/styles/themes/cherry.ts +36 -0
- package/src/styles/themes/coldGray.ts +34 -0
- package/src/styles/themes/counterStrike.ts +33 -0
- package/src/styles/themes/darkTeal.ts +36 -0
- package/src/styles/themes/eggplant.ts +33 -0
- package/src/styles/themes/fxDev.ts +36 -0
- package/src/styles/themes/highContrast.ts +33 -0
- package/src/styles/themes/hotChocolate.ts +36 -0
- package/src/styles/themes/index.ts +103 -0
- package/src/styles/themes/lilac.ts +33 -0
- package/src/styles/themes/lilacRoseDark.ts +34 -0
- package/src/styles/themes/maple.ts +33 -0
- package/src/styles/themes/marine.ts +33 -0
- package/src/styles/themes/matrix.ts +33 -0
- package/src/styles/themes/millenium.ts +33 -0
- package/src/styles/themes/modernDark.ts +33 -0
- package/src/styles/themes/molecule.ts +33 -0
- package/src/styles/themes/monochrome.ts +0 -0
- package/src/styles/themes/ninjaTurtles.ts +33 -0
- package/src/styles/themes/olive.ts +33 -0
- package/src/styles/themes/original.ts +33 -0
- package/src/styles/themes/pamelaAnderson.ts +33 -0
- package/src/styles/themes/plum.ts +33 -0
- package/src/styles/themes/polarized.ts +36 -0
- package/src/styles/themes/powerShell.ts +36 -0
- package/src/styles/themes/rainyDay.ts +33 -0
- package/src/styles/themes/raspberry.ts +36 -0
- package/src/styles/themes/redWine.ts +36 -0
- package/src/styles/themes/rose.ts +33 -0
- package/src/styles/themes/seawater.ts +36 -0
- package/src/styles/themes/slate.ts +33 -0
- package/src/styles/themes/solarizedDark.ts +36 -0
- package/src/styles/themes/solarizedLight.ts +36 -0
- package/src/styles/themes/spruce.ts +33 -0
- package/src/styles/themes/stormClouds.ts +36 -0
- package/src/styles/themes/theSixtiesUSA.ts +33 -0
- package/src/styles/themes/tokyoDark.ts +33 -0
- package/src/styles/themes/tooSexy.ts +33 -0
- package/src/styles/themes/travel.ts +33 -0
- package/src/styles/themes/vaporTeal.ts +33 -0
- package/src/styles/themes/vermillion.ts +33 -0
- package/src/styles/themes/violetDark.ts +33 -0
- package/src/styles/themes/water.ts +33 -0
- package/src/styles/themes/wmii.ts +36 -0
- package/src/types.tsx +55 -0
- package/src/utils/index.ts +57 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { Theme } from '../../types';
|
|
5
|
+
import { withTheme } from '../../core/theming';
|
|
6
|
+
|
|
7
|
+
import { Border } from '../../styles/styleElements';
|
|
8
|
+
|
|
9
|
+
type Props = React.ComponentPropsWithRef<typeof View> & {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
screenStyle?: StyleProp<ViewStyle>;
|
|
13
|
+
theme: Theme;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Desktop = ({ children, style, screenStyle, theme, ...rest }: Props) => {
|
|
17
|
+
return (
|
|
18
|
+
<View style={[styles.wrapper, style]} {...rest}>
|
|
19
|
+
<View style={[styles.monitor, { backgroundColor: theme.material }]}>
|
|
20
|
+
<Border theme={theme} variant='raised'>
|
|
21
|
+
<View
|
|
22
|
+
style={[
|
|
23
|
+
styles.monitorShadowBorder,
|
|
24
|
+
{ borderColor: theme.borderDark },
|
|
25
|
+
]}
|
|
26
|
+
>
|
|
27
|
+
<View
|
|
28
|
+
style={[
|
|
29
|
+
styles.monitorShadowBorder,
|
|
30
|
+
{ borderColor: theme.borderDark },
|
|
31
|
+
]}
|
|
32
|
+
/>
|
|
33
|
+
</View>
|
|
34
|
+
</Border>
|
|
35
|
+
<View style={[styles.screen, screenStyle]} testID='desktopScreen'>
|
|
36
|
+
<Border theme={theme} variant='cutout' />
|
|
37
|
+
{children}
|
|
38
|
+
</View>
|
|
39
|
+
<View style={[styles.light]} />
|
|
40
|
+
</View>
|
|
41
|
+
<View style={[styles.stand]}>
|
|
42
|
+
<View
|
|
43
|
+
style={[styles.standSegmentOne, { borderTopColor: theme.borderDark }]}
|
|
44
|
+
>
|
|
45
|
+
<Border
|
|
46
|
+
theme={theme}
|
|
47
|
+
variant='raised'
|
|
48
|
+
style={{ backgroundColor: theme.material }}
|
|
49
|
+
/>
|
|
50
|
+
</View>
|
|
51
|
+
<View
|
|
52
|
+
style={[styles.standSegmentTwo, { backgroundColor: theme.material }]}
|
|
53
|
+
>
|
|
54
|
+
<Border theme={theme} variant='default' />
|
|
55
|
+
</View>
|
|
56
|
+
<View style={[styles.standSegmentThree]}>
|
|
57
|
+
<Border theme={theme} variant='raised' />
|
|
58
|
+
</View>
|
|
59
|
+
</View>
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
wrapper: {
|
|
66
|
+
position: 'relative',
|
|
67
|
+
width: 'auto',
|
|
68
|
+
alignSelf: 'center',
|
|
69
|
+
},
|
|
70
|
+
monitor: {
|
|
71
|
+
position: 'relative',
|
|
72
|
+
zIndex: 1,
|
|
73
|
+
width: 195,
|
|
74
|
+
height: 155,
|
|
75
|
+
padding: 18,
|
|
76
|
+
},
|
|
77
|
+
monitorShadowBorder: {
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
top: 0,
|
|
80
|
+
left: 0,
|
|
81
|
+
bottom: 0,
|
|
82
|
+
right: 0,
|
|
83
|
+
borderWidth: 1,
|
|
84
|
+
borderStyle: 'dotted',
|
|
85
|
+
// TODO: left and top dotted border shoulg be of light color
|
|
86
|
+
// borderTopColor: theme.borderLightest,
|
|
87
|
+
// borderLeftColor: theme.borderLightest,
|
|
88
|
+
// borderBottomColor: theme.borderDark,
|
|
89
|
+
// borderRightColor: theme.borderDark,
|
|
90
|
+
},
|
|
91
|
+
screen: {
|
|
92
|
+
flex: 1,
|
|
93
|
+
padding: 4,
|
|
94
|
+
},
|
|
95
|
+
light: {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
right: 20,
|
|
98
|
+
top: 140,
|
|
99
|
+
width: 10,
|
|
100
|
+
borderWidth: 2,
|
|
101
|
+
borderTopColor: '#4d9046',
|
|
102
|
+
borderBottomColor: '#07ff00',
|
|
103
|
+
borderLeftColor: '#4d9046',
|
|
104
|
+
borderRightColor: '#07ff00',
|
|
105
|
+
},
|
|
106
|
+
stand: {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
position: 'relative',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
},
|
|
111
|
+
standSegmentOne: {
|
|
112
|
+
width: '50%',
|
|
113
|
+
height: 14,
|
|
114
|
+
borderWidth: 2,
|
|
115
|
+
borderColor: 'transparent',
|
|
116
|
+
zIndex: 1,
|
|
117
|
+
},
|
|
118
|
+
standSegmentTwo: {
|
|
119
|
+
width: '40%',
|
|
120
|
+
height: 12,
|
|
121
|
+
position: 'relative',
|
|
122
|
+
top: -4,
|
|
123
|
+
},
|
|
124
|
+
standSegmentThree: {
|
|
125
|
+
width: '75%',
|
|
126
|
+
height: 8,
|
|
127
|
+
position: 'relative',
|
|
128
|
+
top: -6,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export default withTheme(Desktop);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Desktop';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { Divider } from '../..';
|
|
4
|
+
|
|
5
|
+
describe('<Divider />', () => {
|
|
6
|
+
it('should render Divider', () => {
|
|
7
|
+
const { getByTestId } = render(<Divider testID='divider' />);
|
|
8
|
+
const divider = getByTestId('divider');
|
|
9
|
+
|
|
10
|
+
expect(divider).toBeTruthy();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('prop: size', () => {
|
|
14
|
+
it('defaults to 100%', () => {
|
|
15
|
+
const { getByTestId } = render(<Divider testID='divider' />);
|
|
16
|
+
const divider = getByTestId('divider');
|
|
17
|
+
expect(divider).toHaveStyle({ width: '100%' });
|
|
18
|
+
});
|
|
19
|
+
it('sets size correctly', () => {
|
|
20
|
+
const size = 53;
|
|
21
|
+
const { getByTestId } = render(<Divider testID='divider' size={size} />);
|
|
22
|
+
const divider = getByTestId('divider');
|
|
23
|
+
|
|
24
|
+
expect(divider).toHaveStyle({ width: 53 });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('prop: orientation', () => {
|
|
29
|
+
it('renders horizontal line by default', () => {
|
|
30
|
+
const size = 53;
|
|
31
|
+
const { getByTestId } = render(<Divider testID='divider' size={size} />);
|
|
32
|
+
const divider = getByTestId('divider');
|
|
33
|
+
|
|
34
|
+
expect(divider).toHaveStyle({ width: 53 });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders vertical line when orientation="vertical"', () => {
|
|
38
|
+
const size = 53;
|
|
39
|
+
const { getByTestId } = render(
|
|
40
|
+
<Divider testID='divider' orientation='vertical' size={size} />,
|
|
41
|
+
);
|
|
42
|
+
const divider = getByTestId('divider');
|
|
43
|
+
|
|
44
|
+
expect(divider).toHaveStyle({ height: 53 });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { withTheme } from '../../core/theming';
|
|
5
|
+
import type {
|
|
6
|
+
$RemoveChildren,
|
|
7
|
+
Orientation,
|
|
8
|
+
DimensionValue,
|
|
9
|
+
Theme,
|
|
10
|
+
} from '../../types';
|
|
11
|
+
|
|
12
|
+
import { Border } from '../../styles/styleElements';
|
|
13
|
+
|
|
14
|
+
type Props = $RemoveChildren<typeof View> & {
|
|
15
|
+
orientation?: Orientation;
|
|
16
|
+
size?: DimensionValue;
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
theme: Theme;
|
|
19
|
+
// come up with a better name than 'raised'
|
|
20
|
+
variant?: 'default' | 'raised';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Divider = ({
|
|
24
|
+
orientation = 'horizontal',
|
|
25
|
+
size = '100%',
|
|
26
|
+
style = {},
|
|
27
|
+
theme,
|
|
28
|
+
variant = 'default',
|
|
29
|
+
...rest
|
|
30
|
+
}: Props) => {
|
|
31
|
+
const isHorizontal = orientation === 'horizontal';
|
|
32
|
+
const isRaised = variant === 'raised';
|
|
33
|
+
const thickness = isRaised ? 5 : 4;
|
|
34
|
+
const dynamicStyles: StyleProp<ViewStyle> = {
|
|
35
|
+
width: isHorizontal ? size : thickness,
|
|
36
|
+
height: isHorizontal ? thickness : size,
|
|
37
|
+
backgroundColor: theme.material,
|
|
38
|
+
};
|
|
39
|
+
return (
|
|
40
|
+
<View style={[styles.divider, dynamicStyles, style]} {...rest}>
|
|
41
|
+
<Border variant='well' invert={isRaised} theme={theme} />
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
divider: {
|
|
48
|
+
position: 'relative',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export default withTheme(Divider);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Divider';
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Animated,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
StyleProp,
|
|
8
|
+
TouchableHighlight,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type { AccessibilityState } from 'react-native';
|
|
11
|
+
|
|
12
|
+
import { withTheme } from '../../core/theming';
|
|
13
|
+
import type { $RemoveChildren, Theme } from '../../types';
|
|
14
|
+
|
|
15
|
+
import { Hourglass, Text, Panel, ArrowIcon } from '../..';
|
|
16
|
+
// import FABGroup from './FABGroup';
|
|
17
|
+
|
|
18
|
+
type Props = $RemoveChildren<typeof Panel> & {
|
|
19
|
+
icon?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Optional label for extended `FAB`.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Make the label text uppercased.
|
|
26
|
+
*/
|
|
27
|
+
uppercase?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB.
|
|
30
|
+
* Uses `label` by default if specified.
|
|
31
|
+
*/
|
|
32
|
+
accessibilityLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Accessibility state for the FAB. This is read by the screen reader when the user taps the FAB.
|
|
35
|
+
*/
|
|
36
|
+
accessibilityState?: AccessibilityState;
|
|
37
|
+
/**
|
|
38
|
+
* Whether an icon change is animated.
|
|
39
|
+
*/
|
|
40
|
+
animated?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether FAB is mini-sized, used to create visual continuity with other elements. This has no effect if `label` is specified.
|
|
43
|
+
*/
|
|
44
|
+
small?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Custom color for the icon and label of the `FAB`.
|
|
47
|
+
*/
|
|
48
|
+
color?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether `FAB` is disabled. A disabled button is greyed out and `onPress` is not called on touch.
|
|
51
|
+
*/
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether `FAB` is currently visible.
|
|
55
|
+
*/
|
|
56
|
+
visible?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether to show a loading indicator.
|
|
59
|
+
*/
|
|
60
|
+
loading?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Function to execute on press.
|
|
63
|
+
*/
|
|
64
|
+
onPress?: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Function to execute on long press.
|
|
67
|
+
*/
|
|
68
|
+
onLongPress?: () => void;
|
|
69
|
+
style?: StyleProp<ViewStyle>;
|
|
70
|
+
/**
|
|
71
|
+
* @optional
|
|
72
|
+
*/
|
|
73
|
+
testID?: string;
|
|
74
|
+
theme: Theme;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A floating action button represents the primary action in an application.
|
|
79
|
+
*
|
|
80
|
+
* <div class="screenshots">
|
|
81
|
+
* <img src="screenshots/fab-1.png" />
|
|
82
|
+
* <img src="screenshots/fab-2.png" />
|
|
83
|
+
* </div>
|
|
84
|
+
*
|
|
85
|
+
* ## Usage
|
|
86
|
+
* ```js
|
|
87
|
+
* import * as React from 'react';
|
|
88
|
+
* import { StyleSheet } from 'react-native';
|
|
89
|
+
* import { FAB } from 'react-native-paper';
|
|
90
|
+
*
|
|
91
|
+
* const MyComponent = () => (
|
|
92
|
+
* <FAB
|
|
93
|
+
* style={styles.fab}
|
|
94
|
+
* small
|
|
95
|
+
* icon="plus"
|
|
96
|
+
* onPress={() => console.log('Pressed')}
|
|
97
|
+
* />
|
|
98
|
+
* );
|
|
99
|
+
*
|
|
100
|
+
* const styles = StyleSheet.create({
|
|
101
|
+
* fab: {
|
|
102
|
+
* position: 'absolute',
|
|
103
|
+
* margin: 16,
|
|
104
|
+
* right: 0,
|
|
105
|
+
* bottom: 0,
|
|
106
|
+
* },
|
|
107
|
+
* })
|
|
108
|
+
*
|
|
109
|
+
* export default MyComponent;
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
// const defaultSize = 56;
|
|
114
|
+
// const extendedSize = 48;
|
|
115
|
+
// const smallSize = 40;
|
|
116
|
+
const defaultSize = 64;
|
|
117
|
+
const extendedSize = 56;
|
|
118
|
+
const smallSize = 48;
|
|
119
|
+
|
|
120
|
+
const FAB = ({
|
|
121
|
+
icon = true,
|
|
122
|
+
small,
|
|
123
|
+
label,
|
|
124
|
+
accessibilityLabel = label,
|
|
125
|
+
accessibilityState,
|
|
126
|
+
// animated = true,
|
|
127
|
+
// color: customColor,
|
|
128
|
+
disabled,
|
|
129
|
+
onPress,
|
|
130
|
+
onLongPress,
|
|
131
|
+
style,
|
|
132
|
+
visible = true,
|
|
133
|
+
uppercase = false,
|
|
134
|
+
loading,
|
|
135
|
+
testID,
|
|
136
|
+
theme,
|
|
137
|
+
...rest
|
|
138
|
+
}: Props) => {
|
|
139
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
140
|
+
|
|
141
|
+
const { current: visibility } = React.useRef<Animated.Value>(
|
|
142
|
+
new Animated.Value(visible ? 1 : 0),
|
|
143
|
+
);
|
|
144
|
+
const scale = 0.5;
|
|
145
|
+
|
|
146
|
+
React.useEffect(() => {
|
|
147
|
+
if (visible) {
|
|
148
|
+
Animated.timing(visibility, {
|
|
149
|
+
toValue: 1,
|
|
150
|
+
duration: 200 * scale,
|
|
151
|
+
useNativeDriver: true,
|
|
152
|
+
}).start();
|
|
153
|
+
} else {
|
|
154
|
+
Animated.timing(visibility, {
|
|
155
|
+
toValue: 0,
|
|
156
|
+
duration: 150 * scale,
|
|
157
|
+
useNativeDriver: true,
|
|
158
|
+
}).start();
|
|
159
|
+
}
|
|
160
|
+
}, [visible, scale, visibility]);
|
|
161
|
+
|
|
162
|
+
// const IconComponent = animated ? null : null;
|
|
163
|
+
|
|
164
|
+
// eslint-disable-next-line no-nested-ternary
|
|
165
|
+
const size = label ? extendedSize : small ? smallSize : defaultSize;
|
|
166
|
+
// const size = label ? defaultSize : extendedSize;
|
|
167
|
+
const radius = size / 2;
|
|
168
|
+
return (
|
|
169
|
+
<Panel
|
|
170
|
+
theme={theme}
|
|
171
|
+
{...rest}
|
|
172
|
+
elevation={disabled ? 0 : 4}
|
|
173
|
+
// eslint-disable-next-line no-nested-ternary
|
|
174
|
+
variant={disabled ? 'default' : isPressed ? 'cutout' : 'raised'}
|
|
175
|
+
radius={radius}
|
|
176
|
+
style={[
|
|
177
|
+
// {
|
|
178
|
+
// // opacity: visibility,
|
|
179
|
+
// transform: [
|
|
180
|
+
// {
|
|
181
|
+
// scale: visibility,
|
|
182
|
+
// },
|
|
183
|
+
// ],
|
|
184
|
+
// backgroundColor: disabled ? theme.borderLight : theme.material,
|
|
185
|
+
// },
|
|
186
|
+
styles.container,
|
|
187
|
+
disabled && styles.disabled,
|
|
188
|
+
style,
|
|
189
|
+
]}
|
|
190
|
+
pointerEvents={visible ? 'auto' : 'none'}
|
|
191
|
+
>
|
|
192
|
+
<TouchableHighlight
|
|
193
|
+
onPress={onPress}
|
|
194
|
+
onLongPress={onLongPress}
|
|
195
|
+
onHideUnderlay={() => setIsPressed(false)}
|
|
196
|
+
onShowUnderlay={() => setIsPressed(true)}
|
|
197
|
+
underlayColor='none'
|
|
198
|
+
disabled={disabled}
|
|
199
|
+
accessibilityLabel={accessibilityLabel}
|
|
200
|
+
accessibilityTraits={disabled ? ['button', 'disabled'] : 'button'}
|
|
201
|
+
accessibilityComponentType='button'
|
|
202
|
+
accessibilityRole='button'
|
|
203
|
+
accessibilityState={{ ...accessibilityState, disabled }}
|
|
204
|
+
style={styles.touchable}
|
|
205
|
+
testID={testID}
|
|
206
|
+
>
|
|
207
|
+
<View
|
|
208
|
+
style={[
|
|
209
|
+
styles.content,
|
|
210
|
+
{
|
|
211
|
+
height: size,
|
|
212
|
+
width: label ? 'auto' : size,
|
|
213
|
+
paddingHorizontal: label ? 16 : 0,
|
|
214
|
+
paddingTop: isPressed ? 2 : 0,
|
|
215
|
+
},
|
|
216
|
+
]}
|
|
217
|
+
pointerEvents='none'
|
|
218
|
+
>
|
|
219
|
+
{icon && loading !== true ? (
|
|
220
|
+
<ArrowIcon
|
|
221
|
+
theme={theme}
|
|
222
|
+
segments={4}
|
|
223
|
+
style={{ marginTop: 2, width: 32 }}
|
|
224
|
+
// disabled to drop shadow
|
|
225
|
+
shadowOffset={1}
|
|
226
|
+
disabled
|
|
227
|
+
color={disabled ? undefined : theme.materialText}
|
|
228
|
+
/>
|
|
229
|
+
) : null}
|
|
230
|
+
{loading ? <Hourglass size={32} /> : null}
|
|
231
|
+
{label ? (
|
|
232
|
+
<Text
|
|
233
|
+
theme={theme}
|
|
234
|
+
disabled
|
|
235
|
+
bold
|
|
236
|
+
selectable={false}
|
|
237
|
+
style={[
|
|
238
|
+
styles.label,
|
|
239
|
+
uppercase && styles.uppercaseLabel,
|
|
240
|
+
disabled ? {} : { color: theme.materialText },
|
|
241
|
+
]}
|
|
242
|
+
>
|
|
243
|
+
{label}
|
|
244
|
+
</Text>
|
|
245
|
+
) : null}
|
|
246
|
+
</View>
|
|
247
|
+
</TouchableHighlight>
|
|
248
|
+
</Panel>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const styles = StyleSheet.create({
|
|
253
|
+
container: {
|
|
254
|
+
elevation: 6,
|
|
255
|
+
padding: 0,
|
|
256
|
+
},
|
|
257
|
+
touchable: {},
|
|
258
|
+
// standard: {
|
|
259
|
+
// height: 56,
|
|
260
|
+
// width: 56,
|
|
261
|
+
// },
|
|
262
|
+
// small: {
|
|
263
|
+
// height: 40,
|
|
264
|
+
// width: 40,
|
|
265
|
+
// },
|
|
266
|
+
// extended: {
|
|
267
|
+
// height: 48,
|
|
268
|
+
// paddingHorizontal: 16,
|
|
269
|
+
// },
|
|
270
|
+
content: {
|
|
271
|
+
flexDirection: 'row',
|
|
272
|
+
alignItems: 'center',
|
|
273
|
+
justifyContent: 'center',
|
|
274
|
+
},
|
|
275
|
+
label: {
|
|
276
|
+
marginHorizontal: 8,
|
|
277
|
+
},
|
|
278
|
+
uppercaseLabel: {
|
|
279
|
+
textTransform: 'uppercase',
|
|
280
|
+
},
|
|
281
|
+
disabled: {
|
|
282
|
+
elevation: 0,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// FAB.Group = FABGroup;
|
|
287
|
+
|
|
288
|
+
export default withTheme(FAB);
|