diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4fa84d..0d4bcd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,5 @@
# 1.9.10 (Unreleased)
-- [升级] Flutter 3.24.0
+- [升级] Flutter 3.24.3
- [升级] Package 升级及适配
- [升级] UniMPSDK 4.15
- [修改] 路由管理 fluro 替换为 go_router
diff --git a/README.md b/README.md
index e966a1e..f25376d 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,8 @@
-
-
+
+
@@ -100,12 +100,12 @@
Windows:
```
-[√] Flutter (Channel stable, 3.24.0, on Microsoft Windows [版本 10.0.22621.3007], locale zh-CN)
+[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [版本 10.0.22621.3007], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
-[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.5)
-[√] Android Studio (version 2024.1)
+[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
+[√] Android Studio (version 2024.2)
[√] IntelliJ IDEA Ultimate Edition (version 2024.2)
-[√] VS Code (version 1.92.0)
+[√] VS Code (version 1.94.2)
```
macOS:
diff --git a/android/app/build.gradle b/android/app/build.gradle
index c37c8c8..825a296 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -8,7 +8,7 @@ plugins {
android {
namespace = "com.example.moodexample"
compileSdk = flutter.compileSdkVersion
- ndkVersion = flutter.ndkVersion
+ ndkVersion = "25.1.8937393"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
diff --git a/android/build.gradle b/android/build.gradle
index 549140d..d2ffbff 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,9 +1,7 @@
allprojects {
repositories {
- // google()
- // mavenCentral()
- maven{ url "https://maven.aliyun.com/repository/public" }
- maven{ url "https://maven.aliyun.com/repository/google" }
+ google()
+ mavenCentral()
}
}
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index e1ca574..559efb4 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
diff --git a/android/settings.gradle b/android/settings.gradle
index 3b11d24..91bc9cc 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -10,18 +10,15 @@ pluginManagement {
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
- // google()
- // mavenCentral()
- // gradlePluginPortal()
- maven{ url "https://maven.aliyun.com/repository/public" }
- maven{ url "https://maven.aliyun.com/repository/google" }
- maven{ url "https://maven.aliyun.com/repository/gradle-plugin" }
+ google()
+ mavenCentral()
+ gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
- id "com.android.application" version "7.3.0" apply false
+ id "com.android.application" version "8.3.2" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}
diff --git a/lib/db/database/mood_info.dart b/lib/db/database/mood_info.dart
new file mode 100644
index 0000000..4f9b9c8
--- /dev/null
+++ b/lib/db/database/mood_info.dart
@@ -0,0 +1,46 @@
+/// 心情详细内容表
+class MoodInfo {
+ const MoodInfo._();
+
+ /// 表名称
+ static const String tableName = 'mood_info';
+
+ /// 字段名
+
+ /// 心情ID
+ static const String mood_id = 'mood_id';
+
+ /// 图标
+ static const String icon = 'icon';
+
+ /// 心情(标题)
+ static const String title = 'title';
+
+ /// 心情程度分数
+ static const String score = 'score';
+
+ /// 心情内容
+ static const String content = 'content';
+
+ /// 创建时间
+ static const String create_time = 'create_time';
+
+ /// 修改时间
+ static const String update_time = 'update_time';
+
+ /// 删除数据库
+ static const String dropTable = 'DROP TABLE IF EXISTS $tableName';
+
+ /// 创建数据库
+ static const String createTable = '''
+ CREATE TABLE $tableName (
+ $mood_id INTEGER PRIMARY KEY,
+ $icon TEXT NOT NULL,
+ $title TEXT NOT NULL,
+ $score INT NOT NULL,
+ $content TEXT NULL,
+ $create_time TEXT NOT NULL,
+ $update_time TEXT NOT NULL
+ );
+ ''';
+}
diff --git a/lib/db/database/mood_info_category.dart b/lib/db/database/mood_info_category.dart
new file mode 100644
index 0000000..20fbf7b
--- /dev/null
+++ b/lib/db/database/mood_info_category.dart
@@ -0,0 +1,30 @@
+/// 心情类别表
+class MoodInfoCategory {
+ const MoodInfoCategory._();
+
+ /// 表名称
+ static const String tableName = 'mood_info_category';
+
+ /// 字段名
+
+ /// 类别ID
+ static const String category_id = 'category_id';
+
+ /// 类别图标
+ static const String icon = 'icon';
+
+ /// 类别名称标题
+ static const String title = 'title';
+
+ /// 删除数据库
+ static const String dropTable = 'DROP TABLE IF EXISTS $tableName';
+
+ /// 创建数据库
+ static const String createTable = '''
+ CREATE TABLE $tableName (
+ $category_id INTEGER PRIMARY KEY,
+ $icon TEXT NOT NULL,
+ $title TEXT NOT NULL
+ );
+ ''';
+}
diff --git a/lib/db/database/table_mood_info.dart b/lib/db/database/table_mood_info.dart
deleted file mode 100644
index d4db6aa..0000000
--- a/lib/db/database/table_mood_info.dart
+++ /dev/null
@@ -1,44 +0,0 @@
-/// 心情详细内容表
-class TableMoodInfo {
- /// 表名称
- static const String tableName = 'mood_info';
-
- /// 字段名
-
- /// 心情ID
- static const String fieldMoodId = 'moodId';
-
- /// 图标
- static const String fieldIcon = 'icon';
-
- /// 心情(标题)
- static const String fieldTitle = 'title';
-
- /// 心情程度分数
- static const String fieldScore = 'score';
-
- /// 心情内容
- static const String fieldContent = 'content';
-
- /// 创建时间
- static const String fieldCreateTime = 'createTime';
-
- /// 修改时间
- static const String fieldUpdateTime = 'updateTime';
-
- /// 删除数据库
- final String dropTable = 'DROP TABLE IF EXISTS $tableName';
-
- /// 创建数据库
- final String createTable = '''
- CREATE TABLE $tableName (
- $fieldMoodId INTEGER PRIMARY KEY,
- $fieldIcon TEXT,
- $fieldTitle TEXT,
- $fieldScore INT,
- $fieldContent TEXT,
- $fieldCreateTime VARCHAR(40),
- $fieldUpdateTime VARCHAR(40)
- );
- ''';
-}
diff --git a/lib/db/database/table_mood_info_category.dart b/lib/db/database/table_mood_info_category.dart
deleted file mode 100644
index 6ce0164..0000000
--- a/lib/db/database/table_mood_info_category.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-/// 心情类别表
-class TableMoodInfoCategory {
- /// 表名称
- static const String tableName = 'mood_info_category';
-
- /// 字段名
-
- /// 类别ID
- static const String fieldCategoryId = 'categoryId';
-
- /// 类别图标
- static const String fieldIcon = 'icon';
-
- /// 类别名称标题
- static const String fieldTitle = 'title';
-
- /// 删除数据库
- final String dropTable = 'DROP TABLE IF EXISTS $tableName';
-
- /// 创建数据库
- final String createTable = '''
- CREATE TABLE $tableName (
- $fieldCategoryId INTEGER PRIMARY KEY,
- $fieldIcon TEXT,
- $fieldTitle TEXT
- );
- ''';
-}
diff --git a/lib/db/db.dart b/lib/db/db.dart
index 496c434..213d55d 100644
--- a/lib/db/db.dart
+++ b/lib/db/db.dart
@@ -4,8 +4,8 @@ import 'package:path/path.dart';
import 'package:moodexample/models/mood/mood_category_model.dart';
import 'package:moodexample/models/mood/mood_model.dart';
-import 'package:moodexample/db/database/table_mood_info.dart';
-import 'package:moodexample/db/database/table_mood_info_category.dart';
+import 'database/mood_info.dart';
+import 'database/mood_info_category.dart';
class DB {
DB._();
@@ -40,14 +40,13 @@ class DB {
final batch = db.batch();
/// 心情详细内容表
- final tableMoodInfo = TableMoodInfo();
- batch.execute(tableMoodInfo.dropTable);
- batch.execute(tableMoodInfo.createTable);
+ batch.execute(MoodInfo.dropTable);
+ batch.execute(MoodInfo.createTable);
/// 心情分类表
- final tableMoodInfoCategory = TableMoodInfoCategory();
- batch.execute(tableMoodInfoCategory.dropTable);
- batch.execute(tableMoodInfoCategory.createTable);
+ batch.execute(MoodInfoCategory.dropTable);
+ batch.execute(MoodInfoCategory.createTable);
+
await batch.commit();
}
@@ -67,16 +66,14 @@ class DB {
/// 查询心情详情
///
- /// [datetime] 查询日期(2022-01-04)
- ///
+ /// - [datetime] 查询日期(2022-01-04)
Future selectMood(String datetime) async {
final db = await database;
final List list = await db.query(
- TableMoodInfo.tableName,
- orderBy:
- '${TableMoodInfo.fieldCreateTime} asc, ${TableMoodInfo.fieldMoodId} desc',
+ MoodInfo.tableName,
+ orderBy: '${MoodInfo.create_time} asc, ${MoodInfo.mood_id} desc',
where: '''
- ${TableMoodInfo.fieldCreateTime} like ?
+ ${MoodInfo.create_time} like ?
''',
whereArgs: ['$datetime%'],
);
@@ -86,8 +83,7 @@ class DB {
/// 新增心情详情
Future insertMood(MoodData moodData) async {
final db = await database;
- final int result =
- await db.insert(TableMoodInfo.tableName, moodData.toJson());
+ final int result = await db.insert(MoodInfo.tableName, moodData.toJson());
return result > 0;
}
@@ -95,10 +91,10 @@ class DB {
Future updateMood(MoodData moodData) async {
final db = await database;
final int result = await db.update(
- TableMoodInfo.tableName,
+ MoodInfo.tableName,
moodData.toJson(),
- where: '${TableMoodInfo.fieldMoodId} = ?',
- whereArgs: [moodData.moodId],
+ where: '${MoodInfo.mood_id} = ?',
+ whereArgs: [moodData.mood_id],
);
return result > 0;
}
@@ -107,9 +103,9 @@ class DB {
Future deleteMood(MoodData moodData) async {
final db = await database;
final int result = await db.delete(
- TableMoodInfo.tableName,
- where: '${TableMoodInfo.fieldMoodId} = ?',
- whereArgs: [moodData.moodId],
+ MoodInfo.tableName,
+ where: '${MoodInfo.mood_id} = ?',
+ whereArgs: [moodData.mood_id],
);
return result > 0;
}
@@ -119,10 +115,10 @@ class DB {
final db = await database;
final List list = await db.rawQuery('''
SELECT
- DISTINCT DATE(${TableMoodInfo.fieldCreateTime}) as recordDate,
- ${TableMoodInfo.fieldIcon}
- FROM ${TableMoodInfo.tableName}
- group by recordDate
+ DISTINCT DATE(${MoodInfo.create_time}) as record_date,
+ ${MoodInfo.icon}
+ FROM ${MoodInfo.tableName}
+ group by record_date
''');
return list;
}
@@ -131,8 +127,8 @@ class DB {
Future selectAllMood() async {
final db = await database;
final List list = await db.query(
- TableMoodInfo.tableName,
- orderBy: '${TableMoodInfo.fieldCreateTime} desc',
+ MoodInfo.tableName,
+ orderBy: '${MoodInfo.create_time} desc',
);
return list;
}
@@ -142,7 +138,7 @@ class DB {
/// 查询所有心情类别
Future selectMoodCategoryAll() async {
final db = await database;
- final List list = await db.query(TableMoodInfoCategory.tableName);
+ final List list = await db.query(MoodInfoCategory.tableName);
return list;
}
@@ -152,7 +148,7 @@ class DB {
) async {
final db = await database;
final int result = await db.insert(
- TableMoodInfoCategory.tableName,
+ MoodInfoCategory.tableName,
moodCategoryData.toJson(),
);
return result > 0;
@@ -164,7 +160,7 @@ class DB {
Future selectAPPUsageDays() async {
final db = await database;
final List days = await db.rawQuery(
- 'SELECT count(DISTINCT DATE(${TableMoodInfo.fieldCreateTime})) as dayCount FROM ${TableMoodInfo.tableName}',
+ 'SELECT count(DISTINCT DATE(${MoodInfo.create_time})) as dayCount FROM ${MoodInfo.tableName}',
);
return days;
}
@@ -173,7 +169,7 @@ class DB {
Future selectAPPMoodCount() async {
final db = await database;
final List count = await db.rawQuery(
- 'SELECT count(${TableMoodInfo.fieldMoodId}) as moodCount FROM ${TableMoodInfo.tableName}',
+ 'SELECT count(${MoodInfo.mood_id}) as moodCount FROM ${MoodInfo.tableName}',
);
return count;
}
@@ -183,24 +179,23 @@ class DB {
final db = await database;
final List count = await db.rawQuery('''
SELECT
- (sum(${TableMoodInfo.fieldScore})/count(${TableMoodInfo.fieldMoodId})) as moodScoreAverage
- FROM ${TableMoodInfo.tableName}
+ (sum(${MoodInfo.score})/count(${MoodInfo.mood_id})) as moodScoreAverage
+ FROM ${MoodInfo.tableName}
''');
return count;
}
/// 统计-按日期获取平均情绪波动
///
- /// [datetime] 日期平均情绪波动 例如 2022-01-01
- ///
+ /// - [datetime] 日期平均情绪波动 例如 2022-01-01
Future selectDateMoodScoreAverage(String datetime) async {
final db = await database;
final List score = await db.rawQuery(
'''
SELECT
- (sum(${TableMoodInfo.fieldScore})/count(${TableMoodInfo.fieldMoodId})) as moodScoreAverage
- FROM ${TableMoodInfo.tableName}
- WHERE ${TableMoodInfo.fieldCreateTime} like ?
+ (sum(${MoodInfo.score})/count(${MoodInfo.mood_id})) as moodScoreAverage
+ FROM ${MoodInfo.tableName}
+ WHERE ${MoodInfo.create_time} like ?
''',
['$datetime%'],
);
@@ -209,21 +204,20 @@ class DB {
/// 统计-按日期时间段获取心情数量统计
///
- /// [startTime] 开始时间 例如 2022-01-01 00:00:00
- ///
- /// [endTime] 结束时间 例如 2022-01-01 23:59:59
+ /// - [startTime] 开始时间 例如 2022-01-01 00:00:00
+ /// - [endTime] 结束时间 例如 2022-01-01 23:59:59
Future selectDateMoodCount(String startTime, String endTime) async {
final db = await database;
final List count = await db.rawQuery(
'''
SELECT
- ${TableMoodInfo.fieldIcon},
- ${TableMoodInfo.fieldTitle},
- count(${TableMoodInfo.fieldMoodId}) as count
- FROM ${TableMoodInfo.tableName}
- WHERE ${TableMoodInfo.fieldCreateTime} >= ? and
- ${TableMoodInfo.fieldCreateTime} <= ?
- group by ${TableMoodInfo.fieldTitle}
+ ${MoodInfo.icon},
+ ${MoodInfo.title},
+ count(${MoodInfo.mood_id}) as count
+ FROM ${MoodInfo.tableName}
+ WHERE ${MoodInfo.create_time} >= ? and
+ ${MoodInfo.create_time} <= ?
+ group by ${MoodInfo.title}
order by count asc
''',
[startTime, endTime],
diff --git a/lib/models/config/language_model.dart b/lib/models/config/language_model.dart
index 1dd7768..6dc74a2 100644
--- a/lib/models/config/language_model.dart
+++ b/lib/models/config/language_model.dart
@@ -8,8 +8,9 @@ class LanguageData {
this.locale,
);
- // 语言名称
+ /// 语言名称
final String language;
- // Locale
+
+ /// Locale
final Locale locale;
}
diff --git a/lib/models/mood/mood_category_model.dart b/lib/models/mood/mood_category_model.dart
index 336a20a..1905ffa 100644
--- a/lib/models/mood/mood_category_model.dart
+++ b/lib/models/mood/mood_category_model.dart
@@ -20,9 +20,10 @@ class MoodCategoryData {
title: json['title'],
);
- // 表情
+ /// 表情
final String icon;
- // 标题
+
+ /// 标题
final String title;
Map toJson() => {
diff --git a/lib/models/mood/mood_model.dart b/lib/models/mood/mood_model.dart
index 9f39667..ecdb041 100644
--- a/lib/models/mood/mood_model.dart
+++ b/lib/models/mood/mood_model.dart
@@ -7,48 +7,54 @@ String moodDataToJson(MoodData data) => json.encode(data.toJson());
/// 心情详细数据
class MoodData {
MoodData({
- this.moodId,
- this.icon,
- this.title,
+ this.mood_id,
+ required this.icon,
+ required this.title,
this.score,
this.content,
- this.createTime,
- this.updateTime,
+ required this.create_time,
+ required this.update_time,
});
factory MoodData.fromJson(Map json) => MoodData(
- moodId: json['moodId'],
+ mood_id: json['mood_id'],
icon: json['icon'],
title: json['title'],
score: json['score'],
content: json['content'],
- createTime: json['createTime'],
- updateTime: json['updateTime'],
+ create_time: json['create_time'],
+ update_time: json['update_time'],
);
- // ID
- late int? moodId;
- // 图标
- late String? icon;
- // 标题(当前的心情)
- late String? title;
- // 分数
- late int? score;
- // 内容
- late String? content;
- // 创建日期
- late String? createTime;
- // 修改日期
- late String? updateTime;
+ /// ID
+ int? mood_id;
+
+ /// 图标
+ String icon;
+
+ /// 标题(当前的心情)
+ String title;
+
+ /// 分数
+ int? score;
+
+ /// 内容
+ String? content;
+
+ /// 创建日期
+ String create_time;
+
+ /// 修改日期
+ String update_time;
Map toJson() => {
- 'moodId': moodId,
+ 'mood_id': mood_id,
'icon': icon,
'title': title,
'score': score,
'content': content,
- 'createTime': createTime,
- 'updateTime': updateTime,
+ 'create_time': create_time,
+ 'update_time': update_time,
};
}
@@ -60,22 +66,23 @@ String moodRecordDataToJson(MoodRecordData data) => json.encode(data.toJson());
@immutable
class MoodRecordData {
const MoodRecordData({
- required this.recordDate,
+ required this.record_date,
required this.icon,
});
factory MoodRecordData.fromJson(Map json) => MoodRecordData(
- recordDate: json['recordDate'],
+ record_date: json['record_date'],
icon: json['icon'],
);
- // 记录日期
- final String recordDate;
- // 图标
+ /// 记录日期
+ final String record_date;
+
+ /// 图标
final String icon;
Map toJson() => {
- 'recordDate': recordDate,
+ 'record_date': record_date,
'icon': icon,
};
}
diff --git a/lib/models/statistic/statistic_model.dart b/lib/models/statistic/statistic_model.dart
index 4c0bfde..577d4bb 100644
--- a/lib/models/statistic/statistic_model.dart
+++ b/lib/models/statistic/statistic_model.dart
@@ -25,9 +25,10 @@ class StatisticMoodScoreAverageRecentlyData {
score: json['score'],
);
- // 记录日期
+ /// 记录日期
final String datetime;
- // 分数
+
+ /// 分数
final int score;
Map toJson() => {
@@ -59,11 +60,13 @@ class StatisticDateMoodCountData {
count: json['count'],
);
- // 图标
+ /// 图标
final String icon;
- // 心情(标题)
+
+ /// 心情(标题)
final String title;
- // 数量
+
+ /// 数量
final int count;
Map toJson() => {
diff --git a/lib/services/mood/mood_service.dart b/lib/services/mood/mood_service.dart
index 717c96e..2e46886 100644
--- a/lib/services/mood/mood_service.dart
+++ b/lib/services/mood/mood_service.dart
@@ -7,6 +7,8 @@ import 'package:moodexample/models/mood/mood_category_model.dart';
/// 心情相关
class MoodService {
+ const MoodService._();
+
/// 设置心情类别默认值
static Future setCategoryDefault() async {
/// 默认值
diff --git a/lib/services/statistic/statistic_service.dart b/lib/services/statistic/statistic_service.dart
index 04d340b..27488c0 100644
--- a/lib/services/statistic/statistic_service.dart
+++ b/lib/services/statistic/statistic_service.dart
@@ -9,6 +9,8 @@ import 'package:moodexample/models/statistic/statistic_model.dart';
/// 统计相关
class StatisticService {
+ const StatisticService._();
+
/// 获取APP累计记录天数
static Future getAPPUsageDays() async {
final list = await DB.instance.selectAPPUsageDays();
diff --git a/lib/views/home/index.dart b/lib/views/home/index.dart
index 0e1ba06..550a3ce 100644
--- a/lib/views/home/index.dart
+++ b/lib/views/home/index.dart
@@ -307,11 +307,13 @@ class OptionCard extends StatelessWidget {
// 跳转输入内容页
final String nowDateTime =
DateTime.now().toString().substring(0, 10);
- final MoodData moodData = MoodData();
- moodData.icon = icon;
- moodData.title = title;
- moodData.createTime = nowDateTime;
- moodData.updateTime = nowDateTime;
+ final MoodData moodData = MoodData(
+ icon: icon,
+ title: title,
+ create_time: nowDateTime,
+ update_time: nowDateTime,
+ );
+
return MoodContent(moodData: moodData);
},
);
diff --git a/lib/views/menu_screen/widgets/setting_database.dart b/lib/views/menu_screen/widgets/setting_database.dart
index 3dcf34f..9b527c8 100644
--- a/lib/views/menu_screen/widgets/setting_database.dart
+++ b/lib/views/menu_screen/widgets/setting_database.dart
@@ -1,5 +1,4 @@
import 'dart:io';
-import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -199,7 +198,7 @@ class _ImportDatabaseBodyState extends State {
child: Container(
width: 64,
height: 64,
- padding: const EdgeInsets.only(left: 12),
+ margin: const EdgeInsets.only(left: 12),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
@@ -390,7 +389,7 @@ Future importDatabaseTemplate() async {
TextCellValue('开心'),
TextCellValue('今天很开心'),
TextCellValue('55'),
- TextCellValue('2000-11-03'),
+ TextCellValue('2000-01-01'),
]);
/// 保存Excel
@@ -416,14 +415,14 @@ Future