Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions packages/mobile/src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
Theme,
ThemeMode,
ThemePalette,
SystemAppearance
} from '@audius/common/models'
import { useFeatureFlag } from '@audius/common/hooks'
import { Theme, ThemeMode, ThemePalette, SystemAppearance } from '@audius/common/models'
import { FeatureFlags } from '@audius/common/services'
import type { CommonState } from '@audius/common/store'
import { themeSelectors } from '@audius/common/store'
import { useSelector } from 'react-redux'
Expand Down Expand Up @@ -179,6 +176,21 @@ export type ResolvedThemeName =
export const isDarkTheme = (theme: ResolvedThemeName): boolean =>
theme === 'default-dark' || theme === 'classic-dark' || theme === 'matrix'

/**
* Keep legacy `makeStyles` resolution aligned with the Harmony theme provider.
* When the new theme model is disabled, downgrade default-* to classic-*.
*/
const applyThemeFlag = (
themeName: ResolvedThemeName,
isNewThemeModelEnabled: boolean
): ResolvedThemeName => {
if (!isNewThemeModelEnabled) {
if (themeName === 'default-light') return 'classic-light'
if (themeName === 'default-dark') return 'classic-dark'
}
return themeName
}

export const themeColorsByThemeVariant: Record<ResolvedThemeName, ThemeColors> =
{
'default-light': defaultLightThemeColors,
Expand Down Expand Up @@ -251,7 +263,12 @@ export const useResolvedThemeName = (): ResolvedThemeName => {
}

export const useThemeVariant = (): ResolvedThemeName => {
return useResolvedThemeName()
const resolvedThemeName = useResolvedThemeName()
const { isEnabled: isNewThemeModelEnabled } = useFeatureFlag(
FeatureFlags.NEW_THEME_MODEL
)

return applyThemeFlag(resolvedThemeName, isNewThemeModelEnabled)
}

export const useThemeColors = () => {
Expand Down