pikapika/lib/screens/AppScreen.dart

56 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
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> {
static const List<Widget> _widgetOptions = <Widget>[
const CategoriesScreen(),
const SpaceScreen(),
];
static const _navigationItems = <BottomNavigationBarItem>[
const BottomNavigationBarItem(
icon: Icon(Icons.public),
label: '浏览',
),
const BottomNavigationBarItem(
icon: Icon(Icons.face),
label: '我的',
),
];
late int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _selectedIndex,
children: _widgetOptions,
),
bottomNavigationBar: BottomNavigationBar(
items: _navigationItems,
currentIndex: _selectedIndex,
iconSize: 20,
selectedFontSize: 12,
unselectedFontSize: 12,
onTap: _onItemTapped,
),
);
}
}