React-native-swiper: How to do static footer?

Created on 19 Dec 2016  路  4Comments  路  Source: leecade/react-native-swiper

<View style={{ flex: 1 }}>
    <View><Text>static header</Text></View>
    <Swiper ... />
    <View><Text>static footer</Text></View>
</View>

but the Swiper ends up filling the rest of the screen and hiding the static footer. I saw the height prop, but do not want to set fixed height.

Most helpful comment

For anyone coming to this in the future; I was able to get a static footer by wrapping a flex wrapper around the view:

<View style={{ flex: 1 }}>
   <View style={{ flex: 1 }}>
     <Swiper>
         ...
      </Swiper>
   </View>
   <YourFooter />
</View>

All 4 comments

@booboothefool did you find a way to do it ? Care to explain how ?

@gphilipp I just set a % on the height, and it was good enough for my needs.

const SWIPER_HEIGHT = Dimensions.get('window').height * 0.85;
const styles = EStyleSheet.create({
  container: {
    backgroundColor: '$backgroundColor',
    flex: 1,
  },
  footer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    flexDirection: 'row',
  },
});
    return (
      <View style={styles.container}>
        <Swiper
          index={index}
          showsButtons={false}
          showsPagination
          height={SWIPER_HEIGHT}
          renderPagination={(index, total) => <View style={styles.pagination}><Text style={styles.paginationText}>{index + 1} / {total}</Text></View>}
        >
          {games.map((g, index) =>
            <View key={g.id} style={styles.container}>...</View>
          }
        </Swiper>

        <View style={styles.footer}>
          <IconE
            component={TouchableOpacity}
            onPress={() => Actions.pop()}
            reverse
            raised
            type="font-awesome"
            name="close"
            iconStyle={styles.icon}
            color="white"
          />
        </View>

      </View>
    );

IMO it should be fluid layout style instead of directly setting height

For anyone coming to this in the future; I was able to get a static footer by wrapping a flex wrapper around the view:

<View style={{ flex: 1 }}>
   <View style={{ flex: 1 }}>
     <Swiper>
         ...
      </Swiper>
   </View>
   <YourFooter />
</View>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

nomoreboredom picture nomoreboredom  路  3Comments

nicolabortignon picture nicolabortignon  路  3Comments

kylehagler picture kylehagler  路  3Comments

AndrewSouthpaw picture AndrewSouthpaw  路  3Comments

AndriiBoiko picture AndriiBoiko  路  3Comments