Skip to content

Commit 9f93aa8

Browse files
committed
refactor: cleanup
1 parent d7bbd68 commit 9f93aa8

File tree

10 files changed

+19
-110
lines changed

10 files changed

+19
-110
lines changed

docs/docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const config = {
138138
ListItem: 'List/ListItem',
139139
ListSection: 'List/ListSection',
140140
ListSubheader: 'List/ListSubheader',
141+
ListImage: 'List/ListImage',
141142
},
142143
Menu: {
143144
Menu: 'Menu/Menu',

src/components/BottomNavigation/BottomNavigationBar.tsx

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
ViewStyle,
1212
} from 'react-native';
1313

14-
import color from 'color';
1514
import { useSafeAreaInsets } from 'react-native-safe-area-context';
1615

1716
import {
@@ -20,8 +19,6 @@ import {
2019
getLabelColor,
2120
} from './utils';
2221
import { useInternalTheme } from '../../core/theming';
23-
import overlay from '../../styles/overlay';
24-
import { black, white } from '../../styles/themes/v2/colors';
2522
import type { ThemeProp } from '../../types';
2623
import useAnimatedValue from '../../utils/useAnimatedValue';
2724
import useAnimatedValueArray from '../../utils/useAnimatedValueArray';
@@ -333,18 +330,17 @@ const BottomNavigationBar = <Route extends BaseRoute>({
333330
animationEasing,
334331
onTabPress,
335332
onTabLongPress,
336-
shifting: shiftingProp,
333+
shifting: shiftingProp = false,
337334
safeAreaInsets,
338335
labelMaxFontSizeMultiplier = 1,
339-
compact: compactProp,
336+
compact = false,
340337
testID = 'bottom-navigation-bar',
341338
theme: themeOverrides,
342339
}: Props<Route>) => {
343340
const theme = useInternalTheme(themeOverrides);
344341
const { bottom, left, right } = useSafeAreaInsets();
345342
const { scale } = theme.animation;
346-
const compact = compactProp ?? false;
347-
let shifting = shiftingProp ?? false;
343+
let shifting = shiftingProp;
348344

349345
if (shifting && navigationState.routes.length < 2) {
350346
shifting = false;
@@ -476,38 +472,22 @@ const BottomNavigationBar = <Route extends BaseRoute>({
476472
};
477473

478474
const { routes } = navigationState;
479-
const { colors, dark: isDarkTheme, mode } = theme;
480475

481-
const { backgroundColor: customBackground, elevation = 4 } =
482-
(StyleSheet.flatten(style) || {}) as {
483-
elevation?: number;
484-
backgroundColor?: ColorValue;
485-
};
486-
487-
const approxBackgroundColor = customBackground
488-
? customBackground
489-
: isDarkTheme && mode === 'adaptive'
490-
? overlay(elevation, colors?.surface)
491-
: colors?.primary;
476+
const { backgroundColor: customBackground } = (StyleSheet.flatten(style) ||
477+
{}) as {
478+
elevation?: number;
479+
backgroundColor?: ColorValue;
480+
};
492481

493482
const backgroundColor = customBackground || theme.colors.elevation.level2;
494483

495-
const isDark =
496-
typeof approxBackgroundColor === 'string'
497-
? !color(approxBackgroundColor).isLight()
498-
: true;
499-
500-
const textColor = isDark ? white : black;
501-
502484
const activeTintColor = getActiveTintColor({
503485
activeColor,
504-
defaultColor: textColor,
505486
theme,
506487
});
507488

508489
const inactiveTintColor = getInactiveTintColor({
509490
inactiveColor,
510-
defaultColor: textColor,
511491
theme,
512492
});
513493

@@ -615,15 +595,13 @@ const BottomNavigationBar = <Route extends BaseRoute>({
615595
tintColor: activeTintColor,
616596
hasColor: Boolean(activeColor),
617597
focused,
618-
defaultColor: textColor,
619598
theme,
620599
});
621600

622601
const inactiveLabelColor = getLabelColor({
623602
tintColor: inactiveTintColor,
624603
hasColor: Boolean(inactiveColor),
625604
focused,
626-
defaultColor: textColor,
627605
theme,
628606
});
629607

src/components/BottomNavigation/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { InternalTheme } from 'src/types';
22

3-
import type { black, white } from '../../styles/themes/v2/colors';
4-
53
type BaseProps = {
6-
defaultColor: typeof black | typeof white;
74
theme: InternalTheme;
85
};
96

src/components/Button/Button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const Button = (
199199
delayLongPress,
200200
style,
201201
theme: themeOverrides,
202-
uppercase: uppercaseProp,
202+
uppercase = false,
203203
contentStyle,
204204
labelStyle,
205205
testID = 'button',
@@ -219,7 +219,6 @@ const Button = (
219219
[mode]
220220
);
221221
const { roundness, animation, fonts } = theme;
222-
const uppercase = uppercaseProp ?? false;
223222
const isWeb = Platform.OS === 'web';
224223

225224
const hasPassedTouchHandler = hasTouchHandler({

src/components/FAB/AnimatedFAB.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const AnimatedFAB = ({
221221
theme: themeOverrides,
222222
style,
223223
visible = true,
224-
uppercase: uppercaseProp,
224+
uppercase = false,
225225
testID = 'animated-fab',
226226
animateFrom = 'right',
227227
extended = false,
@@ -232,7 +232,6 @@ const AnimatedFAB = ({
232232
...rest
233233
}: Props) => {
234234
const theme = useInternalTheme(themeOverrides);
235-
const uppercase: boolean = uppercaseProp ?? false;
236235
const isIOS = Platform.OS === 'ios';
237236
const isWeb = Platform.OS === 'web';
238237
const isAnimatedFromRight = animateFrom === 'right';

src/components/FAB/FAB.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const FAB = forwardRef<View, Props>(
197197
theme: themeOverrides,
198198
style,
199199
visible = true,
200-
uppercase: uppercaseProp,
200+
uppercase = false,
201201
loading,
202202
testID = 'fab',
203203
size = 'medium',
@@ -215,7 +215,6 @@ const FAB = forwardRef<View, Props>(
215215
fonts,
216216
} = theme;
217217

218-
const uppercase = uppercaseProp ?? false;
219218
const { current: visibility } = React.useRef<Animated.Value>(
220219
new Animated.Value(visible ? 1 : 0)
221220
);

src/components/List/ListImage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import {
88
} from 'react-native';
99

1010
export type Props = {
11+
/**
12+
* Image source.
13+
*/
1114
source: ImageSourcePropType;
15+
/**
16+
* Variant of the image. The default variant is `image`.
17+
*/
1218
variant?: 'image' | 'video';
1319
style?: StyleProp<ImageStyle>;
1420
};

src/components/TextInput/Addons/Underline.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as React from 'react';
22
import { Animated, StyleSheet, StyleProp, ViewStyle } from 'react-native';
33

4-
import type { ThemeProp } from 'src/types';
5-
64
type UnderlineProps = {
75
parentState: {
86
focused: boolean;
@@ -15,7 +13,6 @@ type UnderlineProps = {
1513
underlineColorCustom?: string;
1614
hasActiveOutline?: boolean;
1715
style?: StyleProp<ViewStyle>;
18-
theme?: ThemeProp;
1916
};
2017

2118
export const Underline = ({
@@ -33,8 +30,6 @@ export const Underline = ({
3330

3431
if (error) backgroundColor = colors?.error;
3532

36-
const activeScale = 2;
37-
3833
return (
3934
<Animated.View
4035
testID="text-input-underline"
@@ -45,7 +40,7 @@ export const Underline = ({
4540
// Underlines is thinner when input is not focused
4641
transform: [
4742
{
48-
scaleY: hasActiveOutline ? activeScale : 0.5,
43+
scaleY: hasActiveOutline ? 2 : 0.5,
4944
},
5045
],
5146
},

src/components/TextInput/TextInputFlat.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ const TextInputFlat = ({
346346
error={error}
347347
colors={colors}
348348
activeColor={activeColor}
349-
theme={theme}
350349
/>
351350
<View
352351
onLayout={onInputLayout}

src/styles/overlay.tsx

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,5 @@
11
import { Animated } from 'react-native';
22

3-
import color from 'color';
4-
53
export const isAnimatedValue = (
64
it: number | string | Animated.AnimatedInterpolation<number | string>
75
): it is Animated.Value => it instanceof Animated.Value;
8-
9-
// TODO: Revist this function to see if it's still needed
10-
export default function overlay<T extends Animated.Value | number>(
11-
elevation: T,
12-
surfaceColor: string
13-
): T extends number ? string : Animated.AnimatedInterpolation<number | string> {
14-
if (isAnimatedValue(elevation)) {
15-
const inputRange = [0, 1, 2, 3, 8, 24];
16-
17-
// @ts-expect-error: TS doesn't seem to refine the type correctly
18-
return elevation.interpolate({
19-
inputRange,
20-
outputRange: inputRange.map((elevation) => {
21-
return calculateColor(surfaceColor, elevation);
22-
}),
23-
});
24-
}
25-
26-
// @ts-expect-error: TS doesn't seem to refine the type correctly
27-
return calculateColor(surfaceColor, elevation);
28-
}
29-
30-
function calculateColor(surfaceColor: string, elevation: number = 1) {
31-
let overlayTransparency: number;
32-
if (elevation >= 1 && elevation <= 24) {
33-
overlayTransparency = elevationOverlayTransparency[elevation];
34-
} else if (elevation > 24) {
35-
overlayTransparency = elevationOverlayTransparency[24];
36-
} else {
37-
overlayTransparency = elevationOverlayTransparency[1];
38-
}
39-
return color(surfaceColor)
40-
.mix(color('white'), overlayTransparency * 0.01)
41-
.hex();
42-
}
43-
44-
const elevationOverlayTransparency: Record<string, number> = {
45-
1: 5,
46-
2: 7,
47-
3: 8,
48-
4: 9,
49-
5: 10,
50-
6: 11,
51-
7: 11.5,
52-
8: 12,
53-
9: 12.5,
54-
10: 13,
55-
11: 13.5,
56-
12: 14,
57-
13: 14.25,
58-
14: 14.5,
59-
15: 14.75,
60-
16: 15,
61-
17: 15.12,
62-
18: 15.24,
63-
19: 15.36,
64-
20: 15.48,
65-
21: 15.6,
66-
22: 15.72,
67-
23: 15.84,
68-
24: 16,
69-
};

0 commit comments

Comments
 (0)