Skip to content

Instantly share code, notes, and snippets.

@TDKTechSols
TDKTechSols / DishdetailComponent.js
Created March 21, 2022 04:45
DishdetailComponent.js (Modal & Post Comment) #ReactNative_Assignment2
...
class ModalContent extends Component {
...
handleSubmit() {
/*alert(this.props.dishId + ':' + this.state.rating + ':' + this.state.author + ':' + this.state.comment);*/
this.props.postComment(this.props.dishId, this.state.rating, this.state.author, this.state.comment);
this.props.onPressCancel();
}
}
@TDKTechSols
TDKTechSols / comments.js
Created March 21, 2022 04:44
comments.js #ReactNative_Assignment2
...
export const comments = (state = { errMess: null, comments: [] }, action) => {
switch (action.type) {
...
case ActionTypes.ADD_COMMENT:
var newcmt = action.payload;
newcmt.id = state.comments.length;
return { ...state, comments: state.comments.concat(newcmt) };
...
}
@TDKTechSols
TDKTechSols / ActionCreators.js
Created March 21, 2022 04:43
ActionCreators.js (Comment) #ReactNative_Assignment2
// comments
export const postComment = (dishId, rating, author, comment) => (dispatch) => {
var newcmt = { dishId: dishId, rating: rating, author: author, comment: comment, date: new Date().toISOString() };
setTimeout(() => {
dispatch(addComment(newcmt));
}, 1000);
};
const addComment = (newcmt) => ({
type: ActionTypes.ADD_COMMENT,
payload: newcmt
@TDKTechSols
TDKTechSols / ActionTypes.js
Created March 21, 2022 04:43
ActionTypes.js (Comment) #ReactNative_Assignment2
...
// comments
export const ADD_COMMENT = 'ADD_COMMENT';
...
@TDKTechSols
TDKTechSols / ReservationComponent.js
Created March 21, 2022 04:36
ReservationComponent.js (Calendar) #ReactNative_Assignment4
//$ expo install expo-calendar
...
import * as Calendar from 'expo-calendar';
class Reservation extends Component {
...
handleReservation() {
Alert.alert(
...
{ text: 'Cancel', onPress: () => this.resetForm() },
@TDKTechSols
TDKTechSols / RegisterComponent.js
Created March 21, 2022 04:35
RegisterComponent.js (Image Picker Gallery) #ReactNative_Assignment4
...
class Register extends Component {
...
render() {
return (
<ScrollView>
<View style={{ justifyContent: 'center', margin: 20 }}>
<View style={{ flex: 1, flexDirection: 'row', margin: 20 }}>
...
<View style={{ justifyContent: 'center' }}>
@TDKTechSols
TDKTechSols / DishdetailComponent.js
Last active March 21, 2022 04:41
DishdetailComponent.js (Rating) #ReactNative_Assignment2
...
import { ..., Rating } from 'react-native-elements';
...
class RenderDish extends Component {
render() {
...
return (
<Card>
...
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
@TDKTechSols
TDKTechSols / DishdetailComponent.js
Last active March 21, 2022 04:42
DishdetailComponent.js (Comment) #ReactNative_Assignment2
...
import { ..., Modal, Button } from 'react-native';
import { ..., Input } from 'react-native-elements';
...
class ModalContent extends Component {
constructor(props) {
super(props);
this.state = {
rating: 3,
author: '',
@TDKTechSols
TDKTechSols / DishdetailComponent.js
Last active March 21, 2022 04:30
DishdetailComponent.js #ReactNative_Assignment3
...
class RenderDish extends Component {
render() {
// gesture
const recognizeDrag = ({ moveX, moveY, dx, dy }) => {
if (dx < -200) return 1; // right to left
else if (dx > 200) return 2; // left to right
return 0;
};
const panResponder = PanResponder.create({
@TDKTechSols
TDKTechSols / ReservationComponent.js
Last active March 21, 2022 04:30
ReservationComponent.js (Alert) #ReactNative_Assignment3
...
import { ..., Alert } from 'react-native';
// class ModalContent extends Component {
// ...
// }
class Reservation extends Component {
constructor(props) {
super(props);