Created
November 30, 2016 10:56
-
-
Save vojtatranta/333b7348eb50f9af16830e03d816713f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// před tim | |
<TouchableOpacity onPress={() => this.handleToggleDay('Mo')} style={[styles.weekIcontouch, this.selected('Mo')]}> | |
<Text style={[styles.weekIcon, this.selectedText('Mo')]}>{I18n.t('_general.week.mondayShort')}</Text> | |
</TouchableOpacity> | |
<TouchableOpacity onPress={() => this.handleToggleDay('Tu')}> | |
<Text>{I18n.t('_general.week.tuesdayShort')}</Text> | |
</TouchableOpacity> | |
... a dalsi dny v tydnu | |
//komponenta | |
class TouchableDay extends React.Component { | |
_handlePress = () => { | |
this.props.onDayPress(this.props.dayCode) | |
} | |
return() { | |
return ( | |
<TouchableOpacity onPresst={this._handlePress} style={this.props.style}> | |
{this.props.children} | |
</TouchableOpacity> | |
) | |
} | |
} | |
// použití | |
class Days extends React.Component { | |
_handleDayPress = (dayCode) => { | |
console.log(dayCode) | |
} | |
render() { | |
const days = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] | |
return ( | |
days.map(day => { | |
return <TouchableDay dayCode={day} onDayPress={this._handleDayPress}><Text>{I18n.t('_general.week.%s', day)}</Text></TouchableDay> | |
}) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment