feat:增加博客分类模块
This commit is contained in:
79
lib/layout/drawer.dart
Normal file
79
lib/layout/drawer.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'menu.dart';
|
||||
|
||||
Widget buildDrawerHeader(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [colors.primary, colors.inversePrimary],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/images/avatar.jpg',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Cxx0822',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildDrawerItem({
|
||||
required BuildContext context,
|
||||
required PageInfo page,
|
||||
required VoidCallback onTap,
|
||||
required bool isSelected,
|
||||
}) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? colors.primary.withAlpha(50) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
page.icon,
|
||||
color: isSelected ? colors.primary : Colors.grey[700],
|
||||
size: 24,
|
||||
),
|
||||
title: Text(
|
||||
page.title,
|
||||
style: TextStyle(
|
||||
color: isSelected ? colors.primary : Colors.grey[800],
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
trailing:
|
||||
isSelected
|
||||
? Icon(Icons.arrow_forward_ios, size: 16, color: colors.primary)
|
||||
: null,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
16
lib/layout/menu.dart
Normal file
16
lib/layout/menu.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageInfo {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
|
||||
const PageInfo({required this.title, required this.icon});
|
||||
}
|
||||
|
||||
final List<PageInfo> pages = [
|
||||
PageInfo(title: '博客', icon: Icons.article),
|
||||
PageInfo(title: '分类', icon: Icons.folder),
|
||||
PageInfo(title: '个人中心', icon: Icons.person),
|
||||
PageInfo(title: '设置', icon: Icons.settings),
|
||||
PageInfo(title: '关于我们', icon: Icons.info),
|
||||
];
|
||||
Reference in New Issue
Block a user