build method
- @override
- BuildContext context,
- ViewsSidebarModel model
override
Builds the UI according to the state in model
.
Implementation
@override
Widget build(BuildContext context, ViewsSidebarModel model) => ListView(
children: [
Row(children: [
const SizedBox(
width: 100,
child: ListTile(
title: Text("Split"),
),
),
DropdownMenu<SplitMode>(
initialSelection: models.views.splitMode,
onSelected: models.views.updateSplitMode,
textStyle: context.textTheme.bodyMedium,
dropdownMenuEntries: [
for (final value in SplitMode.values) DropdownMenuEntry(
value: value,
label: value.humanName,
),
],
),
],),
ExpansionTile(
title: const Text("Presets"),
children: [
ReorderableListView(
shrinkWrap: true,
onReorder: models.views.swapPresets,
children: [
for (final preset in models.views.presets) ListTile(
key: ValueKey(preset.name),
title: Text(preset.name),
onTap: () => models.views.loadPreset(preset),
leading: Tooltip(
message: "Set as default preset",
waitDuration: const Duration(milliseconds: 500),
child: IconButton(
onPressed: () => models.views.toggleDefaultPreset(preset),
icon: models.views.isDefaultPreset(preset)
? const Icon(Icons.star)
: const Icon(Icons.star_outline),
splashColor: Colors.blueGrey,
color: Colors.orange,
),
),
trailing: Padding(
padding: const EdgeInsets.only(right: 16),
child: MenuAnchor(
builder: (context, controller, child) => IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () => controller.isOpen ? controller.close() : controller.open(),
),
menuChildren: [
MenuItemButton(
child: const Text("Update"),
onPressed: () => models.views.updatePreset(preset),
),
MenuItemButton(
child: const Text("Delete"),
onPressed: () => _deletePreset(context, preset),
),
],
),
),
),
],
),
ListTile(
title: const Text("Save current layout"),
onTap: () => _savePreset(context),
trailing: const Icon(Icons.save),
),
],
),
ExpansionTile(
title: const Text("Cameras"),
children: [
for (final view in DashboardView.cameraViews)
_buildDraggable(view, dragIcon: const Icon(Icons.camera_alt)),
],
),
ExpansionTile(
title: const Text("Controls"),
children: [
for (final view in DashboardView.uiViews) _buildDraggable(view),
],
),
_buildDraggable(DashboardView.blank),
],
);