Skip to content

Commit

Permalink
Merge branch 'ej/background-maps-settings-flag' of github.com:digidem…
Browse files Browse the repository at this point in the history
…/mapeo-desktop into ej/background-maps-settings-flag
  • Loading branch information
lightlii committed Jul 14, 2023
2 parents 2492b40 + cf6ad29 commit 6774eab
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/renderer/components/SettingsView/ExperimentsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Map as MapIcon } from '@material-ui/icons'
import { SettingsList } from './SettingsList'

const m = defineMessages({
backgroundMaps: 'Background Maps',
backgroundMaps: 'Background Maps'
})

export const ExperiementsMenu = ({ backgroundMaps, setBackgroundMaps }) => {
Expand All @@ -21,8 +21,8 @@ export const ExperiementsMenu = ({ backgroundMaps, setBackgroundMaps }) => {
label: m.backgroundMaps,
checked: backgroundMaps,
onClick: toggleBackgroundMaps,
type: 'toggle',
},
type: 'toggle'
}
]

return <SettingsList options={options} />
Expand Down
22 changes: 17 additions & 5 deletions src/renderer/components/SettingsView/SettingsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ export const SettingsMenu = ({ tabs, currentTab, onTabChange }) => {
height: '100vh',
borderRadius: 0,
zIndex: 1,
position: 'relative',
position: 'relative'
}}
>
<StyledTabs orientation='vertical' value={currentTab} onChange={(e, newValue) => onTabChange(newValue)}>
<StyledTabs
orientation='vertical'
value={currentTab}
onChange={(e, newValue) => onTabChange(newValue)}
>
{tabs.map(tab => (
<Tab
disableRipple
Expand All @@ -47,9 +51,17 @@ export const SettingsMenu = ({ tabs, currentTab, onTabChange }) => {
)
}

export const RenderTab = React.forwardRef(({ tab: { icon, label, subtitle, type }, ...rest }, ref) => (
<SettingsItem icon={icon} label={label} subtitle={subtitle} type={type || 'menuItem'} {...rest} />
))
export const RenderTab = React.forwardRef(
({ tab: { icon, label, subtitle, type }, ...rest }, ref) => (
<SettingsItem
icon={icon}
label={label}
subtitle={subtitle}
type={type || 'menuItem'}
{...rest}
/>
)
)

const StyledTabs = styled(Tabs)`
height: 100vh;
Expand Down
23 changes: 15 additions & 8 deletions src/renderer/components/SettingsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const m = defineMessages({
aboutMapeoSubtitle: 'Version and build number',
experiments: 'Experiments',
experimentsSubtitle: 'Turn on experimental new features',
backgroundMaps: 'Background maps',
backgroundMaps: 'Background maps'
})

const useExperimentsFlagsState = createPersistedState('experimentsFlags')
Expand All @@ -26,34 +26,41 @@ export const SettingsView = () => {
tabId: 'AboutMapeo',
icon: InfoIcon,
label: m.aboutMapeo,
subtitle: m.aboutMapeoSubtitle,
subtitle: m.aboutMapeoSubtitle
},
{
tabId: 'Experiments',
icon: FlagIcon,
label: m.experiments,
subtitle: m.experimentsSubtitle,
subtitle: m.experimentsSubtitle
},
...(backgroundMaps
? [
{
tabId: 'BackgroundMaps',
icon: MapIcon,
label: m.backgroundMaps,
},
label: m.backgroundMaps
}
]
: []),
: [])
]
const initialMenuState = /** {null | number} */ null
const [menuItem, setMenuItem] = useState(initialMenuState)

return (
<Container>
<SettingsMenu tabs={tabs} currentTab={menuItem} onTabChange={setMenuItem} />
<SettingsMenu
tabs={tabs}
currentTab={menuItem}
onTabChange={setMenuItem}
/>

{menuItem === 'AboutMapeo' && <AboutMapeoMenu />}
{menuItem === 'Experiments' && (
<ExperiementsMenu backgroundMaps={backgroundMaps} setBackgroundMaps={setBackgroundMaps} />
<ExperiementsMenu
backgroundMaps={backgroundMaps}
setBackgroundMaps={setBackgroundMaps}
/>
)}
{menuItem === 'BackgroundMaps' && <Boc />}
</Container>
Expand Down

0 comments on commit 6774eab

Please sign in to comment.