112 lines
4 KiB
Dart
112 lines
4 KiB
Dart
import 'package:collection/collection.dart';
|
|
import 'package:flight/controllers/time_controller.dart';
|
|
import 'package:flight/controllers/workspaces_controller.dart';
|
|
import 'package:flight/widgets/bubble.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class Bar extends ConsumerWidget {
|
|
const Bar({super.key});
|
|
|
|
@override
|
|
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(
|
|
(group) => Bubble(
|
|
Row(
|
|
children: group
|
|
.map(
|
|
(workspace) => IconButton(
|
|
onPressed: () => workspace.activate(),
|
|
icon: Icon(
|
|
workspace.activated
|
|
? Icons.circle
|
|
: Icons.circle_outlined,
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
[
|
|
Bubble(
|
|
popover: Bubble(
|
|
Padding(
|
|
padding: EdgeInsetsGeometry.all(8),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
DateFormat.MMMMEEEEd().format(DateTime.now()),
|
|
style: Theme.of(context).textTheme.headlineMedium,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Center(
|
|
child: Text(
|
|
DateFormat.Hm().format(
|
|
ref
|
|
.watch(TimeController.provider)
|
|
.when(
|
|
data: (time) => time,
|
|
loading: DateTime.now,
|
|
error: (_, _) => DateTime.now(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
|
|
[
|
|
Bubble(
|
|
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.bottomLeft,
|
|
Alignment.bottomCenter,
|
|
Alignment.bottomRight,
|
|
][index],
|
|
child: Row(
|
|
spacing: 8,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: children,
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
);
|
|
}
|