feat: redesign and lots of progress
This commit is contained in:
@ -168,6 +168,14 @@ class _SavedDevicesListState extends ConsumerState<_SavedDevicesList> {
|
||||
}
|
||||
|
||||
if (result.isOk()) {
|
||||
await ref
|
||||
.read(nConnectedDevicesProvider.notifier)
|
||||
.updateConnectedDeviceLastConnected(device.id);
|
||||
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.push('/device/${device.deviceAddress}');
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@ -256,21 +264,29 @@ class _ActiveDeviceCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (devices.isEmpty) {
|
||||
return _MessageCard(
|
||||
title: 'No connected devices yet',
|
||||
message: 'Your saved shifters will show up here with status and shortcuts.',
|
||||
actionLabel: 'Connect Device',
|
||||
onAction: () => context.push('/connect_device'),
|
||||
);
|
||||
final shifterDevices = devices
|
||||
.where(
|
||||
(device) =>
|
||||
deviceTypeFromString(device.deviceType) ==
|
||||
DeviceType.universalShifters,
|
||||
)
|
||||
.toList()
|
||||
..sort((a, b) {
|
||||
final aLastConnected = a.lastConnectedAt ?? a.createdAt;
|
||||
final bLastConnected = b.lastConnectedAt ?? b.createdAt;
|
||||
return bLastConnected.compareTo(aLastConnected);
|
||||
});
|
||||
|
||||
if (shifterDevices.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final connectedId = connectionData?.$2;
|
||||
final primaryDevice = connectedId == null
|
||||
? devices.first
|
||||
: devices.firstWhere(
|
||||
? shifterDevices.first
|
||||
: shifterDevices.firstWhere(
|
||||
(device) => device.deviceAddress == connectedId,
|
||||
orElse: () => devices.first,
|
||||
orElse: () => shifterDevices.first,
|
||||
);
|
||||
final isConnected = connectedId == primaryDevice.deviceAddress &&
|
||||
connectionData?.$1 == ConnectionStatus.connected;
|
||||
@ -306,10 +322,9 @@ class _ActiveDeviceCard extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
primaryDevice.deviceName,
|
||||
style:
|
||||
Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_StatusChip(
|
||||
@ -412,14 +427,16 @@ class _SavedDeviceTile extends StatelessWidget {
|
||||
shape: BoxShape.circle,
|
||||
color: isConnected
|
||||
? colorScheme.primary.withValues(alpha: 0.14)
|
||||
: colorScheme.surfaceContainerHighest.withValues(alpha: 0.7),
|
||||
: colorScheme.surfaceContainerHighest
|
||||
.withValues(alpha: 0.7),
|
||||
),
|
||||
child: Icon(
|
||||
deviceTypeFromString(device.deviceType) ==
|
||||
DeviceType.universalShifters
|
||||
? Icons.bluetooth_rounded
|
||||
: Icons.memory_rounded,
|
||||
color: isConnected ? colorScheme.primary : colorScheme.onSurface,
|
||||
color:
|
||||
isConnected ? colorScheme.primary : colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
@ -447,7 +464,8 @@ class _SavedDeviceTile extends StatelessWidget {
|
||||
Text(
|
||||
device.deviceAddress,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurface.withValues(alpha: 0.62),
|
||||
color:
|
||||
colorScheme.onSurface.withValues(alpha: 0.62),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user