更新
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.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/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/new_mine_page.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||
|
||||
class MainPageBBottomChange extends StatefulWidget {
|
||||
// 全局 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
|
||||
static void jumpTo(int index) {
|
||||
@@ -23,7 +26,6 @@ class MainPageBBottomChange extends StatefulWidget {
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
|
||||
class _HomePageState extends State<MainPageBBottomChange>
|
||||
with SingleTickerProviderStateMixin {
|
||||
int selectedIndex = 0;
|
||||
@@ -68,6 +70,7 @@ class _HomePageState extends State<MainPageBBottomChange>
|
||||
|
||||
void _onTabTapped(int index) {
|
||||
setState(() {
|
||||
dealWebSource(index);
|
||||
final begin = currentPosition;
|
||||
final end = index.toDouble();
|
||||
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
||||
@@ -110,21 +113,31 @@ class _HomePageState extends State<MainPageBBottomChange>
|
||||
}
|
||||
|
||||
void switchTab(int index) {
|
||||
final begin = currentPosition;
|
||||
final end = index.toDouble();
|
||||
final begin = currentPosition;
|
||||
final end = index.toDouble();
|
||||
|
||||
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||
)..addListener(() {
|
||||
setState(() {});
|
||||
_positionAnimation = Tween<double>(begin: begin, end: end).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||
)..addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
_controller.forward(from: 0.0);
|
||||
currentPosition = end;
|
||||
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
|
||||
_controller.forward(from: 0.0);
|
||||
currentPosition = end;
|
||||
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Future<void> dealWebSource(int index) async {
|
||||
WebviewTestController webviewTestController = Get.find();
|
||||
if (index == 2) {
|
||||
await webviewTestController.web.jsbridge?.dart
|
||||
.pageActive();
|
||||
}else{
|
||||
await webviewTestController.web.jsbridge?.dart
|
||||
.pageInActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user