Improve Login and Settings
This commit is contained in:
@@ -143,6 +143,7 @@ class _DevicesViewState extends State<DevicesView> {
|
||||
const Divider(),
|
||||
..._devices.map((device) => _DeviceRow(
|
||||
device: device,
|
||||
baseRadioId: _devices.isNotEmpty ? _devices.first.id : null,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
@@ -159,22 +160,46 @@ class _DevicesViewState extends State<DevicesView> {
|
||||
|
||||
class _DeviceRow extends StatelessWidget {
|
||||
final Device device;
|
||||
final int? baseRadioId;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _DeviceRow({
|
||||
required this.device,
|
||||
required this.onTap,
|
||||
this.baseRadioId,
|
||||
});
|
||||
|
||||
String? get _deviceExtension {
|
||||
if (baseRadioId == null) return null;
|
||||
final baseStr = baseRadioId.toString();
|
||||
final idStr = device.id.toString();
|
||||
// Check if device ID starts with the base radio ID
|
||||
if (idStr.startsWith(baseStr)) {
|
||||
final extension = idStr.substring(baseStr.length);
|
||||
return extension.isNotEmpty ? extension : '0';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final extension = _deviceExtension;
|
||||
final showExtension = extension != null && extension != '0';
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
child: Icon(
|
||||
Icons.settings_input_antenna,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
child: showExtension
|
||||
? Text(
|
||||
extension,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
Icons.settings_input_antenna,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
),
|
||||
title: Text(device.callsign ?? 'Unknown'),
|
||||
subtitle: Column(
|
||||
|
||||
Reference in New Issue
Block a user