working workspaces

This commit is contained in:
Henry Hiles 2026-04-19 16:02:50 -04:00
commit 30af165d02
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
54 changed files with 5065 additions and 158 deletions

View file

@ -0,0 +1,12 @@
import "package:flight/src/rust/api/workspace_api.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
class WorkspacesController extends StreamNotifier<List<List<Workspace>>> {
@override
Stream<List<List<Workspace>>> build() => listenWorkspaces();
static final provider =
StreamNotifierProvider<WorkspacesController, List<List<Workspace>>>(
WorkspacesController.new,
);
}

View file

@ -1,5 +1,6 @@
import 'package:dynamic_system_colors/dynamic_system_colors.dart';
import 'package:flight/helpers/extensions/scheme_to_theme.dart';
import 'package:flight/src/rust/frb_generated.dart';
import 'package:flight/widgets/bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -19,6 +20,8 @@ void main() async {
await waylandLayerShellPlugin.setAnchor(ShellEdge.edgeBottom, true);
await waylandLayerShellPlugin.setExclusiveZone(48);
await RustLib.init();
runApp(
ProviderScope(
child: DynamicColorBuilder(
@ -35,7 +38,7 @@ void main() async {
brightness: Brightness.dark,
))
.theme,
home: Scaffold(body: Bar()),
home: Scaffold(body: Bar(), backgroundColor: Colors.transparent),
),
),
),

View file

@ -1,4 +1,5 @@
import 'package:flight/controllers/time_controller.dart';
import 'package:flight/controllers/workspaces_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart';
@ -13,38 +14,84 @@ class Bar extends ConsumerWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
spacing: 4,
children: [
Icon(Icons.circle),
Icon(Icons.circle_outlined),
Icon(Icons.circle_outlined),
],
),
Row(
children: [
Text(
DateFormat.Hm().format(
ref
.watch(TimeController.provider)
children:
[
...ref
.watch(WorkspacesController.provider)
.when(
data: (time) => time,
loading: DateTime.now,
error: (_, _) => DateTime.now(),
error: (error, stackTrace) => [Text(error.toString())],
loading: () => [],
data: (value) => value
.map(
(group) => Row(
children: group
.map(
(workspace) => IconButton(
onPressed: () {},
icon: Icon(
workspace.activated
? Icons.circle
: Icons.circle_outlined,
),
),
)
.toList(),
),
)
.toList(),
),
),
),
],
),
Row(
children: [
IconButton(onPressed: () {}, icon: Icon(Icons.wifi)),
IconButton(onPressed: () {}, icon: Icon(Icons.bluetooth)),
IconButton(onPressed: () {}, icon: Icon(Icons.volume_off)),
],
),
],
Center(
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextButton(
onPressed: () {},
child: Text(
DateFormat.Hm().format(
ref
.watch(TimeController.provider)
.when(
data: (time) => time,
loading: DateTime.now,
error: (_, _) => DateTime.now(),
),
),
),
),
],
),
),
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,
),
),
)
.toList(),
),
),
);