更新
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
|
import 'package:ef/ef.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart';
|
import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/MattressControl.dart';
|
import 'package:vbvs_app/pages/mh_page/MattressControl.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/homepage/mht_sleep_report_page.dart';
|
import 'package:vbvs_app/pages/mh_page/homepage/mht_sleep_report_page.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/homepage/new_Home_page.dart';
|
import 'package:vbvs_app/pages/mh_page/homepage/new_Home_page.dart';
|
||||||
import 'package:vbvs_app/pages/mh_page/new_mine_page.dart';
|
import 'package:vbvs_app/pages/mh_page/new_mine_page.dart';
|
||||||
|
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||||
|
|
||||||
class MainPageBBottomChange extends StatefulWidget {
|
class MainPageBBottomChange extends StatefulWidget {
|
||||||
// 全局 key,用于静态访问 _HomePageState
|
// 全局 key,用于静态访问 _HomePageState
|
||||||
static final GlobalKey<_HomePageState> globalKey = GlobalKey<_HomePageState>();
|
static final GlobalKey<_HomePageState> globalKey =
|
||||||
|
GlobalKey<_HomePageState>();
|
||||||
|
|
||||||
MainPageBBottomChange({Key? key}) : super(key: globalKey);
|
MainPageBBottomChange({Key? key}) : super(key: globalKey);
|
||||||
|
|
||||||
// 静态方法:外部调用,跳转 tab
|
// 静态方法:外部调用,跳转 tab
|
||||||
static void jumpTo(int index) {
|
static void jumpTo(int index) {
|
||||||
@@ -23,7 +26,6 @@ class MainPageBBottomChange extends StatefulWidget {
|
|||||||
_HomePageState createState() => _HomePageState();
|
_HomePageState createState() => _HomePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _HomePageState extends State<MainPageBBottomChange>
|
class _HomePageState extends State<MainPageBBottomChange>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
@@ -68,6 +70,7 @@ class _HomePageState extends State<MainPageBBottomChange>
|
|||||||
|
|
||||||
void _onTabTapped(int index) {
|
void _onTabTapped(int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
dealWebSource(index);
|
||||||
final begin = currentPosition;
|
final begin = currentPosition;
|
||||||
final end = index.toDouble();
|
final end = index.toDouble();
|
||||||
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
||||||
@@ -110,21 +113,31 @@ class _HomePageState extends State<MainPageBBottomChange>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void switchTab(int index) {
|
void switchTab(int index) {
|
||||||
final begin = currentPosition;
|
final begin = currentPosition;
|
||||||
final end = index.toDouble();
|
final end = index.toDouble();
|
||||||
|
|
||||||
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
||||||
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||||
)..addListener(() {
|
)..addListener(() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
_controller.forward(from: 0.0);
|
||||||
|
currentPosition = end;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
selectedIndex = index;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
_controller.forward(from: 0.0);
|
|
||||||
currentPosition = end;
|
Future<void> dealWebSource(int index) async {
|
||||||
|
WebviewTestController webviewTestController = Get.find();
|
||||||
setState(() {
|
if (index == 2) {
|
||||||
selectedIndex = index;
|
await webviewTestController.web.jsbridge?.dart
|
||||||
});
|
.pageActive();
|
||||||
}
|
}else{
|
||||||
|
await webviewTestController.web.jsbridge?.dart
|
||||||
|
.pageInActive();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,17 +67,12 @@ class _MHTWifiPageState extends State<MHTWifiPage> {
|
|||||||
blueteethBindController.updateAll();
|
blueteethBindController.updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
_cleanupResources();
|
_cleanupResources();
|
||||||
try {
|
_disconnectDevice();
|
||||||
THapp bledevice = THapp(device: widget.deviceInfo.scanResult.device);
|
|
||||||
bledevice.disconnect();
|
|
||||||
DailyLogUtils.writeLog("关闭蓝牙连接成功");
|
|
||||||
} catch (e) {
|
|
||||||
DailyLogUtils.writeError("关闭蓝牙连接失败");
|
|
||||||
}
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,4 +1100,14 @@ class _MHTWifiPageState extends State<MHTWifiPage> {
|
|||||||
onFailure: (res) {},
|
onFailure: (res) {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _disconnectDevice() async {
|
||||||
|
try {
|
||||||
|
THapp bledevice = THapp(device: widget.deviceInfo.scanResult.device);
|
||||||
|
await bledevice.disconnect();
|
||||||
|
DailyLogUtils.writeLog("关闭蓝牙连接成功");
|
||||||
|
} catch (e) {
|
||||||
|
DailyLogUtils.writeError("关闭蓝牙连接失败: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:ef/ef.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||||
|
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||||
@@ -80,17 +81,17 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
|
|||||||
WebviewTestController webviewTestController = Get.find();
|
WebviewTestController webviewTestController = Get.find();
|
||||||
var future = webviewTestController.web.jsbridge?.dart
|
var future = webviewTestController.web.jsbridge?.dart
|
||||||
.appToHtmlDevice(device);
|
.appToHtmlDevice(device);
|
||||||
Future.delayed(Duration(seconds: 5), () {
|
Future.delayed(Duration(seconds: 5), () {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
await future;
|
||||||
await future;
|
await webviewTestController.web.jsbridge?.dart
|
||||||
|
.pageActive();
|
||||||
MainPageBBottomChange.jumpTo(2);
|
MainPageBBottomChange.jumpTo(2);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("发生异常: $e");
|
DailyLogUtils.writeError("发生异常: $e");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
colors:
|
colors:
|
||||||
AppConstants().mhtButtongradientColors, // 你原本没有渐变,单色即可
|
AppConstants().mhtButtongradientColors, // 你原本没有渐变,单色即可
|
||||||
enableGradient: true, // 关闭渐变
|
enableGradient: true, // 关闭渐变
|
||||||
|
|||||||
Reference in New Issue
Block a user