about summary refs log tree commit diff
path: root/plugins/withAndroidDayNightThemePlugin.js
blob: d9bc1b2114bff6827c5b38ee80d7ce317c9968ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Based on https://github.com/expo/expo/pull/33957
// Could be removed once the app has been updated to Expo 53
const {withAndroidStyles} = require('@expo/config-plugins')

module.exports = function withAndroidDayNightThemePlugin(appConfig) {
  const cleanupList = new Set([
    'colorPrimary',
    'android:editTextBackground',
    'android:textColor',
    'android:editTextStyle',
  ])

  return withAndroidStyles(appConfig, config => {
    config.modResults.resources.style = config.modResults.resources.style
      ?.map(style => {
        if (style.$.name === 'AppTheme' && style.item != null) {
          style.item = style.item.filter(item => !cleanupList.has(item.$.name))
        }
        return style
      })
      .filter(style => {
        return style.$.name !== 'ResetEditText'
      })

    return config
  })
}