apptentive / apptentive-react-native

Apptentive SDK module for React Native
https://learn.apptentive.com/article-categories/react-native/
BSD 3-Clause "New" or "Revised" License
15 stars 19 forks source link

Turn this into an expo plugin #245

Open NightScript370 opened 9 months ago

NightScript370 commented 9 months ago

I currently use expo by having it generate my apk without having me deal with any Android XML data. With that being said, apptentive expects values written to the styles.xml file that by normal standards I wouldn't be able to write to. As such, I ask that a app.plugin.js file be added which would generate the necessary changes once the plugin is linked in the app's app.config.ts file.

Here's my attempt, which for some reason doesn't end up writing anything

// @ts-check

const expoCP = require('@expo/config-plugins')

/** @type {expoCP.ConfigPlugin} */
function expoModifyPlugin (baseConfig) {
    baseConfig = expoCP
        .withAndroidColors(baseConfig, config => {
            config.modResults = expoCP.AndroidConfig.Colors.assignColorValue(config.modResults, { name: "colorSurface", "value": "#000000" })
            return config
        })
    baseConfig = expoCP
        .withAndroidStyles(baseConfig, config => {
            config.modResults = expoCP.AndroidConfig.Styles.assignStylesValue(config.modResults, { name: "colorSurface", "value": "@color/colorSurface", add: true, parent: expoCP.AndroidConfig.Styles.getAppThemeLightNoActionBarGroup()})
            return config
        })

    return baseConfig;
}

module.exports = expoModifyPlugin;

Let me know if there's any way I could help with this.