diff --git a/App.js b/App.js index 6e1f49e..5c0271c 100644 --- a/App.js +++ b/App.js @@ -1,17 +1,15 @@ import React from "react"; import Nav from "./src/app/App"; -import { I18nManager, Platform } from "react-native"; +import { I18nManager } from "react-native"; import clone from "lodash/clone"; export default class App extends React.Component { async componentWillMount() { try { //I18nManager.swapLeftAndRightInRTL(true) - // if (Platform.OS === "android") await I18nManager.forceRTL(true); if(!I18nManager.isRTL) await I18nManager.forceRTL(true); - console.log("I18nManager:", I18nManager); } catch (e) { console.warn("RTL Error", e); } diff --git a/app.json b/app.json index 48e74d6..3c13558 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "name": "מהפכה של שמחה", "description": "אפליקציה לעידוד התנדבויות בבתי חולים", "slug": "StartachHapRev", - "version": "1.0.9", + "version": "1.1.0", "icon": "./src/images/logo512x512.png", "sdkVersion": "26.0.0", "privacy": "public", @@ -12,12 +12,17 @@ "bundleIdentifier": "com.startach.HapRev" }, "android": { - "versionCode": 9, + "versionCode": 10, "package": "com.startach.HapRev", "adaptiveIcon": { "foregroundImage": "./src/images/logo512x512.png", "backgroundColor": "#FFFFFF" - } + }, + "permissions": [ + "CALENDAR", + "CAMERA_ROLL", + "NOTIFICATIONS" + ] }, "notification": { "icon":"./src/images/logo512x512.png" diff --git a/package.json b/package.json index 1a9d294..d399281 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haprev", - "version": "1.0.9", + "version": "1.1.0", "private": true, "devDependencies": { "react-native-scripts": "1.9.0", @@ -20,17 +20,17 @@ }, "dependencies": { "expo": "^26.0.0", - "firebase": "^4.11.0", + "firebase": "^4.13.1", "react": "16.3.0-alpha.1", "react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz", - "react-native-calendars": "^1.17.0", - "react-native-easy-toast": "^1.1.0", + "react-native-calendars": "^1.22.0", + "react-native-easy-toast": "^1.2.0", "react-native-modal-datetime-picker": "^5.1.0", - "react-native-swiper": "^1.5.13", + "react-native-swiper": "^1.5.14", "react-navigation": "^1.5.8", - "react-redux": "^5.0.6", + "react-redux": "^5.1.1", "redux": "^3.7.2", - "redux-thunk": "^2.2.0", - "remote-redux-devtools": "^0.5.12" + "redux-thunk": "^2.3.0", + "remote-redux-devtools": "^0.5.16" } } diff --git a/src/components/CustomPicker.js b/src/components/CustomPicker.js new file mode 100644 index 0000000..3c08e89 --- /dev/null +++ b/src/components/CustomPicker.js @@ -0,0 +1,80 @@ +import React, { Component } from 'react'; +import { View, Text, StyleSheet, TouchableHighlight, Modal, TouchableOpacity } from 'react-native'; + + +export default class CustomPicker extends Component { + constructor (props) { + super(props); + + this.state = { + pickerSelection: props.items[props.defaultIndex], + pickerDisplayed: false + } + } + + setPickerValue (newValue, newIndex) { + this.setState({ + pickerSelection: newValue + }) + + this.props.onValueChange(newValue, newIndex) + + this.togglePicker(); + } + + togglePicker () { + this.setState({ + pickerDisplayed: !this.state.pickerDisplayed + }) + } + + render () { + return ( + + this.togglePicker()} + underlayColor='#fff'> + {this.state.pickerSelection.name} + + this.setState({pickerDisplayed:false})}> + + אנא בחר בית חולים + {this.props.items.map((value, index) => + this.setPickerValue(value, index)} + style={{ paddingTop: 4, paddingBottom: 4 }}> + {value.name} + + )} + this.togglePicker()} + style={{ paddingTop: 4, paddingBottom: 4 }}> + ביטול + + + + + ); + } +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#fff', + alignItems: 'center', + justifyContent: 'center', + }, + pickerHeaderText: { + fontWeight: 'bold' + }, + modalView: { + margin: 20, padding: 20, + backgroundColor: '#efefef', + bottom: 20, + left: 20, + right: 20, + alignItems: 'center', + position: 'absolute' + } +}); + diff --git a/src/nav/SideMenu.js b/src/nav/SideMenu.js index d1020ea..2e09442 100644 --- a/src/nav/SideMenu.js +++ b/src/nav/SideMenu.js @@ -180,7 +180,7 @@ const styles = StyleSheet.create({ userImage:{ width:85, height:85, - borderRadius:50, + borderRadius:85/2, borderWidth:1, borderColor: '#ffffff', marginBottom:5, diff --git a/src/store/modules/events.js b/src/store/modules/events.js index dd521c1..c4abf10 100644 --- a/src/store/modules/events.js +++ b/src/store/modules/events.js @@ -6,179 +6,210 @@ const REQUEST_EVENTS = 'haprev/events/REQUEST_EVENTS'; const RESPONSE_EVENTS = 'haprev/events/RESPONSE_EVENTS'; const RESPONSE_NEW_ACTIVITY = 'haprev/events/RESPONSE_NEW_ACTIVITY'; const ADD_PARTICIPANT = 'haprev/events/ADD_PARTICIPANT'; -const DELETE_PARTICIPANT= 'haprev/events/DELETE_PARTICIPANT'; +const DELETE_PARTICIPANT = 'haprev/events/DELETE_PARTICIPANT'; const initalState = { status: null, - events:{}, - for:null + events: {}, + for: null }; export default (state = initalState, action = {}) => { switch (action.type) { case REQUEST_EVENTS: - return { ...state, status: 'reqEvents', for: action.payload}; + return {...state, status: 'reqEvents', for: action.payload}; case RESPONSE_EVENTS: - return { ...state, status: '', events: action.payload}; + return {...state, status: '', events: action.payload}; case RESPONSE_NEW_ACTIVITY: - return {...state, events: Object.assign(action.payload,state.events)} + return {...state, events: Object.assign(action.payload, state.events)} case ADD_PARTICIPANT: - const eventId = action.eventId - const participants=action.participants - return {...state, - events: { - ...state.events, - [eventId]: { - ...state.events[eventId] || null, - participants: participants - } - } + const eventId = action.eventId + const participants = action.participants + return { + ...state, + events: { + ...state.events, + [eventId]: { + ...state.events[eventId] || null, + participants: participants + } } + } case DELETE_PARTICIPANT: - const newParticipants=action.newParticipants - return {...state, - for:action.insId, - events: { - ...state.events, - [action.eventId]: { - ...state.events[action.eventId] || null, - participants: newParticipants - } - } + const newParticipants = action.newParticipants + return { + ...state, + for: action.insId, + events: { + ...state.events, + [action.eventId]: { + ...state.events[action.eventId] || null, + participants: newParticipants + } } + } default: return state; } }; const eventsReq = instituteId => { - return ({ - type: REQUEST_EVENTS, - payload: instituteId - }) + return ({ + type: REQUEST_EVENTS, + payload: instituteId + }) } -const eventsRes = data =>({ - type: RESPONSE_EVENTS, - payload:data +const eventsRes = data => ({ + type: RESPONSE_EVENTS, + payload: data }); -const newActivityRes = activity =>({ - type: RESPONSE_NEW_ACTIVITY, - payload: activity, +const newActivityRes = activity => ({ + type: RESPONSE_NEW_ACTIVITY, + payload: activity, }); -const addParticipantRes = (participants,eventId) =>({ - type: ADD_PARTICIPANT, - participants: participants, - eventId: eventId, +const addParticipantRes = (participants, eventId) => ({ + type: ADD_PARTICIPANT, + participants: participants, + eventId: eventId, }); -const deleteParticipantRes = (eventId,insId,newParticipants) =>({ - type: DELETE_PARTICIPANT, - eventId: eventId, - insId:insId, - newParticipants: newParticipants, +const deleteParticipantRes = (eventId, insId, newParticipants) => ({ + type: DELETE_PARTICIPANT, + eventId: eventId, + insId: insId, + newParticipants: newParticipants, }); -export const getEvents = instituteId => async (dispatch,state) =>{ - if(state().events.status != 'reqEvents'){ - dispatch(eventsReq(instituteId)) - res = firebase.database().ref('events/').child(instituteId).once('value', - snapshot =>{ - dispatch(eventsRes(snapshot.val())); - }) - .then(() => {return 'ok'}) - .catch(error => {return 'err'}); - return res; - } - return 'reqEvents' +export const getEvents = instituteId => async (dispatch, state) => { + if (state().events.status != 'reqEvents') { + dispatch(eventsReq(instituteId)) + const res = firebase.database().ref('events/').child(instituteId).once('value', + snapshot => { + dispatch(eventsRes(snapshot.val())); + }) + .then(() => { + return 'ok' + }) + .catch(error => { + return 'err' + }); + + return res; + } + return 'reqEvents' } -export const addNewActivity = (activityName,appId,coordinator,date,time,fullFormatDate) => async(dispatch) => { - let res = null - var objActivity = {} - ref = await firebase.database().ref('events/'+coordinator).push() - let newActivity = { - caption: activityName, - coordinator: appId, - institute:coordinator, - date: date, - time: time, - fullFormatDate: fullFormatDate, - id: ref.key - } - objActivity[ref.key] = newActivity; - await ref.set(newActivity) - .then(() => { - dispatch(newActivityRes(objActivity)) - res = 'ok' - }) - .catch(error => {console.log('Data could not be saved.',error); res = 'err'}); - return res +export const addNewActivity = (activityName, appId, coordinator, date, time, fullFormatDate) => async (dispatch) => { + let res = null + var objActivity = {} + ref = await firebase.database().ref('events/' + coordinator).push() + let newActivity = { + caption: activityName, + coordinator: appId, + institute: coordinator, + date: date, + time: time, + fullFormatDate: fullFormatDate, + id: ref.key + } + objActivity[ref.key] = newActivity; + await ref.set(newActivity) + .then(() => { + dispatch(newActivityRes(objActivity)) + res = 'ok' + }) + .catch(error => { + console.log('Data could not be saved.', error); + res = 'err' + }); + return res } -export const deleteActivity = (activityId) => async(dispatch,state) => { - eventsObj = state().events.events - eventsArray = Object.keys(eventsObj).map(key => {return eventsObj[key]}) - currentEvents = filter(eventsArray,(event) => {return event.id !== activityId}) - currentEventsObjects = keyBy(currentEvents, 'id'); - hospitalId = state().user.user.coordinator - newEvents = {} - newEvents[hospitalId] = currentEventsObjects +export const deleteActivity = (activityId) => async (dispatch, state) => { + eventsObj = state().events.events + eventsArray = Object.keys(eventsObj).map(key => { + return eventsObj[key] + }) + currentEvents = filter(eventsArray, (event) => { + return event.id !== activityId + }) + currentEventsObjects = keyBy(currentEvents, 'id'); + hospitalId = state().user.user.coordinator + newEvents = {} + newEvents[hospitalId] = currentEventsObjects - let res = await firebase.database().ref('events/') + let res = await firebase.database().ref('events/') .update(newEvents) .then(() => { - dispatch(eventsRes(currentEventsObjects)) - return 'ok' + dispatch(eventsRes(currentEventsObjects)) + return 'ok' }) .catch(error => { - console.log('Data could not be saved.' + error); - return 'err' + console.log('Data could not be saved.' + error); + return 'err' }); - return res; + return res; } -export const addUserToEvent = (event,appId,fullName) => async(dispatch,state) => { - let res = 'ok' - let newUser = { - appId: appId, - name: fullName, - } - ref = await firebase.database().ref('events/'+event.institute+'/'+event.id) +export const addUserToEvent = (event, appId, fullName, extraParticipants) => async (dispatch, state) => { + let res = 'ok' + let newUser = { + appId: appId, + name: fullName, + extraParticipants + } + + await firebase.database().ref('events/' + event.institute + '/' + event.id) .child('participants') .push() .set(newUser) - .then(() => { - newParticipants = state().events.events[event.id]['participants'] || [] - newParticipantsArray = Object.keys(newParticipants).map(key => {return newParticipants[key]}) - newParticipantsArray.push(newUser) - dispatch(addParticipantRes(newParticipantsArray,event.id,event.institute)) - res = 'ok' - }) - .catch(error => {console.log('Data could not be saved.',error); res = 'err'}); - return res - } + .then(() => { + const newParticipants = state().events.events[event.id]['participants'] || [] + const newParticipantsArray = Object.keys(newParticipants).map(key => newParticipants[key]) + + newParticipantsArray.push(newUser) + dispatch(addParticipantRes(newParticipantsArray, event.id, event.institute)) + + res = 'ok' + }) + .catch(error => { + console.log('Data could not be saved.', error); + + res = 'err' + }) - export const deleteParticipant = (activityId,insId,appId) => async(dispatch,state) => { - let participantsObj=null - let eventsState=false - if(state().events && state().events.for == insId){ - participantsObj = state().events.events[activityId]['participants'] - eventsState = true - } - else{ - await firebase.database().ref('events/'+insId).child(activityId).child('participants').once('value', - async snapshot =>{ participantsObj = await snapshot.val() }) - .catch(error => {console.log('error',error)}); - } - participantsArray = Object.keys(participantsObj).map(key => {return participantsObj[key]}) - currParticipants = filter(participantsArray,(participant) => {return participant.appId !== appId}) - await firebase.database().ref('events/'+insId).child(activityId) - .update({participants:currParticipants}) - .then(() => { - if(eventsState) - dispatch(deleteParticipantRes(activityId,insId,currParticipants)) - }) -} \ No newline at end of file + return res +} + +export const deleteParticipant = (activityId, insId, appId) => async (dispatch, state) => { + let participantsObj = null + let eventsState = false + if (state().events && state().events.for == insId) { + participantsObj = state().events.events[activityId]['participants'] + eventsState = true + } + else { + await firebase.database().ref('events/' + insId).child(activityId).child('participants').once('value', + async snapshot => { + participantsObj = await snapshot.val() + }) + .catch(error => { + console.log('error', error) + }); + } + participantsArray = Object.keys(participantsObj).map(key => { + return participantsObj[key] + }) + currParticipants = filter(participantsArray, (participant) => { + return participant.appId !== appId + }) + await firebase.database().ref('events/' + insId).child(activityId) + .update({participants: currParticipants}) + .then(() => { + if (eventsState) + dispatch(deleteParticipantRes(activityId, insId, currParticipants)) + }) +} diff --git a/src/store/modules/user.js b/src/store/modules/user.js index cca041c..6407c01 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -14,48 +14,51 @@ const NOTIFICATION_SETTINGS = "haprev/user/NOTIFICATION_SETTINGS" const initalState = { user: {}, status: '', - splashStatus:false, - authStatus:'' + splashStatus: false, + authStatus: '' }; export default (state = initalState, action = {}) => { switch (action.type) { case AUTHORIZE_REQ: - return { ...state, authStatus: 'auth_request', user: {} }; + return {...state, authStatus: 'auth_request', user: {}}; case AUTHORIZE_RES: - return { ...state, authStatus: 'user', user: action.payload ,status:canProceed(state) } + return {...state, authStatus: 'user', user: action.payload, status: canProceed(state)} case REGISTER_REQ: - return { ...state, authStatus: 'reg_request', user: {} }; + return {...state, authStatus: 'reg_request', user: {}}; case REGISTER_RES: - return { ...state, authStatus: 'user', user: action.payload ,status:canProceed(state) } + return {...state, authStatus: 'user', user: action.payload, status: canProceed(state)} case NO_USER_FOUND: - return {...state,authStatus:'no_user',status:canProceed(state) } + return {...state, authStatus: 'no_user', status: canProceed(state)} case SPLASH: - return {...state, splashStatus: action.payload,status:canProceed(state)} + return {...state, splashStatus: action.payload, status: canProceed(state)} case SET_MESSAGE_READ: - return {...state, - user: { - ...state.user, - ["messages"]: action.payload - } - }; + return { + ...state, + user: { + ...state.user, + ["messages"]: action.payload + } + }; case UPDATE_NEW_EVENTS: - return {...state, - user: { - ...state.user, - activities:{ - ...state.user.activities || null, - [action.insId]: action.newEvents - } - } - } + return { + ...state, + user: { + ...state.user, + activities: { + ...state.user.activities || null, + [action.insId]: action.newEvents + } + } + } case NOTIFICATION_SETTINGS: - return {...state, - user: { - ...state.user, - settings: action.payload - } - }; + return { + ...state, + user: { + ...state.user, + settings: action.payload + } + }; default: return state; } @@ -76,12 +79,12 @@ const authRes = data => { return tmpRes; }; -const noUserFound = () =>({ +const noUserFound = () => ({ type: NO_USER_FOUND }) -const canProceed = state =>{ - return (!state.user.splashStatus && state.user.authStatus!='auth_request') +const canProceed = state => { + return (!state.user.splashStatus && state.user.authStatus != 'auth_request') } const registerReq = user => ({ @@ -99,16 +102,16 @@ const registerRes = data => { return tmpRes; } -const updateNewEvents = (newEvents,insId) => ({ +const updateNewEvents = (newEvents, insId) => ({ type: UPDATE_NEW_EVENTS, newEvents: newEvents, insId: insId }) export const splash = (display) => ({ - type:SPLASH , - payload:display -}) + type: SPLASH, + payload: display +}) const setMessagesRead = msgId => { return { @@ -118,105 +121,118 @@ const setMessagesRead = msgId => { } const updateNotificationSettings = settings => ({ - type:NOTIFICATION_SETTINGS, - payload:settings + type: NOTIFICATION_SETTINGS, + payload: settings }) -export const authorize = appId => dispatch => { +export const authorize = appId => dispatch => { dispatch(authReq(appId)) - // Is there any user associated with this appId? - firebase.database().ref('users').orderByChild('appId').equalTo(appId).once('value' , - snapshot => { - let dbResList = snapshot.val() - if(dbResList){ - // Get the 1st response - let userId = Object.keys(dbResList)[0] - let dbRes = dbResList[userId] - // Keep the key! - dbRes.userId = userId - dispatch (authRes(dbRes)) - } - else - dispatch (noUserFound()) - }) + + try { + firebase // Is there any user associated with this appId? + .database() + .ref('users') + .orderByChild('appId') + .equalTo(appId) + .once('value') + .then(snapshot => { + let dbResList = snapshot.val() + + if (dbResList) { + let userId = Object.keys(dbResList)[0] // Get the 1st response + let dbRes = dbResList[userId] + + dbRes.userId = userId // Keep the key! + return dispatch(authRes(dbRes)) + } else { + dispatch(noUserFound()) + } + }) + } catch (e) { + console.error(e) + } } -export const register = user => async(dispatch) => { +export const register = user => async (dispatch) => { user.appId = Expo.Constants.deviceId let ref = firebase.database().ref('users') let register = true // Query by phone first... await ref.orderByChild('phone').equalTo(user.phone) - .once('value' , - snapshot => { - let dbResList = snapshot.val() - if (dbResList) { - register = false - } - else { // New user - dispatch(registerReq(user)) - user.userId = ref.push().key - ref.child(user.userId).set(user) - dispatch (registerRes(user)) - } - }) + .once('value', + snapshot => { + let dbResList = snapshot.val() + if (dbResList) { + register = false + } + else { // New user + dispatch(registerReq(user)) + user.userId = ref.push().key + ref.child(user.userId).set(user) + dispatch(registerRes(user)) + } + }) return register } -export const signInWithAnotherDevice = (user) =>async(dispatch) =>{ +export const signInWithAnotherDevice = (user) => async (dispatch) => { let appId = Expo.Constants.deviceId let login = true let dbResUser = null // Query by phone first... - await firebase.database().ref('users').orderByChild('phone').equalTo(user.phone).once('value' , + await firebase.database().ref('users').orderByChild('phone').equalTo(user.phone).once('value', snapshot => { let dbResList = snapshot.val() if (dbResList) { let userId = Object.keys(dbResList)[0] dbResUser = dbResList[userId] - if(dbResUser.password != user.password) + if (dbResUser.password != user.password) login = false else - dbResUser['appId']=appId + dbResUser['appId'] = appId } else // Phone not exist login = false - }) + }) - if(login){ + if (login) { let userId = dbResUser.userId - await firebase.database().ref('users/'+userId).update({appId:appId}) - .then(() => { - dispatch (authRes(dbResUser)) - }) + await firebase.database().ref('users/' + userId).update({appId: appId}) + .then(() => { + dispatch(authRes(dbResUser)) + }) } return login } -export const update = user => dispatch => { +export const update = user => dispatch => { dispatch(registerReq(user)) - let ref = firebase.database().ref('users/'+user.userId) - ref.once('value', + let ref = firebase.database().ref('users/' + user.userId) + ref.once('value', snapshot => { let dbRes = snapshot.val() if (dbRes) { - dispatch (registerRes(dbRes)) + dispatch(registerRes(dbRes)) } else { //handle user not found - dispatch (noUserFound()) + dispatch(noUserFound()) } - }) + }) ref.update(user) return true } -export const readMessage = msgId => async (dispatch,state) => { +export const readMessage = msgId => async (dispatch, state) => { messagesObj = state().user.user.messages; - messagesArray = Object.keys(messagesObj).map(key => { return messagesObj[key] }); - currentMessages = messagesArray.filter(msg => { return msg.id !== msgId }) + messagesArray = Object.keys(messagesObj).map(key => { + return messagesObj[key] + }); + currentMessages = messagesArray.filter(msg => { + return msg.id !== msgId + }) await dispatch(setMessagesRead(currentMessages)); - let res = firebase.database().ref('users/'+state().user.user.userId) + let res = firebase.database().ref('users/' + state().user.user.userId) .update({['messages']: currentMessages}) .then(() => { return 'ok' @@ -225,60 +241,74 @@ export const readMessage = msgId => async (dispatch,state) => { console.log('Data could not be saved.' + error); return 'err' }); - return res; + return res; }; -export const addEventToUser = (userId,event) => async(dispatch,state) => { +export const addEventToUser = (userId, event) => async (dispatch, state) => { let res = 'ok' const insId = event.institute - newActivity = { - caption: event.caption, - fullFormatDate: event.fullFormatDate, - id:event.id, + const newActivity = { + caption: event.caption, + fullFormatDate: event.fullFormatDate, + id: event.id, } - ref = await firebase.database().ref('users/'+userId+'/activities/'+insId) - .child(event.id) - .set(newActivity) - .then(() => { - if(state().user.user.activities) - newEventsObj = state().user.user.activities[insId] || [] - else - newEventsObj = [] - newEventsArray = Object.keys(newEventsObj).map(key => {return newEventsObj[key]}) - newEventsArray.push(newActivity) - dispatch(updateNewEvents(newEventsArray,event.institute)) - res = 'ok' - }) - .catch(error => {console.log('Data could not be saved.',error); res = 'err'}); + let newEventsObj + + await firebase.database().ref('users/' + userId + '/activities/' + insId) + .child(event.id) + .set(newActivity) + .then(() => { + if (state().user.user.activities) + newEventsObj = state().user.user.activities[insId] || [] + else + newEventsObj = [] + const newEventsArray = Object.keys(newEventsObj).map(key => newEventsObj[key]) + newEventsArray.push(newActivity) + dispatch(updateNewEvents(newEventsArray, event.institute)) + res = 'ok' + }) + .catch(error => { + console.log('Data could not be saved.', error); + res = 'err' + }); return res } -export const deleteActivity = (activityId,insId) => async(dispatch,state) => { +export const deleteActivity = (activityId, insId) => async (dispatch, state) => { //function - delete my (current user) activity - let currentUser=state().user.user + let currentUser = state().user.user activitiesObj = currentUser.activities[insId] - activitiesArray = Object.keys(activitiesObj).map(key => {return activitiesObj[key]}) - currActivities = filter(activitiesArray,(activity) => {return activity.id !== activityId}) - await firebase.database().ref('users/'+currentUser.userId).child('activities') - .update({[insId]:currActivities}) - .then(() => { - dispatch(updateNewEvents(currActivities,insId)) - }) + activitiesArray = Object.keys(activitiesObj).map(key => { + return activitiesObj[key] + }) + currActivities = filter(activitiesArray, (activity) => { + return activity.id !== activityId + }) + await firebase.database().ref('users/' + currentUser.userId).child('activities') + .update({[insId]: currActivities}) + .then(() => { + dispatch(updateNewEvents(currActivities, insId)) + }) //Check for more activities - var numActivities=0 - if(currActivities.length==0){ - stateActivities=state().user.user.activities - var ins=[] - stateActivitiesArray = Object.keys(stateActivities).map(key => {ins.push(key); return stateActivities[key]}) + var numActivities = 0 + if (currActivities.length == 0) { + stateActivities = state().user.user.activities + var ins = [] + stateActivitiesArray = Object.keys(stateActivities).map(key => { + ins.push(key); + return stateActivities[key] + }) for (var index in ins) - allActivities = Object.keys(stateActivitiesArray[index]).map(key => {numActivities++}) + allActivities = Object.keys(stateActivitiesArray[index]).map(key => { + numActivities++ + }) } - if(currActivities.length==0 && numActivities == 0) + if (currActivities.length == 0 && numActivities == 0) return 'empty' } -export const updateNotificationSettingUser = (settings) => async(dispatch,state) => { - let res = firebase.database().ref('users/'+state().user.user.userId).update({settings}) +export const updateNotificationSettingUser = (settings) => async (dispatch, state) => { + let res = firebase.database().ref('users/' + state().user.user.userId).update({settings}) .then(() => { dispatch(updateNotificationSettings(settings)); return 'ok' @@ -290,17 +320,17 @@ export const updateNotificationSettingUser = (settings) => async(dispatch,state) return res; } -export const updateUserSatet = () => async(dispatch,state) => { - let ref = firebase.database().ref('users/'+state().user.user.userId) - ref.once('value', +export const updateUserSatet = () => async (dispatch, state) => { + let ref = firebase.database().ref('users/' + state().user.user.userId) + ref.once('value', snapshot => { let dbRes = snapshot.val() if (dbRes) { - dispatch (registerRes(dbRes)) + dispatch(registerRes(dbRes)) } else { //handle user not found - dispatch (noUserFound()) + dispatch(noUserFound()) } - }) + }) return true } \ No newline at end of file diff --git a/src/views/activities/Activities.js b/src/views/activities/Activities.js index 6e748f0..b2367d0 100644 --- a/src/views/activities/Activities.js +++ b/src/views/activities/Activities.js @@ -35,18 +35,22 @@ class Activities extends React.Component{ this.setState({activityElements : activityElements, process:false}) } - deleteMyActivity = async(activity,coordinatorUserId)=>{ - const {first,last,deleteParticipant,deleteActivity,appId} = this.props - await deleteParticipant(activity.id,activity.hospitalId,appId) - res = await deleteActivity(activity.id,activity.hospitalId) + deleteMyActivity = async (activity, coordinatorUserId) => { + const { first, last, deleteParticipant, deleteActivity, appId } = this.props + + await deleteParticipant(activity.id, activity.hospitalId, appId) + const res = await deleteActivity(activity.id, activity.hospitalId) + let coordinatorToken = await getUserTokenNotification(coordinatorUserId) - if(coordinatorToken){ + + if (coordinatorToken) { let title = 'ביטול משתתף' - let msg = first +' '+last + ' ביטל את ההשתתפות בפעילות: ' + event.caption - sendPushNotification(coordinatorToken,title,msg) + let msg = first + ' ' + last + ' ביטל את ההשתתפות בפעילות: ' + activity.caption + sendPushNotification(coordinatorToken, title, msg) } - if(res == 'empty') - this.setState({activityElements : null}) + + if (res == 'empty') + this.setState({ activityElements: null }) else await this.componentWillMount() } @@ -76,4 +80,4 @@ const mapStateToProps = state =>{ }) } -export default connect(mapStateToProps,{deleteParticipant,deleteActivity})(Activities) \ No newline at end of file +export default connect(mapStateToProps,{deleteParticipant,deleteActivity})(Activities) diff --git a/src/views/activities/ActivitiesStyle.js b/src/views/activities/ActivitiesStyle.js index e185fc0..5f74501 100644 --- a/src/views/activities/ActivitiesStyle.js +++ b/src/views/activities/ActivitiesStyle.js @@ -1,4 +1,5 @@ -import { StyleSheet } from 'react-native'; +import { StyleSheet, Dimensions } from 'react-native'; +const { height } = Dimensions.get('screen'); export default StyleSheet.create({ container: { @@ -97,10 +98,10 @@ export default StyleSheet.create({ alignItems: 'center', alignSelf: "center", backgroundColor: "#B4B7BA", - marginTop: 100, - height: 300, + marginTop: height * 0.25, + height: height * 0.5, width: "90%", - borderRadius: 15 + borderRadius: 10, }, participantsContainer: { flex: 1, @@ -125,7 +126,7 @@ export default StyleSheet.create({ marginBottom: 3, width: 30, height: 30, - borderRadius: 100 + borderRadius: 30 / 2 }, withoutImgList: { margin: 5, diff --git a/src/views/activities/ActivitiesView.js b/src/views/activities/ActivitiesView.js index 68906ea..c5a3948 100644 --- a/src/views/activities/ActivitiesView.js +++ b/src/views/activities/ActivitiesView.js @@ -7,7 +7,7 @@ import {AnimatableView} from '../AnimatableService' import * as Animatable from 'react-native-animatable' const renderText = (text)=> { - if (text.length > 17 ) + if (text.length > 15 ) return text.slice(0,14)+'...' return text } @@ -49,6 +49,14 @@ class ActivityItem extends React.Component{ } } + deleteActivity = async () => { + try { + await this.props.deleteMyActivity(this.props.activity, this.state.coordinatorData.userId) + } catch (e) { + console.error(e) + } + } + renderActivityData = async(activityId,insId)=> { if(!this.state.showFullActivity){ const activityData = await this.props.renderActicityData(activityId,insId) @@ -111,7 +119,7 @@ class ActivityItem extends React.Component{ } render() { - const {activity, index, deleteMyActivity} = this.props + const {activity, index} = this.props return ( {this.activityNode.tada(1000); await this.renderActivityData(activity.id,activity.hospitalId)}}> @@ -143,7 +151,7 @@ class ActivityItem extends React.Component{ {this.state.deleteVisible ? לבטל השתתפותך בפעילות? - {await deleteMyActivity(activity,this.state.coordinatorData.userId)}}> + this.setState({deleteVisible:false})}> @@ -241,4 +249,4 @@ class ActivitiesView extends React.Component{ } } -export default ActivitiesView \ No newline at end of file +export default ActivitiesView diff --git a/src/views/adminActivities/AdminActivitiyList.js b/src/views/adminActivities/AdminActivitiyList.js index b522b86..e3bc728 100644 --- a/src/views/adminActivities/AdminActivitiyList.js +++ b/src/views/adminActivities/AdminActivitiyList.js @@ -77,7 +77,6 @@ class AdminActivitiyList extends React.Component { } render() { - const {navigation:{navigate}} =this.props; return ( { const ActivityItem = ({activity, index, openActivity, participants}) => { return {openActivity(activity,participants[index])}}> - {activity.date} + {activity.date} | - {renderCaptionText(activity.caption)} + {renderCaptionText(activity.caption)} | - {renderParticipantsText(participants[index])} + {renderParticipantsText(participants[index])} diff --git a/src/views/adminActivities/AdminActivityView.js b/src/views/adminActivities/AdminActivityView.js index d14fd60..e3f3f8b 100644 --- a/src/views/adminActivities/AdminActivityView.js +++ b/src/views/adminActivities/AdminActivityView.js @@ -111,7 +111,7 @@ class AdminActivityView extends Component{ onRequestClose={() => this.setState({displaySendMessagesDialog:true})} > { !this.props.process ? - + שלח הודעה למתנדבים {'\n'} + {this.state.success ? 'פעילות נוספה בהצלחה' +'\n' + this.state.activityName + '\nבתאריך ' + this.state.fullDate + '\nבשעה ' +this.state.fullTime + '\nבבית חולים ' + hospital : 'שגיאה! נסה שנית מאוחר יותר' } @@ -88,61 +88,61 @@ class CreateActivityView extends Component { const { hospital, first, last } = this.props; return ( - - - שם הרכז - {first +' '+ last} - מקום פעילות - {hospital} - שם הפעילות - { this.setState({activityName:text,isButtonDisabled: !(text.length > 0)}) } } - value={this.state.activityName} - maxLength={60} - /> - - בחר תאריך וזמן פעילות - - - { - this.state.fullTime ? - 'תאריך: ' + this.state.fullDate + ' שעה: ' + this.state.fullTime - : this.alertDate - } - - - לשלוח התראות על האירוע לכל המשתמשים? - this.setState({notificationToAll:!this.state.notificationToAll})} - value={this.state.notificationToAll} + + + שם הרכז + {first +' '+ last} + מקום פעילות + {hospital} + שם הפעילות + { this.setState({activityName:text,isButtonDisabled: !(text.length > 0)}) } } + value={this.state.activityName} + maxLength={60} /> - - + + בחר תאריך וזמן פעילות + + { - !this.state.loading ? - אישור - : + this.state.fullTime ? + 'תאריך: ' + this.state.fullDate + ' שעה: ' + this.state.fullTime + : this.alertDate + } + - שולח התראות - + לשלוח התראות על האירוע לכל המשתמשים? + this.setState({notificationToAll:!this.state.notificationToAll})} + value={this.state.notificationToAll} + /> - } - - + + { + !this.state.loading ? + אישור + : + + שולח התראות + + + } + + { this.state.success ? this.backToList() : this.setState({modalVisible:false})}} > אישור diff --git a/src/views/adminActivities/EventView.js b/src/views/adminActivities/EventView.js index ac574b2..8358c83 100644 --- a/src/views/adminActivities/EventView.js +++ b/src/views/adminActivities/EventView.js @@ -9,6 +9,7 @@ import {getUserData, setMessage, makeArrayFromObjects, deleteActivityByUserId} f import {getUserTokenNotification, sendPushNotification} from '../notification/NotificationService'; import Toast from 'react-native-easy-toast' import {showToast} from '../../utils/taost'; +import * as firebase from "firebase"; export const ParticipantItem = ({avatarUrl, phone, _name, isCoordinator, participant}) => { return ( @@ -53,40 +54,48 @@ class EventView extends Component { }; } + async getEventById () { + const {params} = this.props.navigation.state + const eventId = params.event.id + const instituteId = params.event.institute + let event + + await firebase + .database() + .ref('events/') + .child(instituteId) + .child(eventId) + .once('value', snapshot => { + event = snapshot.val() + }) + + return event + } + async componentWillMount() { + let event = await this.getEventById() + this.state.userIdArray = null const {params} = this.props.navigation.state - if (params.adminActivityScreen) - currParticipants = params.event.participants - else - currParticipants = params.updateParticipants(params.event.id) + const currParticipants = event.participants || {} + // const currParticipants = params.adminActivityScreen ? params.event.participants : params.updateParticipants(params.event.id) const participants = await makeArrayFromObjects(currParticipants) - if (!this.state.userIdArray) { - registeredNow = await this.checkAlreadyRegistered(participants, params.appId) - avatarsArray = [] - phonesArray = [] - userIdArray = [] - namesArray = [] - coordinatorData = await getUserData(params.event.coordinator) - for (var i in participants) { - userInfo = await getUserData(participants[i].appId) + + const registeredNow = await this.checkAlreadyRegistered(participants, params.appId) + const avatarsArray = [] + const phonesArray = [] + const userIdArray = [] + const namesArray = [] + const coordinatorData = await getUserData(params.event.coordinator) + + for (const key in participants) { + const userInfo = await getUserData(participants[key].appId) + avatarsArray.push(userInfo.avatarUrl) phonesArray.push(userInfo.phone) userIdArray.push(userInfo.userId) namesArray.push(userInfo.name) - } - } - else { - avatarsArray = this.state.avatarsArray - phonesArray = this.state.phonesArray - userIdArray = this.state.userIdArray - coordinatorData = this.state.coordinatorData - userInfo = await getUserData(params.appId) - avatarsArray.push(userInfo.avatarUrl) - phonesArray.push(userInfo.phone) - userIdArray.push(userInfo.userId) - namesArray.push(userInfo.name) - registeredNow = true } + this.setState({ avatarsArray: avatarsArray, phonesArray: phonesArray, @@ -162,7 +171,7 @@ class EventView extends Component { res = await addEventToUser(userId, event) //push notification to the coordinator if (res === 'ok') { - let coordinatorToken = await getUserTokenNotification(coordinatorData.userId) + let coordinatorToken = await getUserTokenNotification(this.state.coordinatorData.userId) if (coordinatorToken) { let title = 'רישום חדש להתנדבות' let msg = fullName + ' נרשם לפעילות: ' + event.caption @@ -288,10 +297,10 @@ class EventView extends Component { : null } - + ) } } -export default EventView \ No newline at end of file +export default EventView diff --git a/src/views/adminActivities/styles.js b/src/views/adminActivities/styles.js index 915079e..3b01541 100644 --- a/src/views/adminActivities/styles.js +++ b/src/views/adminActivities/styles.js @@ -1,4 +1,5 @@ -import { StyleSheet } from "react-native"; +import { StyleSheet, Dimensions } from "react-native"; +const { height } = Dimensions.get('screen'); const adminActivityStyle = StyleSheet.create({ container: { @@ -26,7 +27,7 @@ const adminActivityStyle = StyleSheet.create({ marginBottom: 3, width: 35, height: 35, - borderRadius: 100 + borderRadius: 35 / 2 }, withoutImgList: { margin: 5, @@ -138,21 +139,21 @@ const modalActivityStyle = StyleSheet.create({ justifyContent: 'center', alignItems: 'center', alignSelf: "center", - marginTop: "20%", - backgroundColor: "#B4B7BA", - height: 300, + marginTop: height * 0.15, + backgroundColor: '#c2185b', + height: height * 0.4, width: "90%", - borderRadius: 15, + borderRadius: 10, }, modalContainer: { - marginTop: "30%", + marginTop: height * 0.2, justifyContent: "center", alignSelf: "center", - backgroundColor: "#B4B7BA", - height: "80%", + backgroundColor: '#c2185b', + height: height * 0.4, width: "90%", borderWidth: 2, - borderRadius: 15 + borderRadius: 10 }, title: { fontSize: 22, @@ -207,7 +208,7 @@ const adminActivityListStyle = StyleSheet.create({ }, userImage: { marginBottom: 10, - borderRadius: 100, + borderRadius: 65 / 2, width: 65, height: 65 }, @@ -247,7 +248,22 @@ const adminActivityListStyle = StyleSheet.create({ justifyContent: "space-around", alignItems: "center", backgroundColor: "#ddd" - } + }, + dateText:{ + width: '25%', + paddingRight: 2, + textAlign: 'left', + }, + captionText:{ + width: '35%', + paddingRight: 2, + textAlign: 'left', + }, + participantsText:{ + width: '25%', + paddingRight: 2, + textAlign: 'left', + }, }); const CreateActivityStyle = StyleSheet.create({ @@ -256,7 +272,10 @@ const CreateActivityStyle = StyleSheet.create({ justifyContent: "center", alignContent: "center", borderWidth: 2, - borderColor: "#D81A4C" + borderColor: "#D81A4C", + }, + scrollContainer:{ + paddingVertical: 20 }, name: { height: 100 @@ -303,14 +322,13 @@ const CreateActivityStyle = StyleSheet.create({ paddingBottom: 20 }, modalContainer: { - marginTop: "40%", - justifyContent: "center", + marginTop: height * 0.25, alignSelf: "center", - backgroundColor: "#B4B7BA", - height: "35%", + backgroundColor: '#c2185b', + height: "45%", width: "90%", borderWidth: 2, - borderRadius: 15 + borderRadius: 10, } }); diff --git a/src/views/eventsList/EventsList.js b/src/views/eventsList/EventsList.js index d092f94..74900a2 100644 --- a/src/views/eventsList/EventsList.js +++ b/src/views/eventsList/EventsList.js @@ -1,11 +1,18 @@ import React from 'react' import { connect } from 'react-redux' -import { View, Text, Slider, Picker, Dimensions } from 'react-native' +import { View, Text, Slider, Picker } from 'react-native' import EventsListView from './EventsListView' import map from 'lodash/map' import {getEventsList} from './EventsListService' import {sortArrayByDate_Descending} from '../adminActivities/AdminActivitiesService.js' import styles from './EventsListStyle' +import CustomPicker from '../../components/CustomPicker' + +const customStyles = { + historyInstitutesPicker: { + backgroundColor: 'transparent' + } +} class EventsList extends React.Component{ constructor(props) { @@ -52,20 +59,16 @@ class EventsList extends React.Component{ } getPicker = () => { - let serviceItems = this.props.institutes.map((ins, i) => { - return - }); - return ( - {await this.setState({currentHospital: itemValue}); await this.componentWillMount(true)}}> - - {serviceItems} - - ); + return ( + { + await this.setState({currentHospital: itemValue.name}); + await this.componentWillMount(true)} + } /> + ); } @@ -111,4 +114,4 @@ const mapStateToProps = state =>{ }) } -export default connect(mapStateToProps)(EventsList) \ No newline at end of file +export default connect(mapStateToProps)(EventsList) diff --git a/src/views/eventsList/EventsListStyle.js b/src/views/eventsList/EventsListStyle.js index c07588a..90a9d09 100644 --- a/src/views/eventsList/EventsListStyle.js +++ b/src/views/eventsList/EventsListStyle.js @@ -8,8 +8,8 @@ export default StyleSheet.create({ borderWidth: 2, borderColor: "#D81A4C" }, - name: { - height: 100 + listContainer:{ + flex: 1, }, button: { width: "70%", @@ -55,9 +55,12 @@ export default StyleSheet.create({ activityBox: { borderBottomColor: '#bbb', borderBottomWidth: StyleSheet.hairlineWidth, + flexDirection: "row", justifyContent: "space-around", + alignItems: 'center', height:50, - flexDirection: "row" + padding: 4, + width: '98%' }, activityBoxClean: { flex: 1, @@ -73,7 +76,28 @@ export default StyleSheet.create({ color: '#C2185B', textAlign: 'center', fontSize: 14, - margin:3, + }, + dateFlex:{ + flex: 0.25 + }, + timeFlex:{ + flex: 0.5 + }, + captionFlex:{ + flex: 1 + }, + hospitalFlex:{ + flex: 0.75 + }, + noActivitiesText: { + margin: 5, + fontSize: 14, + color: "gray" + }, + lineText:{ + color: '#C2185B', + fontSize: 14, + margin: 1 }, boxDetails:{ backgroundColor:'#C2185B', @@ -102,10 +126,10 @@ export default StyleSheet.create({ marginBottom: "30%", justifyContent: 'center', alignSelf:'center', - backgroundColor: '#B4B7BA', + backgroundColor: '#c2185b', width: '70%', borderWidth:2, - borderRadius:15, + borderRadius:10, }, participantItem: { marginHorizontal: "17.5%", @@ -121,7 +145,7 @@ export default StyleSheet.create({ marginBottom: 3, width: 30, height: 30, - borderRadius: 100 + borderRadius: 30/2 }, withoutImgList: { margin: 5, @@ -146,15 +170,15 @@ export default StyleSheet.create({ backgroundColor: '#cd1848', }, filterText: { - fontSize: 14, + fontSize: 16, textAlign: 'center', padding: 3, color: '#ffffff', - fontWeight: 'bold', + fontWeight: 'bold' }, pickerText: { color: '#ffffff', - height: 40, - width: 200, - }, -}); \ No newline at end of file + height: 40, + width: 200 + } +}); diff --git a/src/views/eventsList/EventsListView.js b/src/views/eventsList/EventsListView.js index 674c96e..bb40d79 100644 --- a/src/views/eventsList/EventsListView.js +++ b/src/views/eventsList/EventsListView.js @@ -19,57 +19,58 @@ class ActivityItem extends React.Component{ renderText = (text,len)=> { if (text.length > len ) - return text.slice(0, len-3)+'...' + return text.slice(0, len - 3) + '...' return text } renderDate = (fullDate,isNextEvents) =>{ var fulldate = new Date(fullDate) - var dateString = fulldate.getDate() + "/" + (fulldate.getMonth() + 1) + var dateString = fulldate.getDate() + "/" + (fulldate.getMonth() + 1) dateString += isNextEvents ? '' : "/" + fulldate.getFullYear() return dateString } render() { - const {activity, index, isNextEvents} = this.props - return ( - - { this.renderDate(activity.fullFormatDate,isNextEvents)} - [ {activity.time} ] - {this.renderText(activity.caption,isNextEvents ? 17 : 19)} - | - {activity.hospitalName} - - ) -} + const {activity, index, isNextEvents} = this.props + return ( + + { this.renderDate(activity.fullFormatDate,isNextEvents)} + [ {activity.time} ] + + { activity && activity.caption && activity.caption.length > 17 ? + activity.caption.substring(0, 17 - 3) + '...' : activity.caption } + + | + {activity.hospitalName} + + ) + } } class EventsListView extends React.Component{ render() { const {processEventsList, activityElements, isNextEvents} = this.props return( - + { !processEventsList ? activityElements.length>0 ? - } keyExtractor={(item) => item.id}/> - : - אין מידע על פעילויות + אין מידע על פעילויות : } - + ) } } -export default EventsListView \ No newline at end of file +export default EventsListView diff --git a/src/views/help/HelpViewStyle.js b/src/views/help/HelpViewStyle.js index ec7ad6c..ac0a6ff 100644 --- a/src/views/help/HelpViewStyle.js +++ b/src/views/help/HelpViewStyle.js @@ -1,4 +1,5 @@ -import { StyleSheet } from 'react-native'; +import { StyleSheet, Dimensions } from 'react-native'; +const { height } = Dimensions.get('screen'); export default StyleSheet.create({ container: { @@ -56,13 +57,12 @@ export default StyleSheet.create({ textAlign:'center', }, modalContainer: { - marginTop: "40%", + marginTop: height * 0.25, justifyContent: 'center', alignSelf:'center', - backgroundColor: '#B4B7BA', + backgroundColor: '#c2185b', height:'40%', width: '90%', - borderWidth:2, - borderRadius:15, + borderRadius:10, }, }); \ No newline at end of file diff --git a/src/views/home/Home.js b/src/views/home/Home.js index d98a502..8f5fde2 100644 --- a/src/views/home/Home.js +++ b/src/views/home/Home.js @@ -20,7 +20,6 @@ class Home extends React.Component{ exit:0, processNextEvents:true, EventsListElements:null, - notFirstTime:this.props.navScreen }; this.onBackClicked = this._onBackClicked.bind(this); } @@ -64,7 +63,6 @@ class Home extends React.Component{ componentDidMount() { if(this.props.navScreen==''){ this.props.updateNavScreen('Home') - this.setState({notFirstTime:true}) } } @@ -120,7 +118,6 @@ class Home extends React.Component{ images={this.state.images} processEventsList={this.state.processNextEvents} activityElements={this.state.EventsListElements} - notFirstTime={this.state.notFirstTime} /> ) diff --git a/src/views/home/HomeStyle.js b/src/views/home/HomeStyle.js index 04cf67f..ead8542 100644 --- a/src/views/home/HomeStyle.js +++ b/src/views/home/HomeStyle.js @@ -1,8 +1,12 @@ -import { StyleSheet,Dimensions } from "react-native"; +import { StyleSheet, Dimensions } from "react-native"; +const { height } = Dimensions.get("screen"); -export default styles = StyleSheet.create({ +export default (styles = StyleSheet.create({ container: { - flex: 1 + flex: 1, + justifyContent: "space-around", + paddingBottom: 20, + backgroundColor: "#FFF" }, picture: { flex: 1, @@ -31,8 +35,8 @@ export default styles = StyleSheet.create({ }, allActivityButton: { alignSelf: "center", - marginRight: 10, - marginLeft: 10 + marginHorizontal: 10, + marginVertical: 5, }, opacityBtn: { backgroundColor: "#FFFFFF", @@ -43,7 +47,7 @@ export default styles = StyleSheet.create({ borderColor: "#9f144b" }, swiper: { - height: Dimensions.get("screen").height / 3 + height: height / 3 }, buttonText: { fontSize: 50, @@ -53,14 +57,19 @@ export default styles = StyleSheet.create({ flex: 1, alignItems: "center", borderWidth: 2, - marginTop: 15, + marginVertical: height * .01, marginHorizontal: "5%", borderRadius: 10, - justifyContent: "flex-start", width: "90%", backgroundColor: "#f2f2f2", borderColor: "#C2185B" }, + firstBox: { + marginTop: height * 0.02 + }, + imageContainer: { + flex: 1 + }, imageTitle: { color: "#C2185B", fontSize: 15, @@ -71,6 +80,6 @@ export default styles = StyleSheet.create({ width: "100%", opacity: 0.75, top: "90%", - paddingBottom: 1, + paddingBottom: 1 } -}); +})); diff --git a/src/views/home/HomeView.js b/src/views/home/HomeView.js index 22f5639..7f0c8ec 100644 --- a/src/views/home/HomeView.js +++ b/src/views/home/HomeView.js @@ -3,7 +3,7 @@ import { View, Text, Image, ScrollView, ActivityIndicator, TouchableOpacity } fr import styles from './HomeStyle'; import Swiper from 'react-native-swiper' import EventsListView from '../eventsList/EventsListView' -import {AnimatableView,AnimatableText} from '../AnimatableService' +import {AnimatableText} from '../AnimatableService' import { WebBrowser } from 'expo'; const HomeView = (props) => { @@ -13,7 +13,6 @@ const HomeView = (props) => { images, processEventsList, activityElements, - notFirstTime } = props const allActivityButton = ( @@ -30,7 +29,7 @@ const HomeView = (props) => { images.map((img,i)=> {await WebBrowser.openBrowserAsync(img.imgUrl)}} > @@ -42,46 +41,31 @@ const HomeView = (props) => { return ( - - - - - } - /> - + + + + + {myNextEvent ? (myNextEvent.caption + ' ב-' +myNextEvent.date) : 'לא קיימות התנדבויות'} {allActivityButton} - - } - /> - - - + + + + { showsButtons nextButton={} prevButton={} - > - {swiperImages(images)} - - + > + {swiperImages(images)} + - } - /> + ) diff --git a/src/views/institutes/EventRegistrationView.js b/src/views/institutes/EventRegistrationView.js index 56b462e..8cdc8e5 100644 --- a/src/views/institutes/EventRegistrationView.js +++ b/src/views/institutes/EventRegistrationView.js @@ -29,10 +29,18 @@ class EventRegistrationView extends Component { this.setState({displayCancelEventDialog: false}); registration = async () => { - const res = await this.props.registerUserEventHandler(this.state.extraParticipants) - if (res !== 'ok') - alert("שגיאה בהרשמה, אנא נסה שנית מאוחר יותר") - this.hideCancelEventDialog() + debugger + try { + const res = await this.props.registerUserEventHandler(this.state.extraParticipants) + + if (res !== 'ok') { + alert("שגיאה בהרשמה, אנא נסה שנית מאוחר יותר") + } + + this.hideCancelEventDialog() + } catch (e) { + console.error(e) + } } onChanged = (text) => { @@ -44,7 +52,7 @@ class EventRegistrationView extends Component { newText = newText + text[i] } else { - alert("please enter numbers only") // your call back function + alert("Please enter numbers only") // your call back function } } this.setState({extraParticipants: newText}) @@ -57,7 +65,7 @@ class EventRegistrationView extends Component { render() { return ( - + {this.props.registeredNow ? @@ -126,7 +134,8 @@ class EventRegistrationView extends Component { underlineColorAndroid='transparent' onChangeText={(text) => this.onChanged(text)} value={(this.state.extraParticipants && this.state.extraParticipants.toString()) || null} - maxLength={2} + maxLength={1} + keyboardType='numeric' /> @@ -165,4 +174,4 @@ class EventRegistrationView extends Component { } } -export default EventRegistrationView \ No newline at end of file +export default EventRegistrationView diff --git a/src/views/institutes/SelectDate.js b/src/views/institutes/SelectDate.js index cadbf94..2804443 100644 --- a/src/views/institutes/SelectDate.js +++ b/src/views/institutes/SelectDate.js @@ -55,7 +55,7 @@ class SelectDate extends Component { return ( @@ -64,7 +64,7 @@ class SelectDate extends Component { } -mapStateToProps = state =>{ +const mapStateToProps = state =>{ return { events:state.events.events, userId:state.user.user.userId, @@ -73,4 +73,4 @@ mapStateToProps = state =>{ } } -export default connect (mapStateToProps, {addEventToUser, addUserToEvent})(SelectDate); \ No newline at end of file +export default connect (mapStateToProps, {addEventToUser, addUserToEvent})(SelectDate); diff --git a/src/views/notification/Settings.js b/src/views/notification/Settings.js index 9005009..a01ad9b 100644 --- a/src/views/notification/Settings.js +++ b/src/views/notification/Settings.js @@ -45,7 +45,7 @@ class Settings extends React.Component{ return( - + קבלת התראות - + ) @@ -114,7 +114,7 @@ const styles = StyleSheet.create({ fontWeight: "bold", textAlign: "center" }, - modalContainer: { + settingsContainer: { marginVertical: 15, padding: 2, justifyContent: 'center', diff --git a/src/views/register/RegisterView.js b/src/views/register/RegisterView.js index cf45992..c397878 100644 --- a/src/views/register/RegisterView.js +++ b/src/views/register/RegisterView.js @@ -1,8 +1,8 @@ import React from 'react'; -import {Text, View, Image, ImageBackground,ScrollView, TouchableOpacity, KeyboardAvoidingView, ActivityIndicator} from 'react-native'; +import {Text, View, Image, ImageBackground,ScrollView, TouchableOpacity, KeyboardAvoidingView, ActivityIndicator, Platform} from 'react-native'; import styles from './RegisterViewStyles'; import RegisterInput from './RegisterInputField'; -import { ImagePicker } from 'expo'; +import { ImagePicker, Permissions } from 'expo'; import {registerForPushNotificationsAsync} from '../notification/NotificationService' import Toast from 'react-native-easy-toast'; import {showToast} from '../../utils/taost'; @@ -97,19 +97,28 @@ class RegisterView extends React.Component { } pickImage = async () => { - let pickerResult = await ImagePicker.launchImageLibraryAsync({ - allowsEditing: true, - aspect: [4, 3], - quality: 0.8, - base64: true, - mediaTypes: ImagePicker.MediaTypeOptions.Images - }); - - if (!pickerResult.cancelled) { - disabled = !this.state.firstValidate || !this.state.lastValidate || !this.state.phoneValidate || !this.state.passwordValidate - this.setState({ avatarUrl: pickerResult.uri, disabled: disabled}); - let base64Img = `data:image/jpg;base64,${pickerResult.base64}` - this.base64Img = base64Img; + let cameraPermission = true; + if (Platform.OS === "ios"){ + const {status} = await Permissions.askAsync(Permissions.CAMERA_ROLL); + cameraPermission = status === 'granted'; + } + if(cameraPermission){ + const pickerResult = await ImagePicker.launchImageLibraryAsync({ + allowsEditing: true, + aspect: [4, 3], + quality: 0.8, + base64: true, + mediaTypes: ImagePicker.MediaTypeOptions.Images + }); + + if (!pickerResult.cancelled) { + const disabled = !this.state.firstValidate || !this.state.lastValidate || !this.state.phoneValidate || !this.state.passwordValidate + this.setState({ avatarUrl: pickerResult.uri, disabled: disabled}); + let base64Img = `data:image/jpg;base64,${pickerResult.base64}` + this.base64Img = base64Img; + } + } else { + alert('אתה חייב לאשר גישה ללוח השנה של המכשיר בכדי לעדכן אותו'); } }; @@ -218,7 +227,7 @@ class RegisterView extends React.Component { - + );} }; diff --git a/src/views/register/RegisterViewStyles.js b/src/views/register/RegisterViewStyles.js index 187aaf5..256e2a8 100644 --- a/src/views/register/RegisterViewStyles.js +++ b/src/views/register/RegisterViewStyles.js @@ -33,7 +33,7 @@ export default StyleSheet.create({ marginTop: 15, width: 135, height: 135, - borderRadius: 100, + borderRadius: 135 / 2, borderWidth: 1, borderColor: '#fff' }, diff --git a/src/views/splash/InternetConnectionPopUp.js b/src/views/splash/InternetConnectionPopUp.js index fa9825c..503a209 100644 --- a/src/views/splash/InternetConnectionPopUp.js +++ b/src/views/splash/InternetConnectionPopUp.js @@ -64,7 +64,7 @@ const styles = StyleSheet.create({ backgroundColor: '#B4B7BA', width: '70%', borderWidth:2, - borderRadius:15, + borderRadius:10, zIndex:9999, borderColor:'red' }, diff --git a/src/views/splash/Splash.js b/src/views/splash/Splash.js index 92e3a3e..ff08381 100644 --- a/src/views/splash/Splash.js +++ b/src/views/splash/Splash.js @@ -1,41 +1,40 @@ -import React, { Component } from 'react' -import { connect } from 'react-redux' -import SplashView from './SplashView' -import {authorize,splash} from '../../store/modules/user' -import { getInstitutes } from '../../store/modules/Institutes' -import AppNav from '../../nav/AppNav' -import RegisterNav from '../../nav/RegisterNav' +import React, { Component } from "react"; +import { connect } from "react-redux"; +import SplashView from "./SplashView"; +import { authorize, splash } from "../../store/modules/user"; +import { getInstitutes } from "../../store/modules/Institutes"; +import AppNav from "../../nav/AppNav"; +import RegisterNav from "../../nav/RegisterNav"; -class Splash extends Component{ +class Splash extends Component { + async componentDidMount() { + const start = new Date().getTime(); + this.props.splash(true); + await this.props.getInstitutes(); + await this.props.authorize(Expo.Constants.deviceId); + const totalTime = new Date().getTime() - start; + setTimeout(() => { + this.props.splash(false); + }, 2000 - totalTime); + } - async componentDidMount(){ - this.props.splash(true) - await this.props.getInstitutes() - this.props.authorize(Expo.Constants.deviceId) - setTimeout( () => this.props.splash(false), 2200) + render() { + const { splashStatus, userStatus } = this.props; + if (!splashStatus) { + if (userStatus === "user") return ; + if (userStatus === "no_user") return ; } - render(){ - const { splashStatus, userStatus } = this.props - if (!splashStatus){ - if (userStatus=='user') - return ( - - ) - if (userStatus=='no_user') - return ( - - ) - } - return ( - - ) - } + return ; + } } const mapStateToProps = state => ({ - splashStatus: state.user.splashStatus, - userStatus: state.user.authStatus -}) + splashStatus: state.user.splashStatus, + userStatus: state.user.authStatus +}); -export default connect(mapStateToProps,{authorize,splash,getInstitutes})(Splash) \ No newline at end of file +export default connect( + mapStateToProps, + { authorize, splash, getInstitutes } +)(Splash);