feat:增加记录对话框内容
This commit is contained in:
100
lib/pages/home_page.dart
Normal file
100
lib/pages/home_page.dart
Normal file
@@ -0,0 +1,100 @@
|
||||
import 'package:fitnote/layout/app_navbar.dart';
|
||||
import 'package:fitnote/modesl/menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _currentPageIndex = 0;
|
||||
late PageController _pageController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_pageController = PageController(initialPage: _currentPageIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildLeading() {
|
||||
return Builder(
|
||||
builder:
|
||||
(context) => IconButton(
|
||||
icon: Icon(Icons.menu, color: Colors.white),
|
||||
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBarTitle() {
|
||||
return Text(
|
||||
pages[_currentPageIndex].title,
|
||||
style: TextStyle(color: Colors.white),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPageView() {
|
||||
return PageView(
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
_currentPageIndex = index;
|
||||
});
|
||||
},
|
||||
children: pageWidgets,
|
||||
);
|
||||
}
|
||||
|
||||
void _onTapNavbarItem(int index) {
|
||||
setState(() {
|
||||
_currentPageIndex = index;
|
||||
});
|
||||
_pageController.animateToPage(
|
||||
index,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
|
||||
void onTapDrawerItem(int index) {
|
||||
setState(() {
|
||||
_currentPageIndex = index;
|
||||
});
|
||||
_pageController.animateToPage(
|
||||
index,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: _buildAppBarTitle(),
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
elevation: 0,
|
||||
leading: _buildLeading(),
|
||||
),
|
||||
// drawer: AppDrawer(
|
||||
// currentPageIndex: _currentPageIndex,
|
||||
// onTapDrawerItem: onTapDrawerItem,
|
||||
// ),
|
||||
body: Padding(padding: EdgeInsets.all(10), child: _buildPageView()),
|
||||
bottomNavigationBar: AppNavbar(
|
||||
currentPageIndex: _currentPageIndex,
|
||||
onTapNavbarItem: _onTapNavbarItem,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user