init
This commit is contained in:
79
lib/bottom_navigation_widget.dart
Normal file
79
lib/bottom_navigation_widget.dart
Normal file
@ -0,0 +1,79 @@
|
||||
import 'package:fengshui_compass/components/my_icon.dart';
|
||||
import 'package:fengshui_compass/pages/personal_page.dart';
|
||||
import 'package:fengshui_compass/utils/sp_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fengshui_compass/pages/birthcal_page.dart';
|
||||
import 'package:fengshui_compass/pages/compass_page.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class BottomNavigationWidget extends StatefulWidget {
|
||||
const BottomNavigationWidget({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<BottomNavigationWidget> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<BottomNavigationWidget> {
|
||||
int currentIndex = 0;
|
||||
List<Widget> list = [];
|
||||
|
||||
@override
|
||||
Future<void> initState() {
|
||||
list
|
||||
..add(const CompassPage())
|
||||
..add(BirthCalPage())
|
||||
..add(const PersonalPage());
|
||||
super.initState();
|
||||
//
|
||||
Future.delayed(Duration.zero, () {
|
||||
initSP();
|
||||
});
|
||||
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||
}
|
||||
|
||||
void initSP() async {
|
||||
await SPUtil.init();
|
||||
}
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
setState(() {
|
||||
currentIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
extendBody: true,
|
||||
body: list[currentIndex],
|
||||
bottomNavigationBar: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(24.0),
|
||||
topRight: Radius.circular(24.0),
|
||||
),
|
||||
child: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
currentIndex: currentIndex,
|
||||
selectedItemColor: const Color.fromRGBO(237, 173, 89, 1.0), // 抽出单独定义
|
||||
onTap: _onItemTapped,
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(MyIcons.icon_luopan, size: 30),
|
||||
label: '在线罗盘',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(MyIcons.icon_zaixianqiju_, size: 30),
|
||||
label: '在线起局',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person, size: 30),
|
||||
label: '我的',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user