-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
526423a
commit 0b0b25f
Showing
5 changed files
with
118 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { Animated } from 'react-native'; | ||
import color from 'color'; | ||
import { black, white } from '../../styles/themes/v2/colors'; | ||
import type { Theme } from '../../types'; | ||
import overlay from '../../styles/overlay'; | ||
|
||
export type cardMode = 'elevated' | 'outlined' | 'filled'; | ||
|
||
export const getCardColors = ({ | ||
theme, | ||
mode, | ||
dark, | ||
isAdaptiveMode, | ||
elevation, | ||
}: { | ||
theme: Theme; | ||
mode: cardMode; | ||
dark?: boolean; | ||
isAdaptiveMode?: boolean; | ||
elevation: 0 | 1 | 2 | 3 | 4 | 5 | Animated.Value; | ||
}) => { | ||
let backgroundColor; | ||
let borderColor; | ||
|
||
const isMode = (modeToCompare: cardMode) => { | ||
return mode === modeToCompare; | ||
}; | ||
|
||
const darkModeBackgroundColor = | ||
dark && isAdaptiveMode | ||
? overlay(elevation, theme.colors.surface) | ||
: theme.colors.surface; | ||
|
||
if (theme.isV3) { | ||
if (isMode('filled')) { | ||
backgroundColor = theme.colors.surfaceVariant; | ||
} else if (isMode('outlined')) { | ||
borderColor = theme.colors.outline; | ||
backgroundColor = darkModeBackgroundColor; | ||
} else { | ||
backgroundColor = darkModeBackgroundColor; | ||
} | ||
} else { | ||
backgroundColor = darkModeBackgroundColor; | ||
borderColor = color(dark ? white : black) | ||
.alpha(0.12) | ||
.rgb() | ||
.string(); | ||
} | ||
|
||
return { | ||
backgroundColor, | ||
borderColor, | ||
}; | ||
}; |