Tcomb-form-native: Layout question

Created on 27 Apr 2016  路  4Comments  路  Source: gcanti/tcomb-form-native

How can I display to text component one beside another?

is this possible?

Templates

Most helpful comment

Yes @sibeliusseraphini, with a custom template (credit card example):

/* @flow */

import React, { View } from 'react-native'

function creditCard (locals: Object) {
  return (
    <View>
      {locals.inputs.card_number}
      // Here you have this three fields in one line
      <View style={styles.expirationContainer}>
        <View style={[styles.expirationField, styles.margin]}>
          {locals.inputs.card_expire_year}
        </View>
        <View style={[styles.expirationField, styles.margin]}>
          {locals.inputs.card_expire_month}
        </View>
        <View style={styles.expirationField}>
          {locals.inputs.card_cvv2}
        </View>
      </View>
    </View>
  )
}

const styles = React.StyleSheet.create({
  expirationContainer: {
    flexDirection: 'row',
  },
  expirationField: {
    flex: 1,
  },
  margin: {
    paddingRight: 5,
  },
})

module.exports = creditCard

And in your options

options: {
  template: creditCard,
}

All 4 comments

Yes @sibeliusseraphini, with a custom template (credit card example):

/* @flow */

import React, { View } from 'react-native'

function creditCard (locals: Object) {
  return (
    <View>
      {locals.inputs.card_number}
      // Here you have this three fields in one line
      <View style={styles.expirationContainer}>
        <View style={[styles.expirationField, styles.margin]}>
          {locals.inputs.card_expire_year}
        </View>
        <View style={[styles.expirationField, styles.margin]}>
          {locals.inputs.card_expire_month}
        </View>
        <View style={styles.expirationField}>
          {locals.inputs.card_cvv2}
        </View>
      </View>
    </View>
  )
}

const styles = React.StyleSheet.create({
  expirationContainer: {
    flexDirection: 'row',
  },
  expirationField: {
    flex: 1,
  },
  margin: {
    paddingRight: 5,
  },
})

module.exports = creditCard

And in your options

options: {
  template: creditCard,
}

Please let me know if you need further info @sibeliusseraphini 馃憤

thanks, I will try that

May I know how I can read the values from a custom template view added to tcomb-form. I have added a slider to show a range of values,

function sliderTemplate(locals) { return ( <View> <Slider minimumValue={0} locals={locals} decimal={locals.config.decimal ? locals.config.decimal : 0} maximumValue={locals.config.maxVal} step={locals.config.step} /> </View> ); }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pocesar picture pocesar  路  4Comments

abdelghafourzguindou picture abdelghafourzguindou  路  4Comments

semirturgay picture semirturgay  路  4Comments

scarlac picture scarlac  路  4Comments

ishigamii picture ishigamii  路  3Comments