基本完成

This commit is contained in:
zhutao
2025-08-28 16:27:56 +08:00
commit 5d7d233d2e
132 changed files with 6390 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';
import '../page/home/home_page.dart';
import '../page/profile/my/my_page.dart';
import '../page/record/list/record_list_page.dart';
import 'tabbar.dart';
class LayoutPage extends StatefulWidget {
const LayoutPage({super.key});
@override
State<LayoutPage> createState() => _LayoutPageState();
}
class _LayoutPageState extends State<LayoutPage> {
///分页
final PageController _pageController = PageController(initialPage: 0);
int get currentPage {
if (!_pageController.hasClients) return 1; // 没 attach 直接 0
return _pageController.page?.round() ?? 1;
}
//TabBar列表
final List<PageItem> _pages = [
PageItem(
name: "Home",
icon: RemixIcons.home_2_line,
page: HomePage(),
),
PageItem(name: "record", icon: RemixIcons.history_line, page: RecordListPage()),
PageItem(
name: "Home",
icon: RemixIcons.book_open_line,
page: MyPage(),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: PageView(
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
children: _pages.map((item) => item.page).toList(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentPage,
onTap: (index) {
_pageController.jumpToPage(index);
setState(() {});
},
items: _pages.map((item) {
return BottomNavigationBarItem(
icon: Icon(item.icon),
label: item.name,
);
}).toList(),
showSelectedLabels: false,
showUnselectedLabels: false,
),
);
}
}

9
lib/layout/tabbar.dart Normal file
View File

@@ -0,0 +1,9 @@
import 'package:flutter/material.dart';
class PageItem {
final String name;
final IconData icon;
final Widget page;
PageItem({required this.name, required this.icon, required this.page});
}