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 custom date picker #127

Merged
merged 1 commit into from
Sep 16, 2019
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"react-native-gesture-handler": "~1.3.0",
"react-native-modal-datetime-picker": "^7.5.0",
"react-native-reanimated": "~1.1.0",
"react-native-screens": "1.0.0-alpha.22",
"react-native-svg": "^9.5.1",
Expand Down
31 changes: 30 additions & 1 deletion screens/goal-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from 'react-native';
import {connect} from 'react-redux';
import Icon from 'react-native-vector-icons/FontAwesome5';
import DateTimePicker from 'react-native-modal-datetime-picker';
import * as actionCreators from './actions';
import commonStyles from '../../styles/common';
import MenuCircle from '../../components/menu-circle';
Expand Down Expand Up @@ -52,7 +53,8 @@ class GoalDetails extends Component<Props> {
this.state = {
expanded2: false,
expanded3: false,
menuScale: new Animated.Value(0.01)
menuScale: new Animated.Value(0.01),
isDatePickerVisible: false
};
this.icons = {
dots: 'ellipsis-v',
Expand Down Expand Up @@ -96,6 +98,19 @@ class GoalDetails extends Component<Props> {
);
}

showCustomDatePicker = () => {
this.setState({isDatePickerVisible: true});
};

handleCustomDatePicked = R.curry((update, date) => {
this.hideCustomDatePicker();
update({remind: date})();
})

hideCustomDatePicker = () => {
this.setState({isDatePickerVisible: false});
};

render() {
const dots = this.icons.dots;
const {navigation, uid, actions} = this.props;
Expand Down Expand Up @@ -211,6 +226,12 @@ class GoalDetails extends Component<Props> {
>
<Text style={myStyles.detailButtonText}>in 1 week</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={this.showCustomDatePicker}
style={[myStyles.detailButton, {backgroundColor: '#F6F4D6'}]}
>
<Text style={myStyles.detailButtonText}>Add date</Text>
</TouchableHighlight>
<TouchableHighlight
onPress={update({snoozed: !goal.snoozed})}
style={[myStyles.detailButton, {backgroundColor: '#F2F2CC'}]}>
Expand All @@ -226,6 +247,14 @@ class GoalDetails extends Component<Props> {
{/* <Text*/}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider deleting commented code

johnneed marked this conversation as resolved.
Show resolved Hide resolved
{/* style={[myStyles.detailButtonText, {color: 'white'}]}>{goal.completed ? 'Mark Incomplete' : 'Done!'}</Text>*/}
{/*</TouchableHighlight>*/}
<DateTimePicker
date={new Date()}
isVisible={this.state.isDatePickerVisible}
minimumDate={new Date()}
mode={'date'}
onCancel={this.hideCustomDatePicker}
onConfirm={this.handleCustomDatePicked(update)}
/>
</View>
</ScrollView>
</Container>
Expand Down