37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
const fs = require("fs")
|
|
const path = require("path")
|
|
const { withDangerousMod } = require("expo/config-plugins")
|
|
|
|
// Overrides react-native-screens' 150ms crossfade for `animation: "fade"`.
|
|
// App resources win over library resources with the same name, so the stack
|
|
// fades through black in 100ms: the old page out, then the new page in.
|
|
const anims = {
|
|
"rns_fade_out.xml": `<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
|
android:fromAlpha="1.0"
|
|
android:toAlpha="0.0"
|
|
android:duration="50" />
|
|
`,
|
|
"rns_fade_in.xml": `<alpha xmlns:android="http://schemas.android.com/apk/res/android"
|
|
android:fromAlpha="0.0"
|
|
android:toAlpha="1.0"
|
|
android:startOffset="50"
|
|
android:duration="50" />
|
|
`,
|
|
}
|
|
|
|
module.exports = (config) =>
|
|
withDangerousMod(config, [
|
|
"android",
|
|
(config) => {
|
|
const dir = path.join(
|
|
config.modRequest.platformProjectRoot,
|
|
"app/src/main/res/anim"
|
|
)
|
|
fs.mkdirSync(dir, { recursive: true })
|
|
for (const [name, xml] of Object.entries(anims)) {
|
|
fs.writeFileSync(path.join(dir, name), `<?xml version="1.0" encoding="utf-8"?>\n${xml}`)
|
|
}
|
|
return config
|
|
},
|
|
])
|