Compare commits
7 Commits
61922cbcd8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a10aae25e | |||
| f11b8d6a30 | |||
| e38e26e685 | |||
| 8f0f641d37 | |||
| 50d7657a93 | |||
| 59b439a8ac | |||
| 1132b78ecd |
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 6.5 KiB |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
android/app/src/main/res/mipmap-ldpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
android/app/src/main/res/mipmap-ldpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 3.2 KiB |
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 11 KiB |
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 22 KiB |
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 34 KiB |
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
@@ -1,13 +1,14 @@
|
|||||||
|
import 'package:blog_app/config/app_config.dart';
|
||||||
import 'package:blog_app/models/blog.dart';
|
import 'package:blog_app/models/blog.dart';
|
||||||
import 'package:blog_app/models/common.dart';
|
import 'package:flutter_common/models/common_model.dart';
|
||||||
import 'package:blog_app/utils/http_utils.dart';
|
import 'package:flutter_common/utils/convert_utils.dart';
|
||||||
import 'package:blog_app/utils/index.dart';
|
import 'package:flutter_common/utils/http_utils.dart';
|
||||||
|
|
||||||
Future<PageResult<Blog>> queryBlogByPageApi(int currentPage, int pageSize) {
|
Future<PageResult<Blog>> queryBlogByPageApi(int currentPage, int pageSize) {
|
||||||
return HttpUtil().get<PageResult<Blog>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<PageResult<Blog>>(
|
||||||
"/blog/page",
|
"/blog/page",
|
||||||
queryParameters: {"currentPage": currentPage, "pageSize": pageSize},
|
queryParameters: {"currentPage": currentPage, "pageSize": pageSize},
|
||||||
converter: (data) => convertPageResponse(data, Blog.fromJson),
|
converter: (data) => convertPage(data, Blog.fromJson),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,83 +29,74 @@ Future<List<Blog>> queryBlogByConditionApi(
|
|||||||
queryParams['year'] = year;
|
queryParams['year'] = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpUtil().get<List<Blog>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<Blog>>(
|
||||||
"/blog/condition",
|
"/blog/condition",
|
||||||
queryParameters: queryParams,
|
queryParameters: queryParams,
|
||||||
converter: (data) => convertListResponse<Blog>(data, Blog.fromJson),
|
converter: (data) => convertList<Blog>(data, Blog.fromJson),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<BlogSearch>> searchBlog(String keyword) {
|
Future<List<BlogSearch>> searchBlog(String keyword) {
|
||||||
return HttpUtil().get<List<BlogSearch>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<BlogSearch>>(
|
||||||
"/blog/search",
|
"/blog/search",
|
||||||
queryParameters: {"keyword": keyword},
|
queryParameters: {"keyword": keyword},
|
||||||
converter:
|
converter: (data) => convertList<BlogSearch>(data, BlogSearch.fromJson),
|
||||||
(data) => convertListResponse<BlogSearch>(data, BlogSearch.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Blog> queryBlogByIdApi(int id) {
|
Future<Blog> queryBlogByIdApi(int id) {
|
||||||
return HttpUtil().get<Blog>(
|
return HttpUtil(
|
||||||
"/blog/$id/content",
|
baseUrl: AppConfig.baseApiUrl,
|
||||||
converter: (data) => Blog.fromJson(data),
|
).get<Blog>("/blog/$id/content", converter: (data) => Blog.fromJson(data));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<BlogCategory>> queryBlogCategoryApi() {
|
Future<List<BlogCategory>> queryBlogCategoryApi() {
|
||||||
return HttpUtil().get<List<BlogCategory>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<BlogCategory>>(
|
||||||
"/blog/category",
|
"/blog/category",
|
||||||
converter:
|
converter: (data) => convertList<BlogCategory>(data, BlogCategory.fromJson),
|
||||||
(data) =>
|
|
||||||
convertListResponse<BlogCategory>(data, BlogCategory.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BlogStats> queryBlogOverviewStatsApi() {
|
Future<BlogStats> queryBlogOverviewStatsApi() {
|
||||||
return HttpUtil().get<BlogStats>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<BlogStats>(
|
||||||
"/stats/overview",
|
"/stats/overview",
|
||||||
converter: (data) => BlogStats.fromJson(data),
|
converter: (data) => BlogStats.fromJson(data),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ChartData>> queryBlogApprovedStatsApi(int year) {
|
Future<List<ChartData>> queryBlogApprovedStatsApi(int year) {
|
||||||
return HttpUtil().get<List<ChartData>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<ChartData>>(
|
||||||
"/stats/approved/monthly",
|
"/stats/approved/monthly",
|
||||||
queryParameters: {"year": year},
|
queryParameters: {"year": year},
|
||||||
converter:
|
converter: (data) => convertList<ChartData>(data, ChartData.fromJson),
|
||||||
(data) => convertListResponse<ChartData>(data, ChartData.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ChartData>> queryBlogVisitStatsApi(int year) {
|
Future<List<ChartData>> queryBlogVisitStatsApi(int year) {
|
||||||
return HttpUtil().get<List<ChartData>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<ChartData>>(
|
||||||
"/stats/visit/monthly",
|
"/stats/visit/monthly",
|
||||||
queryParameters: {"year": year},
|
queryParameters: {"year": year},
|
||||||
converter:
|
converter: (data) => convertList<ChartData>(data, ChartData.fromJson),
|
||||||
(data) => convertListResponse<ChartData>(data, ChartData.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ChartData>> queryBlogVisitRankStatsApi() {
|
Future<List<ChartData>> queryBlogVisitRankStatsApi() {
|
||||||
return HttpUtil().get<List<ChartData>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<ChartData>>(
|
||||||
"/stats/visit/rank",
|
"/stats/visit/rank",
|
||||||
converter:
|
converter: (data) => convertList<ChartData>(data, ChartData.fromJson),
|
||||||
(data) => convertListResponse<ChartData>(data, ChartData.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ChartData>> queryBlogCategoryStatsApi() {
|
Future<List<ChartData>> queryBlogCategoryStatsApi() {
|
||||||
return HttpUtil().get<List<ChartData>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<ChartData>>(
|
||||||
"/stats/category",
|
"/stats/category",
|
||||||
converter:
|
converter: (data) => convertList<ChartData>(data, ChartData.fromJson),
|
||||||
(data) => convertListResponse<ChartData>(data, ChartData.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<ChartData>> queryBlogReadRankStatsApi() {
|
Future<List<ChartData>> queryBlogReadRankStatsApi() {
|
||||||
return HttpUtil().get<List<ChartData>>(
|
return HttpUtil(baseUrl: AppConfig.baseApiUrl).get<List<ChartData>>(
|
||||||
"/stats/read/rank",
|
"/stats/read/rank",
|
||||||
converter:
|
converter: (data) => convertList<ChartData>(data, ChartData.fromJson),
|
||||||
(data) => convertListResponse<ChartData>(data, ChartData.fromJson),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
121
lib/layout/app_drawer.dart
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import 'package:blog_app/layout/menu.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_common/layout/theme_layout.dart';
|
||||||
|
|
||||||
|
class AppDrawer extends StatefulWidget {
|
||||||
|
final int currentPageIndex;
|
||||||
|
final Function(int) onTapDrawerItem;
|
||||||
|
|
||||||
|
const AppDrawer({
|
||||||
|
super.key,
|
||||||
|
required this.currentPageIndex,
|
||||||
|
required this.onTapDrawerItem,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AppDrawer> createState() => AppDrawerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppDrawerState extends State<AppDrawer> {
|
||||||
|
Widget _buildDrawerHeader() {
|
||||||
|
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.surface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDrawerBody() {
|
||||||
|
return ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
itemCount: pages.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||||
|
itemBuilder: (context, index) => _buildDrawerItem(index),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDrawerItem(int index) {
|
||||||
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
final isSelected = index == widget.currentPageIndex;
|
||||||
|
final boxColor =
|
||||||
|
isSelected ? colors.primary.withAlpha(50) : Colors.transparent;
|
||||||
|
final iconColor =
|
||||||
|
isSelected ? colors.primary : colors.onSurface.withAlpha(100);
|
||||||
|
final textColor =
|
||||||
|
isSelected ? colors.primary : colors.onSurface.withAlpha(200);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: boxColor,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(pages[index].icon, color: iconColor, size: 24),
|
||||||
|
title: Text(
|
||||||
|
pages[index].title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: textColor,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing:
|
||||||
|
isSelected
|
||||||
|
? Icon(Icons.arrow_forward_ios, size: 16, color: iconColor)
|
||||||
|
: null,
|
||||||
|
onTap: () => widget.onTapDrawerItem(index),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Drawer(
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildDrawerHeader(),
|
||||||
|
_buildDrawerBody(),
|
||||||
|
const Divider(),
|
||||||
|
ThemeLayout(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
lib/layout/app_navbar.dart
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:blog_app/layout/menu.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppNavbar extends StatefulWidget {
|
||||||
|
final int currentPageIndex;
|
||||||
|
final Function(int) onTapNavbarItem;
|
||||||
|
|
||||||
|
const AppNavbar({
|
||||||
|
super.key,
|
||||||
|
required this.currentPageIndex,
|
||||||
|
required this.onTapNavbarItem,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AppNavbar> createState() => AppNavbarState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppNavbarState extends State<AppNavbar> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return BottomNavigationBar(
|
||||||
|
currentIndex: widget.currentPageIndex,
|
||||||
|
onTap: widget.onTapNavbarItem,
|
||||||
|
items: bottomNavItems,
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
|
selectedItemColor: colors.primary,
|
||||||
|
unselectedItemColor: colors.onSurface.withAlpha(150),
|
||||||
|
showSelectedLabels: true,
|
||||||
|
showUnselectedLabels: true,
|
||||||
|
backgroundColor: colors.surface,
|
||||||
|
elevation: 8,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
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,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -20,3 +20,8 @@ final List<PageInfo> pages = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
final List<Widget> pageWidgets = pages.map((item) => item.page).toList();
|
final List<Widget> pageWidgets = pages.map((item) => item.page).toList();
|
||||||
|
|
||||||
|
final List<BottomNavigationBarItem> bottomNavItems =
|
||||||
|
pages.map((page) {
|
||||||
|
return BottomNavigationBarItem(icon: Icon(page.icon), label: page.title);
|
||||||
|
}).toList();
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import 'package:blog_app/pages/home_page.dart';
|
import 'package:blog_app/pages/home_page.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/utils/sp_utils.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_common/provider/theme_provider.dart';
|
||||||
|
import 'package:flutter_common/utils/sp_utils.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@@ -12,6 +13,7 @@ void main() async {
|
|||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider(create: (context) => BlogProvider()),
|
ChangeNotifierProvider(create: (context) => BlogProvider()),
|
||||||
|
ChangeNotifierProvider(create: (context) => ThemeProvider()),
|
||||||
],
|
],
|
||||||
child: MyApp(),
|
child: MyApp(),
|
||||||
),
|
),
|
||||||
@@ -23,13 +25,12 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final themeProvider = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
home: HomePage(),
|
home: HomePage(),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: themeProvider.currentThemeData,
|
||||||
scaffoldBackgroundColor: Color(0xFFF5F5F5),
|
|
||||||
fontFamily: 'CustomFont',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import 'package:json_annotation/json_annotation.dart';
|
|
||||||
|
|
||||||
part 'common.g.dart';
|
|
||||||
|
|
||||||
@JsonSerializable(genericArgumentFactories: true)
|
|
||||||
class PageResult<T> {
|
|
||||||
@JsonKey(name: 'records')
|
|
||||||
final List<T> records;
|
|
||||||
|
|
||||||
@JsonKey(name: 'total')
|
|
||||||
final int total;
|
|
||||||
|
|
||||||
@JsonKey(name: 'size')
|
|
||||||
final int size;
|
|
||||||
|
|
||||||
@JsonKey(name: 'current')
|
|
||||||
final int current;
|
|
||||||
|
|
||||||
@JsonKey(name: 'pages')
|
|
||||||
final int pages;
|
|
||||||
|
|
||||||
const PageResult({
|
|
||||||
required this.records,
|
|
||||||
required this.total,
|
|
||||||
required this.size,
|
|
||||||
required this.current,
|
|
||||||
required this.pages,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory PageResult.fromJson(
|
|
||||||
Map<String, dynamic> json,
|
|
||||||
T Function(Object? json) fromJsonT,
|
|
||||||
) => _$PageResultFromJson(json, fromJsonT);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson(Object? Function(T value) toJsonT) =>
|
|
||||||
_$PageResultToJson(this, toJsonT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonSerializable(genericArgumentFactories: true)
|
|
||||||
class ChartData {
|
|
||||||
@JsonKey(name: 'name')
|
|
||||||
final String name;
|
|
||||||
|
|
||||||
@JsonKey(name: 'value')
|
|
||||||
final double value;
|
|
||||||
|
|
||||||
const ChartData({required this.name, required this.value});
|
|
||||||
|
|
||||||
factory ChartData.fromJson(Map<String, dynamic> json) =>
|
|
||||||
_$ChartDataFromJson(json);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => _$ChartDataToJson(this);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'common.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// JsonSerializableGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
PageResult<T> _$PageResultFromJson<T>(
|
|
||||||
Map<String, dynamic> json,
|
|
||||||
T Function(Object? json) fromJsonT,
|
|
||||||
) => PageResult<T>(
|
|
||||||
records: (json['records'] as List<dynamic>).map(fromJsonT).toList(),
|
|
||||||
total: (json['total'] as num).toInt(),
|
|
||||||
size: (json['size'] as num).toInt(),
|
|
||||||
current: (json['current'] as num).toInt(),
|
|
||||||
pages: (json['pages'] as num).toInt(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$PageResultToJson<T>(
|
|
||||||
PageResult<T> instance,
|
|
||||||
Object? Function(T value) toJsonT,
|
|
||||||
) => <String, dynamic>{
|
|
||||||
'records': instance.records.map(toJsonT).toList(),
|
|
||||||
'total': instance.total,
|
|
||||||
'size': instance.size,
|
|
||||||
'current': instance.current,
|
|
||||||
'pages': instance.pages,
|
|
||||||
};
|
|
||||||
|
|
||||||
ChartData _$ChartDataFromJson(Map<String, dynamic> json) => ChartData(
|
|
||||||
name: json['name'] as String,
|
|
||||||
value: (json['value'] as num).toDouble(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$ChartDataToJson(ChartData instance) => <String, dynamic>{
|
|
||||||
'name': instance.name,
|
|
||||||
'value': instance.value,
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:blog_app/widget/markdown.dart';
|
import 'package:blog_app/widget/markdown.dart';
|
||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -43,7 +43,7 @@ class _BlogDetailPageState extends State<BlogDetailPage> {
|
|||||||
return FloatingActionButton(
|
return FloatingActionButton(
|
||||||
onPressed: () => setState(() => _showToc = !_showToc),
|
onPressed: () => setState(() => _showToc = !_showToc),
|
||||||
mini: true,
|
mini: true,
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
child: Icon(_showToc ? Icons.close : Icons.list, color: Colors.white),
|
child: Icon(_showToc ? Icons.close : Icons.list, color: Colors.white),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -73,7 +73,11 @@ class _BlogDetailPageState extends State<BlogDetailPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
buildTocPanel(tocController: tocController, showToc: _showToc),
|
buildTocPanel(
|
||||||
|
context: context,
|
||||||
|
tocController: tocController,
|
||||||
|
showToc: _showToc,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/widget/easy_refresh.dart';
|
import 'package:blog_app/widget/easy_refresh.dart';
|
||||||
import 'package:blog_app/widget/blog.dart';
|
import 'package:blog_app/widget/blog.dart';
|
||||||
@@ -80,13 +80,14 @@ class _BlogPageState extends State<BlogPage> {
|
|||||||
if (provider.error != null) {
|
if (provider.error != null) {
|
||||||
return buildErrorInfo(
|
return buildErrorInfo(
|
||||||
errorInfo: provider.error!,
|
errorInfo: provider.error!,
|
||||||
onPressed: () => provider.refreshBlogList,
|
onPressed: () => provider.refreshBlogList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.separated(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
itemCount: provider.blogList.length,
|
itemCount: provider.blogList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final blog = provider.blogList[index];
|
final blog = provider.blogList[index];
|
||||||
return InkWell(
|
return InkWell(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:blog_app/widget/common.dart';
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/widget/blog.dart';
|
import 'package:blog_app/widget/blog.dart';
|
||||||
@@ -24,7 +24,7 @@ class _CategoryListPageState extends State<CategoryListPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBlogList(BlogProvider provider) {
|
Widget _buildBlogList(BlogProvider provider) {
|
||||||
return ListView.builder(
|
return ListView.separated(
|
||||||
itemCount: provider.blogList.length,
|
itemCount: provider.blogList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final blog = provider.blogList[index];
|
final blog = provider.blogList[index];
|
||||||
@@ -33,6 +33,9 @@ class _CategoryListPageState extends State<CategoryListPage> {
|
|||||||
child: buildBlogListItem(context, blog, index + 1),
|
child: buildBlogListItem(context, blog, index + 1),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return SizedBox(height: 8);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:blog_app/widget/common.dart';
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/widget/blog.dart';
|
import 'package:blog_app/widget/blog.dart';
|
||||||
@@ -36,8 +36,9 @@ class _CategoryPageState extends State<CategoryPage> {
|
|||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
// 分类列表
|
// 分类列表
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.separated(
|
||||||
itemCount: provider.categoryList.length,
|
itemCount: provider.categoryList.length,
|
||||||
|
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final category = provider.categoryList[index];
|
final category = provider.categoryList[index];
|
||||||
return buildCategoryCard(context, category);
|
return buildCategoryCard(context, category);
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import 'package:blog_app/apis/blog.dart';
|
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/menu.dart';
|
||||||
import 'package:blog_app/models/blog.dart';
|
import 'package:blog_app/models/blog.dart';
|
||||||
import 'package:blog_app/widget/search.dart';
|
import 'package:blog_app/widget/search.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
|
const HomePage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HomePageState createState() => _HomePageState();
|
_HomePageState createState() => _HomePageState();
|
||||||
}
|
}
|
||||||
@@ -162,6 +165,20 @@ class _HomePageState extends State<HomePage> {
|
|||||||
return buildSearchResultList(context, _searchResults);
|
return buildSearchResultList(context, _searchResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onTapNavbarItem(int index) {
|
||||||
|
setState(() {
|
||||||
|
_currentPageIndex = index;
|
||||||
|
if (_isSearching) {
|
||||||
|
_exitSearch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_pageController.animateToPage(
|
||||||
|
index,
|
||||||
|
duration: Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void onTapDrawerItem(int index) {
|
void onTapDrawerItem(int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentPageIndex = index;
|
_currentPageIndex = index;
|
||||||
@@ -177,37 +194,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
Navigator.pop(context);
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -218,8 +204,15 @@ class _HomePageState extends State<HomePage> {
|
|||||||
leading: _buildLeading(),
|
leading: _buildLeading(),
|
||||||
actions: _buildAppBarActions(),
|
actions: _buildAppBarActions(),
|
||||||
),
|
),
|
||||||
drawer: _buildDrawer(),
|
drawer: AppDrawer(
|
||||||
|
currentPageIndex: _currentPageIndex,
|
||||||
|
onTapDrawerItem: onTapDrawerItem,
|
||||||
|
),
|
||||||
body: Padding(padding: EdgeInsets.all(10), child: _buildPageView()),
|
body: Padding(padding: EdgeInsets.all(10), child: _buildPageView()),
|
||||||
|
bottomNavigationBar: AppNavbar(
|
||||||
|
currentPageIndex: _currentPageIndex,
|
||||||
|
onTapNavbarItem: _onTapNavbarItem,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import 'package:flutter_common/utils/number_utils.dart';
|
||||||
|
import 'package:flutter_common/widget/chart.dart';
|
||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
|
import 'package:flutter_common/widget/year_selector.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/widget/blog.dart';
|
|
||||||
import 'package:blog_app/widget/chart.dart';
|
|
||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:blog_app/widget/year_selector.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class StatsPage extends StatefulWidget {
|
class StatsPage extends StatefulWidget {
|
||||||
@@ -27,133 +27,37 @@ class StatsPageState extends State<StatsPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildApprovedStats(BlogProvider provider) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
buildChartTitle(context, '每月博客发布统计', Icons.show_chart),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
buildChartDivider(context),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Expanded(
|
|
||||||
child: lineChart(
|
|
||||||
context: context,
|
|
||||||
xAxisName: '月份',
|
|
||||||
yAxisName: '数量',
|
|
||||||
unit: '篇',
|
|
||||||
data: provider.approvedStats,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildVisitStats(BlogProvider provider) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
buildChartTitle(context, '每月博客访问统计', Icons.show_chart),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
buildChartDivider(context),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Expanded(
|
|
||||||
child: lineChart(
|
|
||||||
context: context,
|
|
||||||
xAxisName: '月份',
|
|
||||||
yAxisName: '访问量',
|
|
||||||
unit: '人次',
|
|
||||||
data: provider.visitStats,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildVisitRankStats(BlogProvider provider) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
buildChartTitle(context, '博客访问数量排行', Icons.bar_chart),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
buildChartDivider(context),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Expanded(
|
|
||||||
child: barChart(
|
|
||||||
context: context,
|
|
||||||
xAxisName: '名称',
|
|
||||||
yAxisName: '访问量',
|
|
||||||
unit: '人次',
|
|
||||||
data: provider.visitRankStats,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildCategoryStats(BlogProvider provider) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
buildChartTitle(context, '博客类别统计', Icons.pie_chart),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
buildChartDivider(context),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Expanded(
|
|
||||||
child: pieChart(
|
|
||||||
context: context,
|
|
||||||
unit: '篇',
|
|
||||||
data: provider.categoryStats,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildReadRankStats(BlogProvider provider) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
buildChartTitle(context, '博客阅读时长排行', Icons.bar_chart),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
buildChartDivider(context),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Expanded(
|
|
||||||
child: barChart(
|
|
||||||
context: context,
|
|
||||||
xAxisName: '名称',
|
|
||||||
yAxisName: '时长',
|
|
||||||
unit: '分钟',
|
|
||||||
data: provider.readRankStats,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBlogStatsGrid(BlogProvider provider) {
|
Widget _buildBlogStatsGrid(BlogProvider provider) {
|
||||||
return GridView.count(
|
return GridView.count(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
childAspectRatio: 2,
|
childAspectRatio: 2,
|
||||||
|
mainAxisSpacing: 8,
|
||||||
|
crossAxisSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
buildStatsCard(
|
StatsCard(
|
||||||
context: context,
|
icon: Icons.article,
|
||||||
title: '博客数量',
|
title: '博客数量',
|
||||||
count: provider.overviewStats.blogCount,
|
value: provider.overviewStats.blogCount.toString(),
|
||||||
unit: '篇',
|
unit: '篇',
|
||||||
),
|
),
|
||||||
buildStatsCard(
|
StatsCard(
|
||||||
context: context,
|
icon: Icons.folder,
|
||||||
title: '分类数量',
|
title: '分类数量',
|
||||||
count: provider.overviewStats.categoryCount,
|
value: provider.overviewStats.categoryCount.toString(),
|
||||||
unit: '个',
|
unit: '个',
|
||||||
),
|
),
|
||||||
buildStatsCard(
|
StatsCard(
|
||||||
context: context,
|
icon: Icons.remove_red_eye,
|
||||||
title: '访问量',
|
title: '访问量',
|
||||||
count: provider.overviewStats.visitCount,
|
value: formatChineseDecimal(provider.overviewStats.visitCount),
|
||||||
unit: '次',
|
unit: '次',
|
||||||
),
|
),
|
||||||
buildStatsCard(
|
StatsCard(
|
||||||
context: context,
|
icon: Icons.text_fields,
|
||||||
title: '总字数',
|
title: '总字数',
|
||||||
count: provider.overviewStats.wordCount,
|
value: formatChineseDecimal(provider.overviewStats.wordCount),
|
||||||
unit: '字',
|
unit: '字',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -171,53 +75,71 @@ class StatsPageState extends State<StatsPage> {
|
|||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
YearSelector(
|
YearSelector(
|
||||||
initialYear: provider.currentYear,
|
currentYear: provider.currentStatsYear,
|
||||||
minYear: 2000,
|
|
||||||
maxYear: 2100,
|
|
||||||
onYearChanged: (year) {
|
onYearChanged: (year) {
|
||||||
setState(() {
|
provider.currentStatsYear = year;
|
||||||
provider.currentYear = year;
|
|
||||||
provider.refreshBlogStats();
|
provider.refreshBlogStats();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 8),
|
||||||
_buildBlogStatsGrid(provider),
|
_buildBlogStatsGrid(provider),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: CommonCard(
|
||||||
context: context,
|
child: LineChart(
|
||||||
child: _buildApprovedStats(provider),
|
title: '每月博客发布统计',
|
||||||
|
xAxisName: '月份',
|
||||||
|
yAxisName: '数量',
|
||||||
|
unit: '篇',
|
||||||
|
data: provider.approvedStats,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(context: context, child: _buildVisitStats(provider)),
|
child: CommonCard(
|
||||||
|
child: LineChart(
|
||||||
|
title: '每月博客访问统计',
|
||||||
|
xAxisName: '月份',
|
||||||
|
yAxisName: '访问量',
|
||||||
|
unit: '人次',
|
||||||
|
data: provider.visitStats,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: CommonCard(
|
||||||
context: context,
|
child: RankChart(
|
||||||
child: _buildVisitRankStats(provider),
|
title: '博客访问数量排行',
|
||||||
|
unit: '人次',
|
||||||
|
data: provider.visitRankStats,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: CommonCard(
|
||||||
context: context,
|
child: PieChart(
|
||||||
child: _buildCategoryStats(provider),
|
title: '博客类别统计',
|
||||||
|
unit: '篇',
|
||||||
|
data: provider.categoryStats,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: chartHeight,
|
height: chartHeight,
|
||||||
child: buildCard(
|
child: CommonCard(
|
||||||
context: context,
|
child: RankChart(
|
||||||
child: _buildReadRankStats(provider),
|
title: '博客阅读时长排行',
|
||||||
|
unit: '分钟',
|
||||||
|
data: provider.readRankStats,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -233,8 +155,8 @@ class StatsPageState extends State<StatsPage> {
|
|||||||
if (blogProvider.isLoading)
|
if (blogProvider.isLoading)
|
||||||
buildLoadingIndicator()
|
buildLoadingIndicator()
|
||||||
else
|
else
|
||||||
SingleChildScrollView(child: _buildContent(blogProvider))
|
SingleChildScrollView(child: _buildContent(blogProvider)),
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
|
import 'package:flutter_common/widget/year_selector.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:blog_app/provider/blog.dart';
|
import 'package:blog_app/provider/blog.dart';
|
||||||
import 'package:blog_app/widget/blog.dart';
|
import 'package:blog_app/widget/blog.dart';
|
||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:blog_app/widget/year_selector.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:timelines_plus/timelines_plus.dart';
|
import 'package:timelines_plus/timelines_plus.dart';
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ class TimelinePageState extends State<TimelinePage> {
|
|||||||
|
|
||||||
return Timeline.tileBuilder(
|
return Timeline.tileBuilder(
|
||||||
theme: TimelineThemeData(nodePosition: 0, indicatorPosition: 0),
|
theme: TimelineThemeData(nodePosition: 0, indicatorPosition: 0),
|
||||||
padding: EdgeInsets.all(6),
|
padding: EdgeInsets.all(0),
|
||||||
builder: TimelineTileBuilder.connected(
|
builder: TimelineTileBuilder.connected(
|
||||||
itemCount: provider.blogList.length,
|
itemCount: provider.blogList.length,
|
||||||
connectorBuilder:
|
connectorBuilder:
|
||||||
@@ -39,9 +39,12 @@ class TimelinePageState extends State<TimelinePage> {
|
|||||||
},
|
},
|
||||||
contentsBuilder: (context, index) {
|
contentsBuilder: (context, index) {
|
||||||
final blog = provider.blogList[index];
|
final blog = provider.blogList[index];
|
||||||
return InkWell(
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||||
|
child: InkWell(
|
||||||
onTap: () => navigatorToBlogDetail(context, blog.id),
|
onTap: () => navigatorToBlogDetail(context, blog.id),
|
||||||
child: buildBlogListItem(context, blog, index + 1),
|
child: buildBlogListItem(context, blog, index + 1),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -60,14 +63,10 @@ class TimelinePageState extends State<TimelinePage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
YearSelector(
|
YearSelector(
|
||||||
initialYear: DateTime.now().year,
|
currentYear: provider.currentQueryYear,
|
||||||
minYear: 2000,
|
|
||||||
maxYear: 2100,
|
|
||||||
onYearChanged: (year) {
|
onYearChanged: (year) {
|
||||||
setState(() {
|
provider.currentQueryYear = year;
|
||||||
provider.currentYear = year;
|
|
||||||
provider.refreshBlogByYear();
|
provider.refreshBlogByYear();
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:blog_app/models/common.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:blog_app/apis/blog.dart';
|
import 'package:blog_app/apis/blog.dart';
|
||||||
import 'package:blog_app/models/blog.dart';
|
import 'package:blog_app/models/blog.dart';
|
||||||
|
import 'package:flutter_common/models/common_model.dart';
|
||||||
|
|
||||||
class BlogProvider with ChangeNotifier {
|
class BlogProvider with ChangeNotifier {
|
||||||
List<Blog> blogList = [];
|
List<Blog> blogList = [];
|
||||||
@@ -24,7 +24,8 @@ class BlogProvider with ChangeNotifier {
|
|||||||
final int pageSize = 5;
|
final int pageSize = 5;
|
||||||
bool hasMore = true;
|
bool hasMore = true;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
int currentYear = DateTime.now().year;
|
int currentStatsYear = DateTime.now().year;
|
||||||
|
int currentQueryYear = DateTime.now().year;
|
||||||
String? error;
|
String? error;
|
||||||
|
|
||||||
late List<ChartData> approvedStats = [];
|
late List<ChartData> approvedStats = [];
|
||||||
@@ -44,7 +45,10 @@ class BlogProvider with ChangeNotifier {
|
|||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (currentPage == 1) {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
error = null;
|
error = null;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
@@ -104,8 +108,8 @@ class BlogProvider with ChangeNotifier {
|
|||||||
error = null;
|
error = null;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final approvedResult = await queryBlogApprovedStatsApi(currentYear);
|
final approvedResult = await queryBlogApprovedStatsApi(currentStatsYear);
|
||||||
final visitResult = await queryBlogVisitStatsApi(currentYear);
|
final visitResult = await queryBlogVisitStatsApi(currentStatsYear);
|
||||||
final visitRankResult = await queryBlogVisitRankStatsApi();
|
final visitRankResult = await queryBlogVisitRankStatsApi();
|
||||||
final categoryResult = await queryBlogCategoryStatsApi();
|
final categoryResult = await queryBlogCategoryStatsApi();
|
||||||
final readRankResult = await queryBlogReadRankStatsApi();
|
final readRankResult = await queryBlogReadRankStatsApi();
|
||||||
@@ -155,7 +159,7 @@ class BlogProvider with ChangeNotifier {
|
|||||||
blogList = [];
|
blogList = [];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
final result = await queryBlogByConditionApi(null, null, currentYear);
|
final result = await queryBlogByConditionApi(null, null, currentQueryYear);
|
||||||
blogList = result;
|
blogList = result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = '加载数据失败: $e';
|
error = '加载数据失败: $e';
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import 'package:intl/intl.dart';
|
|
||||||
|
|
||||||
String formatDate(DateTime date) {
|
|
||||||
return DateFormat('yyyy-MM-dd').format(date);
|
|
||||||
}
|
|
||||||
|
|
||||||
String formatDateString(String date) {
|
|
||||||
return DateFormat('yyyy-MM-dd').format(DateTime.parse(date));
|
|
||||||
}
|
|
||||||
|
|
||||||
String formatTime(DateTime datetime) {
|
|
||||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
|
||||||
}
|
|
||||||
@@ -1,244 +0,0 @@
|
|||||||
import 'package:blog_app/config/app_config.dart';
|
|
||||||
import 'package:blog_app/utils/sp_utils.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
|
|
||||||
import 'log_utils.dart';
|
|
||||||
|
|
||||||
class HttpUtil {
|
|
||||||
static final HttpUtil _instance = HttpUtil._internal();
|
|
||||||
|
|
||||||
factory HttpUtil() => _instance;
|
|
||||||
|
|
||||||
late Dio _dio;
|
|
||||||
|
|
||||||
// 请求头配置
|
|
||||||
Map<String, dynamic> headers = {
|
|
||||||
'Content-Type': 'application/json;charset=UTF-8',
|
|
||||||
'Accept': 'application/json',
|
|
||||||
};
|
|
||||||
|
|
||||||
// 超时时间
|
|
||||||
final int timeout = 5;
|
|
||||||
|
|
||||||
HttpUtil._internal() {
|
|
||||||
// 初始化Dio实例
|
|
||||||
BaseOptions options = BaseOptions(
|
|
||||||
baseUrl: AppConfig.baseApiUrl,
|
|
||||||
connectTimeout: Duration(seconds: timeout),
|
|
||||||
receiveTimeout: Duration(seconds: timeout),
|
|
||||||
headers: headers,
|
|
||||||
);
|
|
||||||
|
|
||||||
_dio = Dio(options);
|
|
||||||
|
|
||||||
// 添加请求拦截器
|
|
||||||
_dio.interceptors.add(
|
|
||||||
InterceptorsWrapper(
|
|
||||||
onRequest: (options, handler) {
|
|
||||||
logger.d("请求URL: ${options.uri}");
|
|
||||||
if (options.data != null) {
|
|
||||||
logger.d("请求参数: ${options.data}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SPUtil.getString('token').isNotEmpty) {
|
|
||||||
options.headers['satoken'] = SPUtil.getString('token');
|
|
||||||
}
|
|
||||||
return handler.next(options);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 添加响应拦截器
|
|
||||||
_dio.interceptors.add(
|
|
||||||
InterceptorsWrapper(
|
|
||||||
onResponse: (response, handler) {
|
|
||||||
logger.d("响应状态码: ${response.statusCode}");
|
|
||||||
// logger.d("响应数据: ${response.data}");
|
|
||||||
return handler.next(response);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 添加错误拦截器
|
|
||||||
_dio.interceptors.add(
|
|
||||||
InterceptorsWrapper(
|
|
||||||
onError: (DioException e, handler) {
|
|
||||||
_handleError(e);
|
|
||||||
return handler.next(e);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 基础请求方法(处理所有类型的请求)
|
|
||||||
Future<T> _request<T>(
|
|
||||||
String path, {
|
|
||||||
required String method,
|
|
||||||
dynamic data,
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
T Function(dynamic data)? converter,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
Response response = await _dio.request(
|
|
||||||
path,
|
|
||||||
data: data,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
options: Options(method: method),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 处理响应数据
|
|
||||||
if (converter != null) {
|
|
||||||
return converter(response.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 没有转换器时尝试直接返回(可能不安全,建议提供转换器)
|
|
||||||
return response.data;
|
|
||||||
} catch (e) {
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET请求
|
|
||||||
Future<T> get<T>(
|
|
||||||
String path, {
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
T Function(dynamic data)? converter,
|
|
||||||
}) => _request(
|
|
||||||
path,
|
|
||||||
method: "GET",
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
converter: converter,
|
|
||||||
);
|
|
||||||
|
|
||||||
// POST请求
|
|
||||||
Future<T> post<T>(
|
|
||||||
String path, {
|
|
||||||
dynamic data,
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
T Function(dynamic data)? converter,
|
|
||||||
}) => _request(
|
|
||||||
path,
|
|
||||||
method: "POST",
|
|
||||||
data: data,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
converter: converter,
|
|
||||||
);
|
|
||||||
|
|
||||||
// PUT请求
|
|
||||||
Future<T> put<T>(
|
|
||||||
String path, {
|
|
||||||
dynamic data,
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
T Function(dynamic data)? converter,
|
|
||||||
}) => _request(
|
|
||||||
path,
|
|
||||||
method: "PUT",
|
|
||||||
data: data,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
converter: converter,
|
|
||||||
);
|
|
||||||
|
|
||||||
// DELETE请求
|
|
||||||
Future<T> delete<T>(
|
|
||||||
String path, {
|
|
||||||
dynamic data,
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
T Function(dynamic data)? converter,
|
|
||||||
}) => _request(
|
|
||||||
path,
|
|
||||||
method: "DELETE",
|
|
||||||
data: data,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
converter: converter,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 文件上传
|
|
||||||
Future<dynamic> upload(
|
|
||||||
String path,
|
|
||||||
String filePath, {
|
|
||||||
Map<String, dynamic>? queryParameters,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
FormData formData = FormData.fromMap({
|
|
||||||
'file': await MultipartFile.fromFile(filePath),
|
|
||||||
});
|
|
||||||
|
|
||||||
Response response = await _dio.post(
|
|
||||||
path,
|
|
||||||
data: formData,
|
|
||||||
queryParameters: queryParameters,
|
|
||||||
);
|
|
||||||
return response.data;
|
|
||||||
} catch (e) {
|
|
||||||
_handleError(e);
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 错误处理
|
|
||||||
void _handleError(dynamic error) {
|
|
||||||
String errorMessage = '未知错误';
|
|
||||||
if (error is DioException) {
|
|
||||||
switch (error.type) {
|
|
||||||
case DioExceptionType.connectionTimeout:
|
|
||||||
errorMessage = '连接超时,请检查网络连接';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.sendTimeout:
|
|
||||||
errorMessage = '发送超时,请检查网络连接';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.receiveTimeout:
|
|
||||||
errorMessage = '接收超时,请检查网络连接';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.cancel:
|
|
||||||
errorMessage = '请求已取消';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.badCertificate:
|
|
||||||
errorMessage = '证书验证失败';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.badResponse:
|
|
||||||
// 处理HTTP响应错误(4xx, 5xx)
|
|
||||||
final statusCode = error.response?.statusCode ?? 0;
|
|
||||||
final responseData = error.response?.data;
|
|
||||||
|
|
||||||
if (responseData is Map<String, dynamic> && responseData.containsKey('message')) {
|
|
||||||
// 服务器返回了自定义错误消息
|
|
||||||
errorMessage = responseData['message']?.toString() ?? '未知错误';
|
|
||||||
} else {
|
|
||||||
errorMessage = _getHttpErrorMessage(statusCode);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DioExceptionType.connectionError:
|
|
||||||
errorMessage = '网络连接错误,请检查网络设置';
|
|
||||||
break;
|
|
||||||
case DioExceptionType.unknown:
|
|
||||||
if (error.error != null) {
|
|
||||||
errorMessage = '未知错误: ${error.error.toString()}';
|
|
||||||
}
|
|
||||||
errorMessage = '发生未知错误';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorMessage = '非Dio错误: $error';
|
|
||||||
}
|
|
||||||
|
|
||||||
print(errorMessage);
|
|
||||||
// showErrorToast(errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _getHttpErrorMessage(int statusCode) {
|
|
||||||
// 根据HTTP状态码返回对应的错误消息
|
|
||||||
switch (statusCode) {
|
|
||||||
case 400: return '错误请求,请检查参数';
|
|
||||||
case 401: return '未授权,请登录';
|
|
||||||
case 403: return '禁止访问,权限不足';
|
|
||||||
case 404: return '资源不存在';
|
|
||||||
case 405: return '方法不允许';
|
|
||||||
case 408: return '请求超时';
|
|
||||||
case 500: return '服务器内部错误';
|
|
||||||
case 502: return '网关错误';
|
|
||||||
case 503: return '服务不可用';
|
|
||||||
case 504: return '网关超时';
|
|
||||||
default: return 'HTTP错误: $statusCode';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import 'package:blog_app/models/common.dart';
|
|
||||||
|
|
||||||
List<T> convertListResponse<T>(
|
|
||||||
dynamic data,
|
|
||||||
T Function(Map<String, dynamic>) fromJson,
|
|
||||||
) {
|
|
||||||
if (data is List) {
|
|
||||||
return data.map((item) => fromJson(item as Map<String, dynamic>)).toList();
|
|
||||||
}
|
|
||||||
throw FormatException(
|
|
||||||
'Expected a list of items for conversion, but got ${data.runtimeType}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
PageResult<T> convertPageResponse<T>(
|
|
||||||
dynamic data,
|
|
||||||
T Function(Map<String, dynamic>) fromJson,
|
|
||||||
) {
|
|
||||||
if (data is Map<String, dynamic>) {
|
|
||||||
return PageResult<T>.fromJson(
|
|
||||||
data,
|
|
||||||
(json) => fromJson(json as Map<String, dynamic>),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
throw FormatException(
|
|
||||||
'Expected a Map for page response conversion, but got ${data.runtimeType}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import 'package:logger/logger.dart';
|
|
||||||
|
|
||||||
// 全局日志实例,在整个项目中共享
|
|
||||||
final Logger logger = Logger(
|
|
||||||
printer: PrettyPrinter(
|
|
||||||
methodCount: 1,
|
|
||||||
colors: true,
|
|
||||||
dateTimeFormat: DateTimeFormat.dateAndTime,
|
|
||||||
),
|
|
||||||
// 可选:配置输出到文件(需配合文件操作库)
|
|
||||||
// output: FileOutput(file: File('logs/app.log')),
|
|
||||||
);
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
class SPUtil {
|
|
||||||
static late SharedPreferences _prefs;
|
|
||||||
|
|
||||||
/// 初始化
|
|
||||||
static Future<void> init() async {
|
|
||||||
_prefs = await SharedPreferences.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 存储数据
|
|
||||||
static Future<bool> set(String key, dynamic value) {
|
|
||||||
if (value is String) return _prefs.setString(key, value);
|
|
||||||
if (value is int) return _prefs.setInt(key, value);
|
|
||||||
if (value is bool) return _prefs.setBool(key, value);
|
|
||||||
if (value is double) return _prefs.setDouble(key, value);
|
|
||||||
if (value is List<String>) return _prefs.setStringList(key, value);
|
|
||||||
throw ArgumentError('Unsupported value type: ${value.runtimeType}');
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取数据
|
|
||||||
static dynamic get(String key, [dynamic defaultValue]) {
|
|
||||||
if (!_prefs.containsKey(key)) return defaultValue;
|
|
||||||
return _prefs.get(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取字符串
|
|
||||||
static String getString(String key, [String defaultValue = '']) {
|
|
||||||
return _prefs.getString(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取布尔值
|
|
||||||
static bool getBool(String key, [bool defaultValue = false]) {
|
|
||||||
return _prefs.getBool(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取整数
|
|
||||||
static int getInt(String key, [int defaultValue = 0]) {
|
|
||||||
return _prefs.getInt(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取浮点数
|
|
||||||
static double getDouble(String key, [double defaultValue = 0.0]) {
|
|
||||||
return _prefs.getDouble(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 获取字符串列表
|
|
||||||
static List<String> getStringList(String key, [List<String> defaultValue = const []]) {
|
|
||||||
return _prefs.getStringList(key) ?? defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除数据
|
|
||||||
static Future<bool> remove(String key) {
|
|
||||||
return _prefs.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 清空所有数据
|
|
||||||
static Future<bool> clear() {
|
|
||||||
return _prefs.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import 'package:blog_app/models/blog.dart';
|
import 'package:blog_app/models/blog.dart';
|
||||||
import 'package:blog_app/pages/blog_detail_page.dart';
|
import 'package:blog_app/pages/blog_detail_page.dart';
|
||||||
import 'package:blog_app/pages/category_list_page.dart';
|
import 'package:blog_app/pages/category_list_page.dart';
|
||||||
import 'package:blog_app/utils/date_utils.dart';
|
|
||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_common/utils/date_utils.dart';
|
||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
|
|
||||||
class BlogLabel {
|
class BlogLabel {
|
||||||
final String text;
|
final String text;
|
||||||
@@ -53,7 +53,11 @@ class BlogCard extends StatelessWidget {
|
|||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (blog.isGreat)
|
if (blog.isGreat)
|
||||||
_buildBlogLabelItem('精品', Icons.workspace_premium, Colors.amber),
|
_buildBlogLabelItem(
|
||||||
|
'精品',
|
||||||
|
Icons.workspace_premium,
|
||||||
|
Colors.deepOrange,
|
||||||
|
),
|
||||||
if (blog.topValue > 1)
|
if (blog.topValue > 1)
|
||||||
_buildBlogLabelItem('置顶', Icons.push_pin, Colors.red),
|
_buildBlogLabelItem('置顶', Icons.push_pin, Colors.red),
|
||||||
_buildBlogLabelItem(blog.category, Icons.folder, Colors.blue),
|
_buildBlogLabelItem(blog.category, Icons.folder, Colors.blue),
|
||||||
@@ -101,12 +105,14 @@ class BlogCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBlogSummary() {
|
Widget _buildBlogSummary(BuildContext context) {
|
||||||
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: Text(
|
child: Text(
|
||||||
blog.summary,
|
blog.summary,
|
||||||
style: TextStyle(color: Colors.grey.shade700, height: 1.6),
|
style: TextStyle(color: colors.secondary, height: 1.6),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -114,10 +120,9 @@ class BlogCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return buildCard(
|
final colors = Theme.of(context).colorScheme;
|
||||||
context: context,
|
|
||||||
child: Padding(
|
return CommonCard(
|
||||||
padding: EdgeInsets.all(12),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -125,16 +130,11 @@ class BlogCard extends StatelessWidget {
|
|||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
_buildBlogLabel(),
|
_buildBlogLabel(),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Container(
|
Container(height: 1, width: 80, color: colors.primary),
|
||||||
height: 1,
|
|
||||||
width: 80,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
_buildBlogSummary(),
|
_buildBlogSummary(context),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,8 +164,7 @@ Widget buildCategoryTitle(BuildContext context, int count) {
|
|||||||
Widget buildCategoryCard(BuildContext context, BlogCategory category) {
|
Widget buildCategoryCard(BuildContext context, BlogCategory category) {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return buildCard(
|
return CommonCard(
|
||||||
context: context,
|
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
@@ -188,14 +187,16 @@ Widget buildCategoryCard(BuildContext context, BlogCategory category) {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: Container(
|
trailing: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
width: 30,
|
||||||
|
height: 30,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colors.primary.withAlpha(50),
|
color: Theme.of(context).colorScheme.primary.withAlpha(50),
|
||||||
borderRadius: BorderRadius.circular(16),
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Icon(
|
||||||
category.count.toString(),
|
Icons.arrow_forward,
|
||||||
style: TextStyle(color: colors.primary, fontWeight: FontWeight.bold),
|
size: 16,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onTap: () => navigateToBlogList(context, category),
|
onTap: () => navigateToBlogList(context, category),
|
||||||
@@ -222,33 +223,24 @@ Widget buildListTitle(int count) {
|
|||||||
Widget buildBlogListItem(BuildContext context, Blog blog, int index) {
|
Widget buildBlogListItem(BuildContext context, Blog blog, int index) {
|
||||||
final colors = Theme.of(context).colorScheme;
|
final colors = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return buildCard(
|
return CommonCard(
|
||||||
context: context,
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
Text(
|
||||||
width: 25,
|
'$index.',
|
||||||
child: Text(
|
|
||||||
index.toString(),
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
color: colors.onSurface,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: colors.primary,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
formatDateString(blog.createTime),
|
||||||
|
style: TextStyle(fontSize: 14, color: colors.onSurface),
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 10),
|
||||||
// 发布时间
|
|
||||||
SizedBox(
|
|
||||||
width: 150,
|
|
||||||
child: Text(
|
|
||||||
blog.createTime,
|
|
||||||
style: TextStyle(fontSize: 14, color: Colors.grey.shade600),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// 标题
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
blog.title,
|
blog.title,
|
||||||
@@ -267,56 +259,6 @@ Widget buildBlogListItem(BuildContext context, Blog blog, int index) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildStatsCard({
|
|
||||||
required BuildContext context,
|
|
||||||
required String title,
|
|
||||||
required int count,
|
|
||||||
required String unit,
|
|
||||||
}) {
|
|
||||||
return buildCard(
|
|
||||||
context: context,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.grey.shade600,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
count.toString(),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 28,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black87,
|
|
||||||
height: 1.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(
|
|
||||||
unit,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Colors.grey.shade600,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void navigatorToBlogDetail(BuildContext context, int blogId) {
|
void navigatorToBlogDetail(BuildContext context, int blogId) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -1,285 +0,0 @@
|
|||||||
import 'package:blog_app/models/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
|
||||||
|
|
||||||
Widget buildChartTitle(BuildContext context, String title, IconData icon) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
Icon(icon, color: Theme.of(context).colorScheme.primary),
|
|
||||||
Text(title),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildChartDivider(BuildContext context) {
|
|
||||||
return Divider(
|
|
||||||
height: 1,
|
|
||||||
thickness: 1,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
indent: 0,
|
|
||||||
endIndent: 0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget lineChart({
|
|
||||||
required BuildContext context,
|
|
||||||
required String xAxisName,
|
|
||||||
required String yAxisName,
|
|
||||||
required String unit,
|
|
||||||
required List<ChartData> data,
|
|
||||||
}) {
|
|
||||||
return SfCartesianChart(
|
|
||||||
// 图表标题
|
|
||||||
// title: ChartTitle(text: '2023年上半年销售额(万元)'),
|
|
||||||
|
|
||||||
// X轴配置(类别轴)
|
|
||||||
primaryXAxis: CategoryAxis(majorGridLines: MajorGridLines(width: 0)),
|
|
||||||
|
|
||||||
// Y轴配置(数值轴)
|
|
||||||
// primaryYAxis: NumericAxis(title: AxisTitle(text: '$yAxisName($unit)')),
|
|
||||||
|
|
||||||
// 启用图例
|
|
||||||
legend: Legend(isVisible: true, position: LegendPosition.top),
|
|
||||||
|
|
||||||
// 启用交互提示(点击数据点显示详情)
|
|
||||||
tooltipBehavior: TooltipBehavior(
|
|
||||||
enable: true,
|
|
||||||
format: 'point.x: point.y $unit',
|
|
||||||
),
|
|
||||||
|
|
||||||
// 折线图数据系列
|
|
||||||
series: [
|
|
||||||
LineSeries<ChartData, String>(
|
|
||||||
dataSource: data,
|
|
||||||
// X轴数据映射
|
|
||||||
xValueMapper: (ChartData chart, _) => chart.name,
|
|
||||||
// Y轴数据映射
|
|
||||||
yValueMapper: (ChartData chart, _) => chart.value,
|
|
||||||
// 线条颜色
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
// 线条宽度
|
|
||||||
width: 3,
|
|
||||||
|
|
||||||
// 数据点样式
|
|
||||||
markerSettings: const MarkerSettings(
|
|
||||||
isVisible: true,
|
|
||||||
color: Colors.white,
|
|
||||||
shape: DataMarkerType.circle,
|
|
||||||
height: 6,
|
|
||||||
width: 6,
|
|
||||||
),
|
|
||||||
|
|
||||||
// 折线名称(会显示在图例中)
|
|
||||||
name: yAxisName,
|
|
||||||
|
|
||||||
// 启用数据标签(直接显示数值)
|
|
||||||
dataLabelSettings: const DataLabelSettings(
|
|
||||||
isVisible: true,
|
|
||||||
color: Colors.white,
|
|
||||||
opacity: 0,
|
|
||||||
),
|
|
||||||
|
|
||||||
// 动画效果
|
|
||||||
animationDuration: 2000, // 动画时长(毫秒)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget barChart({
|
|
||||||
required BuildContext context,
|
|
||||||
required String xAxisName,
|
|
||||||
required String yAxisName,
|
|
||||||
required String unit,
|
|
||||||
required List<ChartData> data,
|
|
||||||
}) {
|
|
||||||
return SfCartesianChart(
|
|
||||||
// X轴配置(类别轴)
|
|
||||||
primaryXAxis: CategoryAxis(majorGridLines: MajorGridLines(width: 0)),
|
|
||||||
|
|
||||||
// Y轴配置(数值轴)
|
|
||||||
// primaryYAxis: NumericAxis(title: AxisTitle(text: '$yAxisName($unit)')),
|
|
||||||
|
|
||||||
// 启用交互提示
|
|
||||||
tooltipBehavior: TooltipBehavior(
|
|
||||||
enable: true,
|
|
||||||
format: 'point.x: point.y $unit',
|
|
||||||
),
|
|
||||||
|
|
||||||
// 柱状图数据系列
|
|
||||||
series: [
|
|
||||||
ColumnSeries<ChartData, String>(
|
|
||||||
dataSource: data,
|
|
||||||
// X轴数据映射
|
|
||||||
xValueMapper: (ChartData chart, _) => chart.name,
|
|
||||||
// Y轴数据映射
|
|
||||||
yValueMapper: (ChartData chart, _) => chart.value,
|
|
||||||
|
|
||||||
// 名称
|
|
||||||
name: yAxisName,
|
|
||||||
|
|
||||||
// 柱子颜色
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
|
|
||||||
// 柱子宽度(0-1之间,1表示占满类别间隔)
|
|
||||||
width: 0.6,
|
|
||||||
|
|
||||||
// 柱子边框
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: Colors.black12,
|
|
||||||
|
|
||||||
// 数据标签
|
|
||||||
dataLabelSettings: const DataLabelSettings(
|
|
||||||
isVisible: true,
|
|
||||||
color: Colors.white,
|
|
||||||
opacity: 0,
|
|
||||||
alignment: ChartAlignment.center,
|
|
||||||
),
|
|
||||||
|
|
||||||
// 动画效果
|
|
||||||
animationDuration: 2000,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget doubleBarChart({
|
|
||||||
required BuildContext context,
|
|
||||||
required String xAxisName,
|
|
||||||
required String yAxisName,
|
|
||||||
required String unit,
|
|
||||||
required List<ChartData> data1,
|
|
||||||
required List<ChartData> data2,
|
|
||||||
required String series1Name,
|
|
||||||
required String series2Name,
|
|
||||||
}) {
|
|
||||||
return SfCartesianChart(
|
|
||||||
// X轴配置(类别轴)
|
|
||||||
primaryXAxis: CategoryAxis(majorGridLines: const MajorGridLines(width: 0)),
|
|
||||||
|
|
||||||
// Y轴配置(数值轴)
|
|
||||||
// primaryYAxis: NumericAxis(title: AxisTitle(text: '$yAxisName($unit)')),
|
|
||||||
|
|
||||||
// 图例配置
|
|
||||||
legend: Legend(
|
|
||||||
isVisible: true,
|
|
||||||
position: LegendPosition.top,
|
|
||||||
overflowMode: LegendItemOverflowMode.wrap,
|
|
||||||
),
|
|
||||||
|
|
||||||
// 启用交互提示
|
|
||||||
tooltipBehavior: TooltipBehavior(
|
|
||||||
enable: true,
|
|
||||||
format: 'series.name: point.y $unit',
|
|
||||||
),
|
|
||||||
|
|
||||||
// 双柱状图数据系列
|
|
||||||
series: <ColumnSeries<ChartData, String>>[
|
|
||||||
ColumnSeries<ChartData, String>(
|
|
||||||
dataSource: data1,
|
|
||||||
// X轴数据映射
|
|
||||||
xValueMapper: (ChartData chart, _) => chart.name,
|
|
||||||
// Y轴数据映射
|
|
||||||
yValueMapper: (ChartData chart, _) => chart.value,
|
|
||||||
// 系列名称
|
|
||||||
name: series1Name,
|
|
||||||
// 柱子颜色
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
// 柱子宽度
|
|
||||||
width: 0.3,
|
|
||||||
// 柱子边框
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: Colors.black12,
|
|
||||||
// 数据标签
|
|
||||||
dataLabelSettings: const DataLabelSettings(
|
|
||||||
isVisible: true,
|
|
||||||
color: Colors.white,
|
|
||||||
opacity: 0,
|
|
||||||
alignment: ChartAlignment.center,
|
|
||||||
),
|
|
||||||
// 动画效果
|
|
||||||
animationDuration: 2000,
|
|
||||||
),
|
|
||||||
ColumnSeries<ChartData, String>(
|
|
||||||
dataSource: data2,
|
|
||||||
// X轴数据映射
|
|
||||||
xValueMapper: (ChartData chart, _) => chart.name,
|
|
||||||
// Y轴数据映射
|
|
||||||
yValueMapper: (ChartData chart, _) => chart.value,
|
|
||||||
// 系列名称
|
|
||||||
name: series2Name,
|
|
||||||
// 柱子颜色
|
|
||||||
color: Theme.of(context).colorScheme.inversePrimary,
|
|
||||||
// 柱子宽度
|
|
||||||
width: 0.3,
|
|
||||||
// 柱子边框
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: Colors.black12,
|
|
||||||
// 数据标签
|
|
||||||
dataLabelSettings: const DataLabelSettings(
|
|
||||||
isVisible: true,
|
|
||||||
color: Colors.white,
|
|
||||||
opacity: 0,
|
|
||||||
alignment: ChartAlignment.center,
|
|
||||||
),
|
|
||||||
// 动画效果
|
|
||||||
animationDuration: 2000,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget pieChart({
|
|
||||||
required BuildContext context,
|
|
||||||
required String unit,
|
|
||||||
required List<ChartData> data,
|
|
||||||
}) {
|
|
||||||
// 计算 value 的总和
|
|
||||||
double sumValue = data.fold(0.0, (sum, item) => sum + item.value);
|
|
||||||
|
|
||||||
return SfCircularChart(
|
|
||||||
// 饼图标题
|
|
||||||
// title: ChartTitle(text: '菜谱类别占比分布'),
|
|
||||||
|
|
||||||
// 启用图例
|
|
||||||
legend: const Legend(isVisible: true, position: LegendPosition.right),
|
|
||||||
|
|
||||||
// 启用交互提示(点击扇区显示详情)
|
|
||||||
tooltipBehavior: TooltipBehavior(
|
|
||||||
enable: true,
|
|
||||||
format: 'point.x: point.y $unit',
|
|
||||||
),
|
|
||||||
|
|
||||||
// 饼图系列配置
|
|
||||||
series: [
|
|
||||||
PieSeries<ChartData, String>(
|
|
||||||
dataSource: data,
|
|
||||||
// 类别映射(饼图扇区名称)
|
|
||||||
xValueMapper: (ChartData data, _) => data.name,
|
|
||||||
// 数值映射(扇区大小占比)
|
|
||||||
yValueMapper: (ChartData data, _) => data.value,
|
|
||||||
|
|
||||||
// 扇区半径(0-1之间,1表示充满容器)
|
|
||||||
// radius: '50%',
|
|
||||||
|
|
||||||
// 启用扇区分离效果
|
|
||||||
explode: true,
|
|
||||||
// 指定分离的扇区索引(这里分离第一个扇区)
|
|
||||||
explodeIndex: 0,
|
|
||||||
// 分离距离
|
|
||||||
explodeOffset: '5%',
|
|
||||||
|
|
||||||
dataLabelMapper: (ChartData data, _) {
|
|
||||||
final percentage = (data.value / sumValue * 100).toStringAsFixed(0);
|
|
||||||
return '$percentage%';
|
|
||||||
},
|
|
||||||
|
|
||||||
// 数据标签(显示在扇区上的文本)
|
|
||||||
dataLabelSettings: DataLabelSettings(isVisible: true),
|
|
||||||
|
|
||||||
// 动画效果
|
|
||||||
animationDuration: 2000,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
Widget buildCard({required BuildContext context, required Widget child}) {
|
|
||||||
final colors = Theme.of(context).colorScheme;
|
|
||||||
return Card(
|
|
||||||
elevation: 0,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: colors.surface,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(color: colors.outline.withAlpha(50), width: 1),
|
|
||||||
),
|
|
||||||
child: Padding(padding: EdgeInsets.all(8), child: child),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget circleIconButton({
|
|
||||||
required IconData icon,
|
|
||||||
required VoidCallback onPressed,
|
|
||||||
required BuildContext context,
|
|
||||||
}) {
|
|
||||||
return ElevatedButton(
|
|
||||||
onPressed: onPressed,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
shape: CircleBorder(),
|
|
||||||
elevation: 0,
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
minimumSize: const Size(0, 0),
|
|
||||||
),
|
|
||||||
child: Icon(icon, color: Colors.white),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildErrorInfo({
|
|
||||||
required String errorInfo,
|
|
||||||
required VoidCallback onPressed,
|
|
||||||
}) {
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text('加载失败: $errorInfo'),
|
|
||||||
ElevatedButton(onPressed: onPressed, child: Text('重试')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildLoadingIndicator() {
|
|
||||||
return Center(child: CircularProgressIndicator());
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,7 @@ Widget buildMarkdown({
|
|||||||
}) => MarkdownWidget(data: data, tocController: tocController);
|
}) => MarkdownWidget(data: data, tocController: tocController);
|
||||||
|
|
||||||
Widget buildTocPanel({
|
Widget buildTocPanel({
|
||||||
|
required BuildContext context,
|
||||||
required TocController tocController,
|
required TocController tocController,
|
||||||
required bool showToc,
|
required bool showToc,
|
||||||
}) => Visibility(
|
}) => Visibility(
|
||||||
@@ -18,7 +19,7 @@ Widget buildTocPanel({
|
|||||||
width: 250,
|
width: 250,
|
||||||
height: 400,
|
height: 400,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
@@ -34,7 +35,7 @@ Widget buildTocPanel({
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[100],
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topLeft: Radius.circular(12),
|
topLeft: Radius.circular(12),
|
||||||
topRight: Radius.circular(12),
|
topRight: Radius.circular(12),
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import 'package:blog_app/models/blog.dart';
|
import 'package:blog_app/models/blog.dart';
|
||||||
import 'package:blog_app/pages/blog_detail_page.dart';
|
|
||||||
import 'package:blog_app/widget/blog.dart';
|
import 'package:blog_app/widget/blog.dart';
|
||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_common/widget/common_widget.dart';
|
||||||
|
|
||||||
Widget buildSearchField({
|
Widget buildSearchField({
|
||||||
required TextEditingController controller,
|
required TextEditingController controller,
|
||||||
@@ -28,15 +27,13 @@ Widget buildSearchField({
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSearchResultItem(BuildContext context, BlogSearch blog) {
|
Widget buildSearchResultItem(BuildContext context, BlogSearch blog) {
|
||||||
return buildCard(
|
final colors = Theme.of(context).colorScheme;
|
||||||
context: context,
|
|
||||||
|
return CommonCard(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
blog.title,
|
blog.title,
|
||||||
style: TextStyle(
|
style: TextStyle(fontWeight: FontWeight.bold, color: colors.primary),
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -44,7 +41,7 @@ Widget buildSearchResultItem(BuildContext context, BlogSearch blog) {
|
|||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
blog.content,
|
blog.content,
|
||||||
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
style: TextStyle(color: colors.secondary, fontSize: 14),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -57,11 +54,14 @@ Widget buildSearchResultList(
|
|||||||
BuildContext context,
|
BuildContext context,
|
||||||
List<BlogSearch> searchResultList,
|
List<BlogSearch> searchResultList,
|
||||||
) {
|
) {
|
||||||
return ListView.builder(
|
return ListView.separated(
|
||||||
itemCount: searchResultList.length,
|
itemCount: searchResultList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return buildSearchResultItem(context, searchResultList[index]);
|
return buildSearchResultItem(context, searchResultList[index]);
|
||||||
},
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return SizedBox(height: 8);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
import 'package:blog_app/widget/common.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class YearSelector extends StatefulWidget {
|
|
||||||
final int initialYear;
|
|
||||||
final int? minYear;
|
|
||||||
final int? maxYear;
|
|
||||||
final Function(int) onYearChanged;
|
|
||||||
|
|
||||||
const YearSelector({
|
|
||||||
super.key,
|
|
||||||
required this.initialYear,
|
|
||||||
required this.onYearChanged,
|
|
||||||
this.minYear,
|
|
||||||
this.maxYear,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<YearSelector> createState() => _YearSelectorState();
|
|
||||||
}
|
|
||||||
|
|
||||||
// SingleTickerProviderStateMixin 动画控制器
|
|
||||||
class _YearSelectorState extends State<YearSelector>
|
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
late int _currentYear;
|
|
||||||
|
|
||||||
// 用于动画效果
|
|
||||||
late AnimationController _animationController;
|
|
||||||
late Animation<double> _scaleAnimation;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_currentYear = widget.initialYear;
|
|
||||||
|
|
||||||
// 初始化动画控制器
|
|
||||||
_animationController = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 缩放动画
|
|
||||||
_scaleAnimation = Tween<double>(begin: 1.0, end: 1.1).animate(
|
|
||||||
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_animationController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 切换到上一年
|
|
||||||
void _previousYear() {
|
|
||||||
if (widget.minYear == null || _currentYear > widget.minYear!) {
|
|
||||||
_animateYearChange(() {
|
|
||||||
setState(() {
|
|
||||||
_currentYear--;
|
|
||||||
});
|
|
||||||
widget.onYearChanged(_currentYear);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 切换到下一年
|
|
||||||
void _nextYear() {
|
|
||||||
if (widget.maxYear == null || _currentYear < widget.maxYear!) {
|
|
||||||
_animateYearChange(() {
|
|
||||||
setState(() {
|
|
||||||
_currentYear++;
|
|
||||||
});
|
|
||||||
widget.onYearChanged(_currentYear);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 年份变化时的动画效果
|
|
||||||
void _animateYearChange(VoidCallback onComplete) {
|
|
||||||
_animationController.forward().then((_) {
|
|
||||||
onComplete();
|
|
||||||
_animationController.reverse();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
circleIconButton(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.chevron_left,
|
|
||||||
onPressed: () => _previousYear(),
|
|
||||||
),
|
|
||||||
// 年份显示
|
|
||||||
AnimatedBuilder(
|
|
||||||
animation: _scaleAnimation,
|
|
||||||
builder: (context, child) {
|
|
||||||
return Transform.scale(scale: _scaleAnimation.value, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'$_currentYear',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
circleIconButton(
|
|
||||||
context: context,
|
|
||||||
icon: Icons.chevron_right,
|
|
||||||
onPressed: () => _nextYear(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,13 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <rive_native/rive_native_plugin.h>
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
|
g_autoptr(FlPluginRegistrar) rive_native_registrar =
|
||||||
|
fl_plugin_registry_get_registrar_for_plugin(registry, "RiveNativePlugin");
|
||||||
|
rive_native_plugin_register_with_registrar(rive_native_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
rive_native
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,16 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import file_picker
|
||||||
|
import flutter_image_compress_macos
|
||||||
|
import rive_native
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||||
|
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
|
||||||
|
RiveNativePlugin.register(with: registry.registrar(forPlugin: "RiveNativePlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
167
pubspec.lock
@@ -33,6 +33,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.12.0"
|
version: "2.12.0"
|
||||||
|
awesome_dialog:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: awesome_dialog
|
||||||
|
sha256: "4c5821a0a637ceee022084e78c1b8237dd4b8bfca4dd24ac2484662a56707338"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "3.3.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -41,6 +49,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
buffer:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: buffer
|
||||||
|
sha256: "389da2ec2c16283c8787e0adaede82b1842102f8c8aae2f49003a766c5c6b3d1"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.3"
|
||||||
build:
|
build:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -153,6 +169,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
|
cross_file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cross_file
|
||||||
|
sha256: "942a4791cd385a68ccb3b32c71c427aba508a1bb949b86dff2adbe4049f16239"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.5"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -177,8 +201,16 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.1"
|
version: "3.1.1"
|
||||||
|
dbus:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: dbus
|
||||||
|
sha256: "79e0c23480ff85dc68de79e2cd6334add97e48f7f4865d17686dd6ea81a47e8c"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.11"
|
||||||
dio:
|
dio:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dio
|
name: dio
|
||||||
sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9
|
sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9
|
||||||
@@ -225,6 +257,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.1"
|
version: "7.0.1"
|
||||||
|
file_picker:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: file_picker
|
||||||
|
sha256: "7872545770c277236fd32b022767576c562ba28366204ff1a5628853cf8f2200"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "10.3.7"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -238,6 +278,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_common:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "D:\\Projects\\FlutterProjects\\flutter_common"
|
||||||
|
relative: false
|
||||||
|
source: path
|
||||||
|
version: "1.0.0+1"
|
||||||
flutter_highlight:
|
flutter_highlight:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -246,6 +293,54 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.0"
|
version: "0.7.0"
|
||||||
|
flutter_image_compress:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress
|
||||||
|
sha256: "51d23be39efc2185e72e290042a0da41aed70b14ef97db362a6b5368d0523b27"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.0"
|
||||||
|
flutter_image_compress_common:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress_common
|
||||||
|
sha256: c5c5d50c15e97dd7dc72ff96bd7077b9f791932f2076c5c5b6c43f2c88607bfb
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.6"
|
||||||
|
flutter_image_compress_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress_macos
|
||||||
|
sha256: "20019719b71b743aba0ef874ed29c50747461e5e8438980dfa5c2031898f7337"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.3"
|
||||||
|
flutter_image_compress_ohos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress_ohos
|
||||||
|
sha256: e76b92bbc830ee08f5b05962fc78a532011fcd2041f620b5400a593e96da3f51
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.3"
|
||||||
|
flutter_image_compress_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress_platform_interface
|
||||||
|
sha256: "579cb3947fd4309103afe6442a01ca01e1e6f93dc53bb4cbd090e8ce34a41889"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.5"
|
||||||
|
flutter_image_compress_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_image_compress_web
|
||||||
|
sha256: b9b141ac7c686a2ce7bb9a98176321e1182c9074650e47bb140741a44b6f5a96
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.5"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -254,6 +349,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
sha256: c2fe1001710127dfa7da89977a08d591398370d099aacdaa6d44da7eb14b8476
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.31"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -264,6 +367,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
fluttertoast:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: fluttertoast
|
||||||
|
sha256: "90778fe0497fe3a09166e8cf2e0867310ff434b794526589e77ec03cf08ba8e8"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "8.2.14"
|
||||||
frontend_server_client:
|
frontend_server_client:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -393,7 +504,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.1"
|
version: "5.1.1"
|
||||||
logger:
|
logger:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: logger
|
name: logger
|
||||||
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
||||||
@@ -456,6 +567,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
minio:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: minio
|
||||||
|
sha256: ee2ce47766e46c7d164f960f2f5ed6a9a82844d877f6b82574f6876ec50c56d1
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "3.5.8"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -520,6 +639,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.3.0"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.0"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -568,6 +695,22 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.0"
|
version: "1.5.0"
|
||||||
|
rive:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: rive
|
||||||
|
sha256: fc0abf65d03d1c9afaeb35be9e71c7cf04d2d1f76e94e69d2af1b3ba413cddf9
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.14.0-dev.14"
|
||||||
|
rive_native:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: rive_native
|
||||||
|
sha256: e9c7d36f19eb6d32f563825d4e9d5032b19a36d3ca3341641431035bca022d19
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.17"
|
||||||
scroll_to_index:
|
scroll_to_index:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -577,7 +720,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.1"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences
|
name: shared_preferences
|
||||||
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
|
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
|
||||||
@@ -710,7 +853,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.1"
|
||||||
syncfusion_flutter_charts:
|
syncfusion_flutter_charts:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: syncfusion_flutter_charts
|
name: syncfusion_flutter_charts
|
||||||
sha256: "68fdb029dad34a46e4c9cfad8ad66fe29db7b303bd96849261ab2b23a168d0e8"
|
sha256: "68fdb029dad34a46e4c9cfad8ad66fe29db7b303bd96849261ab2b23a168d0e8"
|
||||||
@@ -893,6 +1036,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.3"
|
version: "3.0.3"
|
||||||
|
win32:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: win32
|
||||||
|
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "5.13.0"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -901,6 +1052,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
|
xml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.0"
|
||||||
yaml:
|
yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
73
pubspec.yaml
@@ -1,72 +1 @@
|
|||||||
name: blog_app
|
name: blog_app
|
||||||
description: "博客App"
|
|
||||||
# The following line prevents the package from being accidentally published to
|
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
# The following defines the version and build number for your application.
|
|
||||||
# A version number is three numbers separated by dots, like 1.2.43
|
|
||||||
# followed by an optional build number separated by a +.
|
|
||||||
# Both the version and the builder number may be overridden in flutter
|
|
||||||
# build by specifying --build-name and --build-number, respectively.
|
|
||||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
|
||||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
|
|
||||||
# Read more about iOS versioning at
|
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
|
||||||
version: 1.0.0+1
|
|
||||||
|
|
||||||
environment:
|
|
||||||
sdk: ^3.7.0
|
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
|
||||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
|
||||||
# dependencies can be manually updated by changing the version numbers below to
|
|
||||||
# the latest version available on pub.dev. To see which dependencies have newer
|
|
||||||
# versions available, run `flutter pub outdated`.
|
|
||||||
dependencies:
|
|
||||||
flutter:
|
|
||||||
sdk: flutter
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
|
||||||
cupertino_icons: ^1.0.8
|
|
||||||
markdown_widget: ^2.3.2+8
|
|
||||||
dio: ^5.7.0
|
|
||||||
shared_preferences: ^2.3.0
|
|
||||||
logger: ^2.6.0
|
|
||||||
json_annotation: ^4.9.0
|
|
||||||
intl: ^0.19.0
|
|
||||||
easy_refresh: ^3.4.0
|
|
||||||
timelines_plus: ^1.0.7
|
|
||||||
syncfusion_localizations: ^30.1.37
|
|
||||||
syncfusion_flutter_charts: ^30.1.41
|
|
||||||
provider: ^6.1.1
|
|
||||||
|
|
||||||
dev_dependencies:
|
|
||||||
flutter_test:
|
|
||||||
sdk: flutter
|
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
|
||||||
# package. See that file for information about deactivating specific lint
|
|
||||||
# rules and activating additional ones.
|
|
||||||
flutter_lints: ^5.0.0
|
|
||||||
build_runner: ^2.4.5
|
|
||||||
json_serializable: ^6.7.1
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
|
||||||
|
|
||||||
flutter:
|
|
||||||
uses-material-design: true
|
|
||||||
assets:
|
|
||||||
- assets/images/
|
|
||||||
fonts:
|
|
||||||
- family: CustomFont
|
|
||||||
fonts:
|
|
||||||
- asset: assets/fonts/custom.ttf
|
|
||||||
@@ -6,9 +6,12 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
|
#include <rive_native/rive_native_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
|
RiveNativePluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("RiveNativePlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
|
rive_native
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||