build method

  1. @override
Widget build(
  1. BuildContext context,
  2. FooterViewModel model
)
override

Builds the UI according to the state in model.

Implementation

@override
Widget build(BuildContext context, FooterViewModel model) => Row(
  mainAxisSize: MainAxisSize.min,
  children: [
    Tooltip(  // battery level
      message: model.batteryMessage,
      child: Icon(
        model.isConnected
          ? getBatteryIcon(model.batteryPercentage)
          : Icons.battery_unknown,
        color: model.isConnected
          ? getColor(model.batteryPercentage)
          : Colors.black,
      ),
    ),
    NetworkStatusIcon(  // network icon
      device: Device.SUBSYSTEMS,
      tooltip: "${model.connectionSummary}\nClick to reset",
      onPressed: model.resetNetwork,
    ),
    PopupMenuButton(  // rover mode
      tooltip: "Change mode",
      onSelected: (input) => changeMode(context, input),
      icon: Icon(
        getStatusIcon(model.status),
        color: getStatusColor(model.status),
      ),
      itemBuilder: (_) => [
        for (final value in RoverStatus.values)
          if (value != RoverStatus.DISCONNECTED)  // can't select this!
            PopupMenuItem(value: value, child: Text(value.humanName)),
      ],
    ),
    IconButton(  // LED strip
      icon: Icon(
        Icons.circle,
        color: model.isConnected
          ? getLedColor(model.ledColor)
          : Colors.black,
        ),
      onPressed: () => showDialog<void>(context: context, builder: (_) => ColorEditor(ColorBuilder())),
      tooltip: "Change LED strip",
    ),
    const SizedBox(width: 4),
  ],
);