Skip to content

Commit

Permalink
fix(actions/ui): Split ItineraryView hidden state.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Apr 9, 2021
1 parent 804b53c commit af9f653
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,14 @@ export const ItineraryView = {
DEFAULT: 'list',
/** One itinerary is shown. (In mobile view, the map is hidden.) */
FULL: 'full',
/** Itinerary is hidden. (In mobile view, the map is expanded.) */
HIDDEN: 'hidden',
/** One itinerary is shown, itinerary and map are focused on a leg. (The mobile view is split.) */
LEG: 'leg',
/** One itinerary leg is hidden. (In mobile view, the map is expanded.) */
LEG_HIDDEN: 'leg-hidden',
/** The list of itineraries is shown. (The mobile view is split.) */
LIST: 'list'
LIST: 'list',
/** The list of itineraries is hidden. (In mobile view, the map is expanded.) */
LIST_HIDDEN: 'list-hidden'
}

/**
Expand Down
9 changes: 6 additions & 3 deletions lib/components/mobile/batch-results-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ class BatchMobileResultsScreen extends Component {
_toggleMapExpanded = () => {
const { itineraryView, setItineraryView } = this.props

if (itineraryView !== ItineraryView.HIDDEN) {
if (itineraryView === ItineraryView.LEG) {
this.setState({ previousSplitView: itineraryView })
setItineraryView(ItineraryView.HIDDEN)
setItineraryView(ItineraryView.LEG_HIDDEN)
} else if (itineraryView === ItineraryView.LIST) {
this.setState({ previousSplitView: itineraryView })
setItineraryView(ItineraryView.LIST_HIDDEN)
} else {
setItineraryView(this.state.previousSplitView)
}
Expand All @@ -96,7 +99,7 @@ class BatchMobileResultsScreen extends Component {
render () {
const { errors, itineraries, itineraryView } = this.props
const hasErrorsAndNoResult = itineraries.length === 0 && errors.length > 0
const mapExpanded = itineraryView === ItineraryView.HIDDEN
const mapExpanded = itineraryView === ItineraryView.LEG_HIDDEN || itineraryView === ItineraryView.LIST_HIDDEN
const itineraryExpanded = itineraryView === ItineraryView.FULL

return (
Expand Down
4 changes: 3 additions & 1 deletion lib/components/narrative/narrative-itineraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class NarrativeItineraries extends Component {

_isShowingDetails = () => {
const { itineraryView } = this.props
return itineraryView === ItineraryView.FULL || itineraryView === ItineraryView.LEG
return itineraryView === ItineraryView.FULL ||
itineraryView === ItineraryView.LEG ||
itineraryView === ItineraryView.LEG_HIDDEN
}

_toggleDetailedItinerary = () => {
Expand Down

0 comments on commit af9f653

Please sign in to comment.