Skip to content

Commit

Permalink
fea: support dark mode: update tokens and background
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirDhahri committed Jan 21, 2025
1 parent 157b9ca commit 5396fdd
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/elements/Screen/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Body: React.FC<BodyProps> = ({
? {}
: { style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : "height" })}
>
<Flex flex={1} {...flexProps}>
<Flex flex={1} backgroundColor="background" {...flexProps}>
<Flex flex={1} px={fullwidth ? undefined : SCREEN_HORIZONTAL_PADDING}>
{scroll ? <ScrollView>{children}</ScrollView> : children}
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Screen/BottomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const BottomView: React.FC<BottomViewProps> = ({ children, darkMode }) =>
}}
pointerEvents="none"
/>
<Flex px={SCREEN_HORIZONTAL_PADDING} pt={1} pb={4} backgroundColor="white100">
<Flex px={SCREEN_HORIZONTAL_PADDING} pt={1} pb={4} backgroundColor="background">
{children}
</Flex>
</>
Expand Down
1 change: 1 addition & 0 deletions src/elements/Screen/FloatingHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const FloatingHeader: React.FC<FloatingHeaderProps> = ({
py={1}
flexDirection="row"
alignItems="center"
backgroundColor="background"
{...flexProps}
>
<BackButtonWithBackground onPress={onBack} />
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Screen/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const Header: React.FC<HeaderProps> = ({
flexDirection="row"
px={2}
zIndex={ZINDEX.header}
backgroundColor="white100"
backgroundColor="background"
alignItems="center"
>
<Flex flex={1}>
Expand Down
8 changes: 1 addition & 7 deletions src/elements/Screen/ScreenBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ export const ScreenBase: React.FC<ScreenBaseProps> = ({

return (
<ScreenScrollContextProvider>
<Flex
flex={1}
backgroundColor="white100"
mt={safeArea ? (insets.top as FlexProps["mt"]) : 0}
{...flexProps}
>
<Flex flex={1} mt={safeArea ? (insets.top as FlexProps["mt"]) : 0} {...flexProps}>
{children}

<SafeAreaCover safeArea />
Expand All @@ -40,7 +35,6 @@ const SafeAreaCover: React.FC<{ safeArea: boolean }> = ({ safeArea }) => {
right={0}
top={safeArea ? -insets.top : 0}
height={insets.top}
backgroundColor="white100"
/>
)
}
2 changes: 1 addition & 1 deletion src/elements/Screen/StickySubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const StickySubHeader: React.FC<StickySubHeaderProps> = ({
<Flex
onLayout={(event) => handleLayout(event)}
position="absolute"
backgroundColor="white100"
backgroundColor="background"
zIndex={-1000}
style={sharedStyles}
>
Expand Down
3 changes: 3 additions & 0 deletions src/elements/Tabs/TabFlashList.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { FlashListProps } from "@shopify/flash-list"
import { Tabs } from "react-native-collapsible-tab-view"
import { useListenForTabContentScroll } from "./hooks/useListenForTabContentScroll"
import { useColor } from "../../utils/hooks"
import { useSpace } from "../../utils/hooks/useSpace"

export function TabFlashList<T>(props: FlashListProps<T>) {
useListenForTabContentScroll()

const space = useSpace()
const color = useColor()

const contentContainerStyle = (props.contentContainerStyle ?? {}) as object

return (
<Tabs.FlashList
contentContainerStyle={{
paddingHorizontal: space(2),
backgroundColor: color("background"),
...contentContainerStyle,
}}
{...props}
Expand Down
3 changes: 3 additions & 0 deletions src/elements/Tabs/TabFlatList.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { FlatListProps } from "react-native"
import { Tabs } from "react-native-collapsible-tab-view"
import { useListenForTabContentScroll } from "./hooks/useListenForTabContentScroll"
import { useColor } from "../../utils/hooks"
import { useSpace } from "../../utils/hooks/useSpace"

export function TabFlatList<T>(props: FlatListProps<T>) {
useListenForTabContentScroll()

const space = useSpace()
const color = useColor()

const contentContainerStyle = (props.contentContainerStyle ?? {}) as object

return (
<Tabs.FlatList
contentContainerStyle={{
marginHorizontal: space(2),
backgroundColor: color("background"),
...contentContainerStyle,
}}
{...props}
Expand Down
3 changes: 3 additions & 0 deletions src/elements/Tabs/TabMasonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MasonryFlashListProps, MasonryFlashListRef } from "@shopify/flash-list"
import { RefObject } from "react"
import { Tabs } from "react-native-collapsible-tab-view"
import { useListenForTabContentScroll } from "./hooks/useListenForTabContentScroll"
import { useColor } from "../../utils/hooks"
import { useSpace } from "../../utils/hooks/useSpace"

export function TabMasonry<T>(
Expand All @@ -12,13 +13,15 @@ export function TabMasonry<T>(
useListenForTabContentScroll()

const space = useSpace()
const color = useColor()

const contentContainerStyle = (props.contentContainerStyle ?? {}) as object

return (
<Tabs.MasonryFlashList
contentContainerStyle={{
paddingHorizontal: space(2),
backgroundColor: color("background"),
...contentContainerStyle,
}}
{...props}
Expand Down
3 changes: 3 additions & 0 deletions src/elements/Tabs/TabScrollView.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { ScrollViewProps } from "react-native"
import { Tabs } from "react-native-collapsible-tab-view"
import { useListenForTabContentScroll } from "./hooks/useListenForTabContentScroll"
import { useColor } from "../../utils/hooks"
import { useSpace } from "../../utils/hooks/useSpace"

export const TabScrollView: React.FC<ScrollViewProps> = (props) => {
useListenForTabContentScroll()

const space = useSpace()
const color = useColor()

const contentContainerStyle = (props.contentContainerStyle ?? {}) as object

Expand All @@ -18,6 +20,7 @@ export const TabScrollView: React.FC<ScrollViewProps> = (props) => {
accessibilityTraits={undefined}
contentContainerStyle={{
marginHorizontal: space(2),
backgroundColor: color("background"),
...contentContainerStyle,
}}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Tabs/TabsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const TabsContainer: React.FC<TabsContainerProps> = ({
shadowOpacity: 0,
shadowRadius: 0,
elevation: 0,
backgroundColor: color("white100"),
backgroundColor: color("background"),
}}
initialTabName={initialTabName}
containerStyle={{
Expand Down
2 changes: 1 addition & 1 deletion src/svgs/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const Icon = styled(ScaledSvg)<IconProps>`

Icon.defaultProps = {
// @ts-ignore
fill: "black",
fill: "black100",
height: DEFAULT_SIZE,
width: DEFAULT_SIZE,
}
Expand Down
8 changes: 7 additions & 1 deletion src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ const v3dark: ThemeWithDarkModeType = {
...v3,
colors: {
...THEME_DARK.colors,
black10: v3.colors.black60,
black30: v3.colors.black60,
black60: v3.colors.black30,
blue100: "#5E6EFF",
red100: "#E44738",
green100: "#16C193",
devpurple: "rgb(136, 82, 237)",
background: THEME_DARK.colors.black100,
background: "#121212",
onBackground: THEME_DARK.colors.white100,
onBackgroundHigh: THEME_DARK.colors.white100,
onBackgroundMedium: THEME_DARK.colors.black30,
Expand Down

0 comments on commit 5396fdd

Please sign in to comment.