@@ -9,16 +9,15 @@ import {
99 Button ,
1010 Dialog ,
1111 Drawer ,
12- MD2Colors ,
1312 MD3Colors ,
1413 Switch ,
1514 Text ,
1615 TouchableRipple ,
1716 Portal ,
17+ useTheme ,
1818} from 'react-native-paper' ;
1919
2020import { deviceColorsSupported , isWeb } from '../utils' ;
21- import { useExampleTheme } from './hooks/useExampleTheme' ;
2221import { PreferencesContext } from './PreferencesContext' ;
2322
2423const DrawerItemsData = [
@@ -96,7 +95,7 @@ function DrawerItems() {
9695
9796 const _setDrawerItem = ( index : number ) => setDrawerItemIndex ( index ) ;
9897
99- const { isV3 , colors } = useExampleTheme ( ) ;
98+ const { colors } = useTheme ( ) ;
10099 const isIOS = Platform . OS === 'ios' ;
101100 const expoGoExecution =
102101 Constants . executionEnvironment === ExecutionEnvironment . StoreClient ;
@@ -107,7 +106,6 @@ function DrawerItems() {
107106 toggleShouldUseDeviceColors,
108107 toggleTheme,
109108 toggleRtl : toggleRTL ,
110- toggleThemeVersion,
111109 toggleCollapsed,
112110 toggleCustomFont,
113111 toggleRippleEffect,
@@ -137,14 +135,10 @@ function DrawerItems() {
137135 } ;
138136
139137 const coloredLabelTheme = {
140- colors : isV3
141- ? {
142- secondaryContainer : MD3Colors . tertiary80 ,
143- onSecondaryContainer : MD3Colors . tertiary20 ,
144- }
145- : {
146- primary : MD2Colors . tealA200 ,
147- } ,
138+ colors : {
139+ secondaryContainer : MD3Colors . tertiary80 ,
140+ onSecondaryContainer : MD3Colors . tertiary20 ,
141+ } ,
148142 } ;
149143
150144 return (
@@ -157,7 +151,7 @@ function DrawerItems() {
157151 } ,
158152 ] }
159153 >
160- { isV3 && collapsed && (
154+ { collapsed && (
161155 < Drawer . Section style = { styles . collapsedSection } >
162156 { DrawerCollapsedItemsData . map ( ( props , index ) => (
163157 < Drawer . CollapsedItem
@@ -187,9 +181,9 @@ function DrawerItems() {
187181 </ Drawer . Section >
188182
189183 < Drawer . Section title = "Preferences" >
190- { deviceColorsSupported && isV3 ? (
184+ { deviceColorsSupported ? (
191185 < TouchableRipple onPress = { toggleShouldUseDeviceColors } >
192- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
186+ < View style = { styles . preference } >
193187 < Text variant = "labelLarge" > Use device colors *</ Text >
194188 < View pointerEvents = "none" >
195189 < Switch value = { shouldUseDeviceColors } />
@@ -198,7 +192,7 @@ function DrawerItems() {
198192 </ TouchableRipple >
199193 ) : null }
200194 < TouchableRipple onPress = { toggleTheme } >
201- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
195+ < View style = { styles . preference } >
202196 < Text variant = "labelLarge" > Dark Theme</ Text >
203197 < View pointerEvents = "none" >
204198 < Switch value = { isDarkTheme } />
@@ -208,7 +202,7 @@ function DrawerItems() {
208202
209203 { ! isWeb && (
210204 < TouchableRipple onPress = { _handleToggleRTL } >
211- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
205+ < View style = { styles . preference } >
212206 < Text variant = "labelLarge" > RTL</ Text >
213207 < View pointerEvents = "none" >
214208 < Switch value = { isRTL } />
@@ -217,39 +211,26 @@ function DrawerItems() {
217211 </ TouchableRipple >
218212 ) }
219213
220- < TouchableRipple onPress = { toggleThemeVersion } >
221- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
222- < Text variant = "labelLarge" > MD 2 </ Text >
214+ < TouchableRipple onPress = { toggleCollapsed } >
215+ < View style = { styles . preference } >
216+ < Text variant = "labelLarge" > Collapsed drawer * </ Text >
223217 < View pointerEvents = "none" >
224- < Switch value = { ! isV3 } />
218+ < Switch value = { collapsed } />
225219 </ View >
226220 </ View >
227221 </ TouchableRipple >
228222
229- { isV3 && (
230- < TouchableRipple onPress = { toggleCollapsed } >
231- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
232- < Text variant = "labelLarge" > Collapsed drawer *</ Text >
233- < View pointerEvents = "none" >
234- < Switch value = { collapsed } />
235- </ View >
236- </ View >
237- </ TouchableRipple >
238- ) }
239-
240- { isV3 && (
241- < TouchableRipple onPress = { toggleCustomFont } >
242- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
243- < Text variant = "labelLarge" > Custom font *</ Text >
244- < View pointerEvents = "none" >
245- < Switch value = { customFontLoaded } />
246- </ View >
223+ < TouchableRipple onPress = { toggleCustomFont } >
224+ < View style = { styles . preference } >
225+ < Text variant = "labelLarge" > Custom font *</ Text >
226+ < View pointerEvents = "none" >
227+ < Switch value = { customFontLoaded } />
247228 </ View >
248- </ TouchableRipple >
249- ) }
229+ </ View >
230+ </ TouchableRipple >
250231
251232 < TouchableRipple onPress = { toggleRippleEffect } >
252- < View style = { [ styles . preference , isV3 && styles . v3Preference ] } >
233+ < View style = { styles . preference } >
253234 < Text variant = "labelLarge" >
254235 { isIOS ? 'Highlight' : 'Ripple' } effect *
255236 </ Text >
@@ -259,7 +240,7 @@ function DrawerItems() {
259240 </ View >
260241 </ TouchableRipple >
261242 </ Drawer . Section >
262- { isV3 && ! collapsed && (
243+ { ! collapsed && (
263244 < Text variant = "bodySmall" style = { styles . annotation } >
264245 * - available only for MD3
265246 </ Text >
@@ -301,9 +282,6 @@ const styles = StyleSheet.create({
301282 justifyContent : 'space-between' ,
302283 alignItems : 'center' ,
303284 paddingVertical : 12 ,
304- paddingHorizontal : 16 ,
305- } ,
306- v3Preference : {
307285 height : 56 ,
308286 paddingHorizontal : 28 ,
309287 } ,
0 commit comments