2021-09-29 23:57:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-11-26 03:06:20 +00:00
|
|
|
import 'package:pikapika/basic/config/GuiAnimation.dart';
|
2021-11-11 09:05:48 +00:00
|
|
|
import 'package:pikapika/basic/config/Version.dart';
|
|
|
|
import 'package:pikapika/screens/components/Badge.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
import 'CategoriesScreen.dart';
|
|
|
|
import 'SpaceScreen.dart';
|
|
|
|
|
|
|
|
// MAIN UI 底部导航栏
|
|
|
|
class AppScreen extends StatefulWidget {
|
|
|
|
const AppScreen({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AppScreen> createState() => _AppScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AppScreenState extends State<AppScreen> {
|
2021-11-11 09:05:48 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
versionEvent.subscribe(_onVersion);
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
versionEvent.unsubscribe(_onVersion);
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onVersion(dynamic a) {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
2021-11-26 03:20:29 +00:00
|
|
|
static List<Widget> _widgetOptions = <Widget>[
|
|
|
|
CategoriesScreen(),
|
|
|
|
SpaceScreen(),
|
2021-09-29 23:57:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
late int _selectedIndex = 0;
|
2021-11-26 03:06:20 +00:00
|
|
|
PageController _pageController = PageController(initialPage: 0);
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
void _onItemTapped(int index) {
|
2021-11-26 03:06:20 +00:00
|
|
|
if (currentGuiAnimation()) {
|
|
|
|
_pageController.animateToPage(
|
|
|
|
index,
|
|
|
|
duration: Duration(milliseconds: 200),
|
|
|
|
curve: Curves.ease,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
_pageController.jumpToPage(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onPageChanged(int index) {
|
2021-09-29 23:57:09 +00:00
|
|
|
setState(() {
|
2021-11-26 03:06:20 +00:00
|
|
|
this._selectedIndex = index;
|
2021-09-29 23:57:09 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2021-11-26 03:06:20 +00:00
|
|
|
body: PageView(
|
|
|
|
controller: _pageController,
|
2021-09-29 23:57:09 +00:00
|
|
|
children: _widgetOptions,
|
2021-11-26 03:06:20 +00:00
|
|
|
onPageChanged: _onPageChanged,
|
2021-09-29 23:57:09 +00:00
|
|
|
),
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
2021-11-11 09:05:48 +00:00
|
|
|
items: <BottomNavigationBarItem>[
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.public),
|
|
|
|
label: '浏览',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Badged(
|
|
|
|
child: Icon(Icons.face),
|
|
|
|
badge: latestVersion() == null ? null : "1",
|
|
|
|
),
|
|
|
|
label: '我的',
|
|
|
|
),
|
|
|
|
],
|
2021-09-29 23:57:09 +00:00
|
|
|
currentIndex: _selectedIndex,
|
|
|
|
iconSize: 20,
|
|
|
|
selectedFontSize: 12,
|
|
|
|
unselectedFontSize: 12,
|
|
|
|
onTap: _onItemTapped,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|