feat:增加common框架
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:flisp_app/provider/app_provider.dart';
|
||||
import 'package:flisp_app/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/flutter_common.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class AppDrawer extends StatefulWidget {
|
||||
@@ -44,39 +44,6 @@ class AppDrawerState extends State<AppDrawer> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDarkModeSection(AppProvider appProvider) {
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
appProvider.isDarkMode ? Icons.dark_mode : Icons.light_mode,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
title: const Text('暗黑模式'),
|
||||
trailing: Switch(
|
||||
value: appProvider.isDarkMode,
|
||||
onChanged: (value) {
|
||||
appProvider.toggleDarkMode(value);
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
appProvider.toggleDarkMode(!appProvider.isDarkMode);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildThemeSection(AppProvider appProvider) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
||||
child: Text('主题颜色', style: Theme.of(context).textTheme.titleMedium),
|
||||
),
|
||||
_buildDarkModeSection(appProvider),
|
||||
buildThemeColorList(context, appProvider),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 构建抽屉菜单项
|
||||
Widget _buildDrawerItem({
|
||||
required IconData icon,
|
||||
@@ -123,7 +90,7 @@ class AppDrawerState extends State<AppDrawer> {
|
||||
padding: EdgeInsets.zero,
|
||||
children: [
|
||||
_buildDrawerHeader(),
|
||||
_buildThemeSection(appProvider),
|
||||
ThemeLayout(),
|
||||
const Divider(),
|
||||
_buildDrawerItem(
|
||||
icon: Icons.help,
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'package:flisp_app/models/todo.dart';
|
||||
import 'package:flisp_app/provider/app_provider.dart';
|
||||
import 'package:flisp_app/service/calendar_service.dart';
|
||||
import 'package:flisp_app/service/todo_service.dart';
|
||||
import 'package:flisp_app/utils/date_utils.dart';
|
||||
import 'package:flisp_app/utils/notify_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/utils/date_utils.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MainScreen extends StatefulWidget {
|
||||
|
||||
@@ -5,6 +5,8 @@ import 'package:flisp_app/provider/calendar_provider.dart';
|
||||
import 'package:flisp_app/provider/flisp_provider.dart';
|
||||
import 'package:flisp_app/utils/notify_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/flutter_common.dart';
|
||||
import 'package:flutter_common/utils/sp_utils.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -16,6 +18,9 @@ import 'provider/todo_provider.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// 初始化存储
|
||||
await SPUtil.init();
|
||||
|
||||
// 初始化提醒服务
|
||||
final notifyService = NotifyService();
|
||||
await notifyService.initialize();
|
||||
@@ -44,8 +49,18 @@ void main() async {
|
||||
// calendarBox.clear();
|
||||
|
||||
// notifyService.cancelAllNotifications();
|
||||
|
||||
runApp(const MyApp());
|
||||
runApp(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => AppProvider()),
|
||||
ChangeNotifierProvider(create: (_) => ThemeProvider()),
|
||||
ChangeNotifierProvider(create: (_) => TodoProvider()),
|
||||
ChangeNotifierProvider(create: (_) => FlispProvider()),
|
||||
ChangeNotifierProvider(create: (_) => CalendarProvider()),
|
||||
],
|
||||
child: MyApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@@ -53,15 +68,8 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => AppProvider()),
|
||||
ChangeNotifierProvider(create: (_) => TodoProvider()),
|
||||
ChangeNotifierProvider(create: (_) => FlispProvider()),
|
||||
ChangeNotifierProvider(create: (_) => CalendarProvider()),
|
||||
],
|
||||
child: Consumer<AppProvider>(
|
||||
builder: (context, appProvider, child) {
|
||||
final themeProvider = context.watch<ThemeProvider>();
|
||||
|
||||
return MaterialApp(
|
||||
title: '闪灵',
|
||||
localizationsDelegates: [
|
||||
@@ -72,12 +80,9 @@ class MyApp extends StatelessWidget {
|
||||
],
|
||||
supportedLocales: [const Locale('zh'), const Locale('zh', 'CN')],
|
||||
locale: Locale('zh', 'CN'),
|
||||
theme: appProvider.currentThemeData,
|
||||
theme: themeProvider.currentThemeData,
|
||||
home: const MainScreen(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:flisp_app/models/calendar.dart';
|
||||
import 'package:flisp_app/provider/calendar_provider.dart';
|
||||
import 'package:flisp_app/service/calendar_service.dart';
|
||||
import 'package:flisp_app/utils/notify_utils.dart';
|
||||
import 'package:flisp_app/widgets/awesome_dialog.dart';
|
||||
import 'package:flisp_app/widgets/calendar_form.dart';
|
||||
import 'package:flisp_app/widgets/calendar_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||
@@ -107,9 +107,9 @@ class CalendarPageState extends State<CalendarPage> {
|
||||
});
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, isEditing ? '更新成功' : '添加成功');
|
||||
showSuccessTip(context, isEditing ? '更新成功' : '添加成功');
|
||||
} else {
|
||||
showErrorDialog(context, isEditing ? '更新失败' : '添加失败');
|
||||
showErrorTip(context, isEditing ? '更新失败' : '添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ class CalendarPageState extends State<CalendarPage> {
|
||||
});
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, '删除成功');
|
||||
showSuccessTip(context, '删除成功');
|
||||
} else {
|
||||
showErrorDialog(context, '删除失败');
|
||||
showErrorTip(context, '删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ import 'package:flisp_app/models/flisp.dart';
|
||||
import 'package:flisp_app/provider/flisp_provider.dart';
|
||||
import 'package:flisp_app/service/flisp_service.dart';
|
||||
import 'package:flisp_app/utils/flisp_utils.dart';
|
||||
import 'package:flisp_app/widgets/awesome_dialog.dart';
|
||||
import 'package:flisp_app/widgets/flisp_form.dart';
|
||||
import 'package:flisp_app/widgets/flisp_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
@@ -117,9 +117,9 @@ class FlispPageState extends State<FlispPage> {
|
||||
});
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, isEditing ? '更新成功' : '添加成功');
|
||||
showSuccessTip(context, isEditing ? '更新成功' : '添加成功');
|
||||
} else {
|
||||
showErrorDialog(context, isEditing ? '更新失败' : '添加失败');
|
||||
showErrorTip(context, isEditing ? '更新失败' : '添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ class FlispPageState extends State<FlispPage> {
|
||||
});
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, '删除成功');
|
||||
showSuccessTip(context, '删除成功');
|
||||
} else {
|
||||
showErrorDialog(context, '删除失败');
|
||||
showErrorTip(context, '删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ import 'package:flisp_app/models/flisp.dart';
|
||||
import 'package:flisp_app/models/todo.dart';
|
||||
import 'package:flisp_app/service/flisp_service.dart';
|
||||
import 'package:flisp_app/service/todo_service.dart';
|
||||
import 'package:flisp_app/widgets/chart.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flisp_app/widgets/flisp_widget.dart';
|
||||
import 'package:flisp_app/widgets/todo_widget.dart';
|
||||
import 'package:flisp_app/widgets/year_selector.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/models/common_model.dart';
|
||||
import 'package:flutter_common/widget/chart.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:flutter_common/widget/year_selector.dart';
|
||||
|
||||
class StatsPage extends StatefulWidget {
|
||||
const StatsPage({super.key});
|
||||
@@ -128,44 +129,6 @@ class StatsPageState extends State<StatsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlispMonthlyStats(BuildContext context) {
|
||||
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: flispMonthlyStats,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlispCategoryStats(BuildContext context) {
|
||||
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: flispCategoryStats,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTodoStats(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
@@ -183,52 +146,13 @@ class StatsPageState extends State<StatsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTodoMonthlyStats(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
buildChartTitle(context, '每月待办数量统计', Icons.bar_chart),
|
||||
const SizedBox(height: 3),
|
||||
buildChartDivider(context),
|
||||
const SizedBox(height: 3),
|
||||
Expanded(
|
||||
child: doubleBarChart(
|
||||
context: context,
|
||||
xAxisName: '月份',
|
||||
yAxisName: '数量',
|
||||
unit: '个',
|
||||
data1: todoMonthlyStats,
|
||||
data2: todoMonthlyCompleteStats,
|
||||
series1Name: '总数',
|
||||
series2Name: '完成数',
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTodoPriorityStats(BuildContext context) {
|
||||
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: todoPriorityStats),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
YearSelector(
|
||||
initialYear: DateTime.now().year,
|
||||
minYear: 2000,
|
||||
maxYear: 2100,
|
||||
currentYear: DateTime.now().year,
|
||||
onYearChanged:
|
||||
(year) => {
|
||||
setState(() {
|
||||
@@ -243,22 +167,53 @@ class StatsPageState extends State<StatsPage> {
|
||||
SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: chartHeight,
|
||||
child: BuildCard(child: _buildFlispMonthlyStats(context)),
|
||||
child: CommonCard(
|
||||
child: LineChart(
|
||||
title: '每月闪灵数量统计',
|
||||
xAxisName: '月份',
|
||||
yAxisName: '数量',
|
||||
unit: '篇',
|
||||
data: flispMonthlyStats,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: chartHeight,
|
||||
child: BuildCard(child: _buildFlispCategoryStats(context)),
|
||||
child: CommonCard(
|
||||
child: PieChart(
|
||||
title: '闪灵分类统计',
|
||||
unit: '篇',
|
||||
data: flispCategoryStats,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: chartHeight,
|
||||
child: BuildCard(child: _buildTodoMonthlyStats(context)),
|
||||
child: CommonCard(
|
||||
child: DoubleBarChart(
|
||||
title: '每月待办数量统计',
|
||||
xAxisName: '月份',
|
||||
yAxisName: '数量',
|
||||
unit: '个',
|
||||
data1: todoMonthlyStats,
|
||||
data2: todoMonthlyCompleteStats,
|
||||
series1Name: '总数',
|
||||
series2Name: '完成数',
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
SizedBox(
|
||||
height: chartHeight,
|
||||
child: BuildCard(child: _buildTodoPriorityStats(context)),
|
||||
child: CommonCard(
|
||||
child: PieChart(
|
||||
title: '待办分类统计',
|
||||
unit: '个',
|
||||
data: todoPriorityStats,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flisp_app/provider/todo_provider.dart';
|
||||
import 'package:flisp_app/service/todo_service.dart';
|
||||
import 'package:flisp_app/utils/notify_utils.dart';
|
||||
import 'package:flisp_app/widgets/awesome_dialog.dart';
|
||||
import 'package:flisp_app/widgets/todo_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flisp_app/models/todo.dart';
|
||||
@@ -187,9 +187,9 @@ class TodoPageState extends State<TodoPage> {
|
||||
_refreshTodos();
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, isEditing ? '更新成功' : '添加成功');
|
||||
showSuccessTip(context, isEditing ? '更新成功' : '添加成功');
|
||||
} else {
|
||||
showErrorDialog(context, isEditing ? '更新失败' : '添加失败');
|
||||
showErrorTip(context, isEditing ? '更新失败' : '添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ class TodoPageState extends State<TodoPage> {
|
||||
_refreshTodos();
|
||||
|
||||
if (isSuccess) {
|
||||
showSuccessDialog(context, '删除成功');
|
||||
showSuccessTip(context, '删除成功');
|
||||
} else {
|
||||
showErrorDialog(context, '删除失败');
|
||||
showErrorTip(context, '删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +1,14 @@
|
||||
import 'package:flisp_app/utils/theme_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppProvider with ChangeNotifier {
|
||||
static const String _themeKey = 'selected_theme';
|
||||
static const String _darkModeKey = 'is_dark_mode';
|
||||
static const List<String> appBarTitles = ['闪灵', '待办', '日程', '统计'];
|
||||
|
||||
int currentTab = 0;
|
||||
String currentAppBarTitle = '闪灵';
|
||||
bool isDarkMode = false;
|
||||
ThemeColor currentTheme = defaultThemes[0];
|
||||
String appVersion = '1.0.0';
|
||||
String buildNumber = '1';
|
||||
|
||||
late SharedPreferences _prefs;
|
||||
bool isInitialized = false;
|
||||
|
||||
AppProvider() {
|
||||
_initPreferences();
|
||||
}
|
||||
|
||||
// 初始化 SharedPreferences
|
||||
Future<void> _initPreferences() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
_loadPreferences();
|
||||
await _getVersionInfo();
|
||||
|
||||
isInitialized = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 加载存储的设置
|
||||
void _loadPreferences() {
|
||||
isDarkMode = _prefs.getBool(_darkModeKey) ?? false;
|
||||
|
||||
// 加载主题色
|
||||
final themeName = _prefs.getString(_themeKey);
|
||||
if (themeName != null) {
|
||||
currentTheme = getThemeColor(themeName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getVersionInfo() async {
|
||||
try {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
appVersion = packageInfo.version;
|
||||
buildNumber = packageInfo.buildNumber;
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
print('获取版本信息失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// 保存主题色
|
||||
Future<void> _saveTheme() async {
|
||||
await _prefs.setString(_themeKey, currentTheme.name);
|
||||
}
|
||||
|
||||
// 保存暗黑模式
|
||||
Future<void> _saveDarkMode() async {
|
||||
await _prefs.setBool(_darkModeKey, isDarkMode);
|
||||
}
|
||||
|
||||
List<ThemeColor> get availableThemes => defaultThemes;
|
||||
|
||||
String get fullVersion => '$appVersion+$buildNumber';
|
||||
|
||||
void changeTab(int index) {
|
||||
@@ -73,30 +16,4 @@ class AppProvider with ChangeNotifier {
|
||||
currentAppBarTitle = appBarTitles[index];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 切换明暗模式
|
||||
void toggleDarkMode(bool value) {
|
||||
isDarkMode = value;
|
||||
_saveDarkMode();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 更改主题色
|
||||
void changeTheme(ThemeColor theme) {
|
||||
currentTheme = theme;
|
||||
_saveTheme();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
ThemeData get currentThemeData {
|
||||
return ThemeData(
|
||||
primarySwatch: currentTheme.materialColor,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: currentTheme.primaryColor,
|
||||
brightness: isDarkMode ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
useMaterial3: true,
|
||||
fontFamily: 'CustomFont',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
String formatDate(DateTime date) {
|
||||
return DateFormat('yyyy-MM-dd').format(date);
|
||||
}
|
||||
|
||||
String formatTime(DateTime datetime) {
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||
}
|
||||
|
||||
bool isToday(DateTime? date) {
|
||||
if (date == null) return false;
|
||||
|
||||
final now = DateTime.now();
|
||||
return date.year == now.year &&
|
||||
date.month == now.month &&
|
||||
date.day == now.day;
|
||||
}
|
||||
|
||||
bool isAfterToday(DateTime? date) {
|
||||
if (date == null) return false;
|
||||
|
||||
if (!isToday(date)) return false;
|
||||
|
||||
return date.isAfter(DateTime.now());
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
import 'dart:io';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:minio/io.dart';
|
||||
import 'package:minio/minio.dart';
|
||||
|
||||
class MinIOHelper {
|
||||
static final MinIOHelper _instance = MinIOHelper._internal();
|
||||
|
||||
factory MinIOHelper() => _instance;
|
||||
|
||||
final String rustfsIp = '14.103.235.151';
|
||||
final String rustfsFileUrl = 'http://14.103.235.151:9100';
|
||||
final String bucketName = 'flisp';
|
||||
|
||||
MinIOHelper._internal() {
|
||||
_minio = Minio(
|
||||
endPoint: rustfsIp,
|
||||
port: 9100,
|
||||
accessKey: "tHSFfcDW8qpCzKa2Xg6Y",
|
||||
secretKey: "oq79EeYJ4jdczRp2IHUMCnbKtSw58NgDlG3sOkvX",
|
||||
useSSL: false,
|
||||
);
|
||||
}
|
||||
|
||||
late Minio _minio;
|
||||
|
||||
Future<String> uploadFile({
|
||||
required PlatformFile file,
|
||||
Function(double)? onProgress,
|
||||
}) async {
|
||||
try {
|
||||
String hashName = await _generateMD5HashName(file.path!);
|
||||
String fileName = '$hashName${_getFileExtension(file.name)}';
|
||||
|
||||
await _minio.fPutObject(bucketName, fileName, file.path!);
|
||||
return fileName;
|
||||
} catch (e) {
|
||||
throw Exception('文件上传失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String _getFileExtension(String fileName) {
|
||||
if (fileName.contains('.')) {
|
||||
return '.${fileName.split('.').last.toLowerCase()}';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Future<String> _generateMD5HashName(String filePath) async {
|
||||
final file = File(filePath);
|
||||
final bytes = await file.readAsBytes();
|
||||
final hash = md5.convert(bytes);
|
||||
return hash.toString();
|
||||
}
|
||||
}
|
||||
@@ -101,9 +101,8 @@ class NotifyService {
|
||||
body,
|
||||
tz.TZDateTime.from(scheduledTime, tz.local),
|
||||
_details,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime,
|
||||
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
|
||||
uiLocalNotificationDateInterpretation: dateInterpretation,
|
||||
androidScheduleMode: scheduleMode,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ class NotifyService {
|
||||
Future<void> cancelNotification(int id) async {
|
||||
try {
|
||||
await _notifications.cancel(id);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
print('取消通知失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flisp_app/provider/app_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ThemeColor {
|
||||
final String name;
|
||||
final Color primaryColor;
|
||||
final MaterialColor materialColor;
|
||||
|
||||
ThemeColor({
|
||||
required this.name,
|
||||
required this.primaryColor,
|
||||
required this.materialColor,
|
||||
});
|
||||
}
|
||||
|
||||
final List<ThemeColor> defaultThemes = [
|
||||
ThemeColor(
|
||||
name: '梦幻紫',
|
||||
primaryColor: Color(0xFF8B5CF6),
|
||||
materialColor: MaterialColor(0xFF8B5CF6, {
|
||||
50: Color(0xFFF5F3FF),
|
||||
100: Color(0xFFEDE9FE),
|
||||
200: Color(0xFFDDD6FE),
|
||||
300: Color(0xFFC4B5FD),
|
||||
400: Color(0xFFA78BFA),
|
||||
500: Color(0xFF8B5CF6),
|
||||
600: Color(0xFF7C3AED),
|
||||
700: Color(0xFF6D28D9),
|
||||
800: Color(0xFF5B21B6),
|
||||
900: Color(0xFF4C1D95),
|
||||
}),
|
||||
),
|
||||
ThemeColor(
|
||||
name: '活力橙',
|
||||
primaryColor: Color(0xFFF59E0B),
|
||||
materialColor: MaterialColor(0xFFF59E0B, {
|
||||
50: Color(0xFFFFFBEB),
|
||||
100: Color(0xFFFEF3C7),
|
||||
200: Color(0xFFFDE68A),
|
||||
300: Color(0xFFFCD34D),
|
||||
400: Color(0xFFFBBF24),
|
||||
500: Color(0xFFF59E0B),
|
||||
600: Color(0xFFD97706),
|
||||
700: Color(0xFFB45309),
|
||||
800: Color(0xFF92400E),
|
||||
900: Color(0xFF78350F),
|
||||
}),
|
||||
),
|
||||
ThemeColor(
|
||||
name: '浪漫粉',
|
||||
primaryColor: Color(0xFFEC4899),
|
||||
materialColor: MaterialColor(0xFFEC4899, {
|
||||
50: Color(0xFFFDF2F8),
|
||||
100: Color(0xFFFCE7F3),
|
||||
200: Color(0xFFFBCFE8),
|
||||
300: Color(0xFFF9A8D4),
|
||||
400: Color(0xFFF472B6),
|
||||
500: Color(0xFFEC4899),
|
||||
600: Color(0xFFDB2777),
|
||||
700: Color(0xFFBE185D),
|
||||
800: Color(0xFF9D174D),
|
||||
900: Color(0xFF831843),
|
||||
}),
|
||||
),
|
||||
ThemeColor(
|
||||
name: '清新青',
|
||||
primaryColor: Color(0xFF06B6D4),
|
||||
materialColor: MaterialColor(0xFF06B6D4, {
|
||||
50: Color(0xFFF0FDFA),
|
||||
100: Color(0xFFCCFBF1),
|
||||
200: Color(0xFF99F6E4),
|
||||
300: Color(0xFF5EEAD4),
|
||||
400: Color(0xFF2DD4BF),
|
||||
500: Color(0xFF06B6D4),
|
||||
600: Color(0xFF0891B2),
|
||||
700: Color(0xFF0E7490),
|
||||
800: Color(0xFF155E75),
|
||||
900: Color(0xFF164E63),
|
||||
}),
|
||||
),
|
||||
];
|
||||
|
||||
ThemeColor getThemeColor(String themeName) {
|
||||
return defaultThemes.firstWhere(
|
||||
(theme) => theme.name == themeName,
|
||||
orElse: () => defaultThemes[0],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildThemeColorList(BuildContext context, AppProvider appProvider) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
childAspectRatio: 1.2,
|
||||
),
|
||||
itemCount: appProvider.availableThemes.length,
|
||||
itemBuilder: (context, index) {
|
||||
final themeColor = appProvider.availableThemes[index];
|
||||
final isSelected = appProvider.currentTheme == themeColor;
|
||||
|
||||
return _buildThemeColorItem(
|
||||
themeColor: themeColor,
|
||||
isSelected: isSelected,
|
||||
onTap: () => appProvider.changeTheme(themeColor),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildThemeColorItem({
|
||||
required ThemeColor themeColor,
|
||||
required bool isSelected,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isSelected
|
||||
? themeColor.primaryColor.withAlpha(50)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isSelected ? themeColor.primaryColor : Colors.grey.shade300,
|
||||
width: isSelected ? 2 : 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// 颜色圆点
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: themeColor.primaryColor,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withAlpha(10),
|
||||
blurRadius: 2,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
themeColor.name,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color:
|
||||
isSelected ? themeColor.primaryColor : Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class ToastUtil {
|
||||
static void success(String message) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.TOP,
|
||||
backgroundColor: Colors.green,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0,
|
||||
);
|
||||
}
|
||||
|
||||
static void error(String message) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.TOP,
|
||||
backgroundColor: Colors.red,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0,
|
||||
);
|
||||
}
|
||||
|
||||
static void warning(String message) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.TOP,
|
||||
backgroundColor: Colors.orange,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0,
|
||||
);
|
||||
}
|
||||
|
||||
static void info(String message) {
|
||||
Fluttertoast.showToast(
|
||||
msg: message,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.TOP,
|
||||
backgroundColor: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import 'package:awesome_dialog/awesome_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void showAwesomeDialog({
|
||||
required BuildContext context,
|
||||
required Widget body,
|
||||
required VoidCallback onOk,
|
||||
required VoidCallback onCancel,
|
||||
}) {
|
||||
AwesomeDialog(
|
||||
context: context,
|
||||
dialogType: DialogType.noHeader,
|
||||
animType: AnimType.scale,
|
||||
body: body,
|
||||
dialogBackgroundColor: Theme.of(context).colorScheme.surfaceContainer,
|
||||
btnOkText: "确认",
|
||||
btnCancelText: "取消",
|
||||
btnOkColor: Colors.orange,
|
||||
btnCancelColor: Colors.grey,
|
||||
buttonsBorderRadius: BorderRadius.circular(10),
|
||||
headerAnimationLoop: false,
|
||||
dismissOnTouchOutside: false,
|
||||
dismissOnBackKeyPress: true,
|
||||
btnOk: ElevatedButton(
|
||||
onPressed: onOk,
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 6),
|
||||
textStyle: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, fontFamily: 'CustomFont'),
|
||||
),
|
||||
child: Text("确认"),
|
||||
),
|
||||
btnCancelOnPress: onCancel,
|
||||
).show();
|
||||
}
|
||||
|
||||
// 显示成功提示
|
||||
void showSuccessDialog(BuildContext context, String message) {
|
||||
AwesomeDialog(
|
||||
context: context,
|
||||
dialogType: DialogType.success,
|
||||
animType: AnimType.scale,
|
||||
title: message,
|
||||
btnOkText: "好的",
|
||||
btnOkColor: Colors.green,
|
||||
btnOkOnPress: () {},
|
||||
autoHide: Duration(seconds: 2),
|
||||
).show();
|
||||
}
|
||||
|
||||
// 显示失败提示
|
||||
void showErrorDialog(BuildContext context, String message) {
|
||||
AwesomeDialog(
|
||||
context: context,
|
||||
dialogType: DialogType.error,
|
||||
animType: AnimType.scale,
|
||||
title: message,
|
||||
btnOkText: "好的",
|
||||
btnOkColor: Colors.red,
|
||||
btnOkOnPress: () {},
|
||||
autoHide: Duration(seconds: 2),
|
||||
).show();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flisp_app/models/calendar.dart';
|
||||
import 'package:flisp_app/provider/calendar_provider.dart';
|
||||
import 'package:flisp_app/utils/date_utils.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flisp_app/models/calendar.dart';
|
||||
import 'package:flisp_app/provider/calendar_provider.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:syncfusion_flutter_calendar/calendar.dart';
|
||||
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
|
||||
class ChartData {
|
||||
final String name;
|
||||
final double value;
|
||||
|
||||
ChartData({required this.name, required this.value});
|
||||
}
|
||||
|
||||
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,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/dialog_widget.dart';
|
||||
import 'package:toggle_switch/toggle_switch.dart';
|
||||
|
||||
OutlineInputBorder buildFormBoard() {
|
||||
@@ -22,28 +23,6 @@ OutlineInputBorder buildFormFocusedBoard(ColorScheme colors) {
|
||||
);
|
||||
}
|
||||
|
||||
// 卡片
|
||||
class BuildCard extends StatelessWidget {
|
||||
final Widget? child;
|
||||
|
||||
const BuildCard({super.key, this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surfaceContainer,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
// border: Border.all(color: colors.outline.withAlpha(50), width: 1),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部弹出
|
||||
void buildModalBottom({
|
||||
required BuildContext context,
|
||||
@@ -152,35 +131,6 @@ Widget buildDismissible({
|
||||
);
|
||||
}
|
||||
|
||||
// 确认对话框
|
||||
Future<bool?> showConfirmDialog(BuildContext context, String text) async {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('确认'),
|
||||
backgroundColor: colors.surfaceContainer,
|
||||
content: Text(text),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: colors.secondary.withAlpha(150)),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text('确认', style: TextStyle(color: colors.primary)),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDismissBackground() {
|
||||
return Container(
|
||||
color: Colors.red,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flisp_app/models/flisp.dart';
|
||||
import 'package:flisp_app/provider/flisp_provider.dart';
|
||||
import 'package:flisp_app/utils/minio_utils.dart';
|
||||
import 'package:flisp_app/widgets/flisp_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/utils/minio_utils.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -28,6 +28,7 @@ class FlispForm extends StatefulWidget {
|
||||
class _FlispFormState extends State<FlispForm> {
|
||||
bool _showTagOptions = false;
|
||||
final int maxContentCount = 100;
|
||||
final String bucketName = 'flisp';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -52,7 +53,7 @@ class _FlispFormState extends State<FlispForm> {
|
||||
final provider = Provider.of<FlispProvider>(context, listen: false);
|
||||
setState(() {
|
||||
provider.formItem.imageUrl =
|
||||
'${MinIOHelper().rustfsFileUrl}/${MinIOHelper().bucketName}/$fileName';
|
||||
'${MinIOHelper().fileUrl}/$bucketName/$fileName';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,7 +157,10 @@ class _FlispFormState extends State<FlispForm> {
|
||||
|
||||
if (result != null) {
|
||||
PlatformFile file = result.files.first;
|
||||
final fileName = await MinIOHelper().uploadFile(file: file);
|
||||
final fileName = await MinIOHelper().uploadFile(
|
||||
bucketName: bucketName,
|
||||
file: file,
|
||||
);
|
||||
_selectImage(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flisp_app/models/flisp.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
Widget buildFlispStatsCard(BuildContext context, List<Flisp> flisps) {
|
||||
@@ -10,7 +11,7 @@ Widget buildFlispStatsCard(BuildContext context, List<Flisp> flisps) {
|
||||
int workCount = flisps.where((flisp) => flisp.tag == FlispTag.work).length;
|
||||
int studyCount = flisps.where((flisp) => flisp.tag == FlispTag.study).length;
|
||||
|
||||
return BuildCard(
|
||||
return CommonCard(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -275,7 +276,7 @@ Widget _buildFlispItem({
|
||||
context: context,
|
||||
id: flisp.id,
|
||||
onDelete: () => onDelete(flisp),
|
||||
child: BuildCard(
|
||||
child: CommonCard(
|
||||
child: InkWell(
|
||||
onTap: () => onEdit(flisp),
|
||||
child: Column(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
|
||||
class StatisticCard extends StatelessWidget {
|
||||
final IconData icon;
|
||||
@@ -19,7 +19,7 @@ class StatisticCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BuildCard(
|
||||
return CommonCard(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flisp_app/models/todo.dart';
|
||||
import 'package:flisp_app/utils/todo_utils.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_common/widget/common_widget.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// 统计卡片
|
||||
@@ -12,7 +13,7 @@ Widget buildTodoStatsCard(BuildContext context, List<Todo> todos) {
|
||||
|
||||
int completedCount = todos.where((todo) => todo.isCompleted).length;
|
||||
|
||||
return BuildCard(
|
||||
return CommonCard(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
@@ -94,7 +95,7 @@ Widget _buildTodoItem({
|
||||
context: context,
|
||||
id: todo.id,
|
||||
onDelete: () => onDelete(todo),
|
||||
child: BuildCard(
|
||||
child: CommonCard(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||
leading: SizedBox(
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
import 'package:flisp_app/widgets/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).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
circleIconButton(
|
||||
context: context,
|
||||
icon: Icons.chevron_right,
|
||||
onPressed: () => _nextYear(),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_picker
|
||||
import flutter_image_compress_macos
|
||||
import flutter_local_notifications
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
@@ -14,6 +15,7 @@ import shared_preferences_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
|
||||
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
|
||||
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
|
||||
91
pubspec.lock
91
pubspec.lock
@@ -39,7 +39,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.12.0"
|
||||
awesome_dialog:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: awesome_dialog
|
||||
sha256: "4c5821a0a637ceee022084e78c1b8237dd4b8bfca4dd24ac2484662a56707338"
|
||||
@@ -183,7 +183,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.3.5"
|
||||
crypto:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
@@ -214,6 +214,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.7.11"
|
||||
dio:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dio
|
||||
sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.9.0"
|
||||
dio_web_adapter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dio_web_adapter
|
||||
sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -259,6 +275,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
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_form_builder:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -267,6 +290,54 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "10.0.1"
|
||||
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:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -323,7 +394,7 @@ packages:
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
fluttertoast:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fluttertoast
|
||||
sha256: "90778fe0497fe3a09166e8cf2e0867310ff434b794526589e77ec03cf08ba8e8"
|
||||
@@ -474,6 +545,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.1.1"
|
||||
logger:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logger
|
||||
sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -523,7 +602,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
minio:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: minio
|
||||
sha256: ee2ce47766e46c7d164f960f2f5ed6a9a82844d877f6b82574f6876ec50c56d1
|
||||
@@ -691,7 +770,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.0.16"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
|
||||
@@ -832,7 +911,7 @@ packages:
|
||||
source: hosted
|
||||
version: "30.2.7"
|
||||
syncfusion_flutter_charts:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: syncfusion_flutter_charts
|
||||
sha256: "68fdb029dad34a46e4c9cfad8ad66fe29db7b303bd96849261ab2b23a168d0e8"
|
||||
|
||||
11
pubspec.yaml
11
pubspec.yaml
@@ -17,14 +17,8 @@ dependencies:
|
||||
cupertino_icons: ^1.0.8
|
||||
# 状态管理
|
||||
provider: ^6.1.1
|
||||
# 本地存储
|
||||
shared_preferences: ^2.2.2
|
||||
# 对话框组件
|
||||
awesome_dialog: ^3.3.0
|
||||
# 切换开关组件
|
||||
toggle_switch: ^2.3.0
|
||||
# 轻量级提示
|
||||
fluttertoast: ^8.2.2
|
||||
# 表单构建器
|
||||
flutter_form_builder: ^10.0.0
|
||||
# 表单验证器
|
||||
@@ -42,12 +36,11 @@ dependencies:
|
||||
# 时区支持
|
||||
timezone: ^0.10.1
|
||||
file_picker: ^10.3.3
|
||||
minio: ^3.5.8
|
||||
crypto: ^3.0.7
|
||||
syncfusion_flutter_calendar: ^30.1.37
|
||||
syncfusion_localizations: ^30.1.37
|
||||
syncfusion_flutter_charts: ^30.1.41
|
||||
package_info_plus: ^8.0.0
|
||||
flutter_common:
|
||||
path: ..\flutter_common
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user