05-01-2018 09:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-01-2018 09:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
Is it possible to hide or disable elements in the settings screen in reaction to a click/toggle/selection etc?
So for example, in the app settings, if I have a toggle like "Use advanced mode", can I react to a click on that toggle by showing some options (text fields etc.) that would otherwise be hidden, and the reverse? Or even enable/disable certain elements based on the toggle selection?
I've worked out (so far) that I can do something like:
<Section title={<Text bold align="center">Configuration mode</Text>}> <Toggle settingsKey="configMode" label="Simple mode" onChange={(mode) => configModeChanged(mode)} /> </Section>
And:
function configModeChanged(mode) { console.log("configModeChanged called: -- " + JSON.stringify(mode) + " -- "); }
And it will be called with 'true' or 'false', but can I react to that by hiding/showing or enabling/disabling other elements in the settings screen?
Thanks in advance.

05-01-2018 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-01-2018 15:22
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @EoinStronge -
Take a look at this link from the React documentation on conditional rendering of elements. It might be useful for your specific use case.

08-28-2018 13:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-28-2018 13:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hey did you ever find a solution to this? I am in need of something similar

08-28-2018 13:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-28-2018 13:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-28-2018 14:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-29-2018 11:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-29-2018 11:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Figured it out
{((JSON.parse(props.settings.dataSource).values[0].value == 'custom') ? <TextInput label="Api endpoint" settingsKey="endpoint"/> : <TextInput label="Api endp2oint" settingsKey="endpoint"/>)}
05-24-2020 05:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 05:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
hey @Thiern ,
i m super beginner and i need to achieve this exact thing, would you explain it to me, i tried every thing i could with your :
{((JSON.parse(props.settings.dataSource).values[0].value == 'custom') ? <TextInput label="Api endpoint" settingsKey="endpoint"/> : <TextInput label="Api endp2oint" settingsKey="endpoint"/>)}
but as some structural knowledge is still missing from my skill set, (and fitbit SDK is very poor in info/tutorials) it does not work...
*.settings.* is the name of the settings function, wright? the one default as mySettings by fitBit in *.jsx?
i guess 'custom' is the settingsKey= value for the toogle.
an example empty project with the feature working would be hell good !
thank you for answering!

05-24-2020 08:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 08:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Would you be able to create a gist or push your code so I can take a look at it

05-24-2020 09:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 09:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I use the following to show or hide a toggle based on k-pay status. The logic stops if endTrialVisible is false, otherwise the toggle is rendered.
let endTrialVisible = (settings.btnEndTrialVisible === undefined ? false : JSON.parse(settings.btnEndTrialVisible))
{ endTrialVisible && <Toggle settingsKey="kpayPurchase" label={ gText("etNow") } /> }

05-24-2020 09:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 09:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi thank you for answering that fast!
i have been thru dozens of trys on your code in pasting it everywhere and changing every names i could thought of....
the closest i have is disabling a text input using the toggle switch, i want the same thing to hide/unhide...
function mySettings(props) {
return (
<Page>
<Section
title={<Text bold align="center">Demo Settings</Text>}>
<TextInput
label="Example"
title="Text Input"
settingsKey="textInput"
disabled= {!(props.settings.toggleTextInput === "true")}//instead of disabled i want to hide/display from settings?
/>
<Toggle
label="Enable Text Input"
settingsKey="toggleTextInput"
/>
</Section>
</Page>
);
}
registerSettingsPage(mySettings);
//{((JSON.parse(props.settings.dataSource).values[0].value == 'toggleTextInput') ? <TextInput label="Api endpoint" settingsKey="endpoint"/> : <TextInput label="Api endp2oint" settingsKey="endpoint"/>)}
thank you for your time!

05-24-2020 09:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 09:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Give this a try 🙂
05-24-2020 10:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-24-2020 10:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
thank you @Thiern thiern, so cool!
