Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add marked text styles support #231

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Calendar.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ export default StyleSheet.create({
dot: {
width: 6,
height: 6,
marginTop: 1,
marginTop: 0,
borderRadius: 5,
opacity: 0
},

// CALENDAR DOTS
dotsContainer: {
flexDirection: 'row',
justifyContent: 'center'
justifyContent: 'center',
height: 10
},
visibleDot: {
opacity: 1,
Expand Down
67 changes: 41 additions & 26 deletions src/CalendarDay.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import moment from "moment";

import { Text, View, Animated, Easing, LayoutAnimation, TouchableOpacity } from "react-native";
import { Text, View, Animated, Easing, LayoutAnimation, TouchableOpacity, Image } from "react-native";
import styles from "./Calendar.style.js";

class CalendarDay extends Component {
Expand Down Expand Up @@ -288,33 +288,34 @@ class CalendarDay extends Component {
}

renderDots(marking) {
const baseDotStyle = [styles.dot, styles.visibleDot];
const markedDatesStyle = this.props.markedDatesStyle || {};
const formattedDate = this.props.date.format('YYYY-MM-DD');
let validDots = <View style={[styles.dot]} />; // default empty view for no dots case
// const baseDotStyle = [styles.dot, styles.visibleDot];
// const markedDatesStyle = this.props.markedDatesStyle || {};
// const formattedDate = this.props.date.format('YYYY-MM-DD');
// let validDots = <View style={[styles.dot]} />; // default empty view for no dots case

// Filter dots and process only those which have color property
validDots = marking.dots
.filter(d => (d && d.color))
.map((dot, index) => {
const selectedColor = dot.selectedColor || dot.selectedDotColor; // selectedDotColor deprecated
const backgroundColor = this.state.selected && selectedColor ? selectedColor : dot.color;
return (
<View
key={dot.key || (formattedDate + index)}
style={[
baseDotStyle,
{ backgroundColor },
markedDatesStyle
]}
/>
);
});
// validDots = marking.dots
// .filter(d => (d && d.color))
// .map((dot, index) => {
// const selectedColor = dot.selectedColor || dot.selectedDotColor; // selectedDotColor deprecated
// const backgroundColor = this.state.selected && selectedColor ? selectedColor : dot.color;
// return (
// <View
// key={dot.key || (formattedDate + index)}
// style={[
// baseDotStyle,
// { backgroundColor },
// markedDatesStyle
// ]}
// />
// );
// });

return (
<View style={styles.dotsContainer}>
{validDots}
</View>
null
// <View style={styles.dotsContainer}>
// <Image style={{width: 8}} resizeMode="contain" source={require('./img/heart.png')}></Image>
// </View>
);
}

Expand Down Expand Up @@ -348,6 +349,19 @@ class CalendarDay extends Component {
);
}

//Marked Text Styles
getMarkedTextStyles() {
if (!this.props.markedDates || this.props.markedDates.length === 0) {
return null;
}
const marking = this.state.marking;
if(marking.textStyle){
return marking.textStyle;
}else{
return null;
}
}

render() {
// Defaults for disabled state
const {
Expand Down Expand Up @@ -460,7 +474,7 @@ class CalendarDay extends Component {
>
{showDayName && (
<Text
style={[{ fontSize: dateNameFontSize }, _dateNameStyle]}
style={[{ fontSize: dateNameFontSize }, _dateNameStyle, this.getMarkedTextStyles()]}
allowFontScaling={allowDayTextScaling}
>
{date.format("ddd").toUpperCase()}
Expand All @@ -471,7 +485,8 @@ class CalendarDay extends Component {
<Text
style={[
{ fontSize: dateNumberFontSize },
_dateNumberStyle
_dateNumberStyle,
this.getMarkedTextStyles()
]}
allowFontScaling={allowDayTextScaling}
>
Expand Down
Binary file added src/img/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.