Make RN components fully theme-driven for multi-brand support
Refactor all 18 React Native components from static DTColors imports to dynamic useDTTheme() context, enabling proper visual differentiation when switching between DT and Classic brands. Key changes: - Replace static DTColors with theme context in all components - Add shape tokens (bevel/radius) to DTExtendedTheme interface - Conditionally render SVG bevels (DT) vs borderRadius (Classic) - Configure fonts per brand (Tektur for DT, system sans-serif for Classic) - Update buildThemeFromBrand to parse shape and typography tokens - Fix Metro config for monorepo singleton resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
import {StyleSheet, View, ViewStyle, StyleProp} from 'react-native';
|
||||
import {ProgressBar, Text} from 'react-native-paper';
|
||||
import {DTColors} from '../theme/colors';
|
||||
import {useDTTheme} from '../theme/DTThemeProvider';
|
||||
import {type DTVariant, getVariantColor} from '../utils/variantColors';
|
||||
import {useComponentLayout} from '../utils/useComponentLayout';
|
||||
|
||||
@@ -77,7 +77,8 @@ export function DTProgressBar({
|
||||
color,
|
||||
style,
|
||||
}: DTProgressBarProps) {
|
||||
const accentColor = getVariantColor(variant, color);
|
||||
const theme = useDTTheme();
|
||||
const accentColor = getVariantColor(theme, variant, color);
|
||||
const clampedValue = Math.max(0, Math.min(1, value));
|
||||
|
||||
if (orientation === 'vertical') {
|
||||
@@ -85,6 +86,7 @@ export function DTProgressBar({
|
||||
<VerticalProgressBar
|
||||
value={clampedValue}
|
||||
color={accentColor}
|
||||
trackColor={theme.colors.surfaceDisabled}
|
||||
width={height}
|
||||
showLabel={showLabel}
|
||||
style={style}
|
||||
@@ -100,7 +102,7 @@ export function DTProgressBar({
|
||||
style={[styles.bar, {height}]}
|
||||
theme={{
|
||||
colors: {
|
||||
surfaceVariant: DTColors.disabledBackground,
|
||||
surfaceVariant: theme.colors.surfaceDisabled,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
@@ -120,12 +122,14 @@ export function DTProgressBar({
|
||||
function VerticalProgressBar({
|
||||
value,
|
||||
color,
|
||||
trackColor,
|
||||
width,
|
||||
showLabel,
|
||||
style,
|
||||
}: {
|
||||
value: number;
|
||||
color: string;
|
||||
trackColor: string;
|
||||
width: number;
|
||||
showLabel: boolean;
|
||||
style?: StyleProp<ViewStyle>;
|
||||
@@ -135,7 +139,7 @@ function VerticalProgressBar({
|
||||
|
||||
return (
|
||||
<View style={[styles.verticalContainer, {width}, style]}>
|
||||
<View style={styles.verticalTrack} onLayout={onLayout}>
|
||||
<View style={[styles.verticalTrack, {backgroundColor: trackColor}]} onLayout={onLayout}>
|
||||
<View
|
||||
style={[
|
||||
styles.verticalFill,
|
||||
@@ -169,7 +173,6 @@ const styles = StyleSheet.create({
|
||||
verticalTrack: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
backgroundColor: DTColors.disabledBackground,
|
||||
justifyContent: 'flex-end',
|
||||
},
|
||||
verticalFill: {
|
||||
|
||||
Reference in New Issue
Block a user