|
1 | | -import { Dimensions, Platform } from 'react-native' |
| 1 | +import type { ViewStyle } from 'react-native' |
| 2 | +import { Dimensions, Platform, StyleSheet } from 'react-native' |
2 | 3 | import { Orientation, Platform as UniwindPlatform, StyleDependency, UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from '../../common/consts' |
3 | 4 | import { UniwindListener } from '../listener' |
4 | 5 | import type { ComponentState, GenerateStyleSheetsCallback, RNStyle, Style, StyleSheets, ThemeName, UniwindContextType, Var, Vars } from '../types' |
@@ -133,7 +134,7 @@ class UniwindStoreBuilder { |
133 | 134 | || style.maxWidth < this.runtime.screen.width |
134 | 135 | || (style.theme !== null && theme !== style.theme) |
135 | 136 | || (style.orientation !== null && this.runtime.orientation !== style.orientation) |
136 | | - || (style.rtl !== null && this.runtime.rtl !== style.rtl) |
| 137 | + || (style.rtl !== null && !this.validateDir(style.rtl, componentProps)) |
137 | 138 | || (style.active !== null && state?.isPressed !== style.active) |
138 | 139 | || (style.focus !== null && state?.isFocused !== style.focus) |
139 | 140 | || (style.disabled !== null && state?.isDisabled !== style.disabled) |
@@ -250,6 +251,18 @@ class UniwindStoreBuilder { |
250 | 251 | return true |
251 | 252 | } |
252 | 253 |
|
| 254 | + private validateDir(rtl: boolean, props: Record<string, any> = {}) { |
| 255 | + const inlineDir = 'style' in props ? (StyleSheet.flatten(props.style) as ViewStyle)?.direction : undefined |
| 256 | + |
| 257 | + if (inlineDir !== undefined && inlineDir !== 'inherit') { |
| 258 | + const isInlineRtl = inlineDir === 'rtl' |
| 259 | + |
| 260 | + return isInlineRtl === rtl |
| 261 | + } |
| 262 | + |
| 263 | + return rtl === this.runtime.rtl |
| 264 | + } |
| 265 | + |
253 | 266 | private getCurrentPlatform() { |
254 | 267 | const platform = Platform.OS |
255 | 268 |
|
|
0 commit comments