react-native-app-intro-slider icon indicating copy to clipboard operation
react-native-app-intro-slider copied to clipboard

backgroundColor for slides not working[Android]

Open erhan355 opened this issue 4 years ago • 8 comments

This property doesn't has an effect.I fixed as below.

const slides = [ { key: 1, backgroundColor: mainTheme.onBoardingScreen1Color, image: require('../../src/assets/onBoarding1.jpg'), title: strings.onBoardingScreen1Title, text: strings.onBoardingScreen1Subtitle, }, _renderItem = ({ item }) => { return ( <View style={[styles.slide, {backgroundColor: item.backgroundColor}]}> <Text style={styles.title}>{item.title}</Text> <Image source={item.image} /> <Text style={styles.text}>{item.text}</Text> </View> ); }

erhan355 avatar May 07 '20 17:05 erhan355

Hi @erhan355 I think something went wrong when you tried posting the code?

Jacse avatar May 08 '20 14:05 Jacse

_renderItem = ({ item }) => {
    return (
      <View style={[styles.slide, {backgroundColor: item.backgroundColor}]}>
        <Text style={styles.title}>{item.title}</Text>
        <Image source={item.image} />
        <Text style={styles.text}>{item.text}</Text>
      </View>
    );
  }

ShunyaWatanabe avatar May 16 '20 20:05 ShunyaWatanabe

Hi @erhan355 I think something went wrong when you tried posting the code?

Yes some part of my answer was copied.I fixed it ,sorry for late reply

erhan355 avatar May 16 '20 21:05 erhan355

Are you sure mainTheme.onBoardingScreen1Color is defined?

Jacse avatar May 26 '20 12:05 Jacse

Are you sure mainTheme.onBoardingScreen1Color is defined?

erhan355 avatar Jun 05 '20 19:06 erhan355

Are you sure mainTheme.onBoardingScreen1Color is defined?

Yes it is defined.

erhan355 avatar Jun 05 '20 19:06 erhan355

Hi @erhan355 is this still an issue for you?

Jacse avatar Oct 01 '20 07:10 Jacse

@Jacse I can confirm this. It does not work on iOS neither. Minimal example


import React from 'react';
import { View, Text, Image } from 'react-native';
import { StyleSheet } from 'react-native';
import AppIntroSlider from 'react-native-app-intro-slider';


const styles = StyleSheet.create({
    container: {
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        width: '100%',
        height: '100%',
    },
});

const slides = [
    {
        key: 'one',
        title: 'Title 1',
        text: 'Description.\nSay something cool',
        // image: require('./assets/1.jpg'),
        backgroundColor: 'red',
    },
    {
        key: 'two',
        title: 'Title 2',
        text: 'Other cool stuff',
        // image: require('./assets/2.jpg'),
        backgroundColor: 'green',
    },
    {
        key: 'three',
        title: 'Rocket guy',
        text: 'I\'m already out of descriptions\n\nLorem ipsum bla bla bla',
        // image: require('./assets/3.jpg'),
        backgroundColor: 'pink',
    }
];

export default class App extends React.Component {
    _renderItem = ({ item }) => {
        return (
            <View
                style={styles.container}>
                <Text>{item.title}</Text>
                <Image source={item.image} />
                <Text>{item.text}</Text>
            </View>
        );
    }
    _onDone = () => {
        // User finished the introduction. Show real app through
        // navigation or simply by controlling state
    }
    render() {
        return <AppIntroSlider
            renderItem={this._renderItem}
            data={slides}
            onDone={this._onDone} />;
    }
}

However, the workaround from @ShunyaWatanabe works.

Stophface avatar Feb 12 '21 09:02 Stophface