feat: working connection, conn setting, and gear ratio setting for universal shifters

This commit is contained in:
2026-02-22 23:05:12 +01:00
parent f92d6d04f5
commit dcb1e6596e
93 changed files with 10538 additions and 668 deletions

View File

@ -1,18 +1,23 @@
import 'package:abawo_bt_app/model/bluetooth_device_model.dart';
import 'package:flutter/material.dart';
import 'dart:ui'; // Required for ImageFilter
class DeviceListItem extends StatelessWidget {
final String deviceName;
final String deviceId; // Added for potential future use or subtitle
final bool isUnknownDevice;
final DeviceType type;
// final String? imageUrl; // Optional image URL - commented out for now
final bool isConnecting; // Add this line
final Widget? trailing;
const DeviceListItem({
super.key,
required this.deviceName,
required this.deviceId,
this.isUnknownDevice = false,
required this.type,
// this.imageUrl,
this.isConnecting = false, // Add this line
this.trailing,
});
@override
@ -22,11 +27,11 @@ class DeviceListItem extends StatelessWidget {
// Glassy effect colors - adjust transparency and base color as needed
final glassColor = isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.black.withOpacity(0.05);
? Colors.white.withValues(alpha: 0.1)
: Colors.black.withValues(alpha: 0.05);
final shadowColor = isDarkMode
? Colors.black.withOpacity(0.4)
: Colors.grey.withOpacity(0.5);
? Colors.black.withValues(alpha: 0.4)
: Colors.grey.withValues(alpha: 0.5);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
@ -57,21 +62,33 @@ class DeviceListItem extends StatelessWidget {
glassColor, // Semi-transparent color for glass effect
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.white.withOpacity(0.2), // Subtle border
color:
Colors.white.withValues(alpha: 0.2), // Subtle border
width: 0.5,
),
),
child: const Center(
// Placeholder '?' - replace with Image widget when imageUrl is available
child: Text(
'?',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white70, // Adjust color as needed
),
),
),
child: type == DeviceType.universalShifters
// For Universal Shifters: Image fills the container, constrained by rounded borders
? ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Image.asset(
'assets/images/shifter-wireframe.png',
fit: BoxFit.cover, // Cover the entire container
width: 60,
height: 60,
),
)
// For other devices: Question mark with padding
: const Center(
child: Text(
'?',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white70,
),
),
),
),
),
),
@ -84,14 +101,16 @@ class DeviceListItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
isUnknownDevice ? 'Unknown Device' : deviceName,
deviceName.isEmpty ? 'Unknown Device' : deviceName,
style: TextStyle(
fontSize: 16,
fontWeight:
isUnknownDevice ? FontWeight.normal : FontWeight.w500,
fontStyle:
isUnknownDevice ? FontStyle.italic : FontStyle.normal,
color: isUnknownDevice
fontWeight: deviceName.isEmpty
? FontWeight.normal
: FontWeight.w500,
fontStyle: deviceName.isEmpty
? FontStyle.italic
: FontStyle.normal,
color: deviceName.isEmpty
? theme.hintColor
: theme.textTheme.bodyLarge?.color,
),
@ -108,6 +127,19 @@ class DeviceListItem extends StatelessWidget {
],
),
),
// Add spinner if connecting (Add this block)
if (isConnecting)
Padding(
padding: const EdgeInsets.only(left: 12.0), // Add some spacing
child: SizedBox(
width: 20, // Define spinner size
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2.0), // Use a small spinner
),
)
else if (trailing != null)
trailing!,
// Optional: Add an icon or button on the far right if needed later
// Icon(Icons.chevron_right, color: theme.hintColor),
],