factor:布局颜色重构
This commit is contained in:
@@ -43,7 +43,7 @@ class _BlogDetailPageState extends State<BlogDetailPage> {
|
||||
return FloatingActionButton(
|
||||
onPressed: () => setState(() => _showToc = !_showToc),
|
||||
mini: true,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
child: Icon(_showToc ? Icons.close : Icons.list, color: Colors.white),
|
||||
);
|
||||
} else {
|
||||
@@ -73,7 +73,11 @@ class _BlogDetailPageState extends State<BlogDetailPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
buildTocPanel(tocController: tocController, showToc: _showToc),
|
||||
buildTocPanel(
|
||||
context: context,
|
||||
tocController: tocController,
|
||||
showToc: _showToc,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,13 +80,14 @@ class _BlogPageState extends State<BlogPage> {
|
||||
if (provider.error != null) {
|
||||
return buildErrorInfo(
|
||||
errorInfo: provider.error!,
|
||||
onPressed: () => provider.refreshBlogList,
|
||||
onPressed: () => provider.refreshBlogList(),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
controller: _scrollController,
|
||||
itemCount: provider.blogList.length,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
final blog = provider.blogList[index];
|
||||
return InkWell(
|
||||
@@ -94,9 +95,6 @@ class _BlogPageState extends State<BlogPage> {
|
||||
child: BlogCard(blog: blog),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return SizedBox(height: 8);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,11 @@ class _CategoryPageState extends State<CategoryPage> {
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: provider.categoryList.length,
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
final category = provider.categoryList[index];
|
||||
return buildCategoryCard(context, category);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return SizedBox(height: 8);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:blog_app/apis/blog.dart';
|
||||
import 'package:blog_app/layout/drawer.dart';
|
||||
import 'package:blog_app/layout/app_drawer.dart';
|
||||
import 'package:blog_app/layout/app_navbar.dart';
|
||||
import 'package:blog_app/layout/menu.dart';
|
||||
import 'package:blog_app/layout/nav_bar.dart';
|
||||
import 'package:blog_app/models/blog.dart';
|
||||
import 'package:blog_app/widget/search.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -165,7 +165,7 @@ class _HomePageState extends State<HomePage> {
|
||||
return buildSearchResultList(context, _searchResults);
|
||||
}
|
||||
|
||||
void _onBottomNavTap(int index) {
|
||||
void _onTapNavbarItem(int index) {
|
||||
setState(() {
|
||||
_currentPageIndex = index;
|
||||
if (_isSearching) {
|
||||
@@ -194,37 +194,6 @@ class _HomePageState extends State<HomePage> {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
Widget _buildDrawerBody() {
|
||||
return ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
...List.generate(
|
||||
pages.length,
|
||||
(index) => buildDrawerItem(
|
||||
context: context,
|
||||
page: pages[index],
|
||||
isSelected: index == _currentPageIndex,
|
||||
onTap: () => onTapDrawerItem(index),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDrawer() {
|
||||
return Drawer(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
buildDrawerHeader(context),
|
||||
Expanded(child: _buildDrawerBody()),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -235,12 +204,14 @@ class _HomePageState extends State<HomePage> {
|
||||
leading: _buildLeading(),
|
||||
actions: _buildAppBarActions(),
|
||||
),
|
||||
drawer: _buildDrawer(),
|
||||
drawer: AppDrawer(
|
||||
currentPageIndex: _currentPageIndex,
|
||||
onTapDrawerItem: onTapDrawerItem,
|
||||
),
|
||||
body: Padding(padding: EdgeInsets.all(10), child: _buildPageView()),
|
||||
bottomNavigationBar: buildBottomNavigationBar(
|
||||
context: context,
|
||||
index: _currentPageIndex,
|
||||
onTap: _onBottomNavTap,
|
||||
bottomNavigationBar: AppNavbar(
|
||||
currentPageIndex: _currentPageIndex,
|
||||
onTapNavbarItem: _onTapNavbarItem,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,10 +76,8 @@ class StatsPageState extends State<StatsPage> {
|
||||
buildChartDivider(context),
|
||||
const SizedBox(height: 3),
|
||||
Expanded(
|
||||
child: barChart(
|
||||
child: rankChart(
|
||||
context: context,
|
||||
xAxisName: '名称',
|
||||
yAxisName: '访问量',
|
||||
unit: '人次',
|
||||
data: provider.visitRankStats,
|
||||
),
|
||||
@@ -114,10 +112,8 @@ class StatsPageState extends State<StatsPage> {
|
||||
buildChartDivider(context),
|
||||
const SizedBox(height: 3),
|
||||
Expanded(
|
||||
child: barChart(
|
||||
child: rankChart(
|
||||
context: context,
|
||||
xAxisName: '名称',
|
||||
yAxisName: '时长',
|
||||
unit: '分钟',
|
||||
data: provider.readRankStats,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user