Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multiple value entry for Settings API

ANSWERED

Is there a way to add a single entry with multiple components?

 

For example Time, Place. Two separate fields in one entry.

Author | ch, passion for improvement.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@Gondwana  - thanks, with your help the multiple value pair entry is resolved.

 

<Section title={<Text bold>Multiple pair values</Text>}>
<Text>{"Enter the corresponding place for the time "+props.settingsStorage.getItem("myDate")}</Text>
<TextInput
label={"Time at  (" + props.settingsStorage.getItem("myTime1")+")"}
settingsKey="myPlaceSetting1"
/>

<TextInput
label={"Time at  (" + props.settingsStorage.getItem("myTime2")+")"}
settingsKey="myPlaceSetting2"
/>
</Section>

Author | ch, passion for improvement.

View best answer in original post

Best Answer
12 REPLIES 12

Hi @skeil - looking at the watch face in your post "Avoid "origin=null" set in POST request" it seems you may be able to answer this question?

 

If Orange was a time, can a place be associated with it in the Settings of the App in the Fitbit App? It would be necessary to enter both the time and the place for a single entry.

Author | ch, passion for improvement.

Best Answer
0 Votes

Hey, I'm not sure if I correctly understand your question.

I think the way the settings are built can not be transferred 1:1 to a normal app layout.

In the screenshot you used I use tile-list-items and checkbox-tiles:
https://github.com/SaskiaKeil/fitbit-todo/blob/master/resources/widgets.gui

 

But what you want is that one is able to set time and place in the settings, but together in one field?

So far I only used separated fields in the settings, like here for the several auth tokens:
https://github.com/SaskiaKeil/fitbit-todo/blob/master/settings/index.jsx

 

Maybe you can specify your question a bit more and we can see if I can be of help 🙂

Best Answer

Hi @skeil - thank so much for your time and effort.

It is the latter, to be able to enter in Settings two fields [Time and Description] that make one entry.

 

My goal was to have a number of entries in Settings, hopefully being able to use the popup time picker [to avoid validation] to choose a time, and a string field that goes with it to enter the text. This would avoid having to try and do it on the watch,.

 

Not sure at this stage if a tile-list-items will be used to display on the watch, more likely a textbox with the individual lines for information, as any editing would be done in Settings.

 

The idea would be to popup an indication of the Description at the specified time.

 

Author | ch, passion for improvement.

Best Answer
0 Votes

AFAIK this can only be done in two different fields, especially if you want to use any validation like the time validation.
This page should list all the options:
https://dev.fitbit.com/build/guides/settings/

 

I fear though that also having a popup time picker is not supported, at least not from what I read in the documentation.

Best Answer

Using the text input where a label and a user input is shown in Settings, is it possible to programmatically change the label value by picking it up from a variable in the jsx?

 

The jsx should show the current value in the heading label and allow the user to enter the appropriate description for it.

Author | ch, passion for improvement.

Best Answer

Maybe. Try something like

<Text>{props.settingsStorage.getItem('labelHeading')??''}</Text>

Use setItem to put a string value in labelHeading. Note that labelHeading isn't the settingsKey of any setting component.

It may be possible to do this just using a local variable, rather than via settingsStorage. An advantage of using settingsStorage is that you can change the value in companion/index.js, which is sometimes useful.

Peter McLennan
Gondwana Software
Best Answer

@Gondwana  - thanks, with your help the multiple value pair entry is resolved.

 

<Section title={<Text bold>Multiple pair values</Text>}>
<Text>{"Enter the corresponding place for the time "+props.settingsStorage.getItem("myDate")}</Text>
<TextInput
label={"Time at  (" + props.settingsStorage.getItem("myTime1")+")"}
settingsKey="myPlaceSetting1"
/>

<TextInput
label={"Time at  (" + props.settingsStorage.getItem("myTime2")+")"}
settingsKey="myPlaceSetting2"
/>
</Section>

Author | ch, passion for improvement.

Best Answer

Nice!

In theory, it should be possible to put more than one getItem() inside a <Text>.

Peter McLennan
Gondwana Software
Best Answer

@Gondwana  - still need to do more research to set a default value for "myPlaceSetting1" for example.

 

 

 

Author | ch, passion for improvement.

Best Answer
0 Votes

In general, the best approach to initialising a setting component is to determine what default value you want it to have (typically by entering it manually and console.logging in companion). Then, put start-up code in companion that checks whether the setting has a value; if it doesn't, setItem() it to the default you determined.

Note that setItem() takes a string value.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Doesn't seem to accept a default value set in the companion at initialisation. Still investigating.

Author | ch, passion for improvement.

Best Answer
0 Votes

Bonus unsolicited tip: don't try to guess the structure of the value. Inspect a value entered manually.

Peter McLennan
Gondwana Software
Best Answer
0 Votes