mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 09:54:55 -06:00
update title for food and places
This commit is contained in:
parent
8ae0730d0f
commit
5376cec963
4 changed files with 18 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ import { type FoodItem } from '../records/FoodItemRecord';
|
|||
import { type Place } from '../records/PlaceRecord';
|
||||
import theme from '../ui-theme';
|
||||
import { Link } from 'react-router-native';
|
||||
import { routeWithTitle } from '../helpers/RouteHelpers';
|
||||
|
||||
export const Thumbnail = ({ thumb }: { thumb: ?string }) => (
|
||||
<View
|
||||
|
|
@ -35,7 +36,7 @@ export const AvailableCount = ({ count }: { count: number }) => (
|
|||
);
|
||||
|
||||
export const PlaceTile = pure(({ place }: { place: Place, onPress: Function }) => (
|
||||
<Link to={`/place/${place.id}`} underlayColor={theme.itemTile.pressHighlightColor}>
|
||||
<Link to={routeWithTitle(`/place/${place.id}`, place.name)} underlayColor={theme.itemTile.pressHighlightColor}>
|
||||
<View style={{ height: 70, flexDirection: 'row' }}>
|
||||
<Thumbnail thumb={place.thumb} />
|
||||
<NameAndPlace name={place.name} place="Whole Foods" style={{ flex: 1 }} />
|
||||
|
|
@ -44,7 +45,10 @@ export const PlaceTile = pure(({ place }: { place: Place, onPress: Function }) =
|
|||
));
|
||||
|
||||
export const FoodItemTile = pure(({ foodItem }: { foodItem: FoodItem, onPress: Function }) => (
|
||||
<Link to={`/foodItem/${foodItem.id}`} underlayColor={theme.itemTile.pressHighlightColor}>
|
||||
<Link
|
||||
to={routeWithTitle(`/foodItem/${foodItem.id}`, foodItem.name)}
|
||||
underlayColor={theme.itemTile.pressHighlightColor}
|
||||
>
|
||||
<View style={{ height: 70, flexDirection: 'row' }}>
|
||||
<Thumbnail thumb={foodItem.thumb} />
|
||||
<NameAndPlace name={foodItem.name} place="Whole Foods" style={{ flex: 1 }} />
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Toolbar } from 'react-native-material-ui';
|
||||
import { type RoutingContextFlowTypes, routingContextPropTypes } from '../routes';
|
||||
import { path } from 'ramda';
|
||||
|
||||
type Props = {
|
||||
title: ?string,
|
||||
|
|
@ -19,8 +20,10 @@ class TopToolbar extends Component {
|
|||
context: RoutingContextFlowTypes;
|
||||
|
||||
render() {
|
||||
const { toggleSideMenu, title } = this.props;
|
||||
const { router: { history } } = this.context;
|
||||
const { toggleSideMenu } = this.props;
|
||||
const history = path(['router', 'history'], this.context);
|
||||
const routeTitle = path(['router', 'route', 'location', 'state', 'routeTitle'], this.context);
|
||||
const title = routeTitle || this.props.title;
|
||||
const isBasePage = history.index === 0;
|
||||
return (
|
||||
<Toolbar
|
||||
|
|
|
|||
6
js/helpers/RouteHelpers.js
Normal file
6
js/helpers/RouteHelpers.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// @flow
|
||||
import { curry } from 'ramda';
|
||||
|
||||
export const routeWithState = curry((pathname, state) => ({ pathname, state }));
|
||||
|
||||
export const routeWithTitle = curry((pathname, routeTitle) => routeWithState(pathname, { routeTitle }));
|
||||
|
|
@ -76,7 +76,7 @@ export class FoodItemDetail extends Component {
|
|||
style={{ width: 250 }}
|
||||
>
|
||||
{['none', 'few', 'many'].map(quantity => (
|
||||
<Picker.Item label={getQuantityText(quantity)} value={quantity} />
|
||||
<Picker.Item key={quantity} label={getQuantityText(quantity)} value={quantity} />
|
||||
))}
|
||||
</Picker>
|
||||
</Modal>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue