Skip to content

Instantly share code, notes, and snippets.

@gHashTag
Forked from ujinkp/Calendar.js
Last active September 26, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gHashTag/92a2d1cabadbf8986a484ec5df267777 to your computer and use it in GitHub Desktop.
Save gHashTag/92a2d1cabadbf8986a484ec5df267777 to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import {
Text,
StyleSheet,
ScrollView,
View
} from 'react-native';
import {Calendar, LocaleConfig} from 'react-native-calendars';
LocaleConfig.locales['ua'] = {
monthNames: ['Січень','Лютий','Березень','Квітень','Травень','Червень','Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'],
monthNamesShort: ['Січ.','Лют.','Бер.','Квіт.','Трав.','Черв.','Лип.','Серп.','Вер.','Жовт.','Лист.','Груд.'],
dayNames: ['Неділя','Понеділок','Вівторок','Середа','Четвер','Пятниця','Субота'],
dayNamesShort: ['Нд.','Пн.','Вт.','Ср.','Чт.','Пт.','Сб.']
};
LocaleConfig.defaultLocale = 'ua';
export default class CalendarsScreen extends Component {
constructor(props) {
super(props);
this.state = {};
this.onDayPress = this.onDayPress.bind(this);
}
render() {
return (
<View>
<Text style={styles.text}>Сьогодні:</Text>
<Calendar
firstDay={1}
//showWeekNumbers
style={styles.calendarStyle}
onDayLongPress={this.onDayLongPress}
hideExtraDays
current={new Date()}
minDate={'2018-03-01'}
markingType={'custom'}
markedDates={{
'2018-03-01': {
customStyles: {
container: {
backgroundColor: 'white',
elevation: 2
},
text: {
color: 'blue',
},
}
},
'2018-03-08': {selected: true},
'2018-03-09': {
customStyles: {
container: {
backgroundColor: 'red',
elevation: 4,
},
text: {
color: 'white',
},
}
},
'2018-03-10': {disabled: true},
'2018-03-14': {
customStyles: {
container: {
backgroundColor: 'green',
},
text: {
color: 'white',
},
},
},
'2018-03-15': {
customStyles: {
container: {
backgroundColor: 'black',
elevation: 2
},
text: {
color: 'yellow',
},
}
},
'2018-03-20': {
customStyles: {
container: {
backgroundColor: 'pink',
elevation: 4,
},
text: {
color: 'blue',
},
}
},
'2018-03-21': {disabled: true},
'2018-03-28': {
customStyles: {
container: {
backgroundColor: 'green',
},
text: {
color: 'black',
fontWeight: 'bold'
},
},
},
'2018-03-29': {
customStyles: {
container: {
backgroundColor: 'white',
elevation: 2
},
text: {
color: 'blue',
},
}
},
'2018-03-30': {
customStyles: {
container: {
backgroundColor: 'violet',
elevation: 4,
borderColor: 'red',
borderWidth: 5,
},
text: {
marginTop: 3,
fontSize: 11,
color: 'yellow',
},
}
},
'2018-03-31': {
customStyles: {
container: {
backgroundColor: 'green',
borderRadius: 0,
},
text: {
color: 'white',
},
},
}}}
hideArrows={false}
/>
</View>
);
}
onDayPress(day) {
this.setState({
selected: day.dateString
})
}
}
const styles = StyleSheet.create ({
calendarStyle: {
borderTopWidth: 1,
paddingTop: 5,
borderBottomWidth: 1,
borderColor: '#eee',
height: 350
},
text: {
textAlign: 'left',
borderColor: '#bbb',
padding: 10,
backgroundColor: '#05a5d4',
color: '#fff',
fontWeight: 'bold'
},
container: {
flex: 1,
backgroundColor: 'gray'
},
indexText: {
backgroundColor: '#05a5d4',
color: '#fff'
},
indexValue: {
backgroundColor: '#FFFF00',
color: '#05a5d4',
fontWeight: 'bold'
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment