From 45add199140334ac082c52e179fa3eb3dafc2196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrycja=20Kali=C5=84ska?= Date: Tue, 28 May 2024 11:27:13 +0200 Subject: [PATCH] Add (partial) dark theme --- docs/static/examples/BottomSheet.js | 27 ++++++++++++++---------- docs/static/examples/SectionList.js | 32 +++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/docs/static/examples/BottomSheet.js b/docs/static/examples/BottomSheet.js index eecc21c7dd26..6c5f760dd19d 100644 --- a/docs/static/examples/BottomSheet.js +++ b/docs/static/examples/BottomSheet.js @@ -1,4 +1,5 @@ import React from 'react'; +import { useColorScheme } from '@mui/material'; import { Pressable, SafeAreaView, @@ -16,6 +17,7 @@ import Animated, { } from 'react-native-reanimated'; function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) { + const { colorScheme } = useColorScheme(); const height = useSharedValue(0); const progress = useDerivedValue(() => withTiming(isOpen.value ? 0 : 1, { duration }) @@ -23,6 +25,7 @@ function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) { const sheetStyle = useAnimatedStyle(() => ({ transform: [{ translateY: progress.value * 2 * height.value }], + backgroundColor: colorScheme === 'light' ? '#f8f9ff' : '#272B3C', })); const backdropStyle = useAnimatedStyle(() => ({ @@ -50,7 +53,6 @@ function BottomSheet({ isOpen, toggleSheet, duration = 500, children }) { const sheetStyles = StyleSheet.create({ sheet: { - backgroundColor: '#f8f9ff', padding: 16, paddingRight: '2rem', paddingLeft: '2rem', @@ -71,12 +73,18 @@ const sheetStyles = StyleSheet.create({ }); export default function App() { + const { colorScheme } = useColorScheme(); const isOpen = useSharedValue(false); const toggleSheet = () => { isOpen.value = !isOpen.value; }; + const contentStyle = useAnimatedStyle(() => ({ + color: colorScheme === 'light' ? '#001a72' : '#f8f9ff', + textDecorationColor: colorScheme === 'light' ? '#001a72' : '#f8f9ff', + })); + return ( @@ -87,14 +95,16 @@ export default function App() { - + Discover the indispensable convenience of a bottom sheet in mobile app. Seamlessly integrated, it provides quick access to supplementary features and refined details. - + - - Read more + + + Read more + @@ -136,15 +146,10 @@ const styles = StyleSheet.create({ flexDirection: 'row', alignItems: 'center', gap: 8, - borderBottomWidth: 1, - borderBottomColor: '#001a72', paddingBottom: 2, }, bottomSheetButtonText: { fontWeight: 600, - color: '#001a72', - }, - bottomSheetContent: { - color: '#001a72', + textDecorationLine: 'underline', }, }); diff --git a/docs/static/examples/SectionList.js b/docs/static/examples/SectionList.js index fdf48352f76c..522910d576b8 100644 --- a/docs/static/examples/SectionList.js +++ b/docs/static/examples/SectionList.js @@ -1,5 +1,6 @@ import { FlashList } from '@shopify/flash-list'; import React, { useRef, useState } from 'react'; +import { useColorScheme } from '@mui/material'; import { Pressable, StyleSheet, Text, View, SafeAreaView } from 'react-native'; import Animated, { useAnimatedStyle, @@ -105,16 +106,30 @@ const TableOfContentsElement = ({ visibleIndex, sectionCardsRef, }) => { + const { colorScheme } = useColorScheme(); const style = useSelectedStyle(visibleIndex, index); + const tableOfContentsElementTextStyle = useAnimatedStyle(() => ({ + color: colorScheme === 'light' ? '#001a72' : '#f8f9ff', + })); + + const tableOfContentsElementStyle = useAnimatedStyle(() => ({ + borderBottomColor: colorScheme === 'light' ? '#001a72' : '#f8f9ff', + })); + return ( { sectionCardsRef.current?.scrollToIndex({ index, animated: true }); visibleIndex.value = index; }} - style={sectionListStyles.tableOfContentsElement}> - + style={[sectionListStyles.tableOfContentsElement]}> + {item} @@ -184,10 +199,9 @@ const sectionListStyles = StyleSheet.create({ }, tableOfContentsElement: { padding: 4, - color: '#001a72', marginHorizontal: 4, - borderBottomColor: '#001a72', margin: 8, + borderBottomColor: '#001a72', overflow: 'hidden', }, tableOfContents: { @@ -201,6 +215,7 @@ const SectionCards = ({ sectionCardsRef, tableOfContentsRef, }) => { + const { colorScheme } = useColorScheme(); const heights = sections.map((_) => SECTION_HEIGHT); const getOffsetStarts = () => @@ -226,10 +241,16 @@ const SectionCards = ({ } }; + const sectionNameStyle = useAnimatedStyle(() => ({ + color: colorScheme === 'light' ? '#001a72' : '#f8f9ff', + })); + const renderItem = ({ item }) => { return ( - {item.name} + + {item.name} + {item.content} @@ -287,7 +308,6 @@ const sectionCardStyles = StyleSheet.create({ borderRadius: 24, }, header: { - color: '#001a72', textAlign: 'center', fontSize: 24, fontWeight: 'bold',