79 lines
2.0 KiB
Dart
79 lines
2.0 KiB
Dart
import 'package:chat/configs/app_colors.dart';
|
|
import 'package:chat/services/tabbar_service.dart';
|
|
import 'package:chat/views/home/index_page.dart';
|
|
import 'package:chat/views/moments/index/index_page.dart';
|
|
import 'package:chat/views/user/index/user_page.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:proste_indexed_stack/proste_indexed_stack.dart';
|
|
|
|
class AppPage extends StatelessWidget {
|
|
AppPage({Key? key}) : super(key: key);
|
|
|
|
final List<IndexedStackChild> _tabBarPageList = [
|
|
IndexedStackChild(child: const HomePage()),
|
|
IndexedStackChild(child: const MomentsPage()),
|
|
IndexedStackChild(child: const UserPage()),
|
|
];
|
|
|
|
final List<Map> _tabBarList = [
|
|
{
|
|
'icon': 'tabBar_03.png',
|
|
'label': '首页',
|
|
},
|
|
{
|
|
'icon': 'tabBar_03.png',
|
|
'label': '首页',
|
|
},
|
|
{
|
|
'icon': 'tabBar_03.png',
|
|
'label': '首页',
|
|
},
|
|
];
|
|
|
|
Widget _bottomNavigationBar() {
|
|
return GetX<TabbarService>(
|
|
builder: (_) {
|
|
return BottomNavigationBar(
|
|
currentIndex: _.index,
|
|
onTap: (index) {
|
|
_.index = index;
|
|
},
|
|
items: _tabBarList.map((item) {
|
|
return BottomNavigationBarItem(
|
|
icon: Image.asset(
|
|
'assets/icons/${item['icon']}',
|
|
width: 20,
|
|
height: 20,
|
|
),
|
|
activeIcon: Image.asset(
|
|
'assets/icons/${item['icon']}',
|
|
color: AppColors.primary,
|
|
width: 20,
|
|
height: 20,
|
|
),
|
|
label: item['label'],
|
|
tooltip: '',
|
|
);
|
|
}).toList(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: GetX<TabbarService>(
|
|
builder: (_) {
|
|
return ProsteIndexedStack(
|
|
index: _.index,
|
|
children: _tabBarPageList,
|
|
);
|
|
},
|
|
),
|
|
bottomNavigationBar: _bottomNavigationBar(),
|
|
);
|
|
}
|
|
}
|