This commit is contained in:
tao
2025-08-29 13:36:26 +08:00
parent ec7848ad57
commit 6a9c801bd2
9 changed files with 75 additions and 44 deletions

View File

@@ -1,3 +1,4 @@
import 'package:derma_flutter/page/my/my_page.dart';
import 'package:derma_flutter/page/record/list/record_list_page.dart';
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';
@@ -15,30 +16,35 @@ class LayoutPage extends StatefulWidget {
class _LayoutPageState extends State<LayoutPage> {
///分页
final PageController _pageController = PageController(initialPage: 1);
final PageController _pageController = PageController(initialPage: 0);
int get currentPage {
if (!_pageController.hasClients) return 1; // 没 attach 直接 0
return _pageController.page?.round() ?? 1;
}
//tabbar列表
//TabBar列表
final List<PageItem> _pages = [
PageItem(
name: "record",
icon: RemixIcons.history_line,
page: RecordListPage(),
),
PageItem(
name: "Home",
icon: RemixIcons.home_2_line,
page: HomePage(),
),
PageItem(
name: "Home",
name: "Record",
icon: RemixIcons.history_line,
page: RecordListPage(),
),
PageItem(
name: "Book",
icon: RemixIcons.book_open_line,
page: EducationListPage(),
),
PageItem(
name: "My",
icon: RemixIcons.user_line,
page: MyPage(),
),
];
@override
@@ -50,6 +56,7 @@ class _LayoutPageState extends State<LayoutPage> {
children: _pages.map((item) => item.page).toList(),
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: currentPage,
onTap: (index) {
_pageController.jumpToPage(index);