06-11-2019 05:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-11-2019 05:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi, is it possible to create more than one setting page and to switch among them through buttons?

06-11-2019 13:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-11-2019 13:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Yes. Here are some snippets from something of mine. This is highly ugly, but does work. For greater elegance and maintainability, think of your settings page as a state machine and centralise responsibility for setting the relevant menu-control settings when changing states.
<Page> {props.settings.menu === 'false' ? null : ( <Section title={ <Text bold align="center"> MENU </Text> }> <Button label="Defaults" onClick={() => { props.settingsStorage.setItem('menu', 'false'); props.settingsStorage.setItem('defaults', 'true'); props.settingsStorage.setItem('slideSettings', 'false'); props.settingsStorage.setItem('editSlide', 'false'); props.settingsStorage.setItem('deleteSlide', 'false'); }} /> {slides.length>=MAX_SLIDES? null : ( <Button label="Add a slide" onClick={() => { props.settingsStorage.setItem('menu', 'false'); props.settingsStorage.setItem('slideSettings', 'true'); }} /> )} ...
{props.settings.defaults === 'false' ? null : ( <Section title={ <Text bold align="center"> Defaults </Text> }> <Button label="Back to menu" onClick={() => { props.settingsStorage.setItem('menu', 'true'); props.settingsStorage.setItem('defaults', 'false'); }} /> </Section> )} {props.settings.slideSettings === 'false' ? null : ( <Section title={ <Text bold align="center"> Slide Settings </Text> }>
...
Gondwana Software

06-13-2019 00:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-13-2019 00:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi and thanks for the answer! Your solution seems to work, even if i can't properly run your example.
What i've done yesterday is create a function at the event onClick on the back button that call registerSettingsPage with the menu page as argument. Something like this:

06-13-2019 00:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-13-2019 00:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I never thought of that, and had no idea that it would work. It could well lead to better-structured code than my spaghetti-laden mess.
Gondwana Software

