Order displays based on logical position

This commit is contained in:
Henry Hiles 2026-04-21 22:34:41 -04:00
commit 1ba6c8a026
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 228 additions and 180 deletions

View file

@ -9,104 +9,98 @@ class Bar extends ConsumerWidget {
const Bar({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) => Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Stack(
children:
[
ref
.watch(WorkspacesController.provider)
.when(
error: (error, stackTrace) => [Text(error.toString())],
loading: () => [SizedBox.shrink()],
data: (value) => value
.map(
(group) => Row(
children: group
.map(
(workspace) => IconButton(
onPressed: () => workspace.activate(),
icon: Icon(
workspace.activated
? Icons.circle
: Icons.circle_outlined,
),
),
)
.toList(),
),
)
.toList(),
),
[
TextButton(
onPressed: () {},
child: Text(
DateFormat.Hm().format(
ref
.watch(TimeController.provider)
.when(
data: (time) => time,
loading: DateTime.now,
error: (_, _) => DateTime.now(),
),
),
),
),
],
[
Row(
children: [
IconButton(onPressed: () {}, icon: Icon(Icons.wifi)),
IconButton(
onPressed: () {},
icon: Icon(Icons.bluetooth),
),
IconButton(
onPressed: () {},
icon: Icon(Icons.volume_off),
),
],
),
],
]
.mapIndexed(
(index, children) => Align(
alignment: [
Alignment.centerLeft,
Alignment.center,
Alignment.centerRight,
][index],
child: Row(
spacing: 8,
mainAxisSize: MainAxisSize.min,
children: children
Widget build(BuildContext context, WidgetRef ref) => Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Stack(
children:
[
ref
.watch(WorkspacesController.provider)
.when(
error: (error, stackTrace) => [Text(error.toString())],
loading: () => [SizedBox.shrink()],
data: (value) => value
.map(
(child) => Padding(
padding: EdgeInsetsGeometry.directional(
bottom: 6,
),
child: Container(
height: 42,
padding: EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surfaceContainerLow,
borderRadius: BorderRadius.circular(999),
),
child: child,
),
(group) => Row(
children: group
.map(
(workspace) => IconButton(
onPressed: () => workspace.activate(),
icon: Icon(
workspace.activated
? Icons.circle
: Icons.circle_outlined,
),
),
)
.toList(),
),
)
.toList(),
),
[
TextButton(
onPressed: () {},
child: Text(
DateFormat.Hm().format(
ref
.watch(TimeController.provider)
.when(
data: (time) => time,
loading: DateTime.now,
error: (_, _) => DateTime.now(),
),
),
),
),
)
.toList(),
),
],
[
Row(
children: [
IconButton(onPressed: () {}, icon: Icon(Icons.wifi)),
IconButton(onPressed: () {}, icon: Icon(Icons.bluetooth)),
IconButton(
onPressed: () {},
icon: Icon(Icons.volume_off),
),
],
),
],
]
.mapIndexed(
(index, children) => Align(
alignment: [
Alignment.centerLeft,
Alignment.center,
Alignment.centerRight,
][index],
child: Row(
spacing: 8,
mainAxisSize: MainAxisSize.min,
children: children
.map(
(child) => Padding(
padding: EdgeInsetsGeometry.directional(bottom: 6),
child: Container(
height: 42,
padding: EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Theme.of(
context,
).colorScheme.surfaceContainerLow,
borderRadius: BorderRadius.circular(999),
),
child: child,
),
),
)
.toList(),
),
),
)
.toList(),
),
);
}