// @flow import React from "react"; import { ListItem, ListItemIcon } from "@material-ui/core/List"; import { renderIcon } from "utils/parseIconName"; import type { ControlUI } from "config/flowtypes"; import { Toggle, DropDown, Link, Section, Text, Progress, Slider } from "./UiItem"; export type UiItemListProps = { controls: Array, state: State, onChangeState: (topic: string, nextState: Actual) => void }; export default class UiItemList extends React.PureComponent { constructor(props: UiItemListProps) { super(props); } render() { return this.props.controls.map((control, key) => { if (control.type == null) { throw new Error( "A control is missing the \"type\" parameter" ); } if (control.type === "section") { return this.renderControl(control); } return ( {control.icon == null || {renderIcon(control.icon, "mdi-24px")}} {this.renderControl(control)} ); }); } renderControl(control: ControlUI) { switch (control.type) { case "toggle": { return ; } case "dropDown": { return ; } case "section": { return
; } case "link": { return ; } case "slider": { return ; } case "text": { return ; } case "progress": { return ; } default: { throw new Error( `Unknown UI type "${control.type}" for "${control.text}" component` ); } } } }