Pebble App Framework: Phone API
    Preparing search index...

    Function pluginSourcePage

    • Adds a feature's plugin choice to the settings page, with the rows that go with it.

      1. It adds the feature's select below the leading rows of the section holding its anchor row, when the feature brings one and the page has none.
      2. It drops the select when the face declares no message key for it, and logs why. Clay would otherwise put a setting the watch cannot map into the save.
      3. It adds the Preferred Source option when a plugin on the phone serves the item, and opens the select on it when the feature says the choice was never saved. When none does and the plugin is the saved choice, the option stays as Preferred Source (Plugins Off), so a save keeps the choice and the plugin answers again once the wearer turns plugins back on. A kind with a notInstalledLabel takes that label instead while the phone lists other plugins, and offers the option then even with nothing saved, so a wearer learns a plugin can feed it. A plugin list the phone will not give offers the option as usual.
      4. It drops a select left with one option, which is no choice at all.
      5. With no select left on the page, it takes the select's marks off every row, drops the lead line marked for it, and settles the visibleWhen conditions naming it against the value the feature uses, the saved one or else the one option it had left. A section that dropping the select or its lead line leaves with only headings goes too. With the select there but no plugin on offer, it takes the marks off and leaves the conditions.
      6. Otherwise it puts the select first in its section, after the heading and its lead line, with the rows it hides under it and the section's other rows after those. It moves the section the feature names to sit after the select's own, when that section holds only rows for the other sources. It hides each marked row while a plugin is picked, and a section whose rows all hide goes with them.
      7. It then puts the feature's note on where the data comes from under the select, and the warning rows the saved state calls for after it. A plugin choice kept with plugins off gets the one row saying how to turn them on in place of the warnings, or the kind's noPlugin row while the phone lists other plugins.

      Once the select has passed step 2, a feature that asks for it also gets the supported plugins panel at the foot of the page, whatever steps 3 to 7 made of the select.

      Before any of that, every kind records where its plugins stand in the plugin kinds store at the top of the page, as PLUGIN_KINDS_CLASS describes, so a face's own components can read it. A kind left with no select while the face is on a source of its own comes back out of the store, since the face reads no plugin for it. So a kind the store names with no select on the page is one that reads the plugin whatever the page shows.

      A kind with no source choice passes no select key, and none of the steps above apply. It gets its notes alone, always shown: where its data comes from, then the one saying to turn plugins on while nothing on the phone serves the kind, or else the warnings the saved state calls for. A panel opening on its own line to turn plugins on stands in for that note. They go straight after the row the face marks with pluginSourceRows for the kind, or at the foot of the page just above the panel.

      Parameters

      • page: ClayConfigItem[]

        The settings page so far, the page hook's own copy. It is changed in place. Every row and the panel take the face's own wording from pluginTexts in ts/pkjs/plugin-texts.ts, which faceStart keeps from what the face passed startPebbleApp, laid over the feature's.

      • given: PluginSourceInputs

        The select, the plugin list, the saved state and value, and the feature's wording.

      Returns ClayConfigItem[]

      The page, changed.