changeMode method

Future<void> changeMode(
  1. BuildContext context,
  2. RoverStatus input
)

Change the mode of the rover, confirming if the user wants to shut it off.

Implementation

Future<void> changeMode(BuildContext context, RoverStatus input) =>
    input == RoverStatus.POWER_OFF
    ? showDialog<void>(
        context: context,
        builder: (ctx) => AlertDialog(
          title: const Text("Are you sure?"),
          content: const Text(
            "This will turn off the rover and you must physically turn it back on again",
          ),
          actions: [
            TextButton(
              child: const Text("Cancel"),
              onPressed: () => Navigator.of(context).pop(),
            ),
            ElevatedButton(
              onPressed: () {
                models.rover.settings.setStatus(input);
                Navigator.of(context).pop();
              },
              child: const Text("Continue"),
            ),
          ],
        ),
      )
    : models.rover.settings.setStatus(input);