Browse Source

refactor(图片资源): 替换默认耳机图片并优化图片显示逻辑

- 移除旧的headphone_new3.png和headphone_new4.png图片
- 新增defaultPicture.png和defaultPicture.jpg作为统一默认图片
- 修改图片显示逻辑,移除暗黑模式判断,使用统一图片
- 优化图片显示样式,使用cover模式并添加圆角
- 调整图片容器尺寸和间距
weicu
lxm 11 months ago
parent
commit
2fe25cd8d7
  1. BIN
      assets/images/DefaultPicture.jpg
  2. BIN
      assets/images/defaultPicture.png
  3. BIN
      assets/images/headphone_new3.png
  4. BIN
      assets/images/headphone_new4.png
  5. 4
      lib/modules/home/controllers/home_controller.dart
  6. 26
      lib/modules/home/views/home_view.dart
  7. 40
      lib/modules/ota_upgrade/views/ota_upgrade_view.dart
  8. 4
      pubspec.yaml

BIN
assets/images/DefaultPicture.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
assets/images/defaultPicture.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 KiB

BIN
assets/images/headphone_new3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 774 KiB

BIN
assets/images/headphone_new4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 KiB

4
lib/modules/home/controllers/home_controller.dart

@ -542,9 +542,7 @@ class HomeController extends GetxController {
} }
// 使用默认耳机图片 // 使用默认耳机图片
return isDarkMode return 'assets/images/defaultPicture.png';
? 'assets/images/headphone_new3.png'
: 'assets/images/headphone_new4.png';
} }
/// 判断是否为网络图片 /// 判断是否为网络图片

26
lib/modules/home/views/home_view.dart

@ -85,10 +85,12 @@ class HomeView extends GetView<HomeController> {
// 顶部标题栏 // 顶部标题栏
_buildAppBar(isDarkMode), _buildAppBar(isDarkMode),
SizedBox(height: 10.h),
// 顶部图片 // 顶部图片
_buildEarbudsImage(), _buildEarbudsImage(),
SizedBox(height: 20.h), SizedBox(height: 10.h),
// 设备状态卡片 // 设备状态卡片
IntroStepBuilder( IntroStepBuilder(
@ -229,7 +231,7 @@ class HomeView extends GetView<HomeController> {
Center( Center(
child: ClipRRect( child: ClipRRect(
// 添加 ClipRRect // 添加 ClipRRect
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(20.r),
child: GetBuilder<HomeController>( child: GetBuilder<HomeController>(
builder: (controller) { builder: (controller) {
final imagePath = controller.getDeviceImagePath(isDarkMode); final imagePath = controller.getDeviceImagePath(isDarkMode);
@ -238,16 +240,16 @@ class HomeView extends GetView<HomeController> {
return isNetwork return isNetwork
? Image.network( ? Image.network(
imagePath, imagePath,
width: double.infinity,
height: 220.h, height: 220.h,
fit: BoxFit.contain, fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) { errorBuilder: (context, error, stackTrace) {
// 网络图片加载失败时使用默认图片 // 网络图片加载失败时使用默认图片
return Image.asset( return Image.asset(
isDarkMode 'assets/images/defaultPicture.png',
? 'assets/images/headphone_new3.png' width: double.infinity,
: 'assets/images/headphone_new4.png',
height: 220.h, height: 220.h,
fit: BoxFit.contain, fit: BoxFit.cover,
); );
}, },
loadingBuilder: (context, child, loadingProgress) { loadingBuilder: (context, child, loadingProgress) {
@ -268,16 +270,16 @@ class HomeView extends GetView<HomeController> {
) )
: Image.asset( : Image.asset(
imagePath, imagePath,
width: double.infinity,
height: 220.h, height: 220.h,
fit: BoxFit.contain, fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) { errorBuilder: (context, error, stackTrace) {
// 本地图片加载失败时使用默认图片 // 本地图片加载失败时使用默认图片
return Image.asset( return Image.asset(
isDarkMode 'assets/images/defaultPicture.png',
? 'assets/images/headphone_new3.png' width: double.infinity,
: 'assets/images/headphone_new4.png',
height: 220.h, height: 220.h,
fit: BoxFit.contain, fit: BoxFit.cover,
); );
}, },
); );

40
lib/modules/ota_upgrade/views/ota_upgrade_view.dart

@ -173,7 +173,7 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
// 设备图标 // 设备图标
Widget _buildDeviceIcon(bool isDarkMode) { Widget _buildDeviceIcon(bool isDarkMode) {
return Container( return Container(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(6.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isDarkMode color: isDarkMode
? Colors.white.withValues(alpha: 0.05) ? Colors.white.withValues(alpha: 0.05)
@ -191,20 +191,28 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
final imagePath = controller.lastConnectedDeviceImage; final imagePath = controller.lastConnectedDeviceImage;
if (imagePath == null || imagePath.isEmpty) { if (imagePath == null || imagePath.isEmpty) {
return Image.asset( return ClipRRect(
isDarkMode borderRadius: BorderRadius.circular(12.r),
? 'assets/images/headphone_new3.png' child: SizedBox(
: 'assets/images/headphone_new4.png', width: 120.h,
height: 100.h, height: 120.h,
fit: BoxFit.contain, child: Image.asset(
'assets/images/defaultPicture.jpg',
fit: BoxFit.cover,
),
),
); );
} }
// 网络图片 // 网络图片(正方形裁剪)
return Image.network( return ClipRRect(
imagePath, borderRadius: BorderRadius.circular(16.r),
child: SizedBox(
width: 100.h,
height: 100.h, height: 100.h,
fit: BoxFit.contain, child: Image.network(
imagePath,
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) { loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child; if (loadingProgress == null) return child;
return SizedBox( return SizedBox(
@ -222,15 +230,13 @@ class OtaUpgradeView extends GetView<OtaUpgradeController> {
); );
}, },
errorBuilder: (context, error, stackTrace) { errorBuilder: (context, error, stackTrace) {
// 网络图片加载失败时使用默认图片
return Image.asset( return Image.asset(
isDarkMode 'assets/images/defaultPicture.jpg',
? 'assets/images/headphone_new3.png' fit: BoxFit.cover,
: 'assets/images/headphone_new4.png',
height: 100.h,
fit: BoxFit.contain,
); );
}, },
),
),
); );
}, },
), ),

4
pubspec.yaml

@ -142,8 +142,8 @@ flutter:
- assets/fonts/NotoSansSC-Regular.ttf - assets/fonts/NotoSansSC-Regular.ttf
- assets/lottie/ - assets/lottie/
- assets/js/ - assets/js/
- assets/images/headphone_new4.png - assets/images/defaultPicture.png
- assets/images/headphone_new3.png - assets/images/defaultPicture.jpg
- assets/images/qqmusic.png - assets/images/qqmusic.png
- assets/images/music.png - assets/images/music.png
- assets/weather/ - assets/weather/

Loading…
Cancel
Save