105 lines
2.6 KiB
Dart
105 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:wgshare/pages/userPage/user_logic.dart';
|
|
import 'package:wgshare/pages/userPage/user_view.dart';
|
|
|
|
import '../utils/color_util.dart';
|
|
import 'homePage/home_logic.dart';
|
|
import 'homePage/home_view.dart';
|
|
import 'start_page_logic.dart';
|
|
import 'start_page_state.dart';
|
|
|
|
class StartPage extends StatefulWidget {
|
|
const StartPage({super.key});
|
|
|
|
@override
|
|
State<StartPage> createState() => _StartPageState();
|
|
}
|
|
|
|
class _StartPageState extends State<StartPage> {
|
|
|
|
final StartPageLogic logic = Get.put(StartPageLogic());
|
|
final StartPageState state = Get.find<StartPageLogic>().state;
|
|
|
|
final List<BottomNavigationBarItem> bottomNavItems = [
|
|
BottomNavigationBarItem(
|
|
icon: Image.asset(
|
|
'assets/images/home_index_select_n.png',
|
|
width: 22,
|
|
height: 22,
|
|
),
|
|
activeIcon: Image.asset(
|
|
'assets/images/home_index_select_y.png',
|
|
width: 22,
|
|
height: 22,
|
|
),
|
|
label: "首页",
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Image.asset(
|
|
'assets/images/home_user_select_n.png',
|
|
width: 22,
|
|
height: 22,
|
|
),
|
|
activeIcon: Image.asset(
|
|
'assets/images/home_user_select_y.png',
|
|
width: 22,
|
|
height: 22,
|
|
),
|
|
label: "我的",
|
|
),
|
|
];
|
|
|
|
|
|
late final List<Widget> pages;
|
|
|
|
@override
|
|
void initState() {
|
|
|
|
Get.put(HomeLogic());
|
|
Get.lazyPut(() => HomeLogic());
|
|
|
|
Get.put(UserLogic());
|
|
Get.lazyPut(() => UserLogic());
|
|
|
|
pages = [
|
|
HomePage(),
|
|
UserPage(),
|
|
];
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
bottomNavigationBar: Theme(
|
|
data: ThemeData(
|
|
splashColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
),
|
|
child: Obx(() => BottomNavigationBar(
|
|
items: bottomNavItems,
|
|
currentIndex: state.currentIndex.value,
|
|
type: BottomNavigationBarType.fixed,
|
|
backgroundColor: Colors.white,
|
|
selectedFontSize: 14,
|
|
selectedItemColor: ColorUtil.Color_85_117_242,
|
|
unselectedFontSize: 14,
|
|
unselectedItemColor: ColorUtil.Color_80_87_103,
|
|
onTap: (index) {
|
|
if(index != state.currentIndex.value){
|
|
state.currentIndex.value = index;
|
|
}
|
|
},
|
|
)),
|
|
),
|
|
body: Obx(() => pages[state.currentIndex.value])
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
Get.delete<StartPageLogic>();
|
|
super.dispose();
|
|
}
|
|
}
|