-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce expo config plugin (#94)
* feat: introduce expo config plugin * docs: update getting started
- Loading branch information
1 parent
faff34b
commit 0541da0
Showing
6 changed files
with
354 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/commonjs/expo'); |
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,42 @@ | ||
import { | ||
ConfigPlugin, | ||
createRunOncePlugin, | ||
withAndroidStyles, | ||
} from '@expo/config-plugins'; | ||
|
||
const MATERIAL3_THEME = 'Theme.Material3.DayNight.NoActionBar'; | ||
const MATERIAL2_THEME = 'Theme.MaterialComponents.DayNight.NoActionBar'; | ||
|
||
type ConfigProps = { | ||
/* | ||
* Define theme that should be used. | ||
* @default 'material3' | ||
*/ | ||
theme: 'material2' | 'material3'; | ||
}; | ||
|
||
const withMaterial3Theme: ConfigPlugin<ConfigProps> = (config, options) => { | ||
const theme = options?.theme; | ||
|
||
return withAndroidStyles(config, (stylesConfig) => { | ||
stylesConfig.modResults.resources.style = | ||
stylesConfig.modResults.resources.style?.map((style) => { | ||
if (style.$.name === 'AppTheme') { | ||
if (theme === 'material2') { | ||
style.$.parent = MATERIAL2_THEME; | ||
} else { | ||
style.$.parent = MATERIAL3_THEME; | ||
} | ||
} | ||
|
||
return style; | ||
}); | ||
|
||
return stylesConfig; | ||
}); | ||
}; | ||
|
||
export default createRunOncePlugin( | ||
withMaterial3Theme, | ||
'react-native-bottom-tabs' | ||
); |
Oops, something went wrong.