@@ -241,6 +241,92 @@ class SettingsSelectorPanel extends Component {
241
241
}
242
242
}
243
243
244
+ _renderExclusiveAccessSelectors = ( ) => {
245
+ const { config, mode, icons} = this . props
246
+ const { exclusiveModes} = config . modes
247
+ const modeHasTransit = hasTransit ( mode )
248
+
249
+ if ( ! exclusiveModes ) return null
250
+
251
+ // create an array of children to display within a mode-group-row
252
+ // at most 2 exclusive modes will be displayed side-by-side
253
+ const children = [ ]
254
+ const spacer = (
255
+ < Col xs = { 2 } style = { { height : 44 } } > </ Col >
256
+ )
257
+
258
+ exclusiveModes . forEach ( ( exclusiveMode , idx ) => {
259
+ // add left padding for every evenly indexed exclusiveMode
260
+ if ( idx % 2 === 0 ) {
261
+ children . push ( spacer )
262
+ }
263
+
264
+ switch ( exclusiveMode ) {
265
+ case 'WALK' :
266
+ children . push (
267
+ < Col xs = { 4 } >
268
+ < ModeButton
269
+ enabled
270
+ active = { mode === 'WALK' }
271
+ icons = { icons }
272
+ mode = { 'WALK' }
273
+ height = { 36 }
274
+ label = { 'Walk Only' }
275
+ inlineLabel
276
+ onClick = { this . _setWalkOnly }
277
+ />
278
+ </ Col >
279
+ )
280
+ break
281
+ case 'BICYCLE' :
282
+ children . push (
283
+ < Col xs = { 4 } >
284
+ < ModeButton
285
+ enabled
286
+ active = { ! modeHasTransit && hasBike ( mode ) }
287
+ icons = { icons }
288
+ mode = { 'BICYCLE' }
289
+ height = { 36 }
290
+ label = { 'Bike Only' }
291
+ inlineLabel
292
+ onClick = { this . _setBikeOnly }
293
+ />
294
+ </ Col >
295
+ )
296
+ break
297
+ case 'MICROMOBILITY' :
298
+ children . push (
299
+ < Col xs = { 4 } >
300
+ < ModeButton
301
+ enabled
302
+ active = { ! modeHasTransit && hasMicromobility ( mode ) }
303
+ icons = { icons }
304
+ mode = { 'MICROMOBILITY' }
305
+ height = { 36 }
306
+ label = { 'eScooter Only' }
307
+ inlineLabel
308
+ onClick = { this . _setMicromobilityOnly }
309
+ />
310
+ </ Col >
311
+ )
312
+ break
313
+ default :
314
+ throw new Error ( `Unsupported exclusive mode: ${ exclusiveMode } ` )
315
+ }
316
+
317
+ // add right padding for every odd indexed exclusiveMode
318
+ if ( idx % 2 !== 0 ) {
319
+ children . push ( spacer )
320
+ }
321
+ } )
322
+
323
+ return (
324
+ < Row className = 'mode-group-row' >
325
+ { children }
326
+ </ Row >
327
+ )
328
+ }
329
+
244
330
render ( ) {
245
331
const { config, mode, icons, queryModes } = this . props
246
332
@@ -285,46 +371,7 @@ class SettingsSelectorPanel extends Component {
285
371
} ) }
286
372
</ Row >
287
373
288
- < Row className = 'mode-group-row' >
289
- < Col xs = { 1 } />
290
- < Col xs = { 3 } >
291
- < ModeButton
292
- enabled
293
- active = { mode === 'WALK' }
294
- icons = { icons }
295
- mode = { 'WALK' }
296
- height = { 36 }
297
- label = { 'Walk Only' }
298
- inlineLabel
299
- onClick = { this . _setWalkOnly }
300
- />
301
- </ Col >
302
- < Col xs = { 3 } >
303
- < ModeButton
304
- enabled
305
- active = { ! modeHasTransit && hasBike ( mode ) }
306
- icons = { icons }
307
- mode = { 'BICYCLE' }
308
- height = { 36 }
309
- label = { 'Bike Only' }
310
- inlineLabel
311
- onClick = { this . _setBikeOnly }
312
- />
313
- </ Col >
314
- < Col xs = { 4 } >
315
- < ModeButton
316
- enabled
317
- active = { ! modeHasTransit && hasMicromobility ( mode ) }
318
- icons = { icons }
319
- mode = { 'MICROMOBILITY' }
320
- height = { 36 }
321
- label = { 'eScooter Only' }
322
- inlineLabel
323
- onClick = { this . _setMicromobilityOnly }
324
- />
325
- </ Col >
326
- < Col xs = { 1 } />
327
- </ Row >
374
+ { this . _renderExclusiveAccessSelectors ( ) }
328
375
329
376
{ /* Transit mode selector */ }
330
377
{ /* <Row className='mode-group-row'>
0 commit comments