diff --git a/docs/docs/guides/01-getting-started.md b/docs/docs/guides/01-getting-started.md
index 68071c4d25..19fc3c2dea 100644
--- a/docs/docs/guides/01-getting-started.md
+++ b/docs/docs/guides/01-getting-started.md
@@ -165,7 +165,3 @@ export default function Main() {
);
}
```
-
-:::note
-For MD2 check the following [Material Design 2 default theme](https://github.com/callstack/react-native-paper/blob/main/src/styles/themes/v2/LightTheme.tsx).
-:::
diff --git a/docs/docs/guides/02-theming.mdx b/docs/docs/guides/02-theming.mdx
index 76869182ae..beeb8bfaff 100644
--- a/docs/docs/guides/02-theming.mdx
+++ b/docs/docs/guides/02-theming.mdx
@@ -65,9 +65,7 @@ You can change the theme prop dynamically and all the components will automatica
A theme usually contains the following properties:
- `dark` (`boolean`): whether this is a dark theme or light theme.
-- `version`: specify which design system components should follow in the app
- - 3 - new Material You (MD3)
- - 2 - previous Material Design (MD2)
+- `version`: Material You (MD3); kept for compatibility and normalized to `3` by `PaperProvider`
- `mode` (`'adaptive' | 'exact'`): color mode for dark theme (See [Dark Theme](#dark-theme)).
- `roundness` (`number`): roundness of common elements, such as buttons.
- `colors` (`object`): various colors used throughout different elements.
@@ -471,111 +469,13 @@ export default function HomeScreen() {
}
```
-## Material Design 2
+## Material Design 3
-Using Material Design 2 is fully supported in React Native Paper v5.x.
+React Native Paper ships with Material Design 3 (Material You) only. Customize the default experience by extending `MD3LightTheme` or `MD3DarkTheme` (see [Extending the theme](#extending-the-theme) and [Advanced theme overrides](#advanced-theme-overrides)).
-### Simple setup
+### Migrating from Material Design 2
-In order to use the Material Design 2 theme you can just pass `{ version: 2 }` to the PaperProvider theme prop:
-
-```js
-import * as React from 'react';
-import { PaperProvider } from 'react-native-paper';
-import App from './src/App';
-
-export default function Main() {
- return (
-
-
-
- );
-}
-```
-
-Specifying `{ version: 2 }` tells React Native Paper to use the built in Material Design 2 theme, so you don't have to fully extend it on your own.
-
-### Advanced setup
-
-As with any theme, you can also specify your custom properties within the Material Design 2 theme:
-
-```js
-import * as React from 'react';
-import { MD2LightTheme, PaperProvider } from 'react-native-paper';
-import App from './src/App';
-
-export default function Main() {
- const theme = {
- ...MD2LightTheme,
-
- // Specify a custom property
- custom: 'property',
-
- // Specify a custom nested property
- colors: {
- ...MD2LightTheme.colors,
- primary: '#fefefe',
- },
- };
-
- return (
-
-
-
- );
-}
-```
-
-### Typescript
-
-Due to the amount of changes in the theme's schema shape it falls into the [Advanced theme overrides](#advanced-theme-overrides) category. The steps are identical as with any advanced theme, just make sure to extend the built-in `MD2LightTheme` or `MD2DarkTheme` instead of `MD3LightTheme` or `MD3DarkTheme`.
-
-The final example for Material Design 2 would look like this:
-
-```ts
-import * as React from 'react';
-import { MD2LightTheme, PaperProvider, useTheme } from 'react-native-paper';
-import App from './src/App';
-
-const theme = {
- // Extend Material Design 2 theme
-
- ...MD2LightTheme, // or MD2DarkTheme
-
- // Specify a custom property
- myOwnProperty: true,
-
- // Specify a custom nested property
- colors: {
- ...MD2LightTheme.colors,
- myOwnColor: '#BADA55',
- },
-};
-
-export type AppTheme = typeof theme;
-
-export const useAppTheme = () => useTheme();
-
-export default function Main() {
- return (
-
-
-
- );
-}
-
-// App.tsx
-
-export default function App() {
- const { theme } = useAppTheme();
-
- return ;
-}
-```
-
-### Migrating to Material You
-
-If you are migrating from Material Design 2 (4.x and lower) to Material You (5.x), please refer to our [Migration Guide](https://callstack.github.io/react-native-paper/docs/guides/migration-guide-to-5.0)
+If you are upgrading from Material Design 2 (4.x and lower), follow the [Migration Guide](https://callstack.github.io/react-native-paper/docs/guides/migration-guide-to-5.0).
## Applying a theme to a paper component
diff --git a/docs/docs/guides/04-fonts.md b/docs/docs/guides/04-fonts.md
index 60d3c6e457..5e8e435c0a 100644
--- a/docs/docs/guides/04-fonts.md
+++ b/docs/docs/guides/04-fonts.md
@@ -47,99 +47,8 @@ Now, you are able to use `fontFamily` from font files.
## Configuring fonts in ThemeProvider
-### Material Design 2
-
-#### Using `configureFonts` helper
-
-To create a custom font, prepare a `fontConfig` object where fonts are divided by platforms. After that, you have to:
-
-* pass the `fontConfig` into `configureFonts` params object property called `config`
-* set the params object property `isV3` to `false`.
-
-The `fontConfig` object accepts `ios`, `android`, `macos`, `windows`, `web`, and `native`. Use these to override fonts on particular platforms.
-
-:::info
-At a minimum, you need to explicitly pass fonts for `android`, `ios`, and `web`.
-:::
-
-```js
-import * as React from 'react';
-import { configureFonts, MD2LightTheme, PaperProvider } from 'react-native-paper';
-import App from './src/App';
-
-const fontConfig = {
- web: {
- regular: {
- fontFamily: 'sans-serif',
- fontWeight: 'normal',
- },
- medium: {
- fontFamily: 'sans-serif-medium',
- fontWeight: 'normal',
- },
- light: {
- fontFamily: 'sans-serif-light',
- fontWeight: 'normal',
- },
- thin: {
- fontFamily: 'sans-serif-thin',
- fontWeight: 'normal',
- },
- },
- ios: {
- regular: {
- fontFamily: 'sans-serif',
- fontWeight: 'normal',
- },
- medium: {
- fontFamily: 'sans-serif-medium',
- fontWeight: 'normal',
- },
- light: {
- fontFamily: 'sans-serif-light',
- fontWeight: 'normal',
- },
- thin: {
- fontFamily: 'sans-serif-thin',
- fontWeight: 'normal',
- },
- },
- android: {
- regular: {
- fontFamily: 'sans-serif',
- fontWeight: 'normal',
- },
- medium: {
- fontFamily: 'sans-serif-medium',
- fontWeight: 'normal',
- },
- light: {
- fontFamily: 'sans-serif-light',
- fontWeight: 'normal',
- },
- thin: {
- fontFamily: 'sans-serif-thin',
- fontWeight: 'normal',
- },
- }
-};
-
-const theme = {
- ...MD2LightTheme,
- fonts: configureFonts({config: fontConfig, isV3: false}),
-};
-
-export default function Main() {
- return (
-
-
-
- );
-}
-```
-
-:::tip
-If you're using TypeScript use `as const` when defining `fontConfig`.
+:::note
+Older Material Design 2 platform-split font configuration (`configureFonts` with per-platform `ios` / `android` / `web` keys) is no longer supported. Use the Material Design 3 typescale and `configureFonts` as documented below.
:::
### Material Design 3
diff --git a/docs/docs/guides/08-theming-with-react-navigation.md b/docs/docs/guides/08-theming-with-react-navigation.md
index 6003953c02..15dbfbbec6 100644
--- a/docs/docs/guides/08-theming-with-react-navigation.md
+++ b/docs/docs/guides/08-theming-with-react-navigation.md
@@ -11,25 +11,9 @@ But how to make them work together?
## Themes adaptation
-### Material Design 2
-
-Fortunately, in Material Design 2, both React Navigation and React Native Paper offer very similar API when it comes to theming and theme color structure. It's possible to import them in light and dark variants from both.
-
-```js
-import {
- DarkTheme as NavigationDarkTheme,
- DefaultTheme as NavigationDefaultTheme,
-} from '@react-navigation/native';
-
-import {
- MD2LightTheme,
- MD2DarkTheme,
-} from 'react-native-paper';
-```
-
### Material Design 3
-From v5, React Native Paper theme colors structure follows the Material Design 3 (known as Material You) colors system, which differs significantly from both the previous Paper's theme and React Navigation theme.
+React Native Paper follows the Material Design 3 (Material You) color system, which differs from React Navigation’s default theme shape.
However, to simplify adapting React Navigation theme colors, to use the ones from React Native Paper, it's worth using a utility called `adaptNavigationTheme` – it accepts navigation-compliant themes in both modes and returns their equivalents adjusted to Material Design 3.
@@ -127,24 +111,6 @@ To make things easier we can use [deepmerge](https://www.npmjs.com/package/deepm
npm install deepmerge
```
-### Material Design 2
-
-```js
-import {
- NavigationContainer,
- DarkTheme as NavigationDarkTheme,
- DefaultTheme as NavigationDefaultTheme,
-} from '@react-navigation/native';
-import {
- MD2DarkTheme,
- MD2LightTheme,
-} from 'react-native-paper';
-import merge from 'deepmerge';
-
-const CombinedDefaultTheme = merge(MD2LightTheme, NavigationDefaultTheme);
-const CombinedDarkTheme = merge(MD2DarkTheme, NavigationDarkTheme);
-```
-
### Material Design 3
```js
@@ -171,27 +137,6 @@ const CombinedDarkTheme = merge(MD3DarkTheme, DarkTheme);
Alternatively, we could merge those themes using vanilla JavaScript:
-### Material Design 2
-
-```js
-const CombinedDefaultTheme = {
- ...MD2LightTheme,
- ...NavigationDefaultTheme,
- colors: {
- ...MD2LightTheme.colors,
- ...NavigationDefaultTheme.colors,
- },
-};
-const CombinedDarkTheme = {
- ...MD2DarkTheme,
- ...NavigationDarkTheme,
- colors: {
- ...MD2DarkTheme.colors,
- ...NavigationDarkTheme.colors,
- },
-};
-```
-
### Material Design 3
```js
diff --git a/docs/docs/guides/10-migration-guide-to-5.0.md b/docs/docs/guides/10-migration-guide-to-5.0.md
index 6c358d387f..7631b8cf94 100644
--- a/docs/docs/guides/10-migration-guide-to-5.0.md
+++ b/docs/docs/guides/10-migration-guide-to-5.0.md
@@ -4,7 +4,7 @@ title: Introducing v5 with Material You
React Native Paper v5 is all about adopting the new Material Design 3 aka Material You. It was released in October 2021 after intense work and effort to make Material You follow a more expressive approach to design.
-Paper now supports both Material Design 2 and 3 through the configuration described in [Versioning](#versioning) and is compatible with a handful of API changes.
+Current releases use Material Design 3 only; the historical `version: 2` / MD2 theme APIs described below were removed after v5. Use this guide when upgrading older apps to MD3.
# Migration guide to Material You 5.0
@@ -36,15 +36,12 @@ npx pod-install
### Versioning
-Introducing Material You (MD3) into `react-native-paper` doesn't mean dropping previous Material Design (MD2)! On the contrary, both of them will be supported, however, not simultaneously. To specify which design system components should follow in the app, there is a newly created property in [the theme](https://callstack.github.io/react-native-paper/docs/guides/theming#theme-properties) named `version` that accepts one of two values:
-
-* 3 – (default) new Material You (MD3),
-* 2 - previous Material Design (MD2).
+In v5, Material You (MD3) became the default theme. Earlier releases also exposed `version: 2` for Material Design 2; that option and MD2 theme exports have since been removed—use MD3 themes (`MD3LightTheme` / `MD3DarkTheme`) only.
```js
theme: {
/* ... */
- version: 3 | 2
+ version: 3
}
```
@@ -166,35 +163,13 @@ Take a look at the suggested replacement diff:
### Configure fonts
-The existing utility called `configureFonts` was adjusted to help users configure their theme fonts in both version, that's why that function, as of today, is going to accept the object with the follwing properties as an argument:
+The `configureFonts` helper configures the Material Design 3 typescale. Pass overrides via the `config` object (see [Fonts](https://callstack.github.io/react-native-paper/docs/guides/fonts.html)).
```ts
-configureFonts(params)
-```
-
-Parameters:
-
-| NAME | TYPE | REQUIRED |
-| ----------- | ----------- | ----------- |
-| params | object | No |
-
-Valid `params` keys are:
-
- * `config` ([MD2FontsConfig](https://github.com/callstack/react-native-paper/blob/main/src/styles/fonts.tsx#L63) | [MD3FontsConfig](https://github.com/callstack/react-native-paper/blob/main/src/styles/fonts.tsx#L67)) - fonts config object appropriate to the MD version
- * `isV3` (boolean) - whether adjusting theme fonts for v3. Default it true.
-
-To use your current font config from v2 and migrate to v3 there are two requirements:
-* the font config previously passed directly into function has to be passed into the params object property called `config`
-* the params object property `isV3` has to be set to `false`
-
-```diff
-- configureFonts(fontConfig)
-+ configureFonts({config: fontConfig, isV3: false})
+configureFonts({ config: { bodyLarge: { fontFamily: 'System' } } })
```
-:::tip
-If you want to check how to use `configureFonts` on MD3, check the [Fonts](https://callstack.github.io/react-native-paper/docs/guides/fonts.html) guide.
-:::
+Older direct calls like `configureFonts(fontConfig)` and MD2 platform-split configs should be replaced with MD3 variant keys (`displayLarge`, `bodyMedium`, and so on).
## Components
diff --git a/docs/static/llms.txt b/docs/static/llms.txt
index 46da789d41..4029ace3ea 100644
--- a/docs/static/llms.txt
+++ b/docs/static/llms.txt
@@ -7,7 +7,7 @@
- Install: npm install react-native-paper react-native-safe-area-context
- Wrap your app with PaperProvider
-- Default theme is Material You (MD3); set theme.version: 2 for MD2
+- Default theme is Material You (MD3)
- Requires React Native 0.72+ and React 18+
## Guides
@@ -63,7 +63,7 @@
- Theme object accepts colors, dark, roundness, fonts, animation, and version properties
- Use useTheme() hook or ThemeProvider for nested theme overrides
-- MD3 (Material You) is the default; set version: 2 for MD2 compatibility
+- MD3 (Material You) is the only supported design system; extend MD3LightTheme / MD3DarkTheme
- See theming guide: https://callstack.github.io/react-native-paper/docs/guides/theming
## Provider Pattern
diff --git a/example/src/DrawerItems.tsx b/example/src/DrawerItems.tsx
index 2d3ca6c202..2a31565f67 100644
--- a/example/src/DrawerItems.tsx
+++ b/example/src/DrawerItems.tsx
@@ -9,7 +9,6 @@ import {
Button,
Dialog,
Drawer,
- MD2Colors,
MD3Colors,
Switch,
Text,
@@ -107,7 +106,6 @@ function DrawerItems() {
toggleShouldUseDeviceColors,
toggleTheme,
toggleRtl: toggleRTL,
- toggleThemeVersion,
toggleCollapsed,
toggleCustomFont,
toggleRippleEffect,
@@ -137,14 +135,10 @@ function DrawerItems() {
};
const coloredLabelTheme = {
- colors: isV3
- ? {
- secondaryContainer: MD3Colors.tertiary80,
- onSecondaryContainer: MD3Colors.tertiary20,
- }
- : {
- primary: MD2Colors.tealA200,
- },
+ colors: {
+ secondaryContainer: MD3Colors.tertiary80,
+ onSecondaryContainer: MD3Colors.tertiary20,
+ },
};
return (
@@ -217,15 +211,6 @@ function DrawerItems() {
)}
-
-
- MD 2
-
-
-
-
-
-
{isV3 && (
diff --git a/example/src/Examples/ActivityIndicatorExample.tsx b/example/src/Examples/ActivityIndicatorExample.tsx
index 8013142921..15686054fa 100644
--- a/example/src/Examples/ActivityIndicatorExample.tsx
+++ b/example/src/Examples/ActivityIndicatorExample.tsx
@@ -1,20 +1,12 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
-import {
- ActivityIndicator,
- FAB,
- List,
- MD2Colors,
- MD3Colors,
-} from 'react-native-paper';
+import { ActivityIndicator, FAB, List, MD3Colors } from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
const ActivityIndicatorExample = () => {
const [animating, setAnimating] = React.useState(true);
- const { isV3 } = useExampleTheme();
return (
@@ -49,7 +41,7 @@ const ActivityIndicatorExample = () => {
diff --git a/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx b/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx
index 4bffa05322..f9b2303fad 100644
--- a/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx
+++ b/example/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx
@@ -3,13 +3,7 @@ import type { NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
import { Animated, FlatList, Platform, StyleSheet, View } from 'react-native';
import Icon from '@expo/vector-icons/MaterialCommunityIcons';
-import {
- Avatar,
- MD2Colors,
- MD3Colors,
- Paragraph,
- Text,
-} from 'react-native-paper';
+import { Avatar, MD3Colors, Text } from 'react-native-paper';
import CustomFAB from './CustomFAB';
import CustomFABControls, {
@@ -32,7 +26,7 @@ type Item = {
};
const AnimatedFABExample = () => {
- const { colors, isV3 } = useExampleTheme();
+ const { colors } = useExampleTheme();
const isIOS = Platform.OS === 'ios';
@@ -47,63 +41,55 @@ const AnimatedFABExample = () => {
const renderItem = React.useCallback(
({ item }: { item: Item }) => {
- const TextComponent = isV3 ? Text : Paragraph;
-
return (
-
{item.sender}
-
-
+
{item.date}
-
+
-
{item.header}
-
-
+
{item.message}
-
+
setVisible(!visible)}
@@ -114,7 +100,7 @@ const AnimatedFABExample = () => {
);
},
- [visible, isV3]
+ [visible]
);
const onScroll = ({
diff --git a/example/src/Examples/AppbarExample.tsx b/example/src/Examples/AppbarExample.tsx
index 1ebe74bad5..a5b1042ea5 100644
--- a/example/src/Examples/AppbarExample.tsx
+++ b/example/src/Examples/AppbarExample.tsx
@@ -6,7 +6,7 @@ import {
Appbar,
FAB,
List,
- Paragraph,
+ MD3Colors,
RadioButton,
Snackbar,
Switch,
@@ -14,7 +14,6 @@ import {
} from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { yellowA200 } from '../../../src/styles/themes/v2/colors';
import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
@@ -41,7 +40,7 @@ const AppbarExample = ({ navigation }: Props) => {
const theme = useExampleTheme();
const { bottom, left, right } = useSafeAreaInsets();
- const height = theme.isV3 ? 80 : 56;
+ const height = 80;
const isCenterAlignedMode = appbarMode === 'center-aligned';
@@ -92,21 +91,14 @@ const AppbarExample = ({ navigation }: Props) => {
showElevated,
]);
- const TextComponent = theme.isV3 ? Text : Paragraph;
-
const renderFAB = () => {
return (
{}}
- style={[
- styles.fab,
- theme.isV3
- ? { top: (height - MEDIUM_FAB_HEIGHT) / 2 }
- : { bottom: height / 2 + bottom },
- ]}
+ style={[styles.fab, { top: (height - MEDIUM_FAB_HEIGHT) / 2 }]}
/>
);
};
@@ -114,49 +106,41 @@ const AppbarExample = ({ navigation }: Props) => {
const renderDefaultOptions = () => (
<>
- Left icon
+ Left icon
- {!theme.isV3 && (
-
- Subtitle
-
-
- )}
- Search icon
+ Subtitle
+
+
+
+ Search icon
- More icon
+ More icon
- {theme.isV3 && (
-
- Calendar icon
-
-
- )}
- Custom Color
+ Calendar icon
+
+
+
+ Custom Color
- {!theme.isV3 && (
-
- Exact Dark Theme
-
-
- )}
- {theme.isV3 && (
-
- Elevated
-
-
- )}
+
+ Exact Dark Theme
+
+
+
+ Elevated
+
+
>
);
@@ -166,40 +150,34 @@ const AppbarExample = ({ navigation }: Props) => {
style={{ marginBottom: height + bottom }}
contentContainerStyle={styles.contentContainer}
>
- {theme.isV3 ? (
-
- {renderDefaultOptions()}
-
- ) : (
- renderDefaultOptions()
- )}
- {theme.isV3 && (
-
-
- setAppbarMode(value as AppbarModes)
- }
- >
-
- Small (default)
-
-
-
- Medium
-
-
-
- Large
-
-
-
- Center-aligned
-
-
-
-
- )}
+
+ {renderDefaultOptions()}
+
+
+
+ setAppbarMode(value as AppbarModes)
+ }
+ >
+
+ Small (default)
+
+
+
+ Medium
+
+
+
+ Large
+
+
+
+ Center-aligned
+
+
+
+
{
{
height: height + bottom,
},
- theme.isV3 && {
+ {
backgroundColor: theme.colors.elevation.level2,
},
]}
@@ -218,9 +196,8 @@ const AppbarExample = ({ navigation }: Props) => {
{}} />
{}} />
{}} />
- {theme.isV3 && renderFAB()}
+ {renderFAB()}
- {!theme.isV3 && renderFAB()}
setShowSnackbar(false)}
@@ -258,6 +235,6 @@ const styles = StyleSheet.create({
right: 16,
},
customColor: {
- backgroundColor: yellowA200,
+ backgroundColor: MD3Colors.secondary80,
},
});
diff --git a/example/src/Examples/AvatarExample.tsx b/example/src/Examples/AvatarExample.tsx
index b77da80b09..229c2f4a0b 100644
--- a/example/src/Examples/AvatarExample.tsx
+++ b/example/src/Examples/AvatarExample.tsx
@@ -1,13 +1,11 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
-import { Avatar, List, MD2Colors, MD3Colors } from 'react-native-paper';
+import { Avatar, List, MD3Colors } from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
const AvatarExample = () => {
- const { isV3 } = useExampleTheme();
return (
@@ -16,11 +14,11 @@ const AvatarExample = () => {
style={[
styles.avatar,
{
- backgroundColor: isV3 ? MD3Colors.error70 : MD2Colors.yellow500,
+ backgroundColor: MD3Colors.error70,
},
]}
label="XD"
- color={isV3 ? MD3Colors.primary0 : MD2Colors.black}
+ color={MD3Colors.primary0}
/>
@@ -32,11 +30,11 @@ const AvatarExample = () => {
style={[
styles.avatar,
{
- backgroundColor: isV3 ? MD3Colors.error70 : MD2Colors.yellow500,
+ backgroundColor: MD3Colors.error70,
},
]}
icon="folder"
- color={isV3 ? MD3Colors.primary0 : MD2Colors.black}
+ color={MD3Colors.primary0}
/>
diff --git a/example/src/Examples/BadgeExample.tsx b/example/src/Examples/BadgeExample.tsx
index 17f0e1b160..3269dc70a8 100644
--- a/example/src/Examples/BadgeExample.tsx
+++ b/example/src/Examples/BadgeExample.tsx
@@ -5,18 +5,15 @@ import {
Badge,
IconButton,
List,
- MD2Colors,
MD3Colors,
Text,
Switch,
} from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
const BadgeExample = () => {
const [visible, setVisible] = React.useState(true);
- const { isV3 } = useExampleTheme();
return (
@@ -44,9 +41,7 @@ const BadgeExample = () => {
style={[
styles.badge,
{
- backgroundColor: isV3
- ? MD3Colors.primary80
- : MD2Colors.blue500,
+ backgroundColor: MD3Colors.primary80,
},
]}
>
@@ -59,11 +54,11 @@ const BadgeExample = () => {
-
+
-
+
diff --git a/example/src/Examples/BannerExample.tsx b/example/src/Examples/BannerExample.tsx
index 0e856e9699..7ec874a283 100644
--- a/example/src/Examples/BannerExample.tsx
+++ b/example/src/Examples/BannerExample.tsx
@@ -8,7 +8,7 @@ import {
View,
} from 'react-native';
-import { Banner, FAB, MD2Colors, MD3Colors } from 'react-native-paper';
+import { Banner, FAB, MD3Colors } from 'react-native-paper';
import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
@@ -29,25 +29,18 @@ const BannerExample = () => {
setHeight(layoutHeight);
};
- const customTheme = !defaultTheme.isV3
- ? {
- ...defaultTheme,
- colors: {
- text: MD2Colors.white,
- surface: MD2Colors.blue200,
- primary: MD2Colors.purple900,
- },
- }
- : {
- ...defaultTheme,
- colors: {
- onSurface: MD3Colors.tertiary100,
- elevation: {
- level1: MD3Colors.tertiary50,
- },
- primary: MD3Colors.tertiary10,
- },
- };
+ const customTheme = {
+ ...defaultTheme,
+ colors: {
+ ...defaultTheme.colors,
+ onSurface: MD3Colors.tertiary100,
+ elevation: {
+ ...defaultTheme.colors.elevation,
+ level1: MD3Colors.tertiary50,
+ },
+ primary: MD3Colors.tertiary10,
+ },
+ };
return (
<>
diff --git a/example/src/Examples/BottomNavigationExample.tsx b/example/src/Examples/BottomNavigationExample.tsx
index 6ed5d7add5..419aca0f9d 100644
--- a/example/src/Examples/BottomNavigationExample.tsx
+++ b/example/src/Examples/BottomNavigationExample.tsx
@@ -17,7 +17,6 @@ import {
} from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
type Route = { route: { key: string } };
@@ -49,7 +48,6 @@ const PhotoGallery = ({ route }: Route) => {
};
const BottomNavigationExample = ({ navigation }: Props) => {
- const { isV3 } = useExampleTheme();
const insets = useSafeAreaInsets();
const [index, setIndex] = React.useState(0);
const [menuVisible, setMenuVisible] = React.useState(false);
@@ -63,34 +61,25 @@ const BottomNavigationExample = ({ navigation }: Props) => {
key: 'album',
title: 'Album',
focusedIcon: 'image-album',
- ...(!isV3 && { color: '#6200ee' }),
},
{
key: 'library',
title: 'Library',
focusedIcon: 'inbox',
+ unfocusedIcon: 'inbox-outline',
badge: true,
- ...(isV3
- ? { unfocusedIcon: 'inbox-outline' }
- : {
- color: '#2962ff',
- }),
},
{
key: 'favorites',
title: 'Favorites',
focusedIcon: 'heart',
- ...(isV3
- ? { unfocusedIcon: 'heart-outline' }
- : {
- color: '#00796b',
- }),
+ unfocusedIcon: 'heart-outline',
},
{
key: 'purchased',
title: 'Purchased',
focusedIcon: 'shopping',
- ...(isV3 ? { unfocusedIcon: 'shopping-outline' } : { color: '#c51162' }),
+ unfocusedIcon: 'shopping-outline',
},
]);
@@ -112,7 +101,6 @@ const BottomNavigationExample = ({ navigation }: Props) => {
setMenuVisible(true)}
- {...(!isV3 && { color: 'white' })}
/>
}
>
diff --git a/example/src/Examples/ButtonExample.tsx b/example/src/Examples/ButtonExample.tsx
index 7ec58f90f4..c6ecc56d09 100644
--- a/example/src/Examples/ButtonExample.tsx
+++ b/example/src/Examples/ButtonExample.tsx
@@ -9,11 +9,11 @@ import ScreenWrapper from '../ScreenWrapper';
const ButtonExample = () => {
const theme = useExampleTheme();
- const color = theme.isV3 ? theme.colors.inversePrimary : theme.colors.accent;
+ const color = theme.colors.inversePrimary;
return (
-
+
- {theme.isV3 && (
-
-
-
-
-
-
-
-
-
-
- )}
-
+
+
+
+
+
+
+
+
+
+
+
-
+
- {theme.isV3 && (
-
-
-
-
-
-
-
-
-
-
- )}
+
+
+
+
+
+
+
+
+
+
diff --git a/example/src/Examples/CheckboxExample.tsx b/example/src/Examples/CheckboxExample.tsx
index c8ce8c23a7..06088a646a 100644
--- a/example/src/Examples/CheckboxExample.tsx
+++ b/example/src/Examples/CheckboxExample.tsx
@@ -1,16 +1,8 @@
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
-import {
- Checkbox,
- MD2Colors,
- MD3Colors,
- Paragraph,
- Text,
- TouchableRipple,
-} from 'react-native-paper';
+import { Checkbox, MD3Colors, Text, TouchableRipple } from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
const CheckboxExample = () => {
@@ -18,14 +10,11 @@ const CheckboxExample = () => {
const [checkedCustom, setCheckedCustom] = React.useState(true);
const [indeterminate, setIndeterminate] = React.useState(true);
- const { isV3 } = useExampleTheme();
- const TextComponent = isV3 ? Text : Paragraph;
-
return (
setCheckedNormal(!checkedNormal)}>
- Normal
+ Normal
@@ -34,10 +23,10 @@ const CheckboxExample = () => {
setCheckedCustom(!checkedCustom)}>
- Custom
+ Custom
@@ -46,7 +35,7 @@ const CheckboxExample = () => {
setIndeterminate(!indeterminate)}>
- Indeterminate
+ Indeterminate
@@ -54,15 +43,15 @@ const CheckboxExample = () => {
- Checked (Disabled)
+ Checked (Disabled)
- Unchecked (Disabled)
+ Unchecked (Disabled)
- Indeterminate (Disabled)
+ Indeterminate (Disabled)
diff --git a/example/src/Examples/ChipExample.tsx b/example/src/Examples/ChipExample.tsx
index 20f0393153..211ebfde49 100644
--- a/example/src/Examples/ChipExample.tsx
+++ b/example/src/Examples/ChipExample.tsx
@@ -2,16 +2,8 @@ import * as React from 'react';
import { Image, StyleSheet, View } from 'react-native';
import color from 'color';
-import {
- Chip,
- List,
- MD2Colors,
- MD3Colors,
- Snackbar,
- Text,
-} from 'react-native-paper';
+import { Chip, List, MD3Colors, Snackbar, Text } from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
const ChipExample = () => {
@@ -19,8 +11,7 @@ const ChipExample = () => {
visible: false,
text: '',
});
- const { isV3 } = useExampleTheme();
- const customColor = isV3 ? MD3Colors.error50 : MD2Colors.purple900;
+ const customColor = MD3Colors.error50;
return (
<>
@@ -30,24 +21,20 @@ const ChipExample = () => {
{}} style={styles.chip}>
Simple
- {isV3 && (
- <>
- {}}
- style={styles.chip}
- >
- With selected overlay
-
- {}} style={styles.chip}>
- Elevated
-
- {}}>
- Compact chip
-
- >
- )}
+ {}}
+ style={styles.chip}
+ >
+ With selected overlay
+
+ {}} style={styles.chip}>
+ Elevated
+
+ {}}>
+ Compact chip
+
{}}
onClose={() =>
@@ -137,35 +124,31 @@ const ChipExample = () => {
{}} style={styles.chip}>
Simple
- {isV3 && (
- <>
- {}}
- style={styles.chip}
- >
- With selected overlay
-
- {}}
- style={styles.chip}
- >
- Elevated
-
- {}}
- style={styles.chip}
- >
- Compact chip
-
- >
- )}
+ {}}
+ style={styles.chip}
+ >
+ With selected overlay
+
+ {}}
+ style={styles.chip}
+ >
+ Elevated
+
+ {}}
+ style={styles.chip}
+ >
+ Compact chip
+
{}}
@@ -251,38 +234,34 @@ const ChipExample = () => {
- {isV3 && (
- <>
- {}}
- compact
- avatar={
-
- }
- style={[styles.chip, styles.customBorderRadius]}
- >
- Compact with custom border radius
-
- {}}
- compact
- avatar={
-
- }
- style={[styles.chip, styles.customBorderRadius]}
- >
- Compact with custom border radius
-
- >
- )}
+ {}}
+ compact
+ avatar={
+
+ }
+ style={[styles.chip, styles.customBorderRadius]}
+ >
+ Compact with custom border radius
+
+ {}}
+ compact
+ avatar={
+
+ }
+ style={[styles.chip, styles.customBorderRadius]}
+ >
+ Compact with custom border radius
+
{}}
diff --git a/example/src/Examples/Dialogs/DialogWithCustomColors.tsx b/example/src/Examples/Dialogs/DialogWithCustomColors.tsx
index 251b7b6fdb..e3bffafd60 100644
--- a/example/src/Examples/Dialogs/DialogWithCustomColors.tsx
+++ b/example/src/Examples/Dialogs/DialogWithCustomColors.tsx
@@ -1,15 +1,8 @@
import * as React from 'react';
-import {
- Button,
- Portal,
- Dialog,
- MD2Colors,
- MD3Colors,
-} from 'react-native-paper';
+import { Button, Portal, Dialog, MD3Colors } from 'react-native-paper';
import { TextComponent } from './DialogTextComponent';
-import { useExampleTheme } from '../../hooks/useExampleTheme';
const DialogWithCustomColors = ({
visible,
@@ -18,34 +11,25 @@ const DialogWithCustomColors = ({
visible: boolean;
close: () => void;
}) => {
- const { isV3 } = useExampleTheme();
-
return (
diff --git a/example/src/Examples/ProgressBarExample.tsx b/example/src/Examples/ProgressBarExample.tsx
index 565147f4c6..5ab797bb1d 100644
--- a/example/src/Examples/ProgressBarExample.tsx
+++ b/example/src/Examples/ProgressBarExample.tsx
@@ -4,7 +4,6 @@ import { View, StyleSheet, Animated } from 'react-native';
import {
Button,
ProgressBar,
- MD2Colors,
MD3Colors,
ProgressBarProps,
Text,
@@ -29,7 +28,6 @@ const ProgressBarExample = () => {
const [visible, setVisible] = React.useState(true);
const [progress, setProgress] = React.useState(0.3);
const theme = useExampleTheme();
- const { isV3 } = theme;
const { current: progressBarValue } = React.useRef(new Animated.Value(0));
const runCustomAnimation = () => {
@@ -64,7 +62,7 @@ const ProgressBarExample = () => {
@@ -75,9 +73,9 @@ const ProgressBarExample = () => {
diff --git a/example/src/Examples/RadioButtonExample.tsx b/example/src/Examples/RadioButtonExample.tsx
index 88bf9ebfb7..7e3b3cf754 100644
--- a/example/src/Examples/RadioButtonExample.tsx
+++ b/example/src/Examples/RadioButtonExample.tsx
@@ -2,29 +2,24 @@ import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import {
- MD2Colors,
MD3Colors,
- Paragraph,
RadioButton,
Text,
TouchableRipple,
} from 'react-native-paper';
-import { useExampleTheme } from '../hooks/useExampleTheme';
import ScreenWrapper from '../ScreenWrapper';
type State = 'normal' | 'normal-ios' | 'normal-item' | 'custom';
const RadioButtonExample = () => {
const [checked, setChecked] = React.useState('normal');
- const { isV3 } = useExampleTheme();
- const TextComponent = isV3 ? Text : Paragraph;
return (
setChecked('normal')}>
- Normal - Material Design
+ Normal - Material Design
{
setChecked('normal-ios')}>
- Normal 2 - IOS
+ Normal 2 - IOS
{
setChecked('custom')}>
- Custom
+ Custom
@@ -63,11 +58,11 @@ const RadioButtonExample = () => {
onPress={() => setChecked('normal-item')}
/>
- Checked (Disabled)
+ Checked (Disabled)
- Unchecked (Disabled)
+ Unchecked (Disabled)
{
const [valueNormal, setNormalValue] = React.useState(true);
const [valueCustom, setCustomValue] = React.useState(true);
- const { isV3 } = useExampleTheme();
-
const switchValueNormalLabel = `switch ${
valueNormal === true ? 'on' : 'off'
}`;
@@ -26,13 +16,11 @@ const SwitchExample = () => {
valueCustom === true ? 'on' : 'off'
}`;
- const TextComponent = isV3 ? Text : Paragraph;
-
return Platform.OS === 'android' ? (
setNormalValue(!valueNormal)}>
- Normal {switchValueNormalLabel}
+ Normal {switchValueNormalLabel}
@@ -40,47 +28,44 @@ const SwitchExample = () => {
setCustomValue(!valueCustom)}>
- Custom {switchValueCustomlLabel}
+ Custom {switchValueCustomlLabel}
-
+
- Switch on (disabled)
+ Switch on (disabled)
- Switch off (disabled)
+ Switch off (disabled)
) : (
- Normal {switchValueNormalLabel}
+ Normal {switchValueNormalLabel}
setNormalValue(!valueNormal)}
/>
- Custom {switchValueCustomlLabel}
+ Custom {switchValueCustomlLabel}
setCustomValue(!valueCustom)}
- color={isV3 ? MD3Colors.tertiary50 : MD2Colors.blue500}
+ color={MD3Colors.tertiary50}
/>
- Switch on (disabled)
+ Switch on (disabled)
- Switch off (disabled)
+ Switch off (disabled)
diff --git a/example/src/Examples/TextInputExample.tsx b/example/src/Examples/TextInputExample.tsx
index 7102abd0b6..37c039ba13 100644
--- a/example/src/Examples/TextInputExample.tsx
+++ b/example/src/Examples/TextInputExample.tsx
@@ -13,7 +13,6 @@ import {
configureFonts,
HelperText,
List,
- MD2Colors,
MD3Colors,
TextInput,
} from 'react-native-paper';
@@ -138,11 +137,7 @@ const TextInputExample = () => {
const newColors = {
...state.iconsColor,
- [name]: !color
- ? theme.isV3
- ? theme.colors.primary
- : theme.colors?.accent
- : undefined,
+ [name]: !color ? theme.colors.primary : undefined,
};
dispatch({
@@ -572,9 +567,7 @@ const TextInputExample = () => {
*
@@ -604,12 +597,8 @@ const TextInputExample = () => {
onChangeText={(flatUnderlineColors) =>
inputActionHandler('flatUnderlineColors', flatUnderlineColors)
}
- underlineColor={
- theme.isV3 ? MD3Colors.primary70 : MD2Colors.pink400
- }
- activeUnderlineColor={
- theme.isV3 ? MD3Colors.tertiary50 : MD2Colors.amber900
- }
+ underlineColor={MD3Colors.primary70}
+ activeUnderlineColor={MD3Colors.tertiary50}
/>
{
onChangeText={(outlinedColors) =>
inputActionHandler('outlinedColors', outlinedColors)
}
- outlineColor={
- theme.isV3 ? MD3Colors.primary70 : MD2Colors.pink400
- }
- activeOutlineColor={
- theme.isV3 ? MD3Colors.tertiary50 : MD2Colors.amber900
- }
+ outlineColor={MD3Colors.primary70}
+ activeOutlineColor={MD3Colors.tertiary50}
/>
void;
toggleRtl: () => void;
- toggleThemeVersion: () => void;
toggleCollapsed: () => void;
toggleCustomFont: () => void;
toggleRippleEffect: () => void;
toggleShouldUseDeviceColors?: () => void;
- theme: MD2Theme | MD3Theme;
+ theme: MD3Theme;
rtl: boolean;
collapsed: boolean;
customFontLoaded: boolean;
diff --git a/example/src/hooks/useExampleTheme.ts b/example/src/hooks/useExampleTheme.ts
index 9196f044b0..059ab4d05c 100644
--- a/example/src/hooks/useExampleTheme.ts
+++ b/example/src/hooks/useExampleTheme.ts
@@ -1,3 +1,3 @@
-import { MD2Theme, MD3Theme, useTheme } from 'react-native-paper';
+import { useTheme, type MD3Theme } from 'react-native-paper';
-export const useExampleTheme = () => useTheme();
+export const useExampleTheme = () => useTheme();
diff --git a/example/src/index.native.tsx b/example/src/index.native.tsx
index 0878a1f13b..70d712816b 100644
--- a/example/src/index.native.tsx
+++ b/example/src/index.native.tsx
@@ -9,13 +9,7 @@ import { useFonts } from 'expo-font';
import { useKeepAwake } from 'expo-keep-awake';
import { StatusBar } from 'expo-status-bar';
import * as Updates from 'expo-updates';
-import {
- PaperProvider,
- MD2DarkTheme,
- MD2LightTheme,
- MD3DarkTheme,
- MD3LightTheme,
-} from 'react-native-paper';
+import { PaperProvider, MD3DarkTheme, MD3LightTheme } from 'react-native-paper';
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
import DrawerItems from './DrawerItems';
@@ -49,7 +43,6 @@ export default function PaperExample() {
const [shouldUseDeviceColors, setShouldUseDeviceColors] =
React.useState(true);
const [isDarkMode, setIsDarkMode] = React.useState(false);
- const [themeVersion, setThemeVersion] = React.useState<2 | 3>(3);
const [rtl, setRtl] = React.useState(
I18nManager.getConstants().isRTL
);
@@ -59,10 +52,6 @@ export default function PaperExample() {
const { theme: mdTheme } = useMaterial3Theme();
const theme = React.useMemo(() => {
- if (themeVersion === 2) {
- return isDarkMode ? MD2DarkTheme : MD2LightTheme;
- }
-
if (!deviceColorsSupported || !shouldUseDeviceColors) {
return isDarkMode ? MD3DarkTheme : MD3LightTheme;
}
@@ -70,7 +59,7 @@ export default function PaperExample() {
return isDarkMode
? { ...MD3DarkTheme, colors: mdTheme.dark }
: { ...MD3LightTheme, colors: mdTheme.light };
- }, [isDarkMode, mdTheme, shouldUseDeviceColors, themeVersion]);
+ }, [isDarkMode, mdTheme, shouldUseDeviceColors]);
React.useEffect(() => {
const restoreState = async () => {
@@ -144,12 +133,6 @@ export default function PaperExample() {
toggleCollapsed: () => setCollapsed(!collapsed),
toggleCustomFont: () => setCustomFont(!customFontLoaded),
toggleRippleEffect: () => setRippleEffectEnabled(!rippleEffectEnabled),
- toggleThemeVersion: () => {
- setCustomFont(false);
- setCollapsed(false);
- setThemeVersion((oldThemeVersion) => (oldThemeVersion === 2 ? 3 : 2));
- setRippleEffectEnabled(true);
- },
customFontLoaded,
rippleEffectEnabled,
collapsed,
diff --git a/example/src/index.tsx b/example/src/index.tsx
index 76607763f1..4395d2d55e 100644
--- a/example/src/index.tsx
+++ b/example/src/index.tsx
@@ -5,13 +5,7 @@ import { createDrawerNavigator } from '@react-navigation/drawer';
import { InitialState, NavigationContainer } from '@react-navigation/native';
import { useFonts } from 'expo-font';
import { useKeepAwake } from 'expo-keep-awake';
-import {
- PaperProvider,
- MD3DarkTheme,
- MD3LightTheme,
- MD2DarkTheme,
- MD2LightTheme,
-} from 'react-native-paper';
+import { PaperProvider, MD3DarkTheme, MD3LightTheme } from 'react-native-paper';
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
import DrawerItems from './DrawerItems';
@@ -43,18 +37,14 @@ export default function PaperExample() {
>();
const [isDarkMode, setIsDarkMode] = React.useState(false);
- const [themeVersion, setThemeVersion] = React.useState<2 | 3>(3);
const [collapsed, setCollapsed] = React.useState(false);
const [customFontLoaded, setCustomFont] = React.useState(false);
const [rippleEffectEnabled, setRippleEffectEnabled] = React.useState(true);
- const theme = React.useMemo(() => {
- if (themeVersion === 2) {
- return isDarkMode ? MD2DarkTheme : MD2LightTheme;
- }
-
- return isDarkMode ? MD3DarkTheme : MD3LightTheme;
- }, [isDarkMode, themeVersion]);
+ const theme = React.useMemo(
+ () => (isDarkMode ? MD3DarkTheme : MD3LightTheme),
+ [isDarkMode]
+ );
React.useEffect(() => {
const restoreState = async () => {
@@ -112,12 +102,6 @@ export default function PaperExample() {
const preferences = React.useMemo(
() => ({
toggleTheme: () => setIsDarkMode((oldValue) => !oldValue),
- toggleThemeVersion: () => {
- setCustomFont(false);
- setCollapsed(false);
- setThemeVersion((oldThemeVersion) => (oldThemeVersion === 2 ? 3 : 2));
- setRippleEffectEnabled(true);
- },
toggleCollapsed: () => setCollapsed(!collapsed),
toggleCustomFont: () => setCustomFont(!customFontLoaded),
toggleRippleEffect: () => setRippleEffectEnabled(!rippleEffectEnabled),
diff --git a/src/babel/__fixtures__/rewrite-imports/code.js b/src/babel/__fixtures__/rewrite-imports/code.js
index cc5e6d0b5c..6509ef2f67 100644
--- a/src/babel/__fixtures__/rewrite-imports/code.js
+++ b/src/babel/__fixtures__/rewrite-imports/code.js
@@ -5,7 +5,6 @@ import {
Button,
FAB,
Appbar,
- MD2Colors,
MD3Colors,
NonExistent,
NonExistentSecond as Stuff,
diff --git a/src/babel/__fixtures__/rewrite-imports/output.js b/src/babel/__fixtures__/rewrite-imports/output.js
index ecaff8d814..7204b0ca33 100644
--- a/src/babel/__fixtures__/rewrite-imports/output.js
+++ b/src/babel/__fixtures__/rewrite-imports/output.js
@@ -4,7 +4,6 @@ import BottomNavigation from "react-native-paper/lib/module/components/BottomNav
import Button from "react-native-paper/lib/module/components/Button/Button";
import FAB from "react-native-paper/lib/module/components/FAB";
import Appbar from "react-native-paper/lib/module/components/Appbar";
-import * as MD2Colors from "react-native-paper/lib/module/styles/themes/v2/colors";
import { MD3Colors } from "react-native-paper/lib/module/styles/themes/v3/tokens";
import { NonExistent, NonExistentSecond as Stuff } from "react-native-paper/lib/module/index.js";
import { ThemeProvider } from "react-native-paper/lib/module/core/theming";
diff --git a/src/components/ActivityIndicator.tsx b/src/components/ActivityIndicator.tsx
index 5a3b9f8736..3de4e73d2f 100644
--- a/src/components/ActivityIndicator.tsx
+++ b/src/components/ActivityIndicator.tsx
@@ -45,10 +45,10 @@ const DURATION = 2400;
* ## Usage
* ```js
* import * as React from 'react';
- * import { ActivityIndicator, MD2Colors } from 'react-native-paper';
+ * import { ActivityIndicator, MD3Colors } from 'react-native-paper';
*
* const MyComponent = () => (
- *
+ *
* );
*
* export default MyComponent;
diff --git a/src/components/Appbar/Appbar.tsx b/src/components/Appbar/Appbar.tsx
index d59c626769..4934ef7bf6 100644
--- a/src/components/Appbar/Appbar.tsx
+++ b/src/components/Appbar/Appbar.tsx
@@ -1,7 +1,6 @@
import * as React from 'react';
import {
Animated,
- Platform,
StyleProp,
StyleSheet,
View,
@@ -9,12 +8,9 @@ import {
ColorValue,
} from 'react-native';
-import color from 'color';
-
import AppbarContent from './AppbarContent';
import {
AppbarModes,
- DEFAULT_APPBAR_HEIGHT,
getAppbarBackgroundColor,
modeAppbarHeight,
renderAppbarContent,
@@ -165,11 +161,10 @@ const Appbar = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3 } = theme;
const flattenedStyle = StyleSheet.flatten(style);
const {
backgroundColor: customBackground,
- elevation = isV3 ? (elevated ? 2 : 0) : 4,
+ elevation = elevated ? 2 : 0,
...restStyle
} = (flattenedStyle || {}) as Exclude & {
elevation?: number;
@@ -184,28 +179,17 @@ const Appbar = ({
);
const isMode = (modeToCompare: AppbarModes) => {
- return isV3 && mode === modeToCompare;
+ return mode === modeToCompare;
};
- let isDark = false;
-
- if (typeof dark === 'boolean') {
- isDark = dark;
- } else if (!isV3) {
- isDark =
- backgroundColor === 'transparent'
- ? false
- : typeof backgroundColor === 'string'
- ? !color(backgroundColor).isLight()
- : true;
- }
+ const isDark = typeof dark === 'boolean' ? dark : false;
- const isV3CenterAlignedMode = isV3 && isMode('center-aligned');
+ const isCenterAlignedMode = isMode('center-aligned');
let shouldCenterContent = false;
let shouldAddLeftSpacing = false;
let shouldAddRightSpacing = false;
- if ((!isV3 && Platform.OS === 'ios') || isV3CenterAlignedMode) {
+ if (isCenterAlignedMode) {
let hasAppbarContent = false;
let leftItemsCount = 0;
let rightItemsCount = 0;
@@ -225,14 +209,12 @@ const Appbar = ({
});
shouldCenterContent =
- hasAppbarContent &&
- leftItemsCount < 2 &&
- rightItemsCount < (isV3 ? 3 : 2);
+ hasAppbarContent && leftItemsCount < 2 && rightItemsCount < 3;
shouldAddLeftSpacing = shouldCenterContent && leftItemsCount === 0;
shouldAddRightSpacing = shouldCenterContent && rightItemsCount === 0;
}
- const spacingStyle = isV3 ? styles.v3Spacing : styles.spacing;
+ const spacingStyle = styles.v3Spacing;
const insets = {
paddingBottom: safeAreaInsets?.bottom,
@@ -247,27 +229,25 @@ const Appbar = ({
{ backgroundColor },
styles.appbar,
{
- height: isV3 ? modeAppbarHeight[mode] : DEFAULT_APPBAR_HEIGHT,
+ height: modeAppbarHeight[mode],
},
insets,
restStyle,
- !theme.isV3 && { elevation },
]}
elevation={elevation as MD3Elevation}
container
{...rest}
>
{shouldAddLeftSpacing ? : null}
- {(!isV3 || isMode('small') || isMode('center-aligned')) && (
+ {(isMode('small') || isMode('center-aligned')) && (
<>
{/* Render only the back action at first place */}
{renderAppbarContent({
children,
isDark,
theme,
- isV3,
renderOnly: ['Appbar.BackAction'],
- shouldCenterContent: isV3CenterAlignedMode || shouldCenterContent,
+ shouldCenterContent: isCenterAlignedMode || shouldCenterContent,
})}
{/* Render the rest of the content except the back action */}
{renderAppbarContent({
@@ -278,9 +258,8 @@ const Appbar = ({
],
isDark,
theme,
- isV3,
renderExcept: ['Appbar.BackAction'],
- shouldCenterContent: isV3CenterAlignedMode || shouldCenterContent,
+ shouldCenterContent: isCenterAlignedMode || shouldCenterContent,
})}
>
)}
@@ -297,14 +276,12 @@ const Appbar = ({
{renderAppbarContent({
children,
isDark,
- isV3,
renderOnly: ['Appbar.BackAction'],
mode,
})}
{renderAppbarContent({
children: filterAppbarActions(children, true),
isDark,
- isV3,
renderOnly: ['Appbar.Action'],
mode,
})}
@@ -313,7 +290,6 @@ const Appbar = ({
{renderAppbarContent({
children: filterAppbarActions(children),
isDark,
- isV3,
renderExcept: [
'Appbar',
'Appbar.BackAction',
@@ -327,7 +303,6 @@ const Appbar = ({
{renderAppbarContent({
children,
isDark,
- isV3,
renderOnly: ['Appbar.Content'],
mode,
})}
@@ -344,9 +319,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
paddingHorizontal: 4,
},
- spacing: {
- width: 48,
- },
v3Spacing: {
width: 52,
},
diff --git a/src/components/Appbar/AppbarAction.tsx b/src/components/Appbar/AppbarAction.tsx
index ab5a72a110..14982cbecb 100644
--- a/src/components/Appbar/AppbarAction.tsx
+++ b/src/components/Appbar/AppbarAction.tsx
@@ -7,11 +7,10 @@ import type {
ViewStyle,
} from 'react-native';
-import color from 'color';
import type { ThemeProp } from 'src/types';
import { useInternalTheme } from '../../core/theming';
-import { black } from '../../styles/themes/v2/colors';
+import type { MD3Theme } from '../../types';
import { forwardRef } from '../../utils/forwardRef';
import type { IconSource } from '../Icon';
import IconButton from '../IconButton/IconButton';
@@ -98,14 +97,13 @@ const AppbarAction = forwardRef(
ref
) => {
const theme = useInternalTheme(themeOverrides);
+ const { colors } = theme as MD3Theme;
const actionIconColor = iconColor
? iconColor
- : theme.isV3
- ? isLeading
- ? theme.colors.onSurface
- : theme.colors.onSurfaceVariant
- : color(black).alpha(0.54).rgb().string();
+ : isLeading
+ ? colors.onSurface
+ : colors.onSurfaceVariant;
return (
& {
*/
const AppbarContent = ({
color: titleColor,
- subtitle,
- subtitleStyle,
onPress,
disabled,
style,
@@ -117,15 +117,9 @@ const AppbarContent = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3, colors } = theme;
-
- const titleTextColor = titleColor
- ? titleColor
- : isV3
- ? colors.onSurface
- : white;
+ const { colors, fonts } = theme as MD3Theme;
- const subtitleColor = color(titleTextColor).alpha(0.7).rgb().string();
+ const titleTextColor = titleColor ? titleColor : colors.onSurface;
const modeContainerStyles = {
small: styles.v3DefaultContainer,
@@ -138,7 +132,7 @@ const AppbarContent = ({
const contentWrapperProps = {
pointerEvents: 'box-none' as ViewProps['pointerEvents'],
- style: [styles.container, isV3 && modeContainerStyles[mode], style],
+ style: [styles.container, modeContainerStyles[mode], style],
testID,
...rest,
};
@@ -147,18 +141,13 @@ const AppbarContent = ({
<>
{typeof title === 'string' ? (
- {subtitle}
-
- ) : null}
>
);
@@ -233,12 +214,6 @@ const styles = StyleSheet.create({
justifyContent: 'flex-end',
paddingBottom: 28,
},
- title: {
- fontSize: Platform.OS === 'ios' ? 17 : 20,
- },
- subtitle: {
- fontSize: Platform.OS === 'ios' ? 11 : 14,
- },
});
const touchableRole: AccessibilityRole = 'button';
diff --git a/src/components/Appbar/AppbarHeader.tsx b/src/components/Appbar/AppbarHeader.tsx
index e0eb6386d7..9efe81bba1 100644
--- a/src/components/Appbar/AppbarHeader.tsx
+++ b/src/components/Appbar/AppbarHeader.tsx
@@ -13,7 +13,6 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Appbar } from './Appbar';
import {
- DEFAULT_APPBAR_HEIGHT,
getAppbarBackgroundColor,
modeAppbarHeight,
getAppbarBorders,
@@ -104,14 +103,13 @@ const AppbarHeader = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3 } = theme;
const flattenedStyle = StyleSheet.flatten(style);
const {
- height = isV3 ? modeAppbarHeight[mode] : DEFAULT_APPBAR_HEIGHT,
- elevation = isV3 ? (elevated ? 2 : 0) : 4,
+ height = modeAppbarHeight[mode],
+ elevation = elevated ? 2 : 0,
backgroundColor: customBackground,
- zIndex = isV3 && elevated ? 1 : 0,
+ zIndex = elevated ? 1 : 0,
...restStyle
} = (flattenedStyle || {}) as Exclude & {
height?: number;
@@ -150,10 +148,8 @@ const AppbarHeader = ({
testID={testID}
style={[{ height, backgroundColor }, styles.appbar, restStyle]}
dark={dark}
- {...(isV3 && {
- mode,
- })}
{...rest}
+ mode={mode}
theme={theme}
/>
diff --git a/src/components/Appbar/utils.ts b/src/components/Appbar/utils.ts
index a6c68af2a5..fbf4fe438e 100644
--- a/src/components/Appbar/utils.ts
+++ b/src/components/Appbar/utils.ts
@@ -2,9 +2,8 @@ import React from 'react';
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
import { StyleSheet, Animated } from 'react-native';
-import overlay from '../../styles/overlay';
-import { black, white } from '../../styles/themes/v2/colors';
-import type { InternalTheme, ThemeProp } from '../../types';
+import { white } from '../../styles/themes/v2/colors';
+import type { InternalTheme, MD3Theme, ThemeProp } from '../../types';
export type AppbarModes = 'small' | 'medium' | 'large' | 'center-aligned';
@@ -24,26 +23,17 @@ const borderStyleProperties = [
export const getAppbarBackgroundColor = (
theme: InternalTheme,
- elevation: number,
+ _elevation: number,
customBackground?: ColorValue,
elevated?: boolean
) => {
- const { isV3, dark: isDarkTheme, mode, colors } = theme;
- const isAdaptiveMode = mode === 'adaptive';
+ const { colors } = theme as MD3Theme;
if (customBackground) {
return customBackground;
}
- if (!isV3) {
- if (isDarkTheme && isAdaptiveMode) {
- return overlay(elevation, colors?.surface);
- }
-
- return colors.primary;
- }
-
if (elevated) {
- return theme.colors.elevation.level2;
+ return colors.elevation.level2;
}
return colors.surface;
@@ -52,7 +42,6 @@ export const getAppbarBackgroundColor = (
export const getAppbarColor = ({
color,
isDark,
- isV3,
}: BaseProps & { color: string }) => {
if (typeof color !== 'undefined') {
return color;
@@ -62,11 +51,7 @@ export const getAppbarColor = ({
return white;
}
- if (isV3) {
- return undefined;
- }
-
- return black;
+ return undefined;
};
export const getAppbarBorders = (
@@ -89,13 +74,11 @@ export const getAppbarBorders = (
type BaseProps = {
isDark: boolean;
- isV3: boolean;
};
type RenderAppbarContentProps = BaseProps & {
children: React.ReactNode;
shouldCenterContent?: boolean;
- isV3: boolean;
renderOnly?: (string | boolean)[];
renderExcept?: string[];
mode?: AppbarModes;
@@ -133,7 +116,6 @@ export const renderAppbarContent = ({
children,
isDark,
shouldCenterContent = false,
- isV3,
renderOnly,
renderExcept,
mode = 'small',
@@ -172,16 +154,14 @@ export const renderAppbarContent = ({
theme?: ThemeProp;
} = {
theme,
- color: getAppbarColor({ color: child.props.color, isDark, isV3 }),
+ color: getAppbarColor({ color: child.props.color, isDark }),
};
// @ts-expect-error: TypeScript complains about the type of type but it doesn't matter
if (child.type.displayName === 'Appbar.Content') {
props.mode = mode;
props.style = [
- isV3
- ? i === 0 && !shouldCenterContent && styles.v3Spacing
- : i !== 0 && styles.v2Spacing,
+ i === 0 && !shouldCenterContent && styles.v3Spacing,
shouldCenterContent && styles.centerAlignedContent,
child.props.style,
];
@@ -195,9 +175,6 @@ const styles = StyleSheet.create({
centerAlignedContent: {
alignItems: 'center',
},
- v2Spacing: {
- marginLeft: 8,
- },
v3Spacing: {
marginLeft: 12,
},
diff --git a/src/components/Badge.tsx b/src/components/Badge.tsx
index 54c70770f2..d8bf38015b 100644
--- a/src/components/Badge.tsx
+++ b/src/components/Badge.tsx
@@ -8,9 +8,7 @@ import {
} from 'react-native';
import { useInternalTheme } from '../core/theming';
-import { black, white } from '../styles/themes/v2/colors';
import type { ThemeProp } from '../types';
-import getContrastingColor from '../utils/getContrastingColor';
const defaultSize = 20;
@@ -85,20 +83,14 @@ const Badge = ({
}).start();
}, [visible, opacity, scale]);
- const {
- backgroundColor = theme.isV3
- ? theme.colors.error
- : theme.colors?.notification,
- ...restStyle
- } = (StyleSheet.flatten(style) || {}) as TextStyle;
+ const { backgroundColor = theme.colors.error, ...restStyle } =
+ (StyleSheet.flatten(style) || {}) as TextStyle;
- const textColor = theme.isV3
- ? theme.colors.onError
- : getContrastingColor(backgroundColor, white, black);
+ const textColor = theme.colors.onError;
const borderRadius = size / 2;
- const paddingHorizontal = theme.isV3 ? 3 : 4;
+ const paddingHorizontal = 3;
return (
{
const theme = useInternalTheme(themeOverrides);
+ const { colors } = theme as MD3Theme;
const { current: position } = React.useRef(
new Animated.Value(visible ? 1 : 0)
);
@@ -192,10 +193,10 @@ const Banner = ({
return (
@@ -222,12 +223,11 @@ const Banner = ({
) : null}
@@ -292,9 +292,6 @@ const styles = StyleSheet.create({
button: {
margin: 4,
},
- elevation: {
- elevation: 1,
- },
transparent: {
opacity: 0,
},
diff --git a/src/components/BottomNavigation/BottomNavigation.tsx b/src/components/BottomNavigation/BottomNavigation.tsx
index c4e9b71a60..54df09d236 100644
--- a/src/components/BottomNavigation/BottomNavigation.tsx
+++ b/src/components/BottomNavigation/BottomNavigation.tsx
@@ -353,9 +353,8 @@ const BottomNavigation = ({
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const { scale } = theme.animation;
- const compact = compactProp ?? !theme.isV3;
- let shifting =
- shiftingProp ?? (theme.isV3 ? false : navigationState.routes.length > 3);
+ const compact = compactProp ?? false;
+ let shifting = shiftingProp ?? false;
if (shifting && navigationState.routes.length < 2) {
shifting = false;
@@ -404,7 +403,7 @@ const BottomNavigation = ({
...navigationState.routes.map((_, i) =>
Animated.timing(tabsPositionAnims[i], {
toValue: i === index ? 0 : i >= index ? 1 : -1,
- duration: theme.isV3 || shifting ? 150 * scale : 0,
+ duration: 150 * scale,
useNativeDriver: true,
easing: sceneAnimationEasing,
})
diff --git a/src/components/BottomNavigation/BottomNavigationBar.tsx b/src/components/BottomNavigation/BottomNavigationBar.tsx
index 05264c610a..3d315aea70 100644
--- a/src/components/BottomNavigation/BottomNavigationBar.tsx
+++ b/src/components/BottomNavigation/BottomNavigationBar.tsx
@@ -11,7 +11,6 @@ import {
ViewStyle,
} from 'react-native';
-import color from 'color';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import {
@@ -20,9 +19,7 @@ import {
getLabelColor,
} from './utils';
import { useInternalTheme } from '../../core/theming';
-import overlay from '../../styles/overlay';
-import { black, white } from '../../styles/themes/v2/colors';
-import type { ThemeProp } from '../../types';
+import type { MD3Theme, ThemeProp } from '../../types';
import useAnimatedValue from '../../utils/useAnimatedValue';
import useAnimatedValueArray from '../../utils/useAnimatedValueArray';
import useIsKeyboardShown from '../../utils/useIsKeyboardShown';
@@ -212,7 +209,6 @@ export type Props = {
testID?: string;
};
-const MIN_RIPPLE_SCALE = 0.001; // Minimum scale is not 0 due to bug with animation
const MIN_TAB_WIDTH = 96;
const MAX_TAB_WIDTH = 168;
const BAR_HEIGHT = 56;
@@ -321,7 +317,7 @@ const BottomNavigationBar = ({
),
getLabelText = ({ route }: { route: Route }) => route.title,
getBadge = ({ route }: { route: Route }) => route.badge,
- getColor = ({ route }: { route: Route }) => route.color,
+ getColor: _getColor = ({ route }: { route: Route }) => route.color,
getAccessibilityLabel = ({ route }: { route: Route }) =>
route.accessibilityLabel,
getTestID = ({ route }: { route: Route }) => route.testID,
@@ -342,11 +338,11 @@ const BottomNavigationBar = ({
theme: themeOverrides,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
+ const { colors } = theme as MD3Theme;
const { bottom, left, right } = useSafeAreaInsets();
const { scale } = theme.animation;
- const compact = compactProp ?? !theme.isV3;
- let shifting =
- shiftingProp ?? (theme.isV3 ? false : navigationState.routes.length > 3);
+ const compact = compactProp ?? false;
+ let shifting = shiftingProp ?? false;
if (shifting && navigationState.routes.length < 2) {
shifting = false;
@@ -371,18 +367,7 @@ const BottomNavigationBar = ({
);
/**
- * Index of the currently active tab. Used for setting the background color.
- * We don't use the color as an animated value directly, because `setValue` seems to be buggy with colors?.
- */
- const indexAnim = useAnimatedValue(navigationState.index);
-
- /**
- * Animation for the background color ripple, used to determine it's scale and opacity.
- */
- const rippleAnim = useAnimatedValue(MIN_RIPPLE_SCALE);
-
- /**
- * Layout of the navigation bar. The width is used to determine the size and position of the ripple.
+ * Layout of the navigation bar.
*/
const [layout, onLayout] = useLayout();
@@ -412,42 +397,21 @@ const BottomNavigationBar = ({
const animateToIndex = React.useCallback(
(index: number) => {
- // Reset the ripple to avoid glitch if it's currently animating
- rippleAnim.setValue(MIN_RIPPLE_SCALE);
-
- Animated.parallel([
- Animated.timing(rippleAnim, {
- toValue: 1,
- duration: theme.isV3 || shifting ? 400 * scale : 0,
- useNativeDriver: true,
- }),
- ...navigationState.routes.map((_, i) =>
+ Animated.parallel(
+ navigationState.routes.map((_, i) =>
Animated.timing(tabsAnims[i], {
toValue: i === index ? 1 : 0,
- duration: theme.isV3 || shifting ? 150 * scale : 0,
+ duration: 150 * scale,
useNativeDriver: true,
easing: animationEasing,
})
- ),
- ]).start(() => {
+ )
+ ).start(() => {
// Workaround a bug in native animations where this is reset after first animation
tabsAnims.map((tab, i) => tab.setValue(i === index ? 1 : 0));
-
- // Update the index to change bar's background color and then hide the ripple
- indexAnim.setValue(index);
- rippleAnim.setValue(MIN_RIPPLE_SCALE);
});
},
- [
- rippleAnim,
- theme.isV3,
- shifting,
- scale,
- navigationState.routes,
- tabsAnims,
- animationEasing,
- indexAnim,
- ]
+ [scale, navigationState.routes, tabsAnims, animationEasing]
);
React.useEffect(() => {
@@ -479,62 +443,28 @@ const BottomNavigationBar = ({
};
const { routes } = navigationState;
- const { colors, dark: isDarkTheme, mode, isV3 } = theme;
- const { backgroundColor: customBackground, elevation = 4 } =
- (StyleSheet.flatten(style) || {}) as {
- elevation?: number;
- backgroundColor?: ColorValue;
- };
+ const { backgroundColor: customBackground } = (StyleSheet.flatten(style) ||
+ {}) as {
+ elevation?: number;
+ backgroundColor?: ColorValue;
+ };
- const approxBackgroundColor = customBackground
- ? customBackground
- : isDarkTheme && mode === 'adaptive'
- ? overlay(elevation, colors?.surface)
- : colors?.primary;
-
- const v2BackgroundColorInterpolation = shifting
- ? indexAnim.interpolate({
- inputRange: routes.map((_, i) => i),
- // FIXME: does outputRange support ColorValue or just strings?
- // @ts-expect-error
- outputRange: routes.map(
- (route) => getColor({ route }) || approxBackgroundColor
- ),
- })
- : approxBackgroundColor;
-
- const backgroundColor = isV3
- ? customBackground || theme.colors.elevation.level2
- : shifting
- ? v2BackgroundColorInterpolation
- : approxBackgroundColor;
-
- const isDark =
- typeof approxBackgroundColor === 'string'
- ? !color(approxBackgroundColor).isLight()
- : true;
-
- const textColor = isDark ? white : black;
+ const backgroundColor = customBackground || colors.elevation.level2;
const activeTintColor = getActiveTintColor({
activeColor,
- defaultColor: textColor,
theme,
});
const inactiveTintColor = getInactiveTintColor({
inactiveColor,
- defaultColor: textColor,
theme,
});
- const touchColor = color(activeTintColor).alpha(0.12).rgb().string();
const maxTabWidth = routes.length > 3 ? MIN_TAB_WIDTH : MAX_TAB_WIDTH;
const maxTabBarWidth = maxTabWidth * routes.length;
- const rippleSize = layout.width / 4;
-
const insets = {
left: safeAreaInsets?.left ?? left,
right: safeAreaInsets?.right ?? right,
@@ -543,10 +473,9 @@ const BottomNavigationBar = ({
return (
({
accessibilityRole={'tablist'}
testID={`${testID}-content-wrapper`}
>
- {shifting && !isV3 ? (
-
- ) : null}
{routes.map((route, index) => {
const focused = navigationState.index === index;
const active = tabsAnims[index];
- // Scale the label up
- const scale =
- labeled && shifting
- ? active.interpolate({
- inputRange: [0, 1],
- outputRange: [0.5, 1],
- })
- : 1;
-
// Move down the icon to account for no-label in shifting and smaller label in non-shifting.
const translateY = labeled
? shifting
@@ -684,7 +567,6 @@ const BottomNavigationBar = ({
tintColor: activeTintColor,
hasColor: Boolean(activeColor),
focused,
- defaultColor: textColor,
theme,
});
@@ -692,55 +574,53 @@ const BottomNavigationBar = ({
tintColor: inactiveTintColor,
hasColor: Boolean(inactiveColor),
focused,
- defaultColor: textColor,
theme,
});
const badgeStyle = {
- top: !isV3 ? -2 : typeof badge === 'boolean' ? 4 : 2,
+ top: typeof badge === 'boolean' ? 4 : 2,
right:
- (badge != null && typeof badge !== 'boolean'
+ badge != null && typeof badge !== 'boolean'
? String(badge).length * -2
- : 0) - (!isV3 ? 2 : 0),
+ : 0,
};
- const isLegacyOrV3Shifting = !isV3 || (isV3 && shifting && labeled);
+ const isLegacyOrV3Shifting = shifting && labeled;
- const font = isV3 ? theme.fonts.labelMedium : {};
+ const font = (theme as MD3Theme).fonts.labelMedium;
return renderTouchable({
key: route.key,
route,
borderless: true,
centered: true,
- rippleColor: isV3 ? 'transparent' : touchColor,
+ rippleColor: 'transparent',
onPress: () => onTabPress(eventForIndex(index)),
onLongPress: () => onTabLongPress?.(eventForIndex(index)),
testID: getTestID({ route }),
accessibilityLabel: getAccessibilityLabel({ route }),
accessibilityRole: Platform.OS === 'ios' ? 'button' : 'tab',
accessibilityState: { selected: focused },
- style: [styles.item, isV3 && styles.v3Item],
+ style: [styles.item, styles.v3Item],
children: (
- {isV3 && focused && (
+ {focused && (
({
scaleX: outlineScale,
},
],
- backgroundColor: theme.colors.secondaryContainer,
+ backgroundColor: colors.secondaryContainer,
},
activeIndicatorStyle,
]}
@@ -759,7 +639,7 @@ const BottomNavigationBar = ({
({
({
) : (
({
{typeof badge === 'boolean' ? (
-
+
) : (
{badge}
@@ -821,12 +701,7 @@ const BottomNavigationBar = ({
{labeled ? (
-
+
({
)}
- ) : (
- !isV3 &&
- )}
+ ) : null}
),
});
@@ -939,9 +812,6 @@ const styles = StyleSheet.create({
v3Item: {
paddingVertical: 0,
},
- ripple: {
- position: 'absolute',
- },
iconContainer: {
height: 24,
width: 24,
@@ -1002,7 +872,4 @@ const styles = StyleSheet.create({
borderRadius: OUTLINE_WIDTH / 4,
alignSelf: 'center',
},
- elevation: {
- elevation: 4,
- },
});
diff --git a/src/components/BottomNavigation/utils.ts b/src/components/BottomNavigation/utils.ts
index 93a4d95091..20208d4b7d 100644
--- a/src/components/BottomNavigation/utils.ts
+++ b/src/components/BottomNavigation/utils.ts
@@ -1,70 +1,51 @@
-import color from 'color';
-import type { InternalTheme } from 'src/types';
-
-import type { black, white } from '../../styles/themes/v2/colors';
-
-type BaseProps = {
- defaultColor: typeof black | typeof white;
- theme: InternalTheme;
-};
+import type { InternalTheme, MD3Theme } from '../../types';
export const getActiveTintColor = ({
activeColor,
- defaultColor,
theme,
-}: BaseProps & {
+}: {
activeColor: string | undefined;
+ theme: InternalTheme;
}) => {
if (typeof activeColor === 'string') {
return activeColor;
}
- if (theme.isV3) {
- return theme.colors.onSecondaryContainer;
- }
-
- return defaultColor;
+ return (theme as MD3Theme).colors.onSecondaryContainer;
};
export const getInactiveTintColor = ({
inactiveColor,
- defaultColor,
theme,
-}: BaseProps & {
+}: {
inactiveColor: string | undefined;
+ theme: InternalTheme;
}) => {
if (typeof inactiveColor === 'string') {
return inactiveColor;
}
- if (theme.isV3) {
- return theme.colors.onSurfaceVariant;
- }
-
- return color(defaultColor).alpha(0.5).rgb().string();
+ return (theme as MD3Theme).colors.onSurfaceVariant;
};
export const getLabelColor = ({
tintColor,
hasColor,
focused,
- defaultColor,
theme,
-}: BaseProps & {
+}: {
tintColor: string;
hasColor: boolean;
focused: boolean;
+ theme: InternalTheme;
}) => {
+ const { colors } = theme as MD3Theme;
if (hasColor) {
return tintColor;
}
- if (theme.isV3) {
- if (focused) {
- return theme.colors.onSurface;
- }
- return theme.colors.onSurfaceVariant;
+ if (focused) {
+ return colors.onSurface;
}
-
- return defaultColor;
+ return colors.onSurfaceVariant;
};
diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx
index 2e4d2cf519..1d1d0d3002 100644
--- a/src/components/Button/Button.tsx
+++ b/src/components/Button/Button.tsx
@@ -21,7 +21,7 @@ import {
getButtonTouchableRippleStyle,
} from './utils';
import { useInternalTheme } from '../../core/theming';
-import type { $Omit, ThemeProp } from '../../types';
+import type { $Omit, MD3Theme, ThemeProp } from '../../types';
import { forwardRef } from '../../utils/forwardRef';
import hasTouchHandler from '../../utils/hasTouchHandler';
import { splitStyles } from '../../utils/splitStyles';
@@ -218,8 +218,8 @@ const Button = (
},
[mode]
);
- const { roundness, isV3, animation } = theme;
- const uppercase = uppercaseProp ?? !theme.isV3;
+ const { roundness, animation } = theme;
+ const uppercase = uppercaseProp ?? false;
const isWeb = Platform.OS === 'web';
const hasPassedTouchHandler = hasTouchHandler({
@@ -229,10 +229,9 @@ const Button = (
onLongPress,
});
- const isElevationEntitled =
- !disabled && (isV3 ? isMode('elevated') : isMode('contained'));
- const initialElevation = isV3 ? 1 : 2;
- const activeElevation = isV3 ? 2 : 8;
+ const isElevationEntitled = !disabled && isMode('elevated');
+ const initialElevation = 1;
+ const activeElevation = 2;
const { current: elevation } = React.useRef(
new Animated.Value(isElevationEntitled ? initialElevation : 0)
@@ -250,7 +249,7 @@ const Button = (
const handlePressIn = (e: GestureResponderEvent) => {
onPressIn?.(e);
- if (isV3 ? isMode('elevated') : isMode('contained')) {
+ if (isMode('elevated')) {
const { scale } = animation;
Animated.timing(elevation, {
toValue: activeElevation,
@@ -263,7 +262,7 @@ const Button = (
const handlePressOut = (e: GestureResponderEvent) => {
onPressOut?.(e);
- if (isV3 ? isMode('elevated') : isMode('contained')) {
+ if (isMode('elevated')) {
const { scale } = animation;
Animated.timing(elevation, {
toValue: initialElevation,
@@ -280,8 +279,8 @@ const Button = (
(style) => style.startsWith('border') && style.endsWith('Radius')
);
- const borderRadius = (isV3 ? 5 : 1) * roundness;
- const iconSize = isV3 ? 18 : 16;
+ const borderRadius = 5 * roundness;
+ const iconSize = 18;
const { backgroundColor, borderColor, textColor, borderWidth } =
getButtonColors({
@@ -311,7 +310,7 @@ const Button = (
const { color: customLabelColor, fontSize: customLabelSize } =
StyleSheet.flatten(labelStyle) || {};
- const font = isV3 ? theme.fonts.labelLarge : theme.fonts.medium;
+ const font = (theme as MD3Theme).fonts.labelLarge;
const textStyle = {
color: textColor,
@@ -322,16 +321,14 @@ const Button = (
StyleSheet.flatten(contentStyle)?.flexDirection === 'row-reverse'
? [
styles.iconReverse,
- isV3 && styles[`md3IconReverse${compact ? 'Compact' : ''}`],
- isV3 &&
- isMode('text') &&
+ styles[`md3IconReverse${compact ? 'Compact' : ''}`],
+ isMode('text') &&
styles[`md3IconReverseTextMode${compact ? 'Compact' : ''}`],
]
: [
styles.icon,
- isV3 && styles[`md3Icon${compact ? 'Compact' : ''}`],
- isV3 &&
- isMode('text') &&
+ styles[`md3Icon${compact ? 'Compact' : ''}`],
+ isMode('text') &&
styles[`md3IconTextMode${compact ? 'Compact' : ''}`],
];
@@ -346,10 +343,9 @@ const Button = (
compact && styles.compact,
buttonStyle,
style,
- !isV3 && !disabled && { elevation },
] as Animated.WithAnimatedValue>
}
- {...(isV3 && { elevation: elevation })}
+ elevation={elevation}
container
>
{
+ const { colors } = theme as MD3Theme;
if (customButtonColor && !disabled) {
return customButtonColor;
}
- if (theme.isV3) {
- if (disabled) {
- if (isMode('outlined') || isMode('text')) {
- return 'transparent';
- }
-
- return theme.colors.surfaceDisabled;
- }
-
- if (isMode('elevated')) {
- return theme.colors.elevation.level1;
+ if (disabled) {
+ if (isMode('outlined') || isMode('text')) {
+ return 'transparent';
}
- if (isMode('contained')) {
- return theme.colors.primary;
- }
+ return colors.surfaceDisabled;
+ }
- if (isMode('contained-tonal')) {
- return theme.colors.secondaryContainer;
- }
+ if (isMode('elevated')) {
+ return colors.elevation.level1;
}
if (isMode('contained')) {
- if (disabled) {
- return color(theme.dark ? white : black)
- .alpha(0.12)
- .rgb()
- .string();
- }
+ return colors.primary;
+ }
- return theme.colors.primary;
+ if (isMode('contained-tonal')) {
+ return colors.secondaryContainer;
}
return 'transparent';
@@ -101,85 +89,56 @@ const getButtonTextColor = ({
backgroundColor: string;
dark?: boolean;
}) => {
+ const { colors } = theme as MD3Theme;
if (customTextColor && !disabled) {
return customTextColor;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- if (typeof dark === 'boolean') {
- if (
- isMode('contained') ||
- isMode('contained-tonal') ||
- isMode('elevated')
- ) {
- return isDark({ dark, backgroundColor }) ? white : black;
- }
- }
-
- if (isMode('outlined') || isMode('text') || isMode('elevated')) {
- return theme.colors.primary;
- }
-
- if (isMode('contained')) {
- return theme.colors.onPrimary;
- }
+ if (disabled) {
+ return colors.onSurfaceDisabled;
+ }
- if (isMode('contained-tonal')) {
- return theme.colors.onSecondaryContainer;
+ if (typeof dark === 'boolean') {
+ if (
+ isMode('contained') ||
+ isMode('contained-tonal') ||
+ isMode('elevated')
+ ) {
+ return isDark({ dark, backgroundColor }) ? white : black;
}
}
- if (disabled) {
- return color(theme.dark ? white : black)
- .alpha(0.32)
- .rgb()
- .string();
+ if (isMode('outlined') || isMode('text') || isMode('elevated')) {
+ return colors.primary;
}
if (isMode('contained')) {
- return isDark({ dark, backgroundColor }) ? white : black;
+ return colors.onPrimary;
+ }
+
+ if (isMode('contained-tonal')) {
+ return colors.onSecondaryContainer;
}
- return theme.colors.primary;
+ return colors.primary;
};
const getButtonBorderColor = ({ isMode, disabled, theme }: BaseProps) => {
- if (theme.isV3) {
- if (disabled && isMode('outlined')) {
- return theme.colors.surfaceDisabled;
- }
-
- if (isMode('outlined')) {
- return theme.colors.outline;
- }
+ const { colors } = theme as MD3Theme;
+ if (disabled && isMode('outlined')) {
+ return colors.surfaceDisabled;
}
if (isMode('outlined')) {
- return color(theme.dark ? white : black)
- .alpha(0.29)
- .rgb()
- .string();
+ return colors.outline;
}
return 'transparent';
};
-const getButtonBorderWidth = ({
- isMode,
- theme,
-}: Omit) => {
- if (theme.isV3) {
- if (isMode('outlined')) {
- return 1;
- }
- }
-
+const getButtonBorderWidth = ({ isMode }: Omit) => {
if (isMode('outlined')) {
- return StyleSheet.hairlineWidth;
+ return 1;
}
return 0;
diff --git a/src/components/Card/Card.tsx b/src/components/Card/Card.tsx
index 848be9fa13..422101b4e8 100644
--- a/src/components/Card/Card.tsx
+++ b/src/components/Card/Card.tsx
@@ -181,7 +181,7 @@ const Card = (
const { current: elevationDarkAdaptive } = React.useRef(
new Animated.Value(cardElevation)
);
- const { animation, dark, mode, roundness, isV3 } = theme;
+ const { animation, dark, mode, roundness } = theme;
const prevDarkRef = React.useRef(dark);
React.useEffect(() => {
@@ -213,20 +213,20 @@ const Card = (
]);
const runElevationAnimation = (pressType: HandlePressType) => {
- if (isV3 && isMode('contained')) {
+ if (isMode('contained')) {
return;
}
const isPressTypeIn = pressType === 'in';
if (dark && isAdaptiveMode) {
Animated.timing(elevationDarkAdaptive, {
- toValue: isPressTypeIn ? (isV3 ? 2 : 8) : cardElevation,
+ toValue: isPressTypeIn ? 2 : cardElevation,
duration: animationDuration,
useNativeDriver: false,
}).start();
} else {
Animated.timing(elevation, {
- toValue: isPressTypeIn ? (isV3 ? 2 : 8) : cardElevation,
+ toValue: isPressTypeIn ? 2 : cardElevation,
duration: animationDuration,
useNativeDriver: false,
}).start();
@@ -267,7 +267,7 @@ const Card = (
);
const borderRadiusCombinedStyles = {
- borderRadius: (isV3 ? 3 : 1) * roundness,
+ borderRadius: 3 * roundness,
...borderRadiusStyles,
};
@@ -290,20 +290,12 @@ const Card = (
& {
* ```
*/
const CardActions = ({ theme, style, children, ...rest }: Props) => {
- const { isV3 } = useInternalTheme(theme);
+ useInternalTheme(theme);
- const justifyContent = (
- isV3 ? 'flex-end' : 'flex-start'
- ) as ViewStyle['justifyContent'];
+ const justifyContent = 'flex-end' as ViewStyle['justifyContent'];
const containerStyle = [styles.container, { justifyContent }, style];
return (
@@ -50,11 +48,10 @@ const CardActions = ({ theme, style, children, ...rest }: Props) => {
return child;
}
- const compact = !isV3 && child.props.compact !== false;
+ const compact = child.props.compact;
const mode =
- child.props.mode ??
- (isV3 ? (index === 0 ? 'outlined' : 'contained') : undefined);
- const childStyle = [isV3 && styles.button, child.props.style];
+ child.props.mode ?? (index === 0 ? 'outlined' : 'contained');
+ const childStyle = [styles.button, child.props.style];
return React.cloneElement(child, {
...child.props,
diff --git a/src/components/Card/CardTitle.tsx b/src/components/Card/CardTitle.tsx
index b3d78fc259..f24809c405 100644
--- a/src/components/Card/CardTitle.tsx
+++ b/src/components/Card/CardTitle.tsx
@@ -10,8 +10,6 @@ import {
import { useInternalTheme } from '../../core/theming';
import type { MD3TypescaleKey, ThemeProp } from '../../types';
import Text from '../Typography/Text';
-import Caption from '../Typography/v2/Caption';
-import Title from '../Typography/v2/Title';
export type Props = React.ComponentPropsWithRef & {
/**
@@ -151,9 +149,7 @@ const CardTitle = ({
style,
theme: themeOverrides,
}: Props) => {
- const theme = useInternalTheme(themeOverrides);
- const TitleComponent = theme.isV3 ? Text : Title;
- const SubtitleComponent = theme.isV3 ? Text : Caption;
+ useInternalTheme(themeOverrides);
const minHeight = subtitle || left || right ? 72 : 50;
const marginBottom = subtitle ? 0 : 2;
@@ -170,24 +166,24 @@ const CardTitle = ({
{title && (
-
{title}
-
+
)}
{subtitle && (
-
{subtitle}
-
+
)}
{right ? right({ size: 24 }) : null}
diff --git a/src/components/Card/utils.tsx b/src/components/Card/utils.tsx
index c0f10951c5..9a4ed5df7d 100644
--- a/src/components/Card/utils.tsx
+++ b/src/components/Card/utils.tsx
@@ -1,9 +1,6 @@
import type { StyleProp, ViewStyle } from 'react-native';
-import color from 'color';
-
-import { black, white } from '../../styles/themes/v2/colors';
-import type { InternalTheme } from '../../types';
+import type { InternalTheme, MD3Theme } from '../../types';
type CardMode = 'elevated' | 'outlined' | 'contained';
@@ -20,8 +17,8 @@ export type CardActionChildProps = {
export const getCardCoverStyle = ({
theme,
- index,
- total,
+ index: _index,
+ total: _total,
borderRadiusStyles,
}: {
theme: InternalTheme;
@@ -29,7 +26,7 @@ export const getCardCoverStyle = ({
index?: number;
total?: number;
}) => {
- const { isV3, roundness } = theme;
+ const { roundness } = theme;
if (Object.keys(borderRadiusStyles).length > 0) {
return {
@@ -38,43 +35,13 @@ export const getCardCoverStyle = ({
};
}
- if (isV3) {
- return {
- borderRadius: 3 * roundness,
- };
- }
-
- if (index === 0) {
- if (total === 1) {
- return {
- borderRadius: roundness,
- };
- }
-
- return {
- borderTopLeftRadius: roundness,
- borderTopRightRadius: roundness,
- };
- }
-
- if (typeof total === 'number' && index === total - 1) {
- return {
- borderBottomLeftRadius: roundness,
- };
- }
-
- return undefined;
+ return {
+ borderRadius: 3 * roundness,
+ };
};
const getBorderColor = ({ theme }: { theme: InternalTheme }) => {
- if (theme.isV3) {
- return theme.colors.outline;
- }
-
- if (theme.dark) {
- return color(white).alpha(0.12).rgb().string();
- }
- return color(black).alpha(0.12).rgb().string();
+ return (theme as MD3Theme).colors.outline;
};
const getBackgroundColor = ({
@@ -84,13 +51,12 @@ const getBackgroundColor = ({
theme: InternalTheme;
isMode: (mode: CardMode) => boolean;
}) => {
- if (theme.isV3) {
- if (isMode('contained')) {
- return theme.colors.surfaceVariant;
- }
- if (isMode('outlined')) {
- return theme.colors.surface;
- }
+ const { colors } = theme as MD3Theme;
+ if (isMode('contained')) {
+ return colors.surfaceVariant;
+ }
+ if (isMode('outlined')) {
+ return colors.surface;
}
return undefined;
};
diff --git a/src/components/Checkbox/CheckboxItem.tsx b/src/components/Checkbox/CheckboxItem.tsx
index 92ea124e62..869edd674a 100644
--- a/src/components/Checkbox/CheckboxItem.tsx
+++ b/src/components/Checkbox/CheckboxItem.tsx
@@ -166,10 +166,8 @@ const CheckboxItem = ({
checkbox = ;
}
- const textColor = theme.isV3 ? theme.colors.onSurface : theme.colors.text;
- const disabledTextColor = theme.isV3
- ? theme.colors.onSurfaceDisabled
- : theme.colors.disabled;
+ const textColor = theme.colors.onSurface;
+ const disabledTextColor = theme.colors.onSurfaceDisabled;
const textAlign = isLeading ? 'right' : 'left';
const computedStyle = {
@@ -204,12 +202,7 @@ const CheckboxItem = ({
variant={labelVariant}
testID={`${testID}-text`}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
- style={[
- styles.label,
- !theme.isV3 && styles.font,
- computedStyle,
- labelStyle,
- ]}
+ style={[styles.label, computedStyle, labelStyle]}
>
{label}
@@ -238,7 +231,4 @@ const styles = StyleSheet.create({
flexShrink: 1,
flexGrow: 1,
},
- font: {
- fontSize: 16,
- },
});
diff --git a/src/components/Checkbox/utils.ts b/src/components/Checkbox/utils.ts
index 81677d46b2..4ba3615836 100644
--- a/src/components/Checkbox/utils.ts
+++ b/src/components/Checkbox/utils.ts
@@ -13,11 +13,7 @@ const getAndroidCheckedColor = ({
return customColor;
}
- if (theme.isV3) {
- return theme.colors.primary;
- }
-
- return theme.colors.accent;
+ return theme.colors.primary;
};
const getAndroidUncheckedColor = ({
@@ -31,15 +27,7 @@ const getAndroidUncheckedColor = ({
return customUncheckedColor;
}
- if (theme.isV3) {
- return theme.colors.onSurfaceVariant;
- }
-
- if (theme.dark) {
- return color(theme.colors.text).alpha(0.7).rgb().string();
- }
-
- return color(theme.colors.text).alpha(0.54).rgb().string();
+ return theme.colors.onSurfaceVariant;
};
const getAndroidRippleColor = ({
@@ -52,10 +40,7 @@ const getAndroidRippleColor = ({
disabled?: boolean;
}) => {
if (disabled) {
- if (theme.isV3) {
- return color(theme.colors.onSurface).alpha(0.16).rgb().string();
- }
- return color(theme.colors.text).alpha(0.16).rgb().string();
+ return color(theme.colors.onSurface).alpha(0.16).rgb().string();
}
return color(checkedColor).fade(0.32).rgb().string();
@@ -75,10 +60,7 @@ const getAndroidControlColor = ({
disabled?: boolean;
}) => {
if (disabled) {
- if (theme.isV3) {
- return theme.colors.onSurfaceDisabled;
- }
- return theme.colors.disabled;
+ return theme.colors.onSurfaceDisabled;
}
if (checked) {
@@ -127,21 +109,14 @@ const getIOSCheckedColor = ({
disabled?: boolean;
}) => {
if (disabled) {
- if (theme.isV3) {
- return theme.colors.onSurfaceDisabled;
- }
- return theme.colors.disabled;
+ return theme.colors.onSurfaceDisabled;
}
if (customColor) {
return customColor;
}
- if (theme.isV3) {
- return theme.colors.primary;
- }
-
- return theme.colors.accent;
+ return theme.colors.primary;
};
const getIOSRippleColor = ({
@@ -154,10 +129,7 @@ const getIOSRippleColor = ({
disabled?: boolean;
}) => {
if (disabled) {
- if (theme.isV3) {
- return color(theme.colors.onSurface).alpha(0.16).rgb().string();
- }
- return color(theme.colors.text).alpha(0.16).rgb().string();
+ return color(theme.colors.onSurface).alpha(0.16).rgb().string();
}
return color(checkedColor).fade(0.32).rgb().string();
};
diff --git a/src/components/Chip/Chip.tsx b/src/components/Chip/Chip.tsx
index 0e48e5c145..3706239b71 100644
--- a/src/components/Chip/Chip.tsx
+++ b/src/components/Chip/Chip.tsx
@@ -19,7 +19,7 @@ import useLatestCallback from 'use-latest-callback';
import { ChipAvatarProps, getChipColors } from './helpers';
import { useInternalTheme } from '../../core/theming';
import { white } from '../../styles/themes/v2/colors';
-import type { $Omit, EllipsizeProp, ThemeProp } from '../../types';
+import type { $Omit, EllipsizeProp, MD3Theme, ThemeProp } from '../../types';
import hasTouchHandler from '../../utils/hasTouchHandler';
import type { IconSource } from '../Icon';
import Icon from '../Icon';
@@ -212,11 +212,11 @@ const Chip = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3, roundness } = theme;
+ const { roundness } = theme;
const isWeb = Platform.OS === 'web';
const { current: elevation } = React.useRef(
- new Animated.Value(isV3 && elevated ? 1 : 0)
+ new Animated.Value(elevated ? 1 : 0)
);
const hasPassedTouchHandler = hasTouchHandler({
@@ -232,7 +232,7 @@ const Chip = ({
const { scale } = theme.animation;
onPressIn?.(e);
Animated.timing(elevation, {
- toValue: isV3 ? (elevated ? 2 : 0) : 4,
+ toValue: elevated ? 2 : 0,
duration: 200 * scale,
useNativeDriver:
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
@@ -243,16 +243,16 @@ const Chip = ({
const { scale } = theme.animation;
onPressOut?.(e);
Animated.timing(elevation, {
- toValue: isV3 && elevated ? 1 : 0,
+ toValue: elevated ? 1 : 0,
duration: 150 * scale,
useNativeDriver:
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
}).start();
});
- const opacity = isV3 ? 0.38 : 0.26;
- const defaultBorderRadius = roundness * (isV3 ? 2 : 4);
- const iconSize = isV3 ? 18 : 16;
+ const opacity = 0.38;
+ const defaultBorderRadius = roundness * 2;
+ const iconSize = 18;
const {
backgroundColor: customBackgroundColor,
@@ -281,8 +281,8 @@ const Chip = ({
disabled,
};
- const elevationStyle = isV3 || Platform.OS === 'android' ? elevation : 0;
- const multiplier = isV3 ? (compact ? 1.5 : 2) : 1;
+ const elevationStyle = elevation;
+ const multiplier = compact ? 1.5 : 2;
const labelSpacings = {
marginRight: onClose ? 0 : 8 * multiplier,
marginLeft:
@@ -291,20 +291,17 @@ const Chip = ({
: 8 * multiplier,
};
const contentSpacings = {
- paddingRight: isV3 ? (onClose ? 34 : 0) : onClose ? 32 : 4,
+ paddingRight: onClose ? 34 : 0,
};
const labelTextStyle = {
color: textColor,
- ...(isV3 ? theme.fonts.labelLarge : theme.fonts.regular),
+ ...(theme as MD3Theme).fonts.labelLarge,
};
return (
-
+
{avatar && !icon ? (
@@ -358,12 +353,12 @@ const Chip = ({
-
+
{closeIcon ? (
) : (
theme as MD3Theme;
export type ChipAvatarProps = {
style?: StyleProp;
@@ -20,40 +21,25 @@ const getBorderColor = ({
isOutlined,
disabled,
selectedColor,
- backgroundColor,
+ backgroundColor: _backgroundColor,
}: BaseProps & { backgroundColor: string; selectedColor?: string }) => {
const isSelectedColor = selectedColor !== undefined;
+ const { colors } = md3(theme);
- if (theme.isV3) {
- if (!isOutlined) {
- // If the Chip mode is "flat", set border color to transparent
- return 'transparent';
- }
-
- if (disabled) {
- return color(theme.colors.onSurfaceVariant).alpha(0.12).rgb().string();
- }
-
- if (isSelectedColor) {
- return color(selectedColor).alpha(0.29).rgb().string();
- }
-
- return theme.colors.outline;
+ if (!isOutlined) {
+ // If the Chip mode is "flat", set border color to transparent
+ return 'transparent';
}
- if (isOutlined) {
- if (isSelectedColor) {
- return color(selectedColor).alpha(0.29).rgb().string();
- }
-
- if (theme.dark) {
- return color(white).alpha(0.29).rgb().string();
- }
+ if (disabled) {
+ return color(colors.onSurfaceVariant).alpha(0.12).rgb().string();
+ }
- return color(black).alpha(0.29).rgb().string();
+ if (isSelectedColor) {
+ return color(selectedColor).alpha(0.29).rgb().string();
}
- return backgroundColor;
+ return colors.outline;
};
const getTextColor = ({
@@ -65,54 +51,32 @@ const getTextColor = ({
selectedColor?: string;
}) => {
const isSelectedColor = selectedColor !== undefined;
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- if (isSelectedColor) {
- return selectedColor;
- }
-
- if (isOutlined) {
- return theme.colors.onSurfaceVariant;
- }
-
- return theme.colors.onSecondaryContainer;
- }
-
+ const { colors } = md3(theme);
if (disabled) {
- return theme.colors.disabled;
+ return colors.onSurfaceDisabled;
}
if (isSelectedColor) {
- return color(selectedColor).alpha(0.87).rgb().string();
+ return selectedColor;
+ }
+
+ if (isOutlined) {
+ return colors.onSurfaceVariant;
}
- return color(theme.colors.text).alpha(0.87).rgb().string();
+ return colors.onSecondaryContainer;
};
const getDefaultBackgroundColor = ({
theme,
isOutlined,
}: Omit) => {
- if (theme.isV3) {
- if (isOutlined) {
- return theme.colors.surface;
- }
-
- return theme.colors.secondaryContainer;
- }
-
+ const { colors } = md3(theme);
if (isOutlined) {
- return theme.colors?.surface;
- }
-
- if (theme.dark) {
- return '#383838';
+ return colors.surface;
}
- return '#ebebeb';
+ return colors.secondaryContainer;
};
const getBackgroundColor = ({
@@ -123,17 +87,16 @@ const getBackgroundColor = ({
}: BaseProps & {
customBackgroundColor?: ColorValue;
}) => {
+ const { colors } = md3(theme);
if (typeof customBackgroundColor === 'string') {
return customBackgroundColor;
}
- if (theme.isV3) {
- if (disabled) {
- if (isOutlined) {
- return 'transparent';
- }
- return color(theme.colors.onSurfaceVariant).alpha(0.12).rgb().string();
+ if (disabled) {
+ if (isOutlined) {
+ return 'transparent';
}
+ return color(colors.onSurfaceVariant).alpha(0.12).rgb().string();
}
return getDefaultBackgroundColor({ theme, isOutlined });
@@ -149,6 +112,7 @@ const getSelectedBackgroundColor = ({
customBackgroundColor?: ColorValue;
showSelectedOverlay?: boolean;
}) => {
+ const { colors } = md3(theme);
const backgroundColor = getBackgroundColor({
theme,
disabled,
@@ -156,45 +120,30 @@ const getSelectedBackgroundColor = ({
customBackgroundColor,
});
- if (theme.isV3) {
- if (isOutlined) {
- if (showSelectedOverlay) {
- return color(backgroundColor)
- .mix(color(theme.colors.onSurfaceVariant), 0.12)
- .rgb()
- .string();
- }
- return color(backgroundColor)
- .mix(color(theme.colors.onSurfaceVariant), 0)
- .rgb()
- .string();
- }
-
+ if (isOutlined) {
if (showSelectedOverlay) {
return color(backgroundColor)
- .mix(color(theme.colors.onSecondaryContainer), 0.12)
+ .mix(color(colors.onSurfaceVariant), 0.12)
.rgb()
.string();
}
-
return color(backgroundColor)
- .mix(color(theme.colors.onSecondaryContainer), 0)
+ .mix(color(colors.onSurfaceVariant), 0)
.rgb()
.string();
}
- if (theme.dark) {
- if (isOutlined) {
- return color(backgroundColor).lighten(0.2).rgb().string();
- }
- return color(backgroundColor).lighten(0.4).rgb().string();
- }
-
- if (isOutlined) {
- return color(backgroundColor).darken(0.08).rgb().string();
+ if (showSelectedOverlay) {
+ return color(backgroundColor)
+ .mix(color(colors.onSecondaryContainer), 0.12)
+ .rgb()
+ .string();
}
- return color(backgroundColor).darken(0.2).rgb().string();
+ return color(backgroundColor)
+ .mix(color(colors.onSecondaryContainer), 0)
+ .rgb()
+ .string();
};
const getIconColor = ({
@@ -206,31 +155,20 @@ const getIconColor = ({
selectedColor?: string;
}) => {
const isSelectedColor = selectedColor !== undefined;
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- if (isSelectedColor) {
- return selectedColor;
- }
-
- if (isOutlined) {
- return theme.colors.onSurfaceVariant;
- }
-
- return theme.colors.onSecondaryContainer;
- }
-
+ const { colors } = md3(theme);
if (disabled) {
- return theme.colors.disabled;
+ return colors.onSurfaceDisabled;
}
if (isSelectedColor) {
- return color(selectedColor).alpha(0.54).rgb().string();
+ return selectedColor;
+ }
+
+ if (isOutlined) {
+ return colors.onSurfaceVariant;
}
- return color(theme.colors.text).alpha(0.54).rgb().string();
+ return colors.onSecondaryContainer;
};
const getRippleColor = ({
@@ -238,7 +176,7 @@ const getRippleColor = ({
isOutlined,
disabled,
selectedColor,
- selectedBackgroundColor,
+ selectedBackgroundColor: _selectedBackgroundColor,
customRippleColor,
}: BaseProps & {
selectedBackgroundColor: string;
@@ -257,19 +195,11 @@ const getRippleColor = ({
isOutlined,
});
- if (theme.isV3) {
- if (isSelectedColor) {
- return color(selectedColor).alpha(0.12).rgb().string();
- }
-
- return color(textColor).alpha(0.12).rgb().string();
- }
-
if (isSelectedColor) {
- return color(selectedColor).fade(0.5).rgb().string();
+ return color(selectedColor).alpha(0.12).rgb().string();
}
- return selectedBackgroundColor;
+ return color(textColor).alpha(0.12).rgb().string();
};
export const getChipColors = ({
diff --git a/src/components/DataTable/DataTableHeader.tsx b/src/components/DataTable/DataTableHeader.tsx
index a4619ebb99..1fee2a02ab 100644
--- a/src/components/DataTable/DataTableHeader.tsx
+++ b/src/components/DataTable/DataTableHeader.tsx
@@ -1,10 +1,7 @@
import * as React from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
-import color from 'color';
-
import { useInternalTheme } from '../../core/theming';
-import { black, white } from '../../styles/themes/v2/colors';
import type { ThemeProp } from '../../types';
export type Props = React.ComponentPropsWithRef & {
@@ -52,12 +49,7 @@ const DataTableHeader = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const borderBottomColor = theme.isV3
- ? theme.colors.surfaceVariant
- : color(theme.dark ? white : black)
- .alpha(0.12)
- .rgb()
- .string();
+ const borderBottomColor = theme.colors.surfaceVariant;
return (
diff --git a/src/components/DataTable/DataTablePagination.tsx b/src/components/DataTable/DataTablePagination.tsx
index dd72dbe54f..c7a5375f82 100644
--- a/src/components/DataTable/DataTablePagination.tsx
+++ b/src/components/DataTable/DataTablePagination.tsx
@@ -108,7 +108,7 @@ const PaginationControls = ({
}: PaginationControlsProps) => {
const theme = useInternalTheme(themeOverrides);
- const textColor = theme.isV3 ? theme.colors.onSurface : theme.colors.text;
+ const textColor = theme.colors.onSurface;
return (
<>
@@ -310,12 +310,7 @@ const DataTablePagination = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const labelColor = color(
- theme.isV3 ? theme.colors.onSurface : theme?.colors.text
- )
- .alpha(0.6)
- .rgb()
- .string();
+ const labelColor = color(theme.colors.onSurface).alpha(0.6).rgb().string();
return (
{
const theme = useInternalTheme(themeOverrides);
- const borderBottomColor = theme.isV3
- ? theme.colors.surfaceVariant
- : color(theme.dark ? white : black)
- .alpha(0.12)
- .rgb()
- .string();
+ const borderBottomColor = theme.colors.surfaceVariant;
return (
{
const { right, left } = useSafeAreaInsets();
const theme = useInternalTheme(themeOverrides);
- const { isV3, dark, mode, colors, roundness } = theme;
- const borderRadius = (isV3 ? 7 : 1) * roundness;
+ const { roundness, colors } = theme as MD3Theme;
+ const borderRadius = 7 * roundness;
- const backgroundColorV2 =
- dark && mode === 'adaptive'
- ? overlay(DIALOG_ELEVATION, colors?.surface)
- : colors?.surface;
- const backgroundColor = isV3
- ? theme.colors.elevation.level3
- : backgroundColorV2;
+ const backgroundColor = colors.elevation.level3;
return (
child != null && typeof child !== 'boolean')
.map((child, i) => {
- if (isV3) {
- if (i === 0 && React.isValidElement(child)) {
- return React.cloneElement(child, {
- style: [{ marginTop: 24 }, child.props.style],
- });
- }
- }
-
- if (
- i === 0 &&
- React.isValidElement(child) &&
- child.type === DialogContent
- ) {
- // Dialog content is the first item, so we add a top padding
+ if (i === 0 && React.isValidElement(child)) {
return React.cloneElement(child, {
- style: [{ paddingTop: 24 }, child.props.style],
+ style: [{ marginTop: 24 }, child.props.style],
});
}
diff --git a/src/components/Dialog/DialogActions.tsx b/src/components/Dialog/DialogActions.tsx
index cabebd2fe2..7b34739da5 100644
--- a/src/components/Dialog/DialogActions.tsx
+++ b/src/components/Dialog/DialogActions.tsx
@@ -47,21 +47,18 @@ export type Props = React.ComponentPropsWithRef & {
* ```
*/
const DialogActions = (props: Props) => {
- const { isV3 } = useInternalTheme(props.theme);
+ useInternalTheme(props.theme);
const actionsLength = React.Children.toArray(props.children).length;
return (
-
+
{React.Children.map(props.children, (child, i) =>
React.isValidElement(child)
? React.cloneElement(child, {
compact: true,
- uppercase: !isV3,
+ uppercase: false,
style: [
- isV3 && {
+ {
marginRight: i + 1 === actionsLength ? 0 : 8,
},
child.props.style,
@@ -76,12 +73,6 @@ const DialogActions = (props: Props) => {
DialogActions.displayName = 'Dialog.Actions';
const styles = StyleSheet.create({
- container: {
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-end',
- padding: 8,
- },
v3Container: {
flexDirection: 'row',
flexGrow: 1,
diff --git a/src/components/Dialog/DialogIcon.tsx b/src/components/Dialog/DialogIcon.tsx
index ad5841b93a..7682054003 100644
--- a/src/components/Dialog/DialogIcon.tsx
+++ b/src/components/Dialog/DialogIcon.tsx
@@ -4,6 +4,7 @@ import { StyleSheet, View } from 'react-native';
import type { ThemeProp } from 'src/types';
import { useInternalTheme } from '../../core/theming';
+import type { MD3Theme } from '../../types';
import Icon, { IconSource } from '../Icon';
export type Props = {
@@ -69,13 +70,10 @@ const DialogIcon = ({
theme: themeOverrides,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
-
- if (!theme.isV3) {
- return null;
- }
+ const { colors } = theme as MD3Theme;
//@ts-ignore
- const iconColor = color || theme.colors.secondary;
+ const iconColor = color || colors.secondary;
return (
diff --git a/src/components/Dialog/DialogScrollArea.tsx b/src/components/Dialog/DialogScrollArea.tsx
index 66fdcef6a0..5deeb4a5e6 100644
--- a/src/components/Dialog/DialogScrollArea.tsx
+++ b/src/components/Dialog/DialogScrollArea.tsx
@@ -4,6 +4,7 @@ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import type { ThemeProp } from 'src/types';
import { useInternalTheme } from '../../core/theming';
+import type { MD3Theme } from '../../types';
export type Props = React.ComponentPropsWithRef & {
/**
@@ -50,22 +51,16 @@ export type Props = React.ComponentPropsWithRef & {
*/
const DialogScrollArea = (props: Props) => {
const theme = useInternalTheme(props.theme);
+ const { colors } = theme as MD3Theme;
const borderStyles = {
- borderColor: theme.isV3
- ? theme.colors.surfaceVariant
- : 'rgba(0, 0, 0, .12)',
- borderTopWidth: theme.isV3 ? 1 : StyleSheet.hairlineWidth,
- borderBottomWidth: theme.isV3 ? 1 : StyleSheet.hairlineWidth,
+ borderColor: colors.surfaceVariant,
+ borderTopWidth: 1,
+ borderBottomWidth: 1,
};
return (
{props.children}
diff --git a/src/components/Dialog/DialogTitle.tsx b/src/components/Dialog/DialogTitle.tsx
index 9953fc506c..407acb68b3 100644
--- a/src/components/Dialog/DialogTitle.tsx
+++ b/src/components/Dialog/DialogTitle.tsx
@@ -2,11 +2,10 @@ import * as React from 'react';
import { StyleProp, StyleSheet, TextStyle } from 'react-native';
import { useInternalTheme } from '../../core/theming';
-import type { ThemeProp } from '../../types';
+import type { MD3Theme, ThemeProp } from '../../types';
import Text from '../Typography/Text';
-import Title from '../Typography/v2/Title';
-export type Props = React.ComponentPropsWithRef & {
+export type Props = React.ComponentPropsWithRef & {
/**
* Title text for the `DialogTitle`.
*/
@@ -53,24 +52,22 @@ const DialogTitle = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3, colors, fonts } = theme;
-
- const TextComponent = isV3 ? Text : Title;
+ const { colors, fonts } = theme as MD3Theme;
const headerTextStyle = {
- color: isV3 ? colors.onSurface : colors?.text,
- ...(isV3 ? fonts.headlineSmall : {}),
+ color: colors.onSurface,
+ ...fonts.headlineSmall,
};
return (
-
{children}
-
+
);
};
diff --git a/src/components/Divider.tsx b/src/components/Divider.tsx
index be30d94c7c..c697a2a04a 100644
--- a/src/components/Divider.tsx
+++ b/src/components/Divider.tsx
@@ -1,10 +1,7 @@
import * as React from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
-import color from 'color';
-
import { useInternalTheme } from '../core/theming';
-import { black, white } from '../styles/themes/v2/colors';
import type { $RemoveChildren, ThemeProp } from '../types';
export type Props = $RemoveChildren & {
@@ -60,23 +57,17 @@ const Divider = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { dark: isDarkTheme, isV3 } = theme;
- const dividerColor = isV3
- ? theme.colors.outlineVariant
- : color(isDarkTheme ? white : black)
- .alpha(0.12)
- .rgb()
- .string();
+ const dividerColor = theme.colors.outlineVariant;
return (
@@ -84,9 +75,6 @@ const Divider = ({
};
const styles = StyleSheet.create({
- leftInset: {
- marginLeft: 72,
- },
v3LeftInset: {
marginLeft: 16,
},
diff --git a/src/components/Drawer/DrawerCollapsedItem.tsx b/src/components/Drawer/DrawerCollapsedItem.tsx
index 9fb461e9c5..c10c7ac0b6 100644
--- a/src/components/Drawer/DrawerCollapsedItem.tsx
+++ b/src/components/Drawer/DrawerCollapsedItem.tsx
@@ -111,7 +111,6 @@ const DrawerCollapsedItem = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3 } = theme;
const { scale } = theme.animation;
const [numOfLines, setNumOfLines] = React.useState(1);
@@ -126,10 +125,6 @@ const DrawerCollapsedItem = ({
}
}, [animScale, active]);
- if (!isV3) {
- return null;
- }
-
const handlePressOut = () => {
Animated.timing(animScale, {
toValue: 1,
@@ -163,7 +158,7 @@ const DrawerCollapsedItem = ({
const labelTextStyle = {
color: labelColor,
- ...(isV3 ? theme.fonts.labelMedium : {}),
+ ...theme.fonts.labelMedium,
};
const icon =
diff --git a/src/components/Drawer/DrawerItem.tsx b/src/components/Drawer/DrawerItem.tsx
index 604df1b83b..7af3d9fcf4 100644
--- a/src/components/Drawer/DrawerItem.tsx
+++ b/src/components/Drawer/DrawerItem.tsx
@@ -108,27 +108,17 @@ const DrawerItem = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { roundness, isV3 } = theme;
+ const { roundness } = theme;
- const backgroundColor = active
- ? isV3
- ? theme.colors.secondaryContainer
- : color(theme.colors.primary).alpha(0.12).rgb().string()
- : undefined;
+ const backgroundColor = active ? theme.colors.secondaryContainer : undefined;
const contentColor = active
- ? isV3
- ? theme.colors.onSecondaryContainer
- : theme.colors.primary
- : isV3
- ? theme.colors.onSurfaceVariant
- : color(theme.colors.text).alpha(0.68).rgb().string();
+ ? theme.colors.onSecondaryContainer
+ : theme.colors.onSurfaceVariant;
- const labelMargin = icon ? (isV3 ? 12 : 32) : 0;
- const borderRadius = (isV3 ? 7 : 1) * roundness;
- const rippleColor = isV3
- ? color(contentColor).alpha(0.12).rgb().string()
- : undefined;
- const font = isV3 ? theme.fonts.labelLarge : theme.fonts.medium;
+ const labelMargin = icon ? 12 : 0;
+ const borderRadius = 7 * roundness;
+ const rippleColor = color(contentColor).alpha(0.12).rgb().string();
+ const font = theme.fonts.labelLarge;
return (
@@ -139,8 +129,8 @@ const DrawerItem = ({
onPress={onPress}
style={[
styles.container,
+ styles.v3Container,
{ backgroundColor, borderRadius },
- isV3 && styles.v3Container,
style,
]}
accessibilityRole="button"
@@ -150,7 +140,7 @@ const DrawerItem = ({
theme={theme}
hitSlop={hitSlop}
>
-
+
{icon ? (
diff --git a/src/components/Drawer/DrawerSection.tsx b/src/components/Drawer/DrawerSection.tsx
index ed79c5e054..a701d38ad6 100644
--- a/src/components/Drawer/DrawerSection.tsx
+++ b/src/components/Drawer/DrawerSection.tsx
@@ -1,8 +1,6 @@
import * as React from 'react';
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
-import color from 'color';
-
import { useInternalTheme } from '../../core/theming';
import { MD3Colors } from '../../styles/themes/v3/tokens';
import type { ThemeProp } from '../../types';
@@ -73,17 +71,14 @@ const DrawerSection = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3 } = theme;
- const titleColor = isV3
- ? theme.colors.onSurfaceVariant
- : color(theme.colors.text).alpha(0.54).rgb().string();
- const titleMargin = isV3 ? 28 : 16;
- const font = isV3 ? theme.fonts.titleSmall : theme.fonts.medium;
+ const titleColor = theme.colors.onSurfaceVariant;
+ const titleMargin = 28;
+ const font = theme.fonts.titleSmall;
return (
{title && (
-
+
{title && (
)}
diff --git a/src/components/FAB/AnimatedFAB.tsx b/src/components/FAB/AnimatedFAB.tsx
index ecfe7e1c60..6b6964a4a9 100644
--- a/src/components/FAB/AnimatedFAB.tsx
+++ b/src/components/FAB/AnimatedFAB.tsx
@@ -129,7 +129,6 @@ export type Props = $Omit<$RemoveChildren, 'mode'> & {
};
const SIZE = 56;
-const SCALE = 0.9;
/**
* An animated, extending horizontally floating action button represents the primary action in an application.
@@ -233,7 +232,7 @@ const AnimatedFAB = ({
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const uppercase: boolean = uppercaseProp ?? !theme.isV3;
+ const uppercase: boolean = uppercaseProp ?? false;
const isIOS = Platform.OS === 'ios';
const isWeb = Platform.OS === 'web';
const isAnimatedFromRight = animateFrom === 'right';
@@ -246,7 +245,7 @@ const AnimatedFAB = ({
const { current: animFAB } = React.useRef(
new Animated.Value(0)
);
- const { isV3, animation } = theme;
+ const { animation } = theme;
const { scale } = animation;
const labelSize = isWeb ? getLabelSizeWeb(labelRef) : null;
@@ -257,7 +256,7 @@ const AnimatedFAB = ({
labelSize?.height ?? 0
);
- const borderRadius = SIZE / (isV3 ? 3.5 : 2);
+ const borderRadius = SIZE / 3.5;
React.useEffect(() => {
if (!isWeb) {
@@ -364,17 +363,16 @@ const AnimatedFAB = ({
animFAB,
});
- const font = isV3 ? theme.fonts.labelLarge : theme.fonts.medium;
+ const font = theme.fonts.labelLarge;
const textStyle = {
color: foregroundColor,
...font,
};
- const md2Elevation = disabled || !isIOS ? 0 : 6;
const md3Elevation = disabled || !isIOS ? 0 : 3;
- const shadowStyle = isV3 ? styles.v3Shadow : styles.shadow;
+ const shadowStyle = styles.v3Shadow;
const baseStyle = [
StyleSheet.absoluteFill,
disabled ? styles.disabled : shadowStyle,
@@ -396,32 +394,14 @@ const AnimatedFAB = ({
],
borderRadius,
},
- !isV3 && {
- elevation: md2Elevation,
- },
styles.container,
restStyle,
]}
- {...(isV3 && { elevation: md3Elevation })}
+ elevation={md3Elevation}
theme={theme}
container
>
-
+
(
ref
) => {
const theme = useInternalTheme(themeOverrides);
- const uppercase = uppercaseProp ?? !theme.isV3;
+ const uppercase = uppercaseProp ?? false;
const { current: visibility } = React.useRef(
new Animated.Value(visible ? 1 : 0)
);
- const { isV3, animation } = theme;
+ const { animation } = theme;
const { scale } = animation;
React.useEffect(() => {
@@ -255,7 +255,7 @@ const FAB = forwardRef(
const isFlatMode = mode === 'flat';
const iconSize = isLargeSize ? 36 : 24;
const loadingIndicatorSize = isLargeSize ? 24 : 18;
- const font = isV3 ? theme.fonts.labelLarge : theme.fonts.medium;
+ const font = theme.fonts.labelLarge;
const extendedStyle = getExtendedFabStyle({ customSize, theme });
const textStyle = {
@@ -282,13 +282,11 @@ const FAB = forwardRef(
},
],
},
- !isV3 && styles.elevated,
- !isV3 && disabled && styles.disabled,
style,
]}
pointerEvents={visible ? 'auto' : 'none'}
testID={`${testID}-container`}
- {...(isV3 && { elevation: md3Elevation })}
+ elevation={md3Elevation}
container
>
(
);
const styles = StyleSheet.create({
- elevated: {
- elevation: 6,
- },
content: {
flexDirection: 'row',
alignItems: 'center',
@@ -361,9 +356,6 @@ const styles = StyleSheet.create({
uppercaseLabel: {
textTransform: 'uppercase',
},
- disabled: {
- elevation: 0,
- },
});
export default FAB;
diff --git a/src/components/FAB/FABGroup.tsx b/src/components/FAB/FABGroup.tsx
index ca263e3499..de88de8185 100644
--- a/src/components/FAB/FABGroup.tsx
+++ b/src/components/FAB/FABGroup.tsx
@@ -250,7 +250,6 @@ const FABGroup = ({
>(null);
const { scale } = theme.animation;
- const { isV3 } = theme;
React.useEffect(() => {
if (open) {
@@ -262,7 +261,7 @@ const FABGroup = ({
useNativeDriver: true,
}),
Animated.stagger(
- isV3 ? 15 : 50 * scale,
+ 15,
animations.current
.map((animation) =>
Animated.timing(animation, {
@@ -294,7 +293,7 @@ const FABGroup = ({
}
});
}
- }, [open, actions, backdrop, scale, isV3]);
+ }, [open, actions, backdrop, scale]);
const close = () => onStateChange({ open: false });
const toggle = () => onStateChange({ open: !open });
@@ -326,14 +325,6 @@ const FABGroup = ({
: backdrop;
const opacities = animations.current;
- const scales = opacities.map((opacity) =>
- open
- ? opacity.interpolate({
- inputRange: [0, 1],
- outputRange: [0.5, 1],
- })
- : 1
- );
const translations = opacities.map((opacity) =>
open
@@ -395,7 +386,7 @@ const FABGroup = ({
{actions.map((it, i) => {
const labelTextStyle = {
color: it.labelTextColor ?? labelColor,
- ...(isV3 ? theme.fonts.titleMedium : {}),
+ ...theme.fonts.titleMedium,
};
const marginHorizontal =
typeof it.size === 'undefined' || it.size === 'small' ? 24 : 16;
@@ -430,7 +421,7 @@ const FABGroup = ({
{it.label && (
@@ -467,11 +454,10 @@ const FABGroup = ({
color={it.color}
style={[
{
- transform: [{ scale: scales[i] }],
+ transform: [{ translateY: translations[i] }],
opacity: opacities[i],
backgroundColor: stackedFABBackgroundColor,
},
- isV3 && { transform: [{ translateY: translations[i] }] },
it.style,
]}
accessibilityElementsHidden={true}
diff --git a/src/components/FAB/utils.ts b/src/components/FAB/utils.ts
index e87d24019f..42dd05ff7e 100644
--- a/src/components/FAB/utils.ts
+++ b/src/components/FAB/utils.ts
@@ -9,9 +9,7 @@ import {
import color from 'color';
-import { black, white } from '../../styles/themes/v2/colors';
import type { InternalTheme } from '../../types';
-import getContrastingColor from '../../utils/getContrastingColor';
type GetCombinedStylesProps = {
isAnimatedFromRight: boolean;
@@ -174,88 +172,60 @@ const getBackgroundColor = ({
return customBackgroundColor;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.surfaceDisabled;
- }
-
- if (isVariant('primary')) {
- return theme.colors.primaryContainer;
- }
+ if (disabled) {
+ return theme.colors.surfaceDisabled;
+ }
- if (isVariant('secondary')) {
- return theme.colors.secondaryContainer;
- }
+ if (isVariant('primary')) {
+ return theme.colors.primaryContainer;
+ }
- if (isVariant('tertiary')) {
- return theme.colors.tertiaryContainer;
- }
+ if (isVariant('secondary')) {
+ return theme.colors.secondaryContainer;
+ }
- if (isVariant('surface')) {
- return theme.colors.elevation.level3;
- }
+ if (isVariant('tertiary')) {
+ return theme.colors.tertiaryContainer;
}
- if (disabled) {
- if (theme.dark) {
- return color(white).alpha(0.12).rgb().string();
- }
- return color(black).alpha(0.12).rgb().string();
+ if (isVariant('surface')) {
+ return theme.colors.elevation.level3;
}
- //@ts-ignore
- return theme.colors?.accent;
+ return theme.colors.primaryContainer;
};
const getForegroundColor = ({
theme,
isVariant,
disabled,
- backgroundColor,
customColor,
-}: BaseProps & { backgroundColor: string; customColor?: string }) => {
+}: BaseProps & { customColor?: string }) => {
if (typeof customColor !== 'undefined' && !disabled) {
return customColor;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- if (isVariant('primary')) {
- return theme.colors.onPrimaryContainer;
- }
-
- if (isVariant('secondary')) {
- return theme.colors.onSecondaryContainer;
- }
+ if (disabled) {
+ return theme.colors.onSurfaceDisabled;
+ }
- if (isVariant('tertiary')) {
- return theme.colors.onTertiaryContainer;
- }
+ if (isVariant('primary')) {
+ return theme.colors.onPrimaryContainer;
+ }
- if (isVariant('surface')) {
- return theme.colors.primary;
- }
+ if (isVariant('secondary')) {
+ return theme.colors.onSecondaryContainer;
}
- if (disabled) {
- if (theme.dark) {
- return color(white).alpha(0.32).rgb().string();
- }
- return color(black).alpha(0.32).rgb().string();
+ if (isVariant('tertiary')) {
+ return theme.colors.onTertiaryContainer;
}
- if (backgroundColor) {
- return getContrastingColor(
- backgroundColor || white,
- white,
- 'rgba(0, 0, 0, .54)'
- );
+ if (isVariant('surface')) {
+ return theme.colors.primary;
}
- return getContrastingColor(white, white, 'rgba(0, 0, 0, .54)');
+ return theme.colors.onPrimaryContainer;
};
export const getFABColors = ({
@@ -287,7 +257,6 @@ export const getFABColors = ({
const foregroundColor = getForegroundColor({
...baseFABColorProps,
customColor,
- backgroundColor,
});
return {
@@ -299,15 +268,7 @@ export const getFABColors = ({
};
const getLabelColor = ({ theme }: { theme: InternalTheme }) => {
- if (theme.isV3) {
- return theme.colors.onSurface;
- }
-
- if (theme.dark) {
- return theme.colors.text;
- }
-
- return color(theme.colors.text).fade(0.54).rgb().string();
+ return theme.colors.onSurface;
};
const getBackdropColor = ({
@@ -320,17 +281,11 @@ const getBackdropColor = ({
if (customBackdropColor) {
return customBackdropColor;
}
- if (theme.isV3) {
- return color(theme.colors.background).alpha(0.95).rgb().string();
- }
- return theme.colors?.backdrop;
+ return color(theme.colors.background).alpha(0.95).rgb().string();
};
const getStackedFABBackgroundColor = ({ theme }: { theme: InternalTheme }) => {
- if (theme.isV3) {
- return theme.colors.elevation.level3;
- }
- return theme.colors.surface;
+ return theme.colors.elevation.level3;
};
export const getFABGroupColors = ({
@@ -347,16 +302,6 @@ export const getFABGroupColors = ({
};
};
-const standardSize = {
- height: 56,
- width: 56,
- borderRadius: 28,
-};
-const smallSize = {
- height: 40,
- width: 40,
- borderRadius: 28,
-};
const v3SmallSize = {
height: 40,
width: 40,
@@ -385,30 +330,18 @@ export const getFabStyle = ({
size: 'small' | 'medium' | 'large';
theme: InternalTheme;
}) => {
- const { isV3, roundness } = theme;
+ const { roundness } = theme;
if (customSize) return getCustomFabSize(customSize, roundness);
- if (isV3) {
- switch (size) {
- case 'small':
- return { ...v3SmallSize, borderRadius: 3 * roundness };
- case 'medium':
- return { ...v3MediumSize, borderRadius: 4 * roundness };
- case 'large':
- return { ...v3LargeSize, borderRadius: 7 * roundness };
- }
- }
-
- if (size === 'small') {
- return smallSize;
+ switch (size) {
+ case 'small':
+ return { ...v3SmallSize, borderRadius: 3 * roundness };
+ case 'medium':
+ return { ...v3MediumSize, borderRadius: 4 * roundness };
+ case 'large':
+ return { ...v3LargeSize, borderRadius: 7 * roundness };
}
- return standardSize;
-};
-
-const extended = {
- height: 48,
- paddingHorizontal: 16,
};
const v3Extended = {
@@ -424,16 +357,14 @@ const getExtendedFabDimensions = (customSize: number) => ({
export const getExtendedFabStyle = ({
customSize,
- theme,
+ theme: _theme,
}: {
customSize?: number;
theme: InternalTheme;
}) => {
if (customSize) return getExtendedFabDimensions(customSize);
- const { isV3 } = theme;
-
- return isV3 ? v3Extended : extended;
+ return v3Extended;
};
let cachedContext: CanvasRenderingContext2D | null = null;
diff --git a/src/components/HelperText/utils.ts b/src/components/HelperText/utils.ts
index 4134175416..ab9d2dde8e 100644
--- a/src/components/HelperText/utils.ts
+++ b/src/components/HelperText/utils.ts
@@ -1,5 +1,3 @@
-import color from 'color';
-
import type { InternalTheme } from '../../types';
type BaseProps = {
@@ -9,22 +7,14 @@ type BaseProps = {
};
export function getTextColor({ theme, disabled, type }: BaseProps) {
- const { colors, dark } = theme;
+ const { colors } = theme;
if (type === 'error') {
return colors?.error;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- } else {
- return theme.colors.onSurfaceVariant;
- }
+ if (disabled) {
+ return theme.colors.onSurfaceDisabled;
}
-
- return color(theme?.colors?.text)
- .alpha(dark ? 0.7 : 0.54)
- .rgb()
- .string();
+ return theme.colors.onSurfaceVariant;
}
diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx
index b3d26c699d..b886e06fe2 100644
--- a/src/components/Icon.tsx
+++ b/src/components/Icon.tsx
@@ -122,8 +122,7 @@ const Icon = ({
typeof source === 'object' && source.direction && source.source
? source.source
: source;
- const iconColor =
- color || (theme.isV3 ? theme.colors.onSurface : theme.colors.text);
+ const iconColor = color || theme.colors.onSurface;
if (isImageSource(s)) {
return (
diff --git a/src/components/IconButton/IconButton.tsx b/src/components/IconButton/IconButton.tsx
index 47a87901ca..2da6e12fcf 100644
--- a/src/components/IconButton/IconButton.tsx
+++ b/src/components/IconButton/IconButton.tsx
@@ -138,7 +138,6 @@ const IconButton = forwardRef(
ref
) => {
const theme = useInternalTheme(themeOverrides);
- const { isV3 } = theme;
const IconComponent = animated ? CrossFadeIcon : Icon;
@@ -153,10 +152,10 @@ const IconButton = forwardRef(
customRippleColor,
});
- const buttonSize = isV3 ? size + 2 * PADDING : size * 1.5;
+ const buttonSize = size + 2 * PADDING;
const {
- borderWidth = isV3 && mode === 'outlined' && !selected ? 1 : 0,
+ borderWidth = mode === 'outlined' && !selected ? 1 : 0,
borderRadius = buttonSize / 2,
} = (StyleSheet.flatten(style) || {}) as ViewStyle;
@@ -178,11 +177,10 @@ const IconButton = forwardRef(
},
styles.container,
borderStyles,
- !isV3 && disabled && styles.disabled,
style,
]}
container
- {...(isV3 && { elevation: 0 })}
+ elevation={0}
>
{
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.surfaceDisabled;
- }
-
- return theme.colors.outline;
+ if (disabled) {
+ return theme.colors.surfaceDisabled;
}
- return undefined;
+ return theme.colors.outline;
};
const getBackgroundColor = ({
@@ -38,40 +34,34 @@ const getBackgroundColor = ({
selected,
customContainerColor,
}: BaseProps & { customContainerColor?: string }) => {
- if (theme.isV3) {
- if (disabled) {
- if (isMode('contained') || isMode('contained-tonal')) {
- return theme.colors.surfaceDisabled;
- }
- }
-
- if (typeof customContainerColor !== 'undefined') {
- return customContainerColor;
+ if (disabled) {
+ if (isMode('contained') || isMode('contained-tonal')) {
+ return theme.colors.surfaceDisabled;
}
+ }
- if (isMode('contained')) {
- if (selected) {
- return theme.colors.primary;
- }
- return theme.colors.surfaceVariant;
- }
+ if (typeof customContainerColor !== 'undefined') {
+ return customContainerColor;
+ }
- if (isMode('contained-tonal')) {
- if (selected) {
- return theme.colors.secondaryContainer;
- }
- return theme.colors.surfaceVariant;
+ if (isMode('contained')) {
+ if (selected) {
+ return theme.colors.primary;
}
+ return theme.colors.surfaceVariant;
+ }
- if (isMode('outlined')) {
- if (selected) {
- return theme.colors.inverseSurface;
- }
+ if (isMode('contained-tonal')) {
+ if (selected) {
+ return theme.colors.secondaryContainer;
}
+ return theme.colors.surfaceVariant;
}
- if (typeof customContainerColor !== 'undefined') {
- return customContainerColor;
+ if (isMode('outlined')) {
+ if (selected) {
+ return theme.colors.inverseSurface;
+ }
}
return undefined;
@@ -84,65 +74,52 @@ const getIconColor = ({
selected,
customIconColor,
}: BaseProps & { customIconColor?: string }) => {
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- if (typeof customIconColor !== 'undefined') {
- return customIconColor;
- }
+ if (disabled) {
+ return theme.colors.onSurfaceDisabled;
+ }
- if (isMode('contained')) {
- if (selected) {
- return theme.colors.onPrimary;
- }
- return theme.colors.primary;
- }
+ if (typeof customIconColor !== 'undefined') {
+ return customIconColor;
+ }
- if (isMode('contained-tonal')) {
- if (selected) {
- return theme.colors.onSecondaryContainer;
- }
- return theme.colors.onSurfaceVariant;
+ if (isMode('contained')) {
+ if (selected) {
+ return theme.colors.onPrimary;
}
+ return theme.colors.primary;
+ }
- if (isMode('outlined')) {
- if (selected) {
- return theme.colors.inverseOnSurface;
- }
- return theme.colors.onSurfaceVariant;
+ if (isMode('contained-tonal')) {
+ if (selected) {
+ return theme.colors.onSecondaryContainer;
}
+ return theme.colors.onSurfaceVariant;
+ }
+ if (isMode('outlined')) {
if (selected) {
- return theme.colors.primary;
+ return theme.colors.inverseOnSurface;
}
return theme.colors.onSurfaceVariant;
}
- if (typeof customIconColor !== 'undefined') {
- return customIconColor;
+ if (selected) {
+ return theme.colors.primary;
}
-
- return theme.colors.text;
+ return theme.colors.onSurfaceVariant;
};
const getRippleColor = ({
- theme,
iconColor,
customRippleColor,
}: {
- theme: InternalTheme;
iconColor: string;
customRippleColor?: ColorValue;
}) => {
if (customRippleColor) {
return customRippleColor;
}
- if (theme.isV3) {
- return color(iconColor).alpha(0.12).rgb().string();
- }
- return color(iconColor).alpha(0.32).rgb().string();
+ return color(iconColor).alpha(0.12).rgb().string();
};
export const getIconButtonColor = ({
@@ -184,7 +161,7 @@ export const getIconButtonColor = ({
...baseIconColorProps,
customContainerColor,
}),
- rippleColor: getRippleColor({ theme, iconColor, customRippleColor }),
+ rippleColor: getRippleColor({ iconColor, customRippleColor }),
borderColor: getBorderColor({ theme, disabled }),
};
};
diff --git a/src/components/List/ListAccordion.tsx b/src/components/List/ListAccordion.tsx
index 75505c7367..ace8810a71 100644
--- a/src/components/List/ListAccordion.tsx
+++ b/src/components/List/ListAccordion.tsx
@@ -212,9 +212,6 @@ const ListAccordion = ({
const onDescriptionTextLayout = (
event: NativeSyntheticEvent
) => {
- if (!theme.isV3) {
- return;
- }
const { nativeEvent } = event;
setAlignToTop(nativeEvent.lines.length >= 2);
};
@@ -241,12 +238,11 @@ const ListAccordion = ({
? groupContext.expandedId === id
: expandedInternal;
- const { titleColor, descriptionColor, titleTextColor, rippleColor } =
- getAccordionColors({
- theme,
- isExpanded,
- customRippleColor,
- });
+ const { descriptionColor, titleTextColor, rippleColor } = getAccordionColors({
+ theme,
+ isExpanded,
+ customRippleColor,
+ });
const handlePress =
groupContext && id !== undefined
@@ -256,7 +252,7 @@ const ListAccordion = ({
{left
? left({
color: isExpanded ? theme.colors?.primary : descriptionColor,
- style: getLeftStyles(alignToTop, description, theme.isV3),
+ style: getLeftStyles(alignToTop, description),
})
: null}
-
+
{right ? (
right({
@@ -329,7 +322,7 @@ const ListAccordion = ({
) : (
@@ -348,10 +341,7 @@ const ListAccordion = ({
!child.props.right
) {
return React.cloneElement(child, {
- style: [
- theme.isV3 ? styles.childV3 : styles.child,
- child.props.style,
- ],
+ style: [styles.child, child.props.style],
theme,
});
}
@@ -367,17 +357,10 @@ ListAccordion.displayName = 'List.Accordion';
const styles = StyleSheet.create({
container: {
- padding: 8,
- },
- containerV3: {
paddingVertical: 8,
paddingRight: 24,
},
row: {
- flexDirection: 'row',
- alignItems: 'center',
- },
- rowV3: {
flexDirection: 'row',
marginVertical: 6,
},
@@ -392,17 +375,14 @@ const styles = StyleSheet.create({
description: {
fontSize: 14,
},
- item: {
+ contentItem: {
+ paddingLeft: 16,
+ },
+ trailingItem: {
marginVertical: 6,
paddingLeft: 8,
},
- itemV3: {
- paddingLeft: 16,
- },
child: {
- paddingLeft: 64,
- },
- childV3: {
paddingLeft: 40,
},
content: {
diff --git a/src/components/List/ListIcon.tsx b/src/components/List/ListIcon.tsx
index f1c7194c43..108d642383 100644
--- a/src/components/List/ListIcon.tsx
+++ b/src/components/List/ListIcon.tsx
@@ -51,10 +51,7 @@ const ListIcon = ({
const theme = useInternalTheme(themeOverrides);
return (
-
+
);
@@ -62,13 +59,6 @@ const ListIcon = ({
const styles = StyleSheet.create({
item: {
- margin: 8,
- height: 40,
- width: 40,
- alignItems: 'center',
- justifyContent: 'center',
- },
- itemV3: {
alignItems: 'center',
justifyContent: 'center',
},
diff --git a/src/components/List/ListImage.tsx b/src/components/List/ListImage.tsx
index 9839be7b02..8eb887bddc 100644
--- a/src/components/List/ListImage.tsx
+++ b/src/components/List/ListImage.tsx
@@ -7,7 +7,6 @@ import {
ImageStyle,
} from 'react-native';
-import { useInternalTheme } from '../../core/theming';
import type { ThemeProp } from '../../types';
export type Props = {
@@ -42,16 +41,11 @@ const ListImage = ({
style,
source,
variant = 'image',
- theme: themeOverrides,
+ theme: _theme,
}: Props) => {
- const theme = useInternalTheme(themeOverrides);
const getStyles = () => {
if (variant === 'video') {
- if (!theme.isV3) {
- return [style, styles.video];
- }
-
- return [style, styles.videoV3];
+ return [style, styles.video];
}
return [style, styles.image];
@@ -73,11 +67,6 @@ const styles = StyleSheet.create({
height: 56,
},
video: {
- width: 100,
- height: 64,
- marginLeft: 0,
- },
- videoV3: {
width: 114,
height: 64,
marginLeft: 0,
diff --git a/src/components/List/ListItem.tsx b/src/components/List/ListItem.tsx
index 467eb9b67a..c50d075744 100644
--- a/src/components/List/ListItem.tsx
+++ b/src/components/List/ListItem.tsx
@@ -10,8 +10,6 @@ import {
ViewStyle,
} from 'react-native';
-import color from 'color';
-
import { Style, getLeftStyles, getRightStyles } from './utils';
import { useInternalTheme } from '../../core/theming';
import type { $RemoveChildren, EllipsizeProp, ThemeProp } from '../../types';
@@ -169,9 +167,6 @@ const ListItem = (
const onDescriptionTextLayout = (
event: NativeSyntheticEvent
) => {
- if (!theme.isV3) {
- return;
- }
const { nativeEvent } = event;
setAlignToTop(nativeEvent.lines.length >= 2);
};
@@ -206,9 +201,7 @@ const ListItem = (
};
const renderTitle = () => {
- const titleColor = theme.isV3
- ? theme.colors.onSurface
- : color(theme.colors.text).alpha(0.87).rgb().string();
+ const titleColor = theme.colors.onSurface;
return typeof title === 'function' ? (
title({
@@ -230,32 +223,26 @@ const ListItem = (
);
};
- const descriptionColor = theme.isV3
- ? theme.colors.onSurfaceVariant
- : color(theme.colors.text).alpha(0.54).rgb().string();
+ const descriptionColor = theme.colors.onSurfaceVariant;
return (
-
+
{left
? left({
color: descriptionColor,
- style: getLeftStyles(alignToTop, description, theme.isV3),
+ style: getLeftStyles(alignToTop, description),
})
: null}
{renderTitle()}
@@ -267,7 +254,7 @@ const ListItem = (
{right
? right({
color: descriptionColor,
- style: getRightStyles(alignToTop, description, theme.isV3),
+ style: getRightStyles(alignToTop, description),
})
: null}
@@ -280,19 +267,12 @@ const Component = forwardRef(ListItem);
const styles = StyleSheet.create({
container: {
- padding: 8,
- },
- containerV3: {
paddingVertical: 8,
paddingRight: 24,
},
row: {
width: '100%',
flexDirection: 'row',
- },
- rowV3: {
- width: '100%',
- flexDirection: 'row',
marginVertical: 6,
},
title: {
@@ -302,10 +282,6 @@ const styles = StyleSheet.create({
fontSize: 14,
},
item: {
- marginVertical: 6,
- paddingLeft: 8,
- },
- itemV3: {
paddingLeft: 16,
},
content: {
diff --git a/src/components/List/ListSubheader.tsx b/src/components/List/ListSubheader.tsx
index 038b86a86e..38e0a9d41f 100644
--- a/src/components/List/ListSubheader.tsx
+++ b/src/components/List/ListSubheader.tsx
@@ -1,7 +1,6 @@
import * as React from 'react';
import { StyleProp, StyleSheet, TextStyle } from 'react-native';
-import color from 'color';
import type { ThemeProp } from 'src/types';
import { useInternalTheme } from '../../core/theming';
@@ -43,11 +42,9 @@ const ListSubheader = ({
}: Props) => {
const theme = useInternalTheme(overrideTheme);
- const textColor = theme.isV3
- ? theme.colors.onSurfaceVariant
- : color(theme.colors.text).alpha(0.54).rgb().string();
+ const textColor = theme.colors.onSurfaceVariant;
- const font = theme.isV3 ? theme.fonts.bodyMedium : theme.fonts.medium;
+ const font = theme.fonts.bodyMedium;
return (
{
- const stylesV3 = {
- marginRight: 0,
- marginLeft: 16,
+ const stylesV3: Style = {
+ ...stylesV3Left,
alignSelf: alignToTop ? 'flex-start' : 'center',
};
@@ -47,14 +48,10 @@ export const getLeftStyles = (
return {
...styles.iconMarginLeft,
...styles.marginVerticalNone,
- ...(isV3 && { ...stylesV3 }),
+ ...stylesV3,
};
}
- if (!isV3) {
- return styles.iconMarginLeft;
- }
-
return {
...styles.iconMarginLeft,
...stylesV3,
@@ -63,11 +60,10 @@ export const getLeftStyles = (
export const getRightStyles = (
alignToTop: boolean,
- description: Description,
- isV3: boolean
+ description: Description
) => {
- const stylesV3 = {
- marginLeft: 16,
+ const stylesV3: Style = {
+ ...stylesV3Right,
alignSelf: alignToTop ? 'flex-start' : 'center',
};
@@ -75,14 +71,10 @@ export const getRightStyles = (
return {
...styles.iconMarginRight,
...styles.marginVerticalNone,
- ...(isV3 && { ...stylesV3 }),
+ ...stylesV3,
};
}
- if (!isV3) {
- return styles.iconMarginRight;
- }
-
return {
...styles.iconMarginRight,
...stylesV3,
@@ -104,13 +96,9 @@ export const getAccordionColors = ({
isExpanded?: boolean;
customRippleColor?: ColorValue;
}) => {
- const titleColor = theme.isV3
- ? theme.colors.onSurface
- : color(theme.colors.text).alpha(0.87).rgb().string();
+ const titleColor = theme.colors.onSurface;
- const descriptionColor = theme.isV3
- ? theme.colors.onSurfaceVariant
- : color(theme.colors.text).alpha(0.54).rgb().string();
+ const descriptionColor = theme.colors.onSurfaceVariant;
const titleTextColor = isExpanded ? theme.colors?.primary : titleColor;
@@ -118,7 +106,6 @@ export const getAccordionColors = ({
customRippleColor || color(titleTextColor).alpha(0.12).rgb().string();
return {
- titleColor,
descriptionColor,
titleTextColor,
rippleColor,
diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx
index 956b362562..9ac794021b 100644
--- a/src/components/Menu/Menu.tsx
+++ b/src/components/Menu/Menu.tsx
@@ -23,7 +23,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
import MenuItem from './MenuItem';
import { useInternalTheme } from '../../core/theming';
-import type { MD3Elevation, ThemeProp } from '../../types';
+import type { MD3Elevation, MD3Theme, ThemeProp } from '../../types';
import { ElevationLevels } from '../../types';
import { addEventListener } from '../../utils/addEventListener';
import { BackHandler } from '../../utils/BackHandler/BackHandler';
@@ -196,6 +196,7 @@ const Menu = ({
keyboardShouldPersistTaps,
}: Props) => {
const theme = useInternalTheme(themeOverrides);
+ const { colors: md3Colors } = theme as MD3Theme;
const insets = useSafeAreaInsets();
const [rendered, setRendered] = React.useState(visible);
const [left, setLeft] = React.useState(0);
@@ -618,7 +619,6 @@ const Menu = ({
},
],
borderRadius: theme.roundness,
- ...(!theme.isV3 && { elevation: 8 }),
...(scrollableMenuHeight ? { height: scrollableMenuHeight } : {}),
};
@@ -673,13 +673,13 @@ const Menu = ({
style={[
styles.shadowMenuContainer,
shadowMenuContainerStyle,
- theme.isV3 && {
+ {
backgroundColor:
- theme.colors.elevation[ELEVATION_LEVELS_MAP[elevation]],
+ md3Colors.elevation[ELEVATION_LEVELS_MAP[elevation]],
},
contentStyle,
]}
- {...(theme.isV3 && { elevation })}
+ elevation={elevation}
testID={`${testID}-surface`}
theme={theme}
container
diff --git a/src/components/Menu/MenuItem.tsx b/src/components/Menu/MenuItem.tsx
index 4b8eb3740a..652ffc9a4f 100644
--- a/src/components/Menu/MenuItem.tsx
+++ b/src/components/Menu/MenuItem.tsx
@@ -18,7 +18,7 @@ import {
MIN_WIDTH,
} from './utils';
import { useInternalTheme } from '../../core/theming';
-import type { ThemeProp } from '../../types';
+import type { MD3Theme, ThemeProp } from '../../types';
import Icon, { IconSource } from '../Icon';
import TouchableRipple, {
Props as TouchableRippleProps,
@@ -156,16 +156,13 @@ const MenuItem = ({
disabled,
customRippleColor,
});
- const { isV3 } = theme;
+ const containerPadding = 12;
- const containerPadding = isV3 ? 12 : 8;
+ const iconWidth = 24;
- const iconWidth = isV3 ? 24 : 40;
-
- const minWidth = MIN_WIDTH - (isV3 ? 12 : 16);
+ const minWidth = MIN_WIDTH - 12;
const maxWidth = getContentMaxWidth({
- isV3,
iconWidth,
leadingIcon,
trailingIcon,
@@ -173,7 +170,7 @@ const MenuItem = ({
const titleTextStyle = {
color: titleColor,
- ...(isV3 ? theme.fonts.bodyLarge : {}),
+ ...(theme as MD3Theme).fonts.bodyLarge,
};
const newAccessibilityState = { ...accessibilityState, disabled };
@@ -198,22 +195,15 @@ const MenuItem = ({
>
{leadingIcon ? (
-
+
) : null}
{title}
- {isV3 && trailingIcon ? (
-
+ {trailingIcon ? (
+
) : null}
@@ -257,12 +244,6 @@ const styles = StyleSheet.create({
row: {
flexDirection: 'row',
},
- title: {
- fontSize: 16,
- },
- item: {
- marginHorizontal: 8,
- },
content: {
justifyContent: 'center',
},
diff --git a/src/components/Menu/utils.ts b/src/components/Menu/utils.ts
index c1b6189ba4..71c503bcc2 100644
--- a/src/components/Menu/utils.ts
+++ b/src/components/Menu/utils.ts
@@ -2,15 +2,13 @@ import type { ColorValue } from 'react-native';
import color from 'color';
-import { black, white } from '../../styles/themes/v2/colors';
-import type { InternalTheme } from '../../types';
+import type { InternalTheme, MD3Theme } from '../../types';
import type { IconSource } from '../Icon';
export const MIN_WIDTH = 112;
export const MAX_WIDTH = 280;
type ContentProps = {
- isV3: boolean;
iconWidth: number;
leadingIcon?: IconSource;
trailingIcon?: IconSource;
@@ -23,38 +21,25 @@ type ColorProps = {
};
const getDisabledColor = (theme: InternalTheme) => {
- if (theme.isV3) {
- return theme.colors.onSurfaceDisabled;
- }
-
- return color(theme.dark ? white : black)
- .alpha(0.32)
- .rgb()
- .string();
+ return (theme as MD3Theme).colors.onSurfaceDisabled;
};
const getTitleColor = ({ theme, disabled }: ColorProps) => {
+ const { colors } = theme as MD3Theme;
if (disabled) {
return getDisabledColor(theme);
}
- if (theme.isV3) {
- return theme.colors.onSurface;
- }
-
- return color(theme.colors.text).alpha(0.87).rgb().string();
+ return colors.onSurface;
};
const getIconColor = ({ theme, disabled }: ColorProps) => {
+ const { colors } = theme as MD3Theme;
if (disabled) {
return getDisabledColor(theme);
}
- if (theme.isV3) {
- return theme.colors.onSurfaceVariant;
- }
-
- return color(theme.colors.text).alpha(0.54).rgb().string();
+ return colors.onSurfaceVariant;
};
const getRippleColor = ({
@@ -65,11 +50,10 @@ const getRippleColor = ({
return customRippleColor;
}
- if (theme.isV3) {
- return color(theme.colors.onSurfaceVariant).alpha(0.12).rgb().string();
- }
-
- return undefined;
+ return color((theme as MD3Theme).colors.onSurfaceVariant)
+ .alpha(0.12)
+ .rgb()
+ .string();
};
export const getMenuItemColor = ({
@@ -85,26 +69,17 @@ export const getMenuItemColor = ({
};
export const getContentMaxWidth = ({
- isV3,
iconWidth,
leadingIcon,
trailingIcon,
}: ContentProps) => {
- if (isV3) {
- if (leadingIcon && trailingIcon) {
- return MAX_WIDTH - (2 * iconWidth + 24);
- }
-
- if (leadingIcon || trailingIcon) {
- return MAX_WIDTH - (iconWidth + 24);
- }
-
- return MAX_WIDTH - 12;
+ if (leadingIcon && trailingIcon) {
+ return MAX_WIDTH - (2 * iconWidth + 24);
}
- if (leadingIcon) {
- return MAX_WIDTH - (iconWidth + 48);
+ if (leadingIcon || trailingIcon) {
+ return MAX_WIDTH - (iconWidth + 24);
}
- return MAX_WIDTH - 16;
+ return MAX_WIDTH - 12;
};
diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx
index 790204f4f8..c307df2479 100644
--- a/src/components/ProgressBar.tsx
+++ b/src/components/ProgressBar.tsx
@@ -10,8 +10,6 @@ import {
ViewStyle,
} from 'react-native';
-import setColor from 'color';
-
import { useInternalTheme } from '../core/theming';
import type { ThemeProp } from '../types';
@@ -191,9 +189,7 @@ const ProgressBar = ({
};
const tintColor = color || theme.colors?.primary;
- const trackTintColor = theme.isV3
- ? theme.colors.surfaceVariant
- : setColor(tintColor).alpha(0.38).rgb().string();
+ const trackTintColor = theme.colors.surfaceVariant;
return (
;
}
- const textColor = theme.isV3 ? theme.colors.onSurface : theme.colors.text;
- const disabledTextColor = theme.isV3
- ? theme.colors.onSurfaceDisabled
- : theme.colors.disabled;
+ const textColor = theme.colors.onSurface;
+ const disabledTextColor = theme.colors.onSurfaceDisabled;
const textAlign = isLeading ? 'right' : 'left';
const computedStyle = {
@@ -232,12 +230,7 @@ const RadioButtonItem = ({
{isLeading && radioButton}
{label}
@@ -270,7 +263,4 @@ const styles = StyleSheet.create({
flexShrink: 1,
flexGrow: 1,
},
- font: {
- fontSize: 16,
- },
});
diff --git a/src/components/Searchbar.tsx b/src/components/Searchbar.tsx
index 891df22945..6377899280 100644
--- a/src/components/Searchbar.tsx
+++ b/src/components/Searchbar.tsx
@@ -23,7 +23,7 @@ import IconButton from './IconButton/IconButton';
import MaterialCommunityIcon from './MaterialCommunityIcon';
import Surface from './Surface';
import { useInternalTheme } from '../core/theming';
-import type { ThemeProp } from '../types';
+import type { MD3Theme, ThemeProp } from '../types';
import { forwardRef } from '../utils/forwardRef';
interface Style {
@@ -208,6 +208,7 @@ const Searchbar = forwardRef(
ref
) => {
const theme = useInternalTheme(themeOverrides);
+ const { colors, fonts } = theme as MD3Theme;
const root = React.useRef(null);
React.useImperativeHandle(ref, () => ({
@@ -227,34 +228,26 @@ const Searchbar = forwardRef(
onClearIconPress?.(e);
};
- const { roundness, dark, isV3, fonts } = theme;
+ const { roundness, dark } = theme;
- const placeholderTextColor = isV3
- ? theme.colors.onSurface
- : theme.colors?.placeholder;
- const textColor = isV3 ? theme.colors.onSurfaceVariant : theme.colors.text;
- const md2IconColor = dark
- ? textColor
- : color(textColor).alpha(0.54).rgb().string();
- const iconColor =
- customIconColor || (isV3 ? theme.colors.onSurfaceVariant : md2IconColor);
+ const placeholderTextColor = colors.onSurface;
+ const textColor = colors.onSurfaceVariant;
+ const iconColor = customIconColor || colors.onSurfaceVariant;
const rippleColor =
customRippleColor || color(textColor).alpha(0.32).rgb().string();
const traileringRippleColor =
customTraileringRippleColor ||
color(textColor).alpha(0.32).rgb().string();
- const font = isV3
- ? {
- ...fonts.bodyLarge,
- lineHeight: Platform.select({
- ios: 0,
- default: fonts.bodyLarge.lineHeight,
- }),
- }
- : theme.fonts.regular;
+ const font = {
+ ...fonts.bodyLarge,
+ lineHeight: Platform.select({
+ ios: 0,
+ default: fonts.bodyLarge.lineHeight,
+ }),
+ };
- const isBarMode = isV3 && mode === 'bar';
+ const isBarMode = mode === 'bar';
const shouldRenderTraileringIcon =
isBarMode &&
traileringIcon &&
@@ -265,16 +258,15 @@ const Searchbar = forwardRef(
@@ -307,12 +299,12 @@ const Searchbar = forwardRef(
...font,
...Platform.select({ web: { outline: 'none' } }),
},
- isV3 && (isBarMode ? styles.barModeInput : styles.viewModeInput),
+ isBarMode ? styles.barModeInput : styles.viewModeInput,
inputStyle,
]}
placeholder={placeholder || ''}
placeholderTextColor={placeholderTextColor}
- selectionColor={theme.colors?.primary}
+ selectionColor={colors.primary}
underlineColorAndroid="transparent"
returnKeyType="search"
keyboardAppearance={dark ? 'dark' : 'light'}
@@ -325,7 +317,7 @@ const Searchbar = forwardRef(
{loading ? (
) : (
// Clear icon should be always rendered within Searchbar – it's transparent,
@@ -336,8 +328,8 @@ const Searchbar = forwardRef(
pointerEvents={value ? 'auto' : 'none'}
testID={`${testID}-icon-wrapper`}
style={[
- isV3 && !value && styles.v3ClearIcon,
- isV3 && right !== undefined && styles.v3ClearIconHidden,
+ !value && styles.v3ClearIcon,
+ right !== undefined && styles.v3ClearIconHidden,
]}
>
(
clearIcon ||
(({ size, color }) => (
(
accessibilityRole="button"
borderless
onPress={onTraileringIconPress}
- iconColor={traileringIconColor || theme.colors.onSurfaceVariant}
+ iconColor={traileringIconColor || colors.onSurfaceVariant}
rippleColor={traileringRippleColor}
icon={traileringIcon}
accessibilityLabel={traileringIconAccessibilityLabel}
@@ -377,13 +369,13 @@ const Searchbar = forwardRef(
) : null}
{isBarMode &&
right?.({ color: textColor, style: styles.rightStyle, testID })}
- {isV3 && !isBarMode && showDivider && (
+ {!isBarMode && showDivider && (
{
if (checked) {
- if (theme.isV3) {
- return theme.colors.secondaryContainer;
- } else {
- return color(theme.colors.primary).alpha(0.12).rgb().string();
- }
+ return theme.colors.secondaryContainer;
}
return 'transparent';
};
-const getSegmentedButtonBorderColor = ({
- theme,
- disabled,
- checked,
-}: BaseProps) => {
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.surfaceDisabled;
- }
- return theme.colors.outline;
- }
- if (checked) {
- return theme.colors.primary;
+const getSegmentedButtonBorderColor = ({ theme, disabled }: BaseProps) => {
+ if (disabled) {
+ return theme.colors.surfaceDisabled;
}
-
- return color(theme.dark ? white : black)
- .alpha(0.29)
- .rgb()
- .string();
+ return theme.colors.outline;
};
const getSegmentedButtonBorderWidth = ({
- theme,
+ theme: _t,
}: Omit) => {
- if (theme.isV3) {
- return 1;
- }
-
- return StyleSheet.hairlineWidth;
+ return 1;
};
const getSegmentedButtonTextColor = ({
@@ -133,21 +107,13 @@ const getSegmentedButtonTextColor = ({
checkedColor,
uncheckedColor,
}: SegmentedButtonProps) => {
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
- if (checked) {
- return checkedColor ?? theme.colors.onSecondaryContainer;
- }
- return uncheckedColor ?? theme.colors.onSurface;
- }
-
if (disabled) {
- return theme.colors.disabled;
+ return theme.colors.onSurfaceDisabled;
+ }
+ if (checked) {
+ return checkedColor ?? theme.colors.onSecondaryContainer;
}
- // Primary color is used for checked state too.
- return theme.colors.primary;
+ return uncheckedColor ?? theme.colors.onSurface;
};
export const getSegmentedButtonColors = ({
diff --git a/src/components/Snackbar.tsx b/src/components/Snackbar.tsx
index d11bc91a62..22b55bb02a 100644
--- a/src/components/Snackbar.tsx
+++ b/src/components/Snackbar.tsx
@@ -20,7 +20,7 @@ import MaterialCommunityIcon from './MaterialCommunityIcon';
import Surface from './Surface';
import Text from './Typography/Text';
import { useInternalTheme } from '../core/theming';
-import type { $Omit, $RemoveChildren, ThemeProp } from '../types';
+import type { $Omit, $RemoveChildren, MD3Theme, ThemeProp } from '../types';
export type Props = $Omit, 'mode'> & {
/**
@@ -243,7 +243,7 @@ const Snackbar = ({
}
}, [visible, handleOnVisible, handleOnHidden]);
- const { colors, roundness, isV3 } = theme;
+ const { colors, roundness } = theme as MD3Theme;
if (hidden) {
return null;
@@ -257,11 +257,11 @@ const Snackbar = ({
...actionProps
} = action || {};
- const buttonTextColor = isV3 ? colors.inversePrimary : colors.accent;
- const textColor = isV3 ? colors.inverseOnSurface : colors?.surface;
- const backgroundColor = isV3 ? colors.inverseSurface : colors?.onSurface;
+ const buttonTextColor = colors.inversePrimary;
+ const textColor = colors.inverseOnSurface;
+ const backgroundColor = colors.inverseSurface;
- const isIconButton = isV3 && onIconPress;
+ const isIconButton = Boolean(onIconPress);
const marginLeft = action ? -12 : -16;
@@ -301,7 +301,6 @@ const Snackbar = ({
accessibilityLiveRegion="polite"
theme={theme}
style={[
- !isV3 && styles.elevation,
styles.container,
{
backgroundColor,
@@ -322,7 +321,7 @@ const Snackbar = ({
]}
testID={testID}
container
- {...(isV3 && { elevation })}
+ elevation={elevation}
{...rest}
>
{renderChildrenWithWrapper()}
@@ -336,7 +335,7 @@ const Snackbar = ({
}}
style={[styles.button, actionStyle]}
textColor={buttonTextColor}
- compact={!isV3}
+ compact={false}
mode="text"
theme={theme}
rippleColor={actionRippleColor}
@@ -350,7 +349,7 @@ const Snackbar = ({
accessibilityRole="button"
borderless
onPress={onIconPress}
- iconColor={theme.colors.inverseOnSurface}
+ iconColor={colors.inverseOnSurface}
rippleColor={rippleColor}
theme={theme}
icon={
@@ -423,9 +422,6 @@ const styles = StyleSheet.create({
marginRight: 8,
marginLeft: 4,
},
- elevation: {
- elevation: 6,
- },
icon: {
width: 40,
height: 40,
diff --git a/src/components/Surface.tsx b/src/components/Surface.tsx
index 3b46d099e1..2c8fad2461 100644
--- a/src/components/Surface.tsx
+++ b/src/components/Surface.tsx
@@ -10,9 +10,9 @@ import {
} from 'react-native';
import { useInternalTheme } from '../core/theming';
-import overlay, { isAnimatedValue } from '../styles/overlay';
+import { isAnimatedValue } from '../styles/overlay';
import shadow from '../styles/shadow';
-import type { ThemeProp, MD3Elevation } from '../types';
+import type { MD3Elevation, MD3Theme, ThemeProp } from '../types';
import { forwardRef } from '../utils/forwardRef';
import { splitStyles } from '../utils/splitStyles';
@@ -57,30 +57,6 @@ export type Props = Omit, 'style'> & {
container?: boolean;
};
-const MD2Surface = forwardRef(
- ({ style, theme: overrideTheme, ...rest }: Omit, ref) => {
- const { elevation = 4 } = (StyleSheet.flatten(style) || {}) as ViewStyle;
- const { dark: isDarkTheme, mode, colors } = useInternalTheme(overrideTheme);
-
- return (
-
- );
- }
-);
-
const outerLayerStyleProperties: (keyof ViewStyle)[] = [
'position',
'alignSelf',
@@ -277,14 +253,7 @@ const Surface = forwardRef(
) => {
const theme = useInternalTheme(overridenTheme);
- if (!theme.isV3)
- return (
-
- {children}
-
- );
-
- const { colors } = theme;
+ const { colors } = theme as MD3Theme;
const inputRange = [0, 1, 2, 3, 4, 5];
@@ -313,7 +282,7 @@ const Surface = forwardRef(
testID={testID}
style={[
{ backgroundColor },
- elevation && isElevated ? shadow(elevation, theme.isV3) : null,
+ elevation && isElevated ? shadow(elevation) : null,
style,
]}
>
diff --git a/src/components/Switch/utils.ts b/src/components/Switch/utils.ts
index 2994495af9..34ffc26eb5 100644
--- a/src/components/Switch/utils.ts
+++ b/src/components/Switch/utils.ts
@@ -29,11 +29,7 @@ const getCheckedColor = ({
return color;
}
- if (theme.isV3) {
- return theme.colors.primary;
- }
-
- return theme.colors.accent;
+ return theme.colors.primary;
};
const getThumbTintColor = ({
@@ -79,10 +75,7 @@ const getOnTintColor = ({
if (disabled) {
if (theme.dark) {
- if (theme.isV3) {
- return setColor(white).alpha(0.06).rgb().string();
- }
- return setColor(white).alpha(0.1).rgb().string();
+ return setColor(white).alpha(0.06).rgb().string();
}
return setColor(black).alpha(0.12).rgb().string();
}
diff --git a/src/components/TextInput/Addons/Outline.tsx b/src/components/TextInput/Addons/Outline.tsx
index 45b675fd8b..39ffa48b56 100644
--- a/src/components/TextInput/Addons/Outline.tsx
+++ b/src/components/TextInput/Addons/Outline.tsx
@@ -10,11 +10,9 @@ import {
import { TextInputLabelProp } from '../types';
type OutlineProps = {
- isV3: boolean;
activeColor: string;
backgroundColor: ColorValue;
hasActiveOutline?: boolean;
- focused?: boolean;
outlineColor?: string;
roundness?: number;
label?: TextInputLabelProp;
@@ -22,12 +20,10 @@ type OutlineProps = {
};
export const Outline = ({
- isV3,
label,
activeColor,
backgroundColor,
hasActiveOutline,
- focused,
outlineColor,
roundness,
style,
@@ -42,7 +38,7 @@ export const Outline = ({
{
backgroundColor,
borderRadius: roundness,
- borderWidth: (isV3 ? hasActiveOutline : focused) ? 2 : 1,
+ borderWidth: hasActiveOutline ? 2 : 1,
borderColor: hasActiveOutline ? activeColor : outlineColor,
},
style,
diff --git a/src/components/TextInput/Addons/Underline.tsx b/src/components/TextInput/Addons/Underline.tsx
index 184cbe63b5..20b49233dc 100644
--- a/src/components/TextInput/Addons/Underline.tsx
+++ b/src/components/TextInput/Addons/Underline.tsx
@@ -3,8 +3,6 @@ import { Animated, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import type { ThemeProp } from 'src/types';
-import { useInternalTheme } from '../../../core/theming';
-
type UnderlineProps = {
parentState: {
focused: boolean;
@@ -28,32 +26,28 @@ export const Underline = ({
underlineColorCustom,
hasActiveOutline,
style,
- theme: themeOverrides,
+ theme: _themeOverrides,
}: UnderlineProps) => {
- const { isV3 } = useInternalTheme(themeOverrides);
-
let backgroundColor = parentState.focused
? activeColor
: underlineColorCustom;
if (error) backgroundColor = colors?.error;
- const activeScale = isV3 ? 2 : 1;
+ const activeScale = 2;
return (
= ({
forceFocus,
paddingHorizontal,
maxFontSizeMultiplier,
- theme,
disabled,
}) => {
if (adornmentConfig.length) {
@@ -174,7 +168,6 @@ const TextInputAdornment: React.FunctionComponent = ({
return (
{
const theme = useInternalTheme(themeOverrides);
- const { AFFIX_OFFSET } = getConstants(theme.isV3);
+ const { AFFIX_OFFSET } = getConstants();
const {
textStyle,
diff --git a/src/components/TextInput/Adornment/TextInputIcon.tsx b/src/components/TextInput/Adornment/TextInputIcon.tsx
index bd38ca64ab..8f4ce7c4df 100644
--- a/src/components/TextInput/Adornment/TextInputIcon.tsx
+++ b/src/components/TextInput/Adornment/TextInputIcon.tsx
@@ -69,7 +69,6 @@ const IconAdornment: React.FunctionComponent<
icon: React.ReactNode;
topPosition: number;
side: 'left' | 'right';
- theme?: ThemeProp;
disabled?: boolean;
} & Omit
> = ({
@@ -79,11 +78,9 @@ const IconAdornment: React.FunctionComponent<
isTextInputFocused,
forceFocus,
testID,
- theme: themeOverrides,
disabled,
}) => {
- const { isV3 } = useInternalTheme(themeOverrides);
- const { ICON_OFFSET } = getConstants(isV3);
+ const { ICON_OFFSET } = getConstants();
const style = {
top: topPosition,
diff --git a/src/components/TextInput/Adornment/utils.ts b/src/components/TextInput/Adornment/utils.ts
index e7dae2b487..38d9541706 100644
--- a/src/components/TextInput/Adornment/utils.ts
+++ b/src/components/TextInput/Adornment/utils.ts
@@ -1,5 +1,3 @@
-import color from 'color';
-
import type { InternalTheme } from '../../../types';
type BaseProps = {
@@ -8,16 +6,11 @@ type BaseProps = {
};
export function getTextColor({ theme, disabled }: BaseProps) {
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
- return theme.colors.onSurfaceVariant;
+ if (disabled) {
+ return theme.colors.onSurfaceDisabled;
}
- return color(theme.colors?.text)
- .alpha(theme.dark ? 0.7 : 0.54)
- .rgb()
- .string();
+
+ return theme.colors.onSurfaceVariant;
}
export function getIconColor({
@@ -36,10 +29,6 @@ export function getIconColor({
return customColor;
}
- if (!theme.isV3) {
- return theme.colors.text;
- }
-
if (disabled) {
return theme.colors.onSurfaceDisabled;
}
diff --git a/src/components/TextInput/Label/InputLabel.tsx b/src/components/TextInput/Label/InputLabel.tsx
index f0818f98f0..4877bc236e 100644
--- a/src/components/TextInput/Label/InputLabel.tsx
+++ b/src/components/TextInput/Label/InputLabel.tsx
@@ -48,12 +48,11 @@ const InputLabel = (props: InputLabelProps) => {
labelTranslationXOffset,
maxFontSizeMultiplier,
testID,
- isV3,
inputContainerLayout,
scaledLabel,
} = props;
- const { INPUT_PADDING_HORIZONTAL } = getConstants(isV3);
+ const { INPUT_PADDING_HORIZONTAL } = getConstants();
const { width } = useWindowDimensions();
const isWeb = Platform.OS === 'web';
diff --git a/src/components/TextInput/TextInputFlat.tsx b/src/components/TextInput/TextInputFlat.tsx
index 378366e176..ee8e438fb4 100644
--- a/src/components/TextInput/TextInputFlat.tsx
+++ b/src/components/TextInput/TextInputFlat.tsx
@@ -78,12 +78,12 @@ const TextInputFlat = ({
...rest
}: ChildTextInputProps) => {
const isAndroid = Platform.OS === 'android';
- const { colors, isV3, roundness } = theme;
- const font = isV3 ? theme.fonts.bodyLarge : theme.fonts.regular;
+ const { colors, roundness } = theme;
+ const font = theme.fonts.bodyLarge;
const hasActiveOutline = parentState.focused || error;
const { LABEL_PADDING_TOP, FLAT_INPUT_OFFSET, MIN_HEIGHT, MIN_WIDTH } =
- getConstants(isV3);
+ getConstants();
const {
fontSize: fontSizeStyle,
@@ -108,7 +108,6 @@ const TextInputFlat = ({
let { paddingLeft, paddingRight } = calculateFlatInputHorizontalPadding({
adornmentConfig,
- isV3,
});
if (isPaddingHorizontalPassed) {
@@ -134,7 +133,6 @@ const TextInputFlat = ({
paddingHorizontal,
inputOffset: FLAT_INPUT_OFFSET,
mode: InputMode.Flat,
- isV3,
});
const {
@@ -304,7 +302,6 @@ const TextInputFlat = ({
? 1
: 0
: 1,
- isV3,
};
const affixTopPosition = {
diff --git a/src/components/TextInput/TextInputOutlined.tsx b/src/components/TextInput/TextInputOutlined.tsx
index 70b590fabb..0bd85fb8d9 100644
--- a/src/components/TextInput/TextInputOutlined.tsx
+++ b/src/components/TextInput/TextInputOutlined.tsx
@@ -81,12 +81,12 @@ const TextInputOutlined = ({
}: ChildTextInputProps) => {
const adornmentConfig = getAdornmentConfig({ left, right });
- const { colors, isV3, roundness } = theme;
- const font = isV3 ? theme.fonts.bodyLarge : theme.fonts.regular;
+ const { colors, roundness } = theme;
+ const font = theme.fonts.bodyLarge;
const hasActiveOutline = parentState.focused || error;
const { INPUT_PADDING_HORIZONTAL, MIN_HEIGHT, ADORNMENT_OFFSET, MIN_WIDTH } =
- getConstants(isV3);
+ getConstants();
const {
fontSize: fontSizeStyle,
@@ -148,8 +148,8 @@ const TextInputOutlined = ({
if (isAdornmentLeftIcon) {
labelTranslationXOffset =
- (I18nManager.getConstants().isRTL ? -1 : 1) *
- (ADORNMENT_SIZE + ADORNMENT_OFFSET - (isV3 ? 0 : 8));
+ (I18nManager.getConstants().isRTL ? -1 : 1) * ADORNMENT_SIZE +
+ ADORNMENT_OFFSET;
}
const minInputHeight =
@@ -254,7 +254,6 @@ const TextInputOutlined = ({
? 1
: 0
: 1,
- isV3,
};
const onLayoutChange = React.useCallback(
@@ -303,7 +302,6 @@ const TextInputOutlined = ({
rightAffixWidth,
leftAffixWidth,
mode: 'outlined',
- isV3,
});
const affixTopPosition = {
[AdornmentSide.Left]: leftAffixTopPosition,
@@ -344,12 +342,10 @@ const TextInputOutlined = ({
Otherwise the border will cut off the label on Android
*/}
{
const { LABEL_PADDING_HORIZONTAL, ADORNMENT_OFFSET, FLAT_INPUT_OFFSET } =
- getConstants(isV3);
+ getConstants();
let paddingLeft = LABEL_PADDING_HORIZONTAL;
let paddingRight = LABEL_PADDING_HORIZONTAL;
@@ -320,19 +309,11 @@ const getInputTextColor = ({
return textColor;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- return theme.colors.onSurface;
- }
-
if (disabled) {
- return color(theme.colors.text).alpha(0.54).rgb().string();
+ return theme.colors.onSurfaceDisabled;
}
- return theme.colors.text;
+ return theme.colors.onSurface;
};
const getActiveColor = ({
@@ -360,30 +341,18 @@ const getActiveColor = ({
}
if (disabled) {
- if (theme.isV3) {
- return theme.colors.onSurfaceDisabled;
- }
-
- return color(theme.colors.text).alpha(0.54).rgb().string();
+ return theme.colors.onSurfaceDisabled;
}
return theme.colors.primary;
};
const getPlaceholderColor = ({ theme, disabled }: BaseProps) => {
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- return theme.colors.onSurfaceVariant;
- }
-
if (disabled) {
- return theme.colors.disabled;
+ return theme.colors.onSurfaceDisabled;
}
- return theme.colors.placeholder;
+ return theme.colors.onSurfaceVariant;
};
const getSelectionColor = ({
@@ -405,21 +374,11 @@ const getSelectionColor = ({
};
const getFlatBackgroundColor = ({ theme, disabled }: BaseProps) => {
- if (theme.isV3) {
- if (disabled) {
- return color(theme.colors.onSurface).alpha(0.04).rgb().string();
- } else {
- return theme.colors.surfaceVariant;
- }
- }
-
if (disabled) {
- return undefined;
+ return color(theme.colors.onSurface).alpha(0.04).rgb().string();
}
- return theme.dark
- ? color(theme.colors?.background).lighten(0.24).rgb().string()
- : color(theme.colors?.background).darken(0.06).rgb().string();
+ return theme.colors.surfaceVariant;
};
const getFlatUnderlineColor = ({
@@ -431,19 +390,11 @@ const getFlatUnderlineColor = ({
return underlineColor;
}
- if (theme.isV3) {
- if (disabled) {
- return theme.colors.onSurfaceDisabled;
- }
-
- return theme.colors.onSurfaceVariant;
- }
-
if (disabled) {
- return 'transparent';
+ return theme.colors.onSurfaceDisabled;
}
- return theme.colors.disabled;
+ return theme.colors.onSurfaceVariant;
};
const getOutlinedOutlineInputColor = ({
@@ -451,30 +402,19 @@ const getOutlinedOutlineInputColor = ({
disabled,
customOutlineColor,
}: BaseProps & { customOutlineColor?: string }) => {
- const isTransparent = color(customOutlineColor).alpha() === 0;
-
if (!disabled && customOutlineColor) {
return customOutlineColor;
}
- if (theme.isV3) {
- if (disabled) {
- if (theme.dark) {
- return 'transparent';
- }
- return theme.colors.surfaceDisabled;
+ if (disabled) {
+ if (theme.dark) {
+ return 'transparent';
}
- return theme.colors.outline;
+ return theme.colors.surfaceDisabled;
}
- if (disabled) {
- if (isTransparent) {
- return customOutlineColor;
- }
- return theme.colors.disabled;
- }
- return theme.colors.placeholder;
+ return theme.colors.outline;
};
export const getFlatInputColors = ({
@@ -560,53 +500,17 @@ export const getOutlinedInputColors = ({
};
};
-export const getConstants = (isV3?: boolean) => {
- // Text input affix
- let AFFIX_OFFSET;
- // Text input icon
- let ICON_OFFSET;
- //Text input flat
- let LABEL_PADDING_TOP;
- let LABEL_PADDING_HORIZONTAL;
- let FLAT_INPUT_OFFSET;
- let MIN_HEIGHT;
- // Text input outlined;
- let INPUT_PADDING_HORIZONTAL;
- let ADORNMENT_OFFSET;
- let OUTLINED_INPUT_OFFSET;
-
- if (isV3) {
- AFFIX_OFFSET = MD3_AFFIX_OFFSET;
- ICON_OFFSET = MD3_ICON_OFFSET;
- LABEL_PADDING_TOP = MD3_LABEL_PADDING_TOP;
- LABEL_PADDING_HORIZONTAL = MD3_LABEL_PADDING_HORIZONTAL;
- FLAT_INPUT_OFFSET = MD3_FLAT_INPUT_OFFSET;
- MIN_HEIGHT = MD3_MIN_HEIGHT;
- INPUT_PADDING_HORIZONTAL = MD3_INPUT_PADDING_HORIZONTAL;
- ADORNMENT_OFFSET = MD3_ADORNMENT_OFFSET;
- OUTLINED_INPUT_OFFSET = MD3_OUTLINED_INPUT_OFFSET;
- } else {
- AFFIX_OFFSET = MD2_AFFIX_OFFSET;
- ICON_OFFSET = MD2_ICON_OFFSET;
- LABEL_PADDING_TOP = MD2_LABEL_PADDING_TOP;
- LABEL_PADDING_HORIZONTAL = MD2_LABEL_PADDING_HORIZONTAL;
- FLAT_INPUT_OFFSET = MD2_FLAT_INPUT_OFFSET;
- MIN_HEIGHT = MD2_MIN_HEIGHT;
- INPUT_PADDING_HORIZONTAL = MD2_INPUT_PADDING_HORIZONTAL;
- ADORNMENT_OFFSET = MD2_ADORNMENT_OFFSET;
- OUTLINED_INPUT_OFFSET = MD2_OUTLINED_INPUT_OFFSET;
- }
-
+export const getConstants = () => {
return {
- AFFIX_OFFSET,
- ICON_OFFSET,
- LABEL_PADDING_TOP,
- LABEL_PADDING_HORIZONTAL,
- FLAT_INPUT_OFFSET,
- MIN_HEIGHT,
- INPUT_PADDING_HORIZONTAL,
- ADORNMENT_OFFSET,
- OUTLINED_INPUT_OFFSET,
+ AFFIX_OFFSET: MD3_AFFIX_OFFSET,
+ ICON_OFFSET: MD3_ICON_OFFSET,
+ LABEL_PADDING_TOP: MD3_LABEL_PADDING_TOP,
+ LABEL_PADDING_HORIZONTAL: MD3_LABEL_PADDING_HORIZONTAL,
+ FLAT_INPUT_OFFSET: MD3_FLAT_INPUT_OFFSET,
+ MIN_HEIGHT: MD3_MIN_HEIGHT,
+ INPUT_PADDING_HORIZONTAL: MD3_INPUT_PADDING_HORIZONTAL,
+ ADORNMENT_OFFSET: MD3_ADORNMENT_OFFSET,
+ OUTLINED_INPUT_OFFSET: MD3_OUTLINED_INPUT_OFFSET,
MIN_WIDTH,
};
};
diff --git a/src/components/TextInput/types.tsx b/src/components/TextInput/types.tsx
index 4ec2952366..1f710e4089 100644
--- a/src/components/TextInput/types.tsx
+++ b/src/components/TextInput/types.tsx
@@ -141,7 +141,6 @@ export type InputLabelProps = {
inputContainerLayout: { width: number };
labelBackground?: any;
maxFontSizeMultiplier?: number | undefined | null;
- isV3?: boolean;
scaledLabel?: boolean;
} & LabelProps;
diff --git a/src/components/ToggleButton/ToggleButton.tsx b/src/components/ToggleButton/ToggleButton.tsx
index bfdd3fca5c..e115dec7ec 100644
--- a/src/components/ToggleButton/ToggleButton.tsx
+++ b/src/components/ToggleButton/ToggleButton.tsx
@@ -9,12 +9,9 @@ import {
ColorValue,
} from 'react-native';
-import color from 'color';
-
import { ToggleButtonGroupContext } from './ToggleButtonGroup';
import { getToggleButtonColor } from './utils';
import { useInternalTheme } from '../../core/theming';
-import { black, white } from '../../styles/themes/v2/colors';
import type { ThemeProp } from '../../types';
import { forwardRef } from '../../utils/forwardRef';
import type { IconSource } from '../Icon';
@@ -128,12 +125,7 @@ const ToggleButton = forwardRef(
(context && context.value === value) || status === 'checked';
const backgroundColor = getToggleButtonColor({ theme, checked });
- const borderColor = theme.isV3
- ? theme.colors.outline
- : color(theme.dark ? white : black)
- .alpha(0.29)
- .rgb()
- .string();
+ const borderColor = theme.colors.outline;
return (
{
if (checked) {
- if (theme.isV3) {
- return color(theme.colors.onSecondaryContainer)
- .alpha(tokens.md.ref.opacity.level2)
- .rgb()
- .string();
- }
- if (theme.dark) {
- return 'rgba(255, 255, 255, .12)';
- }
- return 'rgba(0, 0, 0, .08)';
+ return color(theme.colors.onSecondaryContainer)
+ .alpha(tokens.md.ref.opacity.level2)
+ .rgb()
+ .string();
}
return 'transparent';
};
diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx
index f5a483db5a..fdfef8571f 100644
--- a/src/components/Tooltip/Tooltip.tsx
+++ b/src/components/Tooltip/Tooltip.tsx
@@ -204,9 +204,7 @@ const Tooltip = ({
style={[
styles.tooltip,
{
- backgroundColor: theme.isV3
- ? theme.colors.onSurface
- : theme.colors.tooltip,
+ backgroundColor: theme.colors.onSurface,
...getTooltipPosition(
measurement as Measurement,
children as React.ReactElement
diff --git a/src/components/TouchableRipple/utils.ts b/src/components/TouchableRipple/utils.ts
index 29c2b18e25..e3a1e9726f 100644
--- a/src/components/TouchableRipple/utils.ts
+++ b/src/components/TouchableRipple/utils.ts
@@ -5,11 +5,9 @@ import color from 'color';
import type { InternalTheme } from '../../types';
const getUnderlayColor = ({
- theme,
calculatedRippleColor,
underlayColor,
}: {
- theme: InternalTheme;
calculatedRippleColor: ColorValue;
underlayColor?: string;
}) => {
@@ -17,11 +15,7 @@ const getUnderlayColor = ({
return underlayColor;
}
- if (theme.isV3) {
- return color(calculatedRippleColor).rgb().string();
- }
-
- return color(calculatedRippleColor).fade(0.5).rgb().string();
+ return color(calculatedRippleColor).rgb().string();
};
const getRippleColor = ({
@@ -35,14 +29,7 @@ const getRippleColor = ({
return rippleColor;
}
- if (theme.isV3) {
- return color(theme.colors.onSurface).alpha(0.12).rgb().string();
- }
-
- if (theme.dark) {
- return color(theme.colors.text).alpha(0.32).rgb().string();
- }
- return color(theme.colors.text).alpha(0.2).rgb().string();
+ return color(theme.colors.onSurface).alpha(0.12).rgb().string();
};
export const getTouchableRippleColors = ({
@@ -58,7 +45,6 @@ export const getTouchableRippleColors = ({
return {
calculatedRippleColor,
calculatedUnderlayColor: getUnderlayColor({
- theme,
calculatedRippleColor,
underlayColor,
}),
diff --git a/src/components/Typography/AnimatedText.tsx b/src/components/Typography/AnimatedText.tsx
index 6504ad4b92..19872e2d93 100644
--- a/src/components/Typography/AnimatedText.tsx
+++ b/src/components/Typography/AnimatedText.tsx
@@ -50,7 +50,7 @@ const AnimatedText = forwardRef>(
const theme = useInternalTheme(themeOverrides);
const writingDirection = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';
- if (theme.isV3 && variant) {
+ if (variant) {
const font = theme.fonts[variant];
if (typeof font !== 'object') {
throw new Error(
@@ -73,10 +73,10 @@ const AnimatedText = forwardRef>(
/>
);
} else {
- const font = !theme.isV3 ? theme.fonts.regular : theme.fonts.bodyMedium;
+ const font = theme.fonts.bodyMedium;
const textStyle = {
...font,
- color: theme.isV3 ? theme.colors.onSurface : theme.colors.text,
+ color: theme.colors.onSurface,
};
return (
root.current?.setNativeProps(args),
}));
- if (theme.isV3 && variant) {
+ if (variant) {
let font = theme.fonts[variant];
let textStyle = [font, style];
@@ -155,10 +155,10 @@ const Text = (
/>
);
} else {
- const font = theme.isV3 ? theme.fonts.default : theme.fonts?.regular;
+ const font = theme.fonts.default;
const textStyle = {
...font,
- color: theme.isV3 ? theme.colors?.onSurface : theme.colors.text,
+ color: theme.colors?.onSurface,
};
return (
& {
const StyledText = ({
alpha = 1,
- family,
+ family: _family,
style,
theme: themeOverrides,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const textColor = color(
- theme.isV3 ? theme.colors.onSurface : theme.colors?.text
- )
- .alpha(alpha)
- .rgb()
- .string();
+ const textColor = color(theme.colors.onSurface).alpha(alpha).rgb().string();
const writingDirection = I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';
return (
@@ -38,7 +33,6 @@ const StyledText = ({
styles.text,
{
color: textColor,
- ...(!theme.isV3 && theme.fonts?.[family]),
writingDirection,
},
style,
diff --git a/src/components/Typography/v2/Text.tsx b/src/components/Typography/v2/Text.tsx
index 8114915189..4e10eecf54 100644
--- a/src/components/Typography/v2/Text.tsx
+++ b/src/components/Typography/v2/Text.tsx
@@ -6,7 +6,7 @@ import {
TextStyle,
} from 'react-native';
-import type { MD2Theme } from 'src/types';
+import type { ThemeProp } from 'src/types';
import { useInternalTheme } from '../../../core/theming';
import { forwardRef } from '../../../utils/forwardRef';
@@ -16,7 +16,7 @@ type Props = React.ComponentProps & {
/**
* @optional
*/
- theme?: MD2Theme;
+ theme?: ThemeProp;
};
// @component-group Typography
@@ -43,8 +43,7 @@ const Text: React.ForwardRefRenderFunction<{}, Props> = (
ref={root}
style={[
{
- ...(!theme.isV3 && theme.fonts?.regular),
- color: theme.isV3 ? theme.colors?.onSurface : theme.colors.text,
+ color: theme.colors?.onSurface,
},
styles.text,
style,
diff --git a/src/components/__tests__/Appbar/Appbar.test.tsx b/src/components/__tests__/Appbar/Appbar.test.tsx
index 6f76dab75b..60a7827b6e 100644
--- a/src/components/__tests__/Appbar/Appbar.test.tsx
+++ b/src/components/__tests__/Appbar/Appbar.test.tsx
@@ -1,12 +1,10 @@
import React from 'react';
-import { Animated, Platform } from 'react-native';
+import { Animated } from 'react-native';
import { act, render } from '@testing-library/react-native';
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';
-import PaperProvider from '../../../core/PaperProvider';
import { getTheme } from '../../../core/theming';
-import overlay from '../../../styles/overlay';
import { tokens } from '../../../styles/themes/v3/tokens';
import Appbar from '../../Appbar';
import {
@@ -17,7 +15,6 @@ import {
} from '../../Appbar/utils';
import Menu from '../../Menu/Menu';
import Searchbar from '../../Searchbar';
-import Tooltip from '../../Tooltip/Tooltip';
import Text from '../../Typography/Text';
const renderAppbarContent = utilRenderAppbarContent as (
@@ -58,7 +55,6 @@ describe('renderAppbarContent', () => {
it('should render all children types if renderOnly is not specified', () => {
const result = renderAppbarContent({
- isV3: false,
children,
isDark: false,
});
@@ -68,7 +64,6 @@ describe('renderAppbarContent', () => {
it('should render all children types except specified in renderExcept', () => {
const result = renderAppbarContent({
- isV3: false,
children: [
...children,