File tree Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,7 @@ export default function Root() {
2020 return (
2121 < View style = { styles . stackWrapper } >
2222 < Stack . Navigator
23- screenOptions = { ( { navigation } ) => ( {
24- detachPreviousScreen : ! navigation . isFocused ( ) ,
23+ screenOptions = { ( ) => ( {
2524 cardStyleInterpolator,
2625 header : ( { navigation, route, options, back } ) => (
2726 < Appbar . Header elevated >
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
2828 CombinedDefaultTheme ,
2929 CombinedDarkTheme ,
3030 createConfiguredFontTheme ,
31+ createConfiguredFontNavigationTheme ,
3132} from '../utils/themes' ;
3233
3334const PERSISTENCE_KEY = 'NAVIGATION_STATE' ;
@@ -192,6 +193,8 @@ export default function PaperExample() {
192193
193194 const combinedTheme = isDarkMode ? CombinedDarkTheme : CombinedDefaultTheme ;
194195 const configuredFontTheme = createConfiguredFontTheme ( combinedTheme ) ;
196+ const configuredFontNavigationTheme =
197+ createConfiguredFontNavigationTheme ( combinedTheme ) ;
195198
196199 return (
197200 < PaperProvider
@@ -200,8 +203,9 @@ export default function PaperExample() {
200203 >
201204 < PreferencesContext . Provider value = { preferences } >
202205 < NavigationContainer
203- // @ts -ignore - will be adjusted after merging https://github.com/callstack/react-native-paper/pull/4690
204- theme = { combinedTheme }
206+ theme = {
207+ customFontLoaded ? configuredFontNavigationTheme : combinedTheme
208+ }
205209 initialState = { initialState }
206210 onStateChange = { ( state ) =>
207211 AsyncStorage . setItem ( PERSISTENCE_KEY , JSON . stringify ( state ) )
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import App from './RootNavigator';
2222import {
2323 CombinedDarkTheme ,
2424 CombinedDefaultTheme ,
25+ createConfiguredFontNavigationTheme ,
2526 createConfiguredFontTheme ,
2627} from '../utils/themes' ;
2728
@@ -149,6 +150,8 @@ export default function PaperExample() {
149150
150151 const combinedTheme = isDarkMode ? CombinedDarkTheme : CombinedDefaultTheme ;
151152 const configuredFontTheme = createConfiguredFontTheme ( combinedTheme ) ;
153+ const configuredFontNavigationTheme =
154+ createConfiguredFontNavigationTheme ( combinedTheme ) ;
152155
153156 return (
154157 < PaperProvider
@@ -157,8 +160,9 @@ export default function PaperExample() {
157160 >
158161 < PreferencesContext . Provider value = { preferences } >
159162 < NavigationContainer
160- // @ts -ignore - will be adjusted after merging https://github.com/callstack/react-native-paper/pull/4690
161- theme = { combinedTheme }
163+ theme = {
164+ customFontLoaded ? configuredFontNavigationTheme : combinedTheme
165+ }
162166 initialState = { initialState }
163167 onStateChange = { ( state ) =>
164168 AsyncStorage . setItem ( PERSISTENCE_KEY , JSON . stringify ( state ) )
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ export const CombinedDefaultTheme = {
2121 ...MD3LightTheme . colors ,
2222 ...LightTheme . colors ,
2323 } ,
24+ fonts : {
25+ ...MD3LightTheme . fonts ,
26+ ...LightTheme . fonts ,
27+ } ,
2428} ;
2529
2630export const CombinedDarkTheme = {
@@ -30,6 +34,10 @@ export const CombinedDarkTheme = {
3034 ...MD3DarkTheme . colors ,
3135 ...DarkTheme . colors ,
3236 } ,
37+ fonts : {
38+ ...MD3DarkTheme . fonts ,
39+ ...DarkTheme . fonts ,
40+ } ,
3341} ;
3442
3543type CombinedTheme = typeof CombinedDefaultTheme ;
@@ -42,3 +50,26 @@ export const createConfiguredFontTheme = (theme: CombinedTheme) => ({
4250 } ,
4351 } ) ,
4452} ) ;
53+
54+ export const createConfiguredFontNavigationTheme = ( theme : CombinedTheme ) => ( {
55+ ...theme ,
56+ fonts : {
57+ ...theme . fonts ,
58+ regular : {
59+ ...theme . fonts . regular ,
60+ fontFamily : 'Abel' ,
61+ } ,
62+ medium : {
63+ ...theme . fonts . medium ,
64+ fontFamily : 'Abel' ,
65+ } ,
66+ heavy : {
67+ ...theme . fonts . heavy ,
68+ fontFamily : 'Abel' ,
69+ } ,
70+ bold : {
71+ ...theme . fonts . bold ,
72+ fontFamily : 'Abel' ,
73+ } ,
74+ } ,
75+ } ) ;
You can’t perform that action at this time.
0 commit comments