MCPcopy Create free account
hub / github.com/callstack/react-native-paper / getAdaptedTheme

Function getAdaptedTheme

src/core/theming.tsx:116–162  ·  view source on GitHub ↗
(
  theme: T,
  materialTheme: MD3Theme
)

Source from the content-addressed store, hash-verified

114}
115
116const getAdaptedTheme = <T extends NavigationTheme>(
117 theme: T,
118 materialTheme: MD3Theme
119): T => {
120 const base = {
121 ...theme,
122 colors: {
123 ...theme.colors,
124 primary: materialTheme.colors.primary,
125 background: materialTheme.colors.background,
126 card: materialTheme.colors.elevation.level2,
127 text: materialTheme.colors.onSurface,
128 border: materialTheme.colors.outline,
129 notification: materialTheme.colors.error,
130 },
131 };
132
133 if ('fonts' in theme) {
134 return {
135 ...base,
136 fonts: {
137 regular: {
138 fontFamily: materialTheme.fonts.bodyMedium.fontFamily,
139 fontWeight: materialTheme.fonts.bodyMedium.fontWeight,
140 letterSpacing: materialTheme.fonts.bodyMedium.letterSpacing,
141 },
142 medium: {
143 fontFamily: materialTheme.fonts.titleMedium.fontFamily,
144 fontWeight: materialTheme.fonts.titleMedium.fontWeight,
145 letterSpacing: materialTheme.fonts.titleMedium.letterSpacing,
146 },
147 bold: {
148 fontFamily: materialTheme.fonts.headlineSmall.fontFamily,
149 fontWeight: materialTheme.fonts.headlineSmall.fontWeight,
150 letterSpacing: materialTheme.fonts.headlineSmall.letterSpacing,
151 },
152 heavy: {
153 fontFamily: materialTheme.fonts.headlineLarge.fontFamily,
154 fontWeight: materialTheme.fonts.headlineLarge.fontWeight,
155 letterSpacing: materialTheme.fonts.headlineLarge.letterSpacing,
156 },
157 },
158 };
159 }
160
161 return base;
162};
163
164export const getDynamicThemeElevations = (scheme: MD3AndroidColors) => {
165 const elevationValues = ['transparent', 0.05, 0.08, 0.11, 0.12, 0.14];

Callers 1

adaptNavigationThemeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…