From c392cd8c90a0f61f100c7ed43528e3464ce20416 Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 7 Apr 2026 16:29:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=AB=E4=B8=80=E6=89=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/img/icon/album.svg | 1 + assets/img/icon/light.svg | 1 + lib/pages/device/BodyDeviceWidget.dart | 34 ++- .../device_bind/MobileScannerTestPage.dart | 251 ++++++++++-------- lib/pages/main_bottom/home_page.dart | 59 ++-- 5 files changed, 210 insertions(+), 136 deletions(-) create mode 100644 assets/img/icon/album.svg create mode 100644 assets/img/icon/light.svg diff --git a/assets/img/icon/album.svg b/assets/img/icon/album.svg new file mode 100644 index 0000000..a1ddefc --- /dev/null +++ b/assets/img/icon/album.svg @@ -0,0 +1 @@ +资源 407 \ No newline at end of file diff --git a/assets/img/icon/light.svg b/assets/img/icon/light.svg new file mode 100644 index 0000000..2a61fab --- /dev/null +++ b/assets/img/icon/light.svg @@ -0,0 +1 @@ +资源 406 \ No newline at end of file diff --git a/lib/pages/device/BodyDeviceWidget.dart b/lib/pages/device/BodyDeviceWidget.dart index b56850f..a73ff0c 100644 --- a/lib/pages/device/BodyDeviceWidget.dart +++ b/lib/pages/device/BodyDeviceWidget.dart @@ -90,10 +90,40 @@ class _BodyDevicePageState extends State { themeController.currentColor.sc16.withOpacity(0.1), borderRadius: 0.rpx, onTap: () { - _hidePopup(); + _popupEntry?.remove(); + _popupEntry = null; + // TopSlideNotification.show( + // context, + // text: "待开发功能".tr, + // ); + Get.toNamed("/qrView"); + }, + child: Container( + width: double.infinity, + child: Center( + child: Text( + '扫一扫.标题'.tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3, + ), + ), + ), + ), + ), + SizedBox(height: 35.rpx), + ClickableContainer( + padding: EdgeInsets.symmetric(vertical: 10.rpx), + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc16.withOpacity(0.1), + borderRadius: 0.rpx, + onTap: () { + _popupEntry?.remove(); + _popupEntry = null; BlueteethBindController blueteethBindController = Get.find(); - blueteethBindController.returnPage = 1; + blueteethBindController.returnPage = 0; Get.toNamed("/deviceType"); }, child: Container( diff --git a/lib/pages/device_bind/MobileScannerTestPage.dart b/lib/pages/device_bind/MobileScannerTestPage.dart index 6c53f45..7779e81 100644 --- a/lib/pages/device_bind/MobileScannerTestPage.dart +++ b/lib/pages/device_bind/MobileScannerTestPage.dart @@ -1,5 +1,6 @@ import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:img_picker/img_picker.dart'; import 'package:mobile_scanner/mobile_scanner.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; @@ -22,6 +23,7 @@ class _MobileScannerTestPageState extends State with TickerProviderStateMixin { String? scannedText; bool isScanning = true; + bool isTorchOn = false; late AnimationController _controller; late Animation _animation; @@ -87,7 +89,6 @@ class _MobileScannerTestPageState extends State }, onCancel: () { print('用户点击了取消'); - // 执行取消后的处理逻辑 }, ); } @@ -101,15 +102,32 @@ class _MobileScannerTestPageState extends State } } + void _toggleTorch() async { + await _scannerController.toggleTorch(); + setState(() { + isTorchOn = !isTorchOn; + }); + } + + Future _pickImageFromGallery() async { + final picker = ImagePicker(); + final pickedFile = await picker.pickImage(source: ImageSource.gallery); + if (pickedFile != null) { + final bytes = await pickedFile.readAsBytes(); + final image = await decodeImageFromList(bytes); + // 处理相册图片扫码逻辑 + } + } + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( systemOverlayStyle: SystemUiOverlayStyle( - statusBarColor: Colors.transparent, // 状态栏背景色 - statusBarIconBrightness: Brightness.light, // 图标颜色(Android) - statusBarBrightness: Brightness.light, // 图标颜色(iOS) + statusBarColor: Colors.transparent, + statusBarIconBrightness: Brightness.light, + statusBarBrightness: Brightness.light, ), backgroundColor: themeController.currentColor.sc17, automaticallyImplyLeading: false, @@ -139,122 +157,145 @@ class _MobileScannerTestPageState extends State ), centerTitle: false, ), - body: Container( - child: Column( - children: [ - Expanded( - child: Stack( - children: [ - MobileScanner( - controller: _scannerController, - onDetect: _onDetect, - ), - Align( - alignment: Alignment.topCenter, // 使扫描框位于顶部居中 - child: Column( - mainAxisSize: MainAxisSize.min, + body: Stack( + children: [ + // 扫描区域(全屏) + MobileScanner( + controller: _scannerController, + onDetect: _onDetect, + ), + + // 扫描框和提示(顶部)- 使用 Positioned 更精确 + Positioned( + top: 0, + left: 0, + right: 0, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: EdgeInsets.only(top: 219.rpx), + child: SizedBox( + width: scanAreaSize, + height: scanAreaSize, + child: Stack( children: [ - Padding( - padding: EdgeInsets.only(top: 219.rpx), // 向上移动扫描框 - child: SizedBox( - width: scanAreaSize, - height: scanAreaSize, - child: Stack( - children: [ - Container( - decoration: BoxDecoration( - color: themeController.currentColor.sc5, - ), - ), - AnimatedBuilder( - animation: _animation, - builder: (context, child) { - return Positioned( - top: scanAreaSize * _animation.value, - left: 0, - right: 0, - child: Container( - height: 2, - color: themeController.currentColor.sc2, - ), - ); - }, - ), - ], - ), + Container( + decoration: BoxDecoration( + color: themeController.currentColor.sc5, ), ), - SizedBox(height: 31.rpx), - Text( - '扫一扫.提示'.tr, - style: TextStyle( - color: themeController.currentColor.sc2, - fontSize: 26.rpx, - ), + AnimatedBuilder( + animation: _animation, + builder: (context, child) { + return Positioned( + top: scanAreaSize * _animation.value, + left: 0, + right: 0, + child: Container( + height: 1.rpx, + color: themeController.currentColor.sc2, + ), + ); + }, ), ], ), ), - ], - ), + ), + SizedBox(height: 31.rpx), + Text( + '扫一扫.提示'.tr, + style: TextStyle( + color: themeController.currentColor.sc2, + fontSize: 26.rpx, + ), + ), + ], ), - Padding( - padding: EdgeInsets.fromLTRB(0, 0, 0, 83.rpx), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () async { - final picker = ImagePicker(); - final pickedFile = - await picker.pickImage(source: ImageSource.gallery); - if (pickedFile != null) { - final bytes = await pickedFile.readAsBytes(); - final image = await decodeImageFromList(bytes); - } - }, - child: Column( - children: [ - Icon(Icons.photo, - color: themeController.currentColor.sc2, - size: 60.rpx), - SizedBox(height: 10.rpx), - Text( - '扫一扫.相册'.tr, - style: TextStyle( - color: themeController.currentColor.sc2, - fontSize: 24.rpx, + ), + + // 底部按钮区域 - 使用 Positioned 固定在底部 + Positioned( + bottom: 83.rpx, + left: 0, + right: 0, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: _pickImageFromGallery, + child: Column( + children: [ + Container( + width: 91.rpx, + height: 91.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + color: stringToColor("#242835"), + ), + child: Center( + child: SvgPicture.asset( + width: 34.rpx, + height: 26.rpx, + 'assets/img/icon/album.svg', + fit: BoxFit.cover, + color: themeController.currentColor.sc3, ), ), - ], - ), + ), + SizedBox(height: 10.rpx), + Text( + '扫一扫.相册'.tr, + style: TextStyle( + color: themeController.currentColor.sc3, + fontSize: 24.rpx, + ), + ), + ], ), - SizedBox(width: 80.rpx), - GestureDetector( - onTap: () { - _scannerController.toggleTorch(); - }, - child: Column( - children: [ - Icon(Icons.flashlight_on, - color: themeController.currentColor.sc2, - size: 60.rpx), - SizedBox(height: 10.rpx), - Text( - '扫一扫.手电筒'.tr, - style: TextStyle( - color: themeController.currentColor.sc2, - fontSize: 24.rpx, + ), + SizedBox(width: 170.rpx), + GestureDetector( + onTap: _toggleTorch, + child: Column( + children: [ + Container( + width: 91.rpx, + height: 91.rpx, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50.rpx), + color: isTorchOn + ? themeController.currentColor.sc3 + : stringToColor("#242835"), + ), + child: Center( + child: SvgPicture.asset( + width: 26.rpx, + height: 36.rpx, + 'assets/img/icon/light.svg', + fit: BoxFit.cover, + color: isTorchOn + ? stringToColor("#242835") + : themeController.currentColor.sc3, ), ), - ], - ), + ), + SizedBox(height: 10.rpx), + Text( + '扫一扫.手电筒'.tr, + style: TextStyle( + color: themeController.currentColor.sc3, + fontSize: 24.rpx, + ), + ), + ], ), - ], - ), + ), + ], ), - ], - ), + ), + ], ), ); } diff --git a/lib/pages/main_bottom/home_page.dart b/lib/pages/main_bottom/home_page.dart index 993ebc5..ce17f50 100644 --- a/lib/pages/main_bottom/home_page.dart +++ b/lib/pages/main_bottom/home_page.dart @@ -94,35 +94,35 @@ class _HomePageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: 11.rpx), - // ClickableContainer( - // padding: EdgeInsets.symmetric(vertical: 10.rpx), - // backgroundColor: Colors.transparent, - // highlightColor: - // themeController.currentColor.sc16.withOpacity(0.1), - // borderRadius: 0.rpx, - // onTap: () { - // _popupEntry?.remove(); - // _popupEntry = null; - // TopSlideNotification.show( - // context, - // text: "待开发功能".tr, - // ); - // }, - // child: Container( - // width: double.infinity, - // child: Center( - // child: Text( - // '扫一扫.标题'.tr, - // style: TextStyle( - // fontSize: AppConstants().normal_text_fontSize, - // color: themeController.currentColor.sc3, - // ), - // ), - // ), - // ), - // ), - // SizedBox(height: 35.rpx), - + ClickableContainer( + padding: EdgeInsets.symmetric(vertical: 10.rpx), + backgroundColor: Colors.transparent, + highlightColor: + themeController.currentColor.sc16.withOpacity(0.1), + borderRadius: 0.rpx, + onTap: () { + _popupEntry?.remove(); + _popupEntry = null; + // TopSlideNotification.show( + // context, + // text: "待开发功能".tr, + // ); + Get.toNamed("/qrView"); + }, + child: Container( + width: double.infinity, + child: Center( + child: Text( + '扫一扫.标题'.tr, + style: TextStyle( + fontSize: AppConstants().normal_text_fontSize, + color: themeController.currentColor.sc3, + ), + ), + ), + ), + ), + SizedBox(height: 35.rpx), ClickableContainer( padding: EdgeInsets.symmetric(vertical: 10.rpx), backgroundColor: Colors.transparent, @@ -151,6 +151,7 @@ class _HomePageState extends State { ), ), SizedBox(height: 13.rpx), + ], ), ),