Skip to content

Commit

Permalink
fix: Compute progress bar colors at call
Browse files Browse the repository at this point in the history
When need to compute colors at call because we check the darkmode flag and Appearance.colorScheme to determine colors.
  • Loading branch information
zatteo committed Jul 10, 2024
1 parent d3c41c5 commit be66e45
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const INDETERMINATE_WIDTH_FACTOR = 0.6 // 0.3 to 0.6
const BAR_WIDTH_ZERO_POSITION =
INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_WIDTH_FACTOR)

interface ProgressBarProps {
export interface ProgressBarProps {
animated?: boolean
borderRadius?: number
borderWidth?: number
Expand Down
2 changes: 1 addition & 1 deletion src/screens/cozy-app/CozyAppScreen.Animation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Animation = ({
<Animated.View
style={[styles.progressBarContainer, { opacity: animateBarOpacity }]}
>
<ProgressBar {...progressBarConfig} />
<ProgressBar {...progressBarConfig()} />
</Animated.View>
</Animated.View>
)
Expand Down
25 changes: 14 additions & 11 deletions src/screens/cozy-app/CozyAppScreen.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { routes } from '/constants/routes'
import { getDimensions } from '/libs/dimensions'
import { NetService } from '/libs/services/NetService'
import { getColors } from '/ui/colors'

const colors = getColors({ useUserColorScheme: true })
import { ProgressBarProps } from '/components/Bar'

export const handleError = ({ nativeEvent }: WebViewErrorEvent): void => {
const { code, description } = nativeEvent
Expand All @@ -25,15 +24,19 @@ export const config = {

// Width has to be null at start even if it's not a valid value (was set to undefined and it broke the progress bar)
// At the time of this fix we want to go back the previously working value but we have to investigate why it has to be null
export const progressBarConfig = {
width: null as unknown as number | undefined,
indeterminate: true,
unfilledColor: colors.defaultBackgroundColor,
color: colors.primaryColor,
borderWidth: 0,
height: 8,
borderRadius: 100,
indeterminateAnimationDuration: 1500
export const progressBarConfig = (): ProgressBarProps => {
const colors = getColors({ useUserColorScheme: true })

return {
width: null as unknown as number | undefined,
indeterminate: true,
unfilledColor: colors.defaultBackgroundColor,
color: colors.primaryColor,
borderWidth: 0,
height: 8,
borderRadius: 100,
indeterminateAnimationDuration: 1500
}
}

export const progressBarAnimConfig = {
Expand Down

0 comments on commit be66e45

Please sign in to comment.