61 lines
1.6 KiB
Dart
61 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:chatting/chatting_page.dart';
|
|
import 'package:chatting/chatting_friend.dart';
|
|
import 'package:chatting/discover_page.dart';
|
|
import 'package:chatting/personal_page.dart';
|
|
|
|
class App extends StatefulWidget {
|
|
@override
|
|
_AppState createState() => _AppState();
|
|
}
|
|
|
|
class _AppState extends State<App> {
|
|
|
|
final List<BottomNavigationBarItem> bottomTabs = [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(IconData(0xe608,fontFamily: 'appIconFonts')), title: Text('聊天')),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(IconData(0xe601,fontFamily: 'appIconFonts')), title: Text('好友')),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(IconData(0xe600,fontFamily: 'appIconFonts')), title: Text('发现')),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(IconData(0xe607,fontFamily: 'appIconFonts')), title: Text('我的')),
|
|
];
|
|
|
|
final List tabBodies = [
|
|
ChattingPage(),
|
|
ChattinFriendPage(),
|
|
DiscoverPage(),
|
|
PersonalPage()
|
|
];
|
|
|
|
int currentIndex = 0;
|
|
var currentPage;
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
currentPage = tabBodies[currentIndex];
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Color.fromRGBO(244, 245, 245, 1.0),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
type: BottomNavigationBarType.fixed,
|
|
currentIndex: currentIndex,
|
|
items: bottomTabs,
|
|
onTap: (index) {
|
|
setState(() {
|
|
currentIndex = index;
|
|
currentPage = tabBodies[currentIndex];
|
|
});
|
|
},
|
|
),
|
|
body: currentPage,
|
|
);
|
|
}
|
|
} |