app-starlock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart

184 lines
5.6 KiB
Dart
Raw Normal View History

2024-04-15 14:09:23 +08:00
import 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/baseWidget.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_page.dart';
import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_logic.dart';
import 'package:star_lock/mine/mall/lockMall_page.dart';
import 'package:star_lock/mine/message/messageList/messageList_page.dart';
2024-04-29 10:45:49 +08:00
import 'package:star_lock/mine/message/messageList/messageList_xhj_page.dart';
2024-04-15 14:09:23 +08:00
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart';
2024-04-15 14:09:23 +08:00
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/submitBtn.dart';
2024-04-15 16:54:45 +08:00
import 'package:star_lock/translations/trans_lib.dart';
2024-04-15 14:09:23 +08:00
class StarLockMainXHJPage extends StatefulWidget {
const StarLockMainXHJPage({Key? key}) : super(key: key);
@override
State<StarLockMainXHJPage> createState() => _StarLockMainXHJPageState();
}
class _StarLockMainXHJPageState extends State<StarLockMainXHJPage>
with BaseWidget {
2024-04-15 14:09:23 +08:00
@override
void initState() {
super.initState();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
return GetBuilder<LockMainXHJLogic>(
init: LockMainXHJLogic(),
builder: (LockMainXHJLogic logic) {
return Scaffold(
2024-04-28 18:26:31 +08:00
backgroundColor: Colors.white,
body: Stack(
children: <Widget>[
2024-04-28 18:26:31 +08:00
pageView(
widget: StarLockMainPage(
showAppBar: false,
showDrawer: false,
2024-04-15 14:09:23 +08:00
),
2024-04-28 18:26:31 +08:00
logic: logic,
index: 0,
),
pageView(
widget: SafeArea(
bottom: false,
child: LockMallPage(
2024-04-29 11:25:39 +08:00
allowReturn: false,
2024-04-15 16:20:22 +08:00
),
),
2024-04-28 18:26:31 +08:00
logic: logic,
index: 1,
),
pageView(
widget: SafeArea(
bottom: false,
2024-04-29 10:45:49 +08:00
child: MessageListXHJPage(
2024-04-28 09:05:24 +08:00
showAppBar: false,
),
),
2024-04-28 18:26:31 +08:00
logic: logic,
index: 2,
),
pageView(
widget: SafeArea(
bottom: false,
child: MineSetPage(
2024-04-15 16:20:22 +08:00
showAppBar: false,
showAbout: true,
),
),
2024-04-28 18:26:31 +08:00
logic: logic,
index: 3,
),
],
2024-04-15 14:09:23 +08:00
),
bottomNavigationBar: Container(
2024-04-29 18:14:35 +08:00
padding: EdgeInsets.only(
top: 20.h, bottom: GetPlatform.isAndroid ? 20.h : 0),
2024-04-15 14:09:23 +08:00
decoration: const BoxDecoration(
color: Colors.transparent,
border: Border(
top: BorderSide(
color: Colors.black, // 设置边框颜色
width: 0.3, // 设置边框宽度
),
),
),
2024-04-18 16:27:56 +08:00
child: SafeArea(
top: false,
child: Row(
children: <Widget>[
2024-04-28 18:26:31 +08:00
navigationBarItem(Icons.key,
TranslationLoader.lanKeys!.device!.tr, logic, 0, () {
2024-04-18 16:27:56 +08:00
logic.setIndex(0);
}),
2024-04-28 09:05:24 +08:00
navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 1,
() {
2024-04-18 16:27:56 +08:00
logic.setIndex(1);
}),
2024-04-28 09:05:24 +08:00
navigationBarItem(Icons.message,
TranslationLoader.lanKeys!.message!.tr, logic, 2, () {
2024-04-18 16:27:56 +08:00
logic.setIndex(2);
}),
2024-04-28 09:05:24 +08:00
navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3,
() {
logic.setIndex(3);
}),
2024-04-18 16:27:56 +08:00
],
),
2024-04-15 14:09:23 +08:00
),
),
);
});
}
//布局
Widget pageView(
{required Widget widget,
required LockMainXHJLogic logic,
required int index}) {
return Positioned.fill(
child: Offstage(
offstage: logic.state.index != index,
child: widget,
),
);
}
//底部按钮
Widget navigationBarItem(IconData icon, String text, LockMainXHJLogic logic,
int index, GestureTapCallback? onTop) {
final bool check = logic.state.index == index;
2024-04-15 14:09:23 +08:00
return Expanded(
child: GestureDetector(
onTap: onTop,
child: Container(
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
2024-04-15 14:09:23 +08:00
Padding(
padding: EdgeInsets.only(bottom: 8.h),
child: Icon(
icon,
size: 32.r,
color:
check ? AppColors.mainColor : AppColors.darkGrayTextColor,
),
),
Text(
text,
style: TextStyle(
fontSize: 16.sp,
color:
check ? AppColors.mainColor : AppColors.darkGrayTextColor,
),
),
],
),
),
),
);
}
@override
void dispose() {
super.dispose();
}
}