hondavert-dev/lib/ui/widgets/bt_status_chip.dart
2026-10-13 00:34:11 +00:00

39 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/providers/bt_provider.dart';
class BtStatusChip extends ConsumerWidget {
const BtStatusChip({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final bt = ref.watch(btProvider);
final (color, icon, label) = switch (bt.status) {
BtStatus.connected => (Colors.green, Icons.bluetooth_connected, bt.deviceName ?? 'Connected'),
BtStatus.connecting => (Colors.orange, Icons.bluetooth_searching, 'Connecting…'),
BtStatus.error => (Colors.red, Icons.bluetooth_disabled, 'Error'),
BtStatus.disconnected=> (Colors.grey, Icons.bluetooth, 'Disconnected'),
};
return Padding(
padding: const EdgeInsets.only(right: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 14, color: color),
const SizedBox(width: 4),
Text(
label,
style: TextStyle(
color: color,
fontSize: 11,
fontWeight: FontWeight.w600,
),
),
],
),
);
}
}