mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 05:54:56 -06:00
move add button to nav and fix back button
This commit is contained in:
parent
94301532f6
commit
63d5b65951
5 changed files with 36 additions and 12 deletions
|
|
@ -43,7 +43,8 @@ export default class App extends Component {
|
|||
path="/createFoodItem"
|
||||
render={props => {
|
||||
if (!AuthManager.isLoggedIn()) {
|
||||
const loginRoute = `/login?returnto=/createFoodItem${props.location.search}`;
|
||||
const search = props.location.search + '&' || '?'
|
||||
const loginRoute = `/login${search}returnto=/createFoodItem`;
|
||||
return <Redirect to={loginRoute} />;
|
||||
}
|
||||
return <CreateFoodItem />;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import React, { Component } from 'react';
|
||||
import { View, TextInput, TouchableOpacity, SafeAreaView } from 'react-native';
|
||||
import { Toolbar, Icon } from 'react-native-material-ui';
|
||||
import { path } from 'ramda';
|
||||
import { path, pipe, not, cond, isNil, compose, always } from 'ramda';
|
||||
import queryString from 'query-string';
|
||||
import { getSearch } from '../helpers/RouteHelpers';
|
||||
import FoodItemSaveBtn from '../components/FoodItemSaveBtn';
|
||||
|
|
@ -24,6 +24,24 @@ class TopToolbar extends Component {
|
|||
|
||||
props: Props;
|
||||
|
||||
onBackPress = () => {
|
||||
const { router } = this.props;
|
||||
const { history } = router;
|
||||
|
||||
const notNil = compose(not, isNil);
|
||||
const goBackTo = pipe(
|
||||
path(['route', 'location', 'search']),
|
||||
queryString.parse,
|
||||
path(['backto']),
|
||||
cond([
|
||||
[notNil, history.replace],
|
||||
[always(true), history.goBack],
|
||||
]),
|
||||
)
|
||||
|
||||
goBackTo(router)
|
||||
}
|
||||
|
||||
onRightPress = ({ action }: { action: string }) => {
|
||||
const {
|
||||
router: { history },
|
||||
|
|
@ -73,7 +91,7 @@ class TopToolbar extends Component {
|
|||
{!showSearch && (
|
||||
<Toolbar
|
||||
leftElement="arrow-back"
|
||||
onLeftElementPress={history.goBack}
|
||||
onLeftElementPress={this.onBackPress}
|
||||
centerElement={title}
|
||||
rightElement={this.getRightElement()}
|
||||
onRightElementPress={this.onRightPress}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import FilterModal from '../modals/FilterModal';
|
|||
import { withFoodItemsAsSeq } from '../enhancers/foodItemEnhancers';
|
||||
import { type SetSeq } from 'immutable';
|
||||
import { compose, pure, withState, withHandlers, lifecycle } from 'recompose';
|
||||
import ActionsButton from '../components/ActionsButton';
|
||||
import { withFilter } from '../enhancers/filterEnhancers';
|
||||
import { withRouterContext } from '../enhancers/routeEnhancers';
|
||||
import FullScreenMessage from '../components/FullScreenMessage';
|
||||
|
|
@ -54,11 +53,6 @@ const FoodList = (props: Props) => {
|
|||
</ScrollView>
|
||||
)}
|
||||
<FilterModal isVisible={isFilterModalOpen} onClose={toggleFilterModal} />
|
||||
<ActionsButton
|
||||
toggleFilterModal={toggleFilterModal}
|
||||
actions={['add-food', 'filter-modal', 'view-mode']}
|
||||
icon="add"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ type Props = {
|
|||
setRoute: (route: string) => () => void,
|
||||
};
|
||||
|
||||
const Nav = ({ activeTab, setRoute }: Props) => {
|
||||
const Nav = (props: Props) => {
|
||||
const { activeTab, setRoute, location } = props;
|
||||
return (
|
||||
<View style={uiTheme.listView}>
|
||||
<View style={{ flex: 1 }}>
|
||||
|
|
@ -40,6 +41,18 @@ const Nav = ({ activeTab, setRoute }: Props) => {
|
|||
label="Places"
|
||||
onPress={setRoute('/list/places')}
|
||||
/>
|
||||
<BottomNavigation.Action
|
||||
key="add"
|
||||
icon="add-circle"
|
||||
label="Add"
|
||||
onPress={setRoute(`/createFoodItem?backto=${location.pathname}`)}
|
||||
/>
|
||||
<BottomNavigation.Action
|
||||
key="fave"
|
||||
icon="favorite"
|
||||
label="Favorites"
|
||||
onPress={setRoute('/list/food')}
|
||||
/>
|
||||
<BottomNavigation.Action
|
||||
key="profile"
|
||||
icon="person"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { withPlaces } from '../enhancers/placeEnhancers';
|
|||
import { Map, List } from 'immutable';
|
||||
import typeof FoodItemRecord from '../records/FoodItemRecord';
|
||||
import typeof PlaceRecord from '../records/PlaceRecord';
|
||||
import ActionsButton from '../components/ActionsButton';
|
||||
import { withRouterContext } from '../enhancers/routeEnhancers';
|
||||
|
||||
type Props = {
|
||||
|
|
@ -37,7 +36,6 @@ const PlacesList = ({ foodItemsByPlace = Map(), places, isRefreshing, onPulldown
|
|||
})
|
||||
.toList()}
|
||||
</ScrollView>
|
||||
<ActionsButton actions={['view-mode']} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue