Skip to content

Commit 74021c0

Browse files
committed
Topbar styles was updated.
1 parent 128ddcc commit 74021c0

File tree

3 files changed

+50
-41
lines changed

3 files changed

+50
-41
lines changed

example/react-native-calendar/components/Calendar.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,14 @@ export default class Calendar extends Component {
259259
);
260260
}
261261

262-
renderCustomTitleView (localizedMonth, year){
262+
renderCustomTitleView (date){
263263
if(this.props.customTitleView) {
264-
return React.cloneElement(this.props.customTitleView({year, localizedMonth}))
264+
return React.cloneElement(this.props.customTitleView({date}))
265265
}
266266
return null;
267267
}
268268

269269
renderTopBar() {
270-
let localizedMonth = this.props.monthNames[this.state.currentMonthMoment.month()];
271270
if (this.props.showControls) {
272271
if (this.props.customTopBar) {
273272
return React.createElement(this.props.customTopBar, this.props);
@@ -278,9 +277,7 @@ export default class Calendar extends Component {
278277
onPrev={this.onPrev}
279278
scrollToToday={this.scrollToToday}
280279
customStyle={this.props.customStyle}
281-
localizedMonth={localizedMonth}
282-
year={this.state.currentMonthMoment.year()}
283-
customTitleView={this.renderCustomTitleView(localizedMonth, this.state.currentMonthMoment.year())}
280+
customTitleView={this.renderCustomTitleView(this.state.currentMonthMoment.toDate())}
284281
onTitlePress={() => this.props.onTitlePress && this.props.onTitlePress(this.selectMonth)}/>
285282
);
286283
}

example/react-native-calendar/components/TopBar.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,33 @@ Arrow.propTypes = {
3030
height: React.PropTypes.number.isRequired
3131
};
3232
Arrow.defaultProps = {
33-
width: 14,
34-
height: 14
33+
width: 6,
34+
height: 11
3535
};
3636

3737
const todayBtnStyle = StyleSheet.create({
3838
container: {
39-
borderColor: "#d7d7d7",
40-
borderRadius: 7,
41-
borderWidth: 0.5,
42-
paddingVertical: 5,
43-
paddingHorizontal: 9
39+
width: 47,
40+
height: 25,
41+
alignItems: "center",
42+
justifyContent: "center",
43+
borderWidth: 1,
44+
borderRadius: 5,
45+
borderColor: "#d7d7d7"
4446
},
4547
text: {
4648
fontSize: 11,
4749
color: "#676767"
4850
}
4951
});
50-
const TodayBtn = ({text, textStyle}) => (
51-
<View style={todayBtnStyle.container}>
52-
<Text style={[todayBtnStyle.text, textStyle]}>{text}</Text>
53-
</View>
54-
);
5552

5653
const topBarStyles = StyleSheet.create({
57-
centredContent: {
58-
flex: 1,
59-
flexDirection: "row",
60-
justifyContent: "center",
61-
alignItems: "center"
62-
},
6354
title: {
6455
fontWeight: "700",
6556
letterSpacing: 0
6657
}
6758
});
59+
6860
const TopBar = ({
6961
onPrev,
7062
onNext,
@@ -75,18 +67,21 @@ const TopBar = ({
7567
year,
7668
customTitleView}) => (
7769
<View style={[styles.calendarControls, customStyle.calendarControls]}>
70+
<View style={[styles.container, customStyle.container]}>
71+
<TouchableOpacity
72+
style={[styles.controlButton, customStyle.controlButton]}
73+
onPress={onPrev}>
74+
<Arrow source={require("./assets/calendar-arrow-left.png")}/>
75+
</TouchableOpacity>
76+
<View style={styles.controlButton}>
77+
<TouchableOpacity style={todayBtnStyle.container}
78+
onPress={scrollToToday}>
79+
<Text style={todayBtnStyle.text}>Today</Text>
80+
</TouchableOpacity>
81+
</View>
82+
</View>
7883
<TouchableOpacity
79-
style={[styles.controlButton, customStyle.controlButton]}
80-
onPress={onPrev}>
81-
<Arrow source={require("./assets/calendar-arrow-left.png")}/>
82-
</TouchableOpacity>
83-
<TouchableOpacity
84-
style={[styles.controlButton, customStyle.controlButton]}
85-
onPress={scrollToToday}>
86-
<TodayBtn text="Today"/>
87-
</TouchableOpacity>
88-
<TouchableOpacity
89-
style={topBarStyles.centredContent}
84+
style={styles.containerTitle}
9085
onPress={onTitlePress}>
9186
{customTitleView ||
9287
<View style={{flexDirection: "row", alignItems: "center"}}>
@@ -99,11 +94,16 @@ const TopBar = ({
9994
height={10}/>
10095
</View>}
10196
</TouchableOpacity>
102-
<TouchableOpacity
103-
style={[styles.controlButton, customStyle.controlButton]}
104-
onPress={onNext}>
105-
<Arrow source={require("./assets/calendar-arrow-right.png")}/>
106-
</TouchableOpacity>
97+
<View style={[styles.container, customStyle.container]}>
98+
<View style={[styles.controlButton, customStyle.controlButton]}>
99+
</View>
100+
<TouchableOpacity
101+
style={[styles.controlButton, customStyle.controlButton]}
102+
onPress={onNext}>
103+
<Arrow source={require("./assets/calendar-arrow-right.png")}/>
104+
</TouchableOpacity>
105+
106+
</View>
107107
</View>
108108
);
109109
TopBar.defaultProps = {

example/react-native-calendar/components/styles.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ const styles = StyleSheet.create({
1919
},
2020
calendarControls: {
2121
flexDirection: 'row',
22-
alignItems: 'center'
22+
alignItems: 'center',
23+
},
24+
container: {
25+
flex: 2,
26+
flexDirection: "row",
27+
},
28+
containerTitle: {
29+
flex: 3,
30+
alignItems: "center",
31+
justifyContent: "center",
2332
},
2433
controlButton: {
34+
flex: 1,
35+
alignItems: "center",
36+
justifyContent: "center",
2537
},
2638
controlButtonText: {
2739
margin: 10,

0 commit comments

Comments
 (0)