From 97a7c43a93518634941a917f837d10017a01ea5f Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sun, 19 Apr 2026 16:22:38 -0400 Subject: [PATCH] fix alignment of children of bar --- lib/widgets/bar.dart | 108 ++++++++++++++++++++++++------------------- pubspec.lock | 2 +- pubspec.yaml | 1 + 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/lib/widgets/bar.dart b/lib/widgets/bar.dart index 0f30a70..e614820 100644 --- a/lib/widgets/bar.dart +++ b/lib/widgets/bar.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:flight/controllers/time_controller.dart'; import 'package:flight/controllers/workspaces_controller.dart'; import 'package:flutter/material.dart'; @@ -11,16 +12,14 @@ class Bar extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) => Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, + child: Stack( children: [ - ...ref + ref .watch(WorkspacesController.provider) .when( error: (error, stackTrace) => [Text(error.toString())], - loading: () => [], + loading: () => [SizedBox.shrink()], data: (value) => value .map( (group) => Row( @@ -40,54 +39,69 @@ class Bar extends ConsumerWidget { ) .toList(), ), - Center( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, + [ + TextButton( + onPressed: () {}, + child: Text( + DateFormat.Hm().format( + ref + .watch(TimeController.provider) + .when( + data: (time) => time, + loading: DateTime.now, + error: (_, _) => DateTime.now(), + ), + ), + ), + ), + ], + + [ + Row( children: [ - TextButton( + IconButton(onPressed: () {}, icon: Icon(Icons.wifi)), + IconButton( onPressed: () {}, - child: Text( - DateFormat.Hm().format( - ref - .watch(TimeController.provider) - .when( - data: (time) => time, - loading: DateTime.now, - error: (_, _) => DateTime.now(), - ), - ), - ), + icon: Icon(Icons.bluetooth), + ), + IconButton( + onPressed: () {}, + icon: Icon(Icons.volume_off), ), ], ), - ), - Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - IconButton(onPressed: () {}, icon: Icon(Icons.wifi)), - IconButton(onPressed: () {}, icon: Icon(Icons.bluetooth)), - IconButton( - onPressed: () {}, - icon: Icon(Icons.volume_off), - ), - ], - ), + ], ] - .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, + .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(), ), ), ) diff --git a/pubspec.lock b/pubspec.lock index 8819dde..e1523b3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -154,7 +154,7 @@ packages: source: hosted version: "4.11.1" collection: - dependency: transitive + dependency: "direct main" description: name: collection sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" diff --git a/pubspec.yaml b/pubspec.yaml index f952f75..07eed38 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,6 +24,7 @@ dependencies: rust_lib_flight: path: rust_builder flutter_rust_bridge: 2.11.1 + collection: ^1.19.1 dev_dependencies: build_runner: ^2.13.1