|
|
|
@ -99,6 +99,8 @@ class PairingView extends GetView<PairingController> { |
|
|
|
return Obx(() { |
|
|
|
final state = controller.state; |
|
|
|
final isLoading = controller.isLoading.value; |
|
|
|
final isReadyToStart = controller.isReadyToStart.value; |
|
|
|
final isManualMode = controller.isManualMode.value; |
|
|
|
|
|
|
|
// 根据状态决定动画颜色 |
|
|
|
Color primaryColor = Color(0xFF0066CC); |
|
|
|
@ -115,6 +117,53 @@ class PairingView extends GetView<PairingController> { |
|
|
|
secondaryColor = Colors.greenAccent; |
|
|
|
} |
|
|
|
|
|
|
|
// 手动模式待机状态的特殊处理 |
|
|
|
if (isManualMode && isReadyToStart) { |
|
|
|
return Container( |
|
|
|
width: 240.w, |
|
|
|
height: 240.w, |
|
|
|
child: Stack( |
|
|
|
alignment: Alignment.center, |
|
|
|
children: [ |
|
|
|
// 静态背景圆圈 |
|
|
|
Container( |
|
|
|
width: 200.w, |
|
|
|
height: 200.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.topLeft, |
|
|
|
end: Alignment.bottomRight, |
|
|
|
colors: [ |
|
|
|
primaryColor.withOpacity(0.1), |
|
|
|
secondaryColor.withOpacity(0.1), |
|
|
|
], |
|
|
|
), |
|
|
|
shape: BoxShape.circle, |
|
|
|
), |
|
|
|
), |
|
|
|
// 设备图标 |
|
|
|
Container( |
|
|
|
width: 120.w, |
|
|
|
height: 120.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.topLeft, |
|
|
|
end: Alignment.bottomRight, |
|
|
|
colors: [primaryColor, secondaryColor], |
|
|
|
), |
|
|
|
shape: BoxShape.circle, |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
Icons.headphones, |
|
|
|
color: Colors.white, |
|
|
|
size: 60.w, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return Container( |
|
|
|
width: 240.w, |
|
|
|
height: 240.w, |
|
|
|
@ -254,10 +303,14 @@ class PairingView extends GetView<PairingController> { |
|
|
|
|
|
|
|
// 根据状态获取副标题 |
|
|
|
String _getSubtitleForState(PairingState state) { |
|
|
|
if (controller.isManualMode.value && controller.isReadyToStart.value) { |
|
|
|
return '点击下方按钮开始配对您的DeapSound设备'; |
|
|
|
} |
|
|
|
|
|
|
|
switch (state) { |
|
|
|
case PairingState.init: |
|
|
|
case PairingState.btReady: |
|
|
|
return '正在准备配对环境...'; |
|
|
|
return controller.isManualMode.value ? '准备开始配对' : '正在准备配对环境...'; |
|
|
|
case PairingState.classicOk: |
|
|
|
return '请先通过系统蓝牙连接DeapSound设备'; |
|
|
|
case PairingState.serverVerify: |
|
|
|
@ -364,17 +417,50 @@ class PairingView extends GetView<PairingController> { |
|
|
|
final showActionButton = controller.showActionButton; |
|
|
|
final canSkip = controller.canSkip; |
|
|
|
final actionButtonText = controller.actionButtonText.value; |
|
|
|
final isReadyToStart = controller.isReadyToStart.value; |
|
|
|
final isManualMode = controller.isManualMode.value; |
|
|
|
|
|
|
|
return Container( |
|
|
|
width: double.infinity, |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
// 主按钮 - 根据状态显示不同的按钮 |
|
|
|
if (showActionButton) |
|
|
|
// 手动模式:显示开始配对按钮 |
|
|
|
if (isManualMode && isReadyToStart) |
|
|
|
ElevatedButton( |
|
|
|
onPressed: () => controller.startManualPairing(), |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: Color(0xFF0066CC), |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
elevation: 0, |
|
|
|
minimumSize: Size(double.infinity, 56.h), |
|
|
|
), |
|
|
|
child: Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
Icon(Icons.bluetooth_searching, size: 20.w), |
|
|
|
SizedBox(width: 8.w), |
|
|
|
Text( |
|
|
|
'开始配对设备', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
// 原有的状态按钮(错误处理等) |
|
|
|
if (showActionButton && !isManualMode) |
|
|
|
ElevatedButton( |
|
|
|
onPressed: () => controller.handleActionButtonTap(), |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: _getButtonColor(controller.state, isDarkMode), |
|
|
|
backgroundColor: |
|
|
|
_getButtonColor(controller.state, isDarkMode), |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
@ -392,7 +478,7 @@ class PairingView extends GetView<PairingController> { |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
// 只在可以跳过时显示跳过按钮 |
|
|
|
// 跳过按钮和重置按钮 |
|
|
|
if (canSkip) ...[ |
|
|
|
SizedBox(height: 12.h), |
|
|
|
TextButton( |
|
|
|
@ -411,6 +497,24 @@ class PairingView extends GetView<PairingController> { |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
|
|
|
|
// 添加重置按钮(在错误状态下) |
|
|
|
if (!isManualMode && |
|
|
|
!controller.isLoading.value && |
|
|
|
controller.state.name.startsWith('exit')) ...[ |
|
|
|
SizedBox(height: 8.h), |
|
|
|
TextButton( |
|
|
|
onPressed: () => controller.resetToManualMode(), |
|
|
|
style: TextButton.styleFrom( |
|
|
|
foregroundColor: Colors.grey, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.h), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'重新配对', |
|
|
|
style: TextStyle(fontSize: 14.sp), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
|