Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Two navigation fixes. #123

Open
wants to merge 3 commits into
base: develop
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
3 changes: 2 additions & 1 deletion docs/working/DEBUGGING_TOOLS_IOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[Go back to Working with react-native-router-flux](WORKING_WITH_REACT_NATIVE_ROUTER_FLUX.md)

In the iOS simulator press Command+D to get the simulator debugger window (Command+M for Android)
In the iOS simulator press Command+D to get the simulator debug menu (Command+M for Android). On a physical iPhone
attached via a USB cord, shake the device to bring up the debug menu.

<img src="https://github.com/wevote/WeVoteReactNative/blob/develop/docs/images/iOS%20Debugger%20Menu.png" alt="alt text" width="400" >

Expand Down
49 changes: 49 additions & 0 deletions src/js/actions/TabActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
import { Actions } from 'react-native-router-flux';
import Dispatcher from "../dispatcher/Dispatcher";
import RouteConst from "../scenes/RouteConst"

export default class TabActions {

static tabPressed (scene) {
/*
January 2018, Observed locations of the data we need, with
"react-native": "0.47.2"
"react-native-router-flux": "4.0.0-beta.24"
"flux": "3.1.3"
"react-router": "4.2.0"
"react-router-native": "4.2.0"
Observed locations of the data we need...
current key can be at
scene.route.key
scene.scene.route.key
previous key can be at
scene.previousScene.key
scene.scene.previousScene.key
*/

let scene_local;
if (scene.route) {
scene_local = scene;
} else if (scene.scene.route) {
scene_local = scene.scene;
} else {
console.log("ERROR: tabPressed was unable to find a sceneLocal");
return;
}

let sceneLocal = scene_local;
let currentKey = sceneLocal.route.key;
let previousKey;
if (sceneLocal.previousScene) {
previousKey = sceneLocal.previousScene.key;
} else if (scene.previousScene) {
previousKey = scene.previousScene.key;
} else {
console.log("ERROR: tabPressed was unable to find a sceneLocalPrevious");
return;
}
console.log('TabActions.TabPress, currentKey = ' + currentKey + ', previousKey = ', previousKey + ',');
// if on the signin tab, and you click the sign in tab. A special case.
if (previousKey === RouteConst.KEY_SIGNIN_1 && previousKey === currentKey ) {
TabActions.tabStateChanged();
}

return Actions[scene_local.route.key].call();
}

static tabStateChanged () {
console.log('TabActions, received tabStateChanged');
Dispatcher.dispatch({
Expand Down
19 changes: 1 addition & 18 deletions src/js/scenes/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,7 @@ export default class App extends Component {
}

onTabPress(scene) {
// console.log('App.js onTabPress, scene.previousScene.key = ' + scene.previousScene.key +
// ', scene.route.key = ', scene.scene.route.key);

let scene_local;
if (scene.route) {
scene_local = scene;
} else if (scene.scene.route) {
scene_local = scene.scene;
} else {
return;
}

// if on the signin tab, and you click the sign in tab. A special case.
if (scene_local.previousScene && scene_local.previousScene.key === RouteConst.KEY_SIGNIN_1 && scene_local.previousScene.key === scene_local.route.key ) {
TabActions.tabStateChanged();
}

return Actions[scene_local.route.key].call();
return TabActions.tabPressed(scene);
}

render() {
Expand Down
10 changes: 7 additions & 3 deletions src/js/scenes/SignIn/AccountMenuModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Modal from 'react-native-modal'
import { Actions } from 'react-native-router-flux';
import Icon from "react-native-vector-icons/FontAwesome";

import CookieStore from "../../stores/CookieStore";
import styles from "../../stylesheets/components/baseStyles";
import styleConst from "../../stylesheets/styleConst";
import VoterSessionActions from "../../actions/VoterSessionActions";
Expand Down Expand Up @@ -173,9 +174,12 @@ export default class AccountMenu extends Component {
<Text style={styles.grayPromise}>Our Promise: We'll never sell your email.</Text>
{/*<Text style={styles.modalChoiceDummy}>Your Voter Guide (Twitter)</Text>*/}
{/*<Text style={styles.modalChoiceDummy}>Your Voter Guide (Facebook)</Text>*/}
<TouchableOpacity onPress={hide()}>
<Text style={styles.modalChoices}>Your Account</Text>
</TouchableOpacity>

{isAuthenticated &&
<TouchableOpacity onPress={hide()}>
<Text style={styles.modalChoices}>Your Account</Text>
</TouchableOpacity>
}
{! isAuthenticated &&
<TouchableOpacity onPress={hide()}>
<Text style={styles.modalChoices}>Sign In</Text>
Expand Down
4 changes: 2 additions & 2 deletions src/js/scenes/SignIn/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default class SignIn extends Component {
}
{isAuthenticated && <Text style = {[styles.title,{paddingTop: 10}]}>Currently Signed In</Text>}
{isAuthenticatedTwitter &&
<View style={[styles.buttonBasics, styles.twitterColors]} >
<View style={[styles.buttonBasics, styles.twitterColors, {width: 250}]} >
<View style={styles.flexRowSpaced}>
<View style={{paddingTop: 5}}>
<Icon name={"twitter"} size={24} color="white" paddingTop={10}/>
Expand All @@ -311,7 +311,7 @@ export default class SignIn extends Component {
</View>
}
{isAuthenticatedFacebook &&
<View style={[styles.buttonBasics, styles.facebookColors]} >
<View style={[styles.buttonBasics, styles.facebookColors, {width: 250}]} >
<View style={styles.flexRowSpaced}>
<View style={{paddingTop: 5}}>
<Icon name={"twitter"} size={24} color="white" paddingTop={10}/>
Expand Down
13 changes: 6 additions & 7 deletions src/js/stores/CookieStore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Platform } from 'react-native';
import _ from "lodash";
import CookieManager from 'react-native-cookies';
import { default as webAppConfig } from '../config';
import Promise from 'bluebird';
import url from 'url';
import { default as webAppConfig } from '../config';
const logging = require("../utils/logging");

// A wrapper class for react-native-cookie
Expand All @@ -19,9 +20,7 @@ class CookieStore {
directed to a specific route in the webapp that reassembles the url, uses the cookie to join the sessions.
*/
constructor() {
let steve = webAppConfig.WE_VOTE_SERVER_ROOT_URL;
console.log("steve steve steve " , steve);
let host = new URL(webAppConfig.WE_VOTE_SERVER_ROOT_URL).hostname;
let host = url.parse(webAppConfig.WE_VOTE_SERVER_ROOT_URL).host;
this.state = {
urlString: webAppConfig.WE_VOTE_SERVER_ROOT_URL,
current_voter_device_id: '',
Expand All @@ -39,12 +38,12 @@ class CookieStore {
https://wevote.us/more/jump?jump_path=%2Fmore%2Ftools&voter_device_id=G834YIXbfsVB0z
*/
getJumpURLWithCookie(inUrlString) {
let url = new URL(inUrlString);
let urlObject = url.parse(inUrlString);
let urlSearch = '';
if(urlSearch.length > 1) {
urlSearch = '&' + url.search.substr(1); // '?key=value' to '&key=value'
urlSearch = '&' + urlObject.search.substr(1); // '?key=value' to '&key=value'
}
let outUrlString = url.protocol + '//' + url.host + '/more/jump?jump_path=' + encodeURIComponent(url.pathname) +
let outUrlString = urlObject.protocol + '//' + urlObject.host + '/more/jump?jump_path=' + encodeURIComponent(urlObject.pathname) +
'&voter_device_id=' + this.state.current_voter_device_id + urlSearch;
console.log("getJumpURLWithCookie transformed '" + inUrlString + "' to '" + outUrlString + "'");
return outUrlString;
Expand Down