1.修复一个小bug

2.当前donelist的样式算是敲定了吧
This commit is contained in:
oldchen
2019-07-21 14:51:52 +08:00
parent 6a5ec7e5ba
commit c69eb866e5
16 changed files with 436 additions and 172 deletions

View File

@ -22,7 +22,10 @@ class DBProvider {
initDB() async { initDB() async {
var dataBasePath = await getDatabasesPath(); var dataBasePath = await getDatabasesPath();
String path = join(dataBasePath, "todo.db"); String path = join(dataBasePath, "todo.db");
return await openDatabase(path, version: 1, onOpen: (db) {}, return await openDatabase(
path,
version: 2,
onOpen: (db) {},
onCreate: (Database db, int version) async { onCreate: (Database db, int version) async {
await db.execute("CREATE TABLE TodoList (" await db.execute("CREATE TABLE TodoList ("
"id INTEGER PRIMARY KEY AUTOINCREMENT," "id INTEGER PRIMARY KEY AUTOINCREMENT,"
@ -39,7 +42,13 @@ class DBProvider {
"detailList TEXT," "detailList TEXT,"
"taskIconBean TEXT" "taskIconBean TEXT"
")"); ")");
}); },
onUpgrade: (Database db, int oldVersion, int newVersion) async{
if(oldVersion < 2){
await db.execute("ALTER TABLE TodoList ADD COLUMN changeTimes INTEGER DEFAULT 0");
}
},
);
//注意,上面创建表的时候最后一行不能带逗号 //注意,上面创建表的时候最后一行不能带逗号
} }
@ -54,8 +63,10 @@ class DBProvider {
final db = await database; final db = await database;
final account = final account =
await SharedUtil.instance.getString(Keys.account) ?? "default"; await SharedUtil.instance.getString(Keys.account) ?? "default";
var list = var list = await db.query("TodoList",
await db.query("TodoList", where: "account = ?" + (isDone ? " AND overallProgress = ?" : " AND overallProgress != ?"), whereArgs: [account, "1.0"]); where: "account = ?" +
(isDone ? " AND overallProgress >= ?" : " AND overallProgress < ?"),
whereArgs: [account, "1.0"]);
List<TaskBean> beans = []; List<TaskBean> beans = [];
beans.clear(); beans.clear();
beans.addAll(TaskBean.fromMapList(list)); beans.addAll(TaskBean.fromMapList(list));
@ -81,8 +92,7 @@ class DBProvider {
final account = final account =
await SharedUtil.instance.getString(Keys.account) ?? "default"; await SharedUtil.instance.getString(Keys.account) ?? "default";
var list = await db.query("TodoList", var list = await db.query("TodoList",
where: where: "account = ? AND (taskName LIKE ? "
"account = ? AND (taskName LIKE ? "
"OR detailList LIKE ? " "OR detailList LIKE ? "
"OR startDate LIKE ? " "OR startDate LIKE ? "
"OR deadLine LIKE ?)", "OR deadLine LIKE ?)",

View File

@ -24,6 +24,33 @@ class DemoLocalizations {
String get doneList => Intl.message('Done List', name: 'doneList', desc: '完成列表',); String get doneList => Intl.message('Done List', name: 'doneList', desc: '完成列表',);
String get toFinishTask => Intl.message('Try to complete a task!', name: 'toFinishTask', desc: '努力去完成一项任务吧!',); String get toFinishTask => Intl.message('Try to complete a task!', name: 'toFinishTask', desc: '努力去完成一项任务吧!',);
String get taskNum => Intl.message('Task Number', name: 'taskNum', desc: '任务数',);
String get createDate => Intl.message('Create Date', name: 'createDate', desc: '创建日期',);
String get completeDate => Intl.message('Complete Date', name: 'completeDate', desc: '完成日期',);
String get spendTime => Intl.message('Spend Time', name: 'spendTime', desc: '用时',);
String get changedTimes => Intl.message('Changed Times', name: 'changedTimes', desc: '修改次数',);
String hours(int hours){
return Intl.plural(
hours,
zero: "Too Fast",
one: "1 hour",
many: "$hours hours",
other:"$hours hours",
args: [hours],
name: "hours"
);
}
String days(int days){
return Intl.plural(
days,
zero: "Too Fast",
one: "1 day",
many: "$days days",
other:"$days days",
args: [days],
name: "days"
);
}
String get languageTitle { String get languageTitle {
@ -116,10 +143,6 @@ class DemoLocalizations {
String get openSystemSetting => Intl.message('Open System Setting', name: 'openSystemSetting', desc: '打开系统设置',); String get openSystemSetting => Intl.message('Open System Setting', name: 'openSystemSetting', desc: '打开系统设置',);
String get checkUpdate { String get checkUpdate {
return Intl.message( return Intl.message(
'Check Update', 'Check Update',

View File

@ -20,9 +20,13 @@ typedef MessageIfAbsent(String message_str, List args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
get localeName => 'en_US'; get localeName => 'en_US';
static m0(number) => "${Intl.plural(number, zero: 'There is No items ', one: '1 item ', other: '${number} items ')}"; static m0(days) => "${Intl.plural(days, zero: 'Too Fast', one: '1 day', many: '${days} days', other: '${days} days')}";
static m1(taskNumbers) => "${Intl.plural(taskNumbers, zero: 'You have never written a list of tasks.\nLet\'s get started soon.', one: 'This is your todo-list,\nToday, you have 1 task to complete. ', many: 'This is your todo-list,\nToday, you have ${taskNumbers} tasks to complete. ', other: 'This is your todo-list,\nToday, you have ${taskNumbers} tasks to complete. ')}"; static m1(hours) => "${Intl.plural(hours, zero: 'Too Fast', one: '1 hour', many: '${hours} hours', other: '${hours} hours')}";
static m2(number) => "${Intl.plural(number, zero: 'There is No items ', one: '1 item ', other: '${number} items ')}";
static m3(taskNumbers) => "${Intl.plural(taskNumbers, zero: 'You have never written a list of tasks.\nLet\'s get started soon.', one: 'This is your todo-list,\nToday, you have 1 task to complete. ', many: 'This is your todo-list,\nToday, you have ${taskNumbers} tasks to complete. ', other: 'This is your todo-list,\nToday, you have ${taskNumbers} tasks to complete. ')}";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> { static _notInlinedMessages(_) => <String, Function> {
@ -43,14 +47,18 @@ class MessageLookup extends MessageLookupByLibrary {
"cancel" : MessageLookupByLibrary.simpleMessage("cancel"), "cancel" : MessageLookupByLibrary.simpleMessage("cancel"),
"cardChangeWithBg" : MessageLookupByLibrary.simpleMessage("Task icon color follow background"), "cardChangeWithBg" : MessageLookupByLibrary.simpleMessage("Task icon color follow background"),
"changeTheme" : MessageLookupByLibrary.simpleMessage("Change Theme"), "changeTheme" : MessageLookupByLibrary.simpleMessage("Change Theme"),
"changedTimes" : MessageLookupByLibrary.simpleMessage("Changed Times"),
"checkUpdate" : MessageLookupByLibrary.simpleMessage("Check Update"), "checkUpdate" : MessageLookupByLibrary.simpleMessage("Check Update"),
"coffee" : MessageLookupByLibrary.simpleMessage("coffee"), "coffee" : MessageLookupByLibrary.simpleMessage("coffee"),
"completeDate" : MessageLookupByLibrary.simpleMessage("Finish Date"),
"createDate" : MessageLookupByLibrary.simpleMessage("Create Date"),
"currentIcons" : MessageLookupByLibrary.simpleMessage("Current Icons"), "currentIcons" : MessageLookupByLibrary.simpleMessage("Current Icons"),
"customIcon" : MessageLookupByLibrary.simpleMessage("Custom Icon"), "customIcon" : MessageLookupByLibrary.simpleMessage("Custom Icon"),
"customTheme" : MessageLookupByLibrary.simpleMessage("Custom Theme"), "customTheme" : MessageLookupByLibrary.simpleMessage("Custom Theme"),
"cyan" : MessageLookupByLibrary.simpleMessage("cyan"), "cyan" : MessageLookupByLibrary.simpleMessage("cyan"),
"dailyPic" : MessageLookupByLibrary.simpleMessage("Daily wallpaper"), "dailyPic" : MessageLookupByLibrary.simpleMessage("Daily wallpaper"),
"dark" : MessageLookupByLibrary.simpleMessage("dark"), "dark" : MessageLookupByLibrary.simpleMessage("dark"),
"days" : m0,
"deadline" : MessageLookupByLibrary.simpleMessage("deadline"), "deadline" : MessageLookupByLibrary.simpleMessage("deadline"),
"defaultIconName" : MessageLookupByLibrary.simpleMessage("default"), "defaultIconName" : MessageLookupByLibrary.simpleMessage("default"),
"defaultTitle" : MessageLookupByLibrary.simpleMessage("Default title"), "defaultTitle" : MessageLookupByLibrary.simpleMessage("Default title"),
@ -64,8 +72,9 @@ class MessageLookup extends MessageLookupByLibrary {
"game" : MessageLookupByLibrary.simpleMessage("Game"), "game" : MessageLookupByLibrary.simpleMessage("Game"),
"green" : MessageLookupByLibrary.simpleMessage("green"), "green" : MessageLookupByLibrary.simpleMessage("green"),
"history" : MessageLookupByLibrary.simpleMessage("history"), "history" : MessageLookupByLibrary.simpleMessage("history"),
"hours" : m1,
"iconSetting" : MessageLookupByLibrary.simpleMessage("Icon Setting"), "iconSetting" : MessageLookupByLibrary.simpleMessage("Icon Setting"),
"itemNumber" : m0, "itemNumber" : m2,
"languageTitle" : MessageLookupByLibrary.simpleMessage("Change Language"), "languageTitle" : MessageLookupByLibrary.simpleMessage("Change Language"),
"loading" : MessageLookupByLibrary.simpleMessage("loading..."), "loading" : MessageLookupByLibrary.simpleMessage("loading..."),
"loadingEmpty" : MessageLookupByLibrary.simpleMessage("nothing at all"), "loadingEmpty" : MessageLookupByLibrary.simpleMessage("nothing at all"),
@ -88,11 +97,13 @@ class MessageLookup extends MessageLookupByLibrary {
"repeat" : MessageLookupByLibrary.simpleMessage("repeat"), "repeat" : MessageLookupByLibrary.simpleMessage("repeat"),
"restrictedDes" : MessageLookupByLibrary.simpleMessage("Permission is restricted"), "restrictedDes" : MessageLookupByLibrary.simpleMessage("Permission is restricted"),
"setIconName" : MessageLookupByLibrary.simpleMessage("icon name"), "setIconName" : MessageLookupByLibrary.simpleMessage("icon name"),
"spendTime" : MessageLookupByLibrary.simpleMessage("Spend Time"),
"sports" : MessageLookupByLibrary.simpleMessage("Sports"), "sports" : MessageLookupByLibrary.simpleMessage("Sports"),
"startAfterEnd" : MessageLookupByLibrary.simpleMessage("The start date need be smaller than the end date."), "startAfterEnd" : MessageLookupByLibrary.simpleMessage("The start date need be smaller than the end date."),
"startDate" : MessageLookupByLibrary.simpleMessage("start date"), "startDate" : MessageLookupByLibrary.simpleMessage("start date"),
"submit" : MessageLookupByLibrary.simpleMessage("Submit"), "submit" : MessageLookupByLibrary.simpleMessage("Submit"),
"taskItems" : m1, "taskItems" : m3,
"taskNum" : MessageLookupByLibrary.simpleMessage("Task Number"),
"toFinishTask" : MessageLookupByLibrary.simpleMessage("Try to complete a task!"), "toFinishTask" : MessageLookupByLibrary.simpleMessage("Try to complete a task!"),
"travel" : MessageLookupByLibrary.simpleMessage("Travel"), "travel" : MessageLookupByLibrary.simpleMessage("Travel"),
"unknownDes" : MessageLookupByLibrary.simpleMessage("Unknown permission"), "unknownDes" : MessageLookupByLibrary.simpleMessage("Unknown permission"),

View File

@ -20,9 +20,13 @@ typedef MessageIfAbsent(String message_str, List args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
get localeName => 'zh_CN'; get localeName => 'zh_CN';
static m0(number) => "${Intl.plural(number, zero: '还没有任务详情哦 ', one: '1 ', other: '${number} ')}"; static m0(days) => "${Intl.plural(days, zero: '太快了!', one: '1 ', many: '${days} 天', other: '${days} ')}";
static m1(taskNumbers) => "${Intl.plural(taskNumbers, zero: '你还没有写过任务清单呢.\n快快开始吧.', one: '下面你的任务清单,\n今天, 你有 1 项任务尚未完成. ', many: '下面是你的任务清单,\n今天, 你有 ${taskNumbers} 份任务尚未完成. ', other: '下面是你的任务清单,\n今天, 你有 ${taskNumbers} 份任务尚未完成. ')}"; static m1(hours) => "${Intl.plural(hours, zero: '太快了!', one: '1 小时', many: '${hours} 小时', other: '${hours} 小时')}";
static m2(number) => "${Intl.plural(number, zero: '还没有任务详情哦 ', one: '1 项 ', other: '${number} 项 ')}";
static m3(taskNumbers) => "${Intl.plural(taskNumbers, zero: '你还没有写过任务清单呢.\n快快开始吧.', one: '下面你的任务清单,\n今天, 你有 1 项任务尚未完成. ', many: '下面是你的任务清单,\n今天, 你有 ${taskNumbers} 份任务尚未完成. ', other: '下面是你的任务清单,\n今天, 你有 ${taskNumbers} 份任务尚未完成. ')}";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> { static _notInlinedMessages(_) => <String, Function> {
@ -43,14 +47,18 @@ class MessageLookup extends MessageLookupByLibrary {
"cancel" : MessageLookupByLibrary.simpleMessage("取消"), "cancel" : MessageLookupByLibrary.simpleMessage("取消"),
"cardChangeWithBg" : MessageLookupByLibrary.simpleMessage("任务图标颜色跟随背景"), "cardChangeWithBg" : MessageLookupByLibrary.simpleMessage("任务图标颜色跟随背景"),
"changeTheme" : MessageLookupByLibrary.simpleMessage("切换主题"), "changeTheme" : MessageLookupByLibrary.simpleMessage("切换主题"),
"changedTimes" : MessageLookupByLibrary.simpleMessage("修改次数"),
"checkUpdate" : MessageLookupByLibrary.simpleMessage("检查更新"), "checkUpdate" : MessageLookupByLibrary.simpleMessage("检查更新"),
"coffee" : MessageLookupByLibrary.simpleMessage("想入啡啡"), "coffee" : MessageLookupByLibrary.simpleMessage("想入啡啡"),
"completeDate" : MessageLookupByLibrary.simpleMessage("完成日期"),
"createDate" : MessageLookupByLibrary.simpleMessage("创建日期"),
"currentIcons" : MessageLookupByLibrary.simpleMessage("当前图标"), "currentIcons" : MessageLookupByLibrary.simpleMessage("当前图标"),
"customIcon" : MessageLookupByLibrary.simpleMessage("自定义图标"), "customIcon" : MessageLookupByLibrary.simpleMessage("自定义图标"),
"customTheme" : MessageLookupByLibrary.simpleMessage("自定义主题"), "customTheme" : MessageLookupByLibrary.simpleMessage("自定义主题"),
"cyan" : MessageLookupByLibrary.simpleMessage("蓝天白云"), "cyan" : MessageLookupByLibrary.simpleMessage("蓝天白云"),
"dailyPic" : MessageLookupByLibrary.simpleMessage("每日壁纸"), "dailyPic" : MessageLookupByLibrary.simpleMessage("每日壁纸"),
"dark" : MessageLookupByLibrary.simpleMessage("不见五指"), "dark" : MessageLookupByLibrary.simpleMessage("不见五指"),
"days" : m0,
"deadline" : MessageLookupByLibrary.simpleMessage("截止日期"), "deadline" : MessageLookupByLibrary.simpleMessage("截止日期"),
"defaultIconName" : MessageLookupByLibrary.simpleMessage("默认"), "defaultIconName" : MessageLookupByLibrary.simpleMessage("默认"),
"defaultTitle" : MessageLookupByLibrary.simpleMessage("默认标题"), "defaultTitle" : MessageLookupByLibrary.simpleMessage("默认标题"),
@ -64,8 +72,9 @@ class MessageLookup extends MessageLookupByLibrary {
"game" : MessageLookupByLibrary.simpleMessage("打游戏"), "game" : MessageLookupByLibrary.simpleMessage("打游戏"),
"green" : MessageLookupByLibrary.simpleMessage("青青草原"), "green" : MessageLookupByLibrary.simpleMessage("青青草原"),
"history" : MessageLookupByLibrary.simpleMessage("历史"), "history" : MessageLookupByLibrary.simpleMessage("历史"),
"hours" : m1,
"iconSetting" : MessageLookupByLibrary.simpleMessage("图标设置"), "iconSetting" : MessageLookupByLibrary.simpleMessage("图标设置"),
"itemNumber" : m0, "itemNumber" : m2,
"languageTitle" : MessageLookupByLibrary.simpleMessage("切换语言"), "languageTitle" : MessageLookupByLibrary.simpleMessage("切换语言"),
"loading" : MessageLookupByLibrary.simpleMessage("加载中..."), "loading" : MessageLookupByLibrary.simpleMessage("加载中..."),
"loadingEmpty" : MessageLookupByLibrary.simpleMessage("什么都没有哦"), "loadingEmpty" : MessageLookupByLibrary.simpleMessage("什么都没有哦"),
@ -88,11 +97,13 @@ class MessageLookup extends MessageLookupByLibrary {
"repeat" : MessageLookupByLibrary.simpleMessage("重复"), "repeat" : MessageLookupByLibrary.simpleMessage("重复"),
"restrictedDes" : MessageLookupByLibrary.simpleMessage("权限被限制"), "restrictedDes" : MessageLookupByLibrary.simpleMessage("权限被限制"),
"setIconName" : MessageLookupByLibrary.simpleMessage("图标名"), "setIconName" : MessageLookupByLibrary.simpleMessage("图标名"),
"spendTime" : MessageLookupByLibrary.simpleMessage("用时"),
"sports" : MessageLookupByLibrary.simpleMessage("运动"), "sports" : MessageLookupByLibrary.simpleMessage("运动"),
"startAfterEnd" : MessageLookupByLibrary.simpleMessage("开始日期要比结束日期小才行哦"), "startAfterEnd" : MessageLookupByLibrary.simpleMessage("开始日期要比结束日期小才行哦"),
"startDate" : MessageLookupByLibrary.simpleMessage("开始日期"), "startDate" : MessageLookupByLibrary.simpleMessage("开始日期"),
"submit" : MessageLookupByLibrary.simpleMessage("提交"), "submit" : MessageLookupByLibrary.simpleMessage("提交"),
"taskItems" : m1, "taskItems" : m3,
"taskNum" : MessageLookupByLibrary.simpleMessage("任务数"),
"toFinishTask" : MessageLookupByLibrary.simpleMessage("努力去完成一项任务吧"), "toFinishTask" : MessageLookupByLibrary.simpleMessage("努力去完成一项任务吧"),
"travel" : MessageLookupByLibrary.simpleMessage("旅行"), "travel" : MessageLookupByLibrary.simpleMessage("旅行"),
"unknownDes" : MessageLookupByLibrary.simpleMessage("未知权限"), "unknownDes" : MessageLookupByLibrary.simpleMessage("未知权限"),

View File

@ -24,7 +24,7 @@ class TaskItem extends StatelessWidget {
final widget = TaskInfoWidget( final widget = TaskInfoWidget(
index, index,
space: (minSize - 100) / 4, space: 21,
taskBean: taskBean, taskBean: taskBean,
onDelete: onDelete, onDelete: onDelete,
onEdit: onEdit, onEdit: onEdit,
@ -38,7 +38,6 @@ class TaskItem extends StatelessWidget {
Hero( Hero(
tag: "task_bg${index}", tag: "task_bg${index}",
child: Container( child: Container(
height: minSize,
decoration: BoxDecoration( decoration: BoxDecoration(
color: globalModel.logic.getBgInDark(), color: globalModel.logic.getBgInDark(),
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
@ -46,7 +45,6 @@ class TaskItem extends StatelessWidget {
), ),
), ),
Container( Container(
height: minSize,
child: Card( child: Card(
margin: EdgeInsets.all(0), margin: EdgeInsets.all(0),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -54,11 +52,7 @@ class TaskItem extends StatelessWidget {
), ),
child: Container( child: Container(
margin: EdgeInsets.only(left: 16, right: 16), margin: EdgeInsets.only(left: 16, right: 16),
child: minSize < 600
? SingleChildScrollView(
child: widget, child: widget,
)
: widget,
), ),
), ),
), ),

View File

@ -12,6 +12,9 @@ class TaskBean {
int taskDetailNum = 0; int taskDetailNum = 0;
double overallProgress; double overallProgress;
//任务修改次数
int changeTimes;
//创建任务的时间 //创建任务的时间
String createDate; String createDate;
@ -34,6 +37,7 @@ class TaskBean {
this.taskStatus = TaskStatus.todo, this.taskStatus = TaskStatus.todo,
this.taskDetailNum, this.taskDetailNum,
this.overallProgress = 0.0, this.overallProgress = 0.0,
this.changeTimes = 0,
this.createDate = "", this.createDate = "",
this.finishDate = "", this.finishDate = "",
this.account = "default", this.account = "default",
@ -50,6 +54,7 @@ class TaskBean {
taskBean.taskDetailNum = map['taskDetailNum']; taskBean.taskDetailNum = map['taskDetailNum'];
taskBean.taskStatus = map['taskStatus']; taskBean.taskStatus = map['taskStatus'];
taskBean.account = map['account']; taskBean.account = map['account'];
taskBean.changeTimes = map['changeTimes'] ?? 0;
taskBean.overallProgress = double.parse(map['overallProgress']); taskBean.overallProgress = double.parse(map['overallProgress']);
taskBean.createDate = map['createDate']; taskBean.createDate = map['createDate'];
taskBean.finishDate = map['finishDate']; taskBean.finishDate = map['finishDate'];
@ -84,9 +89,10 @@ class TaskBean {
'taskType': taskType, 'taskType': taskType,
'taskStatus': taskStatus, 'taskStatus': taskStatus,
'taskDetailNum': taskDetailNum, 'taskDetailNum': taskDetailNum,
'overallProgress': overallProgress.toString(), 'overallProgress': (overallProgress >= 1.0 ? 1.0 : overallProgress).toString(),
'createDate': createDate, 'createDate': createDate,
'account': account, 'account': account,
'changeTimes': changeTimes ?? 0,
'finishDate': finishDate, 'finishDate': finishDate,
'startDate': startDate, 'startDate': startDate,
'deadLine': deadLine, 'deadLine': deadLine,

View File

@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:todo_list/config/provider_config.dart'; import 'package:todo_list/config/provider_config.dart';
import 'package:todo_list/database/database.dart'; import 'package:todo_list/database/database.dart';
import 'package:todo_list/i10n/localization_intl.dart';
import 'package:todo_list/json/task_bean.dart'; import 'package:todo_list/json/task_bean.dart';
import 'package:todo_list/model/all_model.dart'; import 'package:todo_list/model/all_model.dart';
@ -41,7 +42,10 @@ class DoneTaskPageLogic {
DateTime timeStart = DateTime.parse(dateStart); DateTime timeStart = DateTime.parse(dateStart);
DateTime timeEnd = DateTime.parse(dateEnd); DateTime timeEnd = DateTime.parse(dateEnd);
Duration diff = timeStart.difference(timeEnd); Duration diff = timeStart.difference(timeEnd);
final context = _model.context;
return diff.inDays == 0 ? "${diff.inHours} 小时" : "${diff.inDays}"; return diff.inDays == 0
? "${DemoLocalizations.of(context).hours(diff.inHours)}"
: "${DemoLocalizations.of(context).days(diff.inDays)}";
} }
} }

View File

@ -229,6 +229,7 @@ class EditTaskPageLogic {
return; return;
} }
TaskBean taskBean = await transformDataToBean(id: _model.oldTaskBean.id,overallProgress: _getOverallProgress()); TaskBean taskBean = await transformDataToBean(id: _model.oldTaskBean.id,overallProgress: _getOverallProgress());
taskBean.changeTimes++;
DBProvider.db.updateTask(taskBean); DBProvider.db.updateTask(taskBean);
await _model.mainPageModel.logic.getTasks(); await _model.mainPageModel.logic.getTasks();
_model.mainPageModel.refresh(); _model.mainPageModel.refresh();

View File

@ -33,10 +33,11 @@ class TaskDetailPageLogic {
final mainPageModel = _model.globalModel.mainPageModel; final mainPageModel = _model.globalModel.mainPageModel;
bool needUpdate = needUpdateDatabase(); bool needUpdate = needUpdateDatabase();
if (needUpdate && !isDeleting) { if (needUpdate && !isDeleting) {
if (_model.taskBean.overallProgress == 1.0) { if (_model.taskBean.overallProgress >= 1.0) {
_model.taskBean.finishDate = DateTime.now().toIso8601String(); _model.taskBean.finishDate = DateTime.now().toIso8601String();
mainPageModel.tasks.removeAt(mainPageModel.currentTapIndex); mainPageModel.tasks.removeAt(mainPageModel.currentTapIndex);
} }
_model.taskBean.changeTimes++;
DBProvider.db.updateTask(_model.taskBean).then((value){ DBProvider.db.updateTask(_model.taskBean).then((value){
if (_model.doneTaskPageModel != null) { if (_model.doneTaskPageModel != null) {
mainPageModel.logic.getTasks(); mainPageModel.logic.getTasks();

View File

@ -1,5 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:circle_list/circle_list.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -13,10 +14,15 @@ import 'package:todo_list/utils/theme_util.dart';
class DoneTaskPage extends StatelessWidget { class DoneTaskPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final model = Provider.of<DoneTaskPageModel>(context)..setContext(context); final model = Provider.of<DoneTaskPageModel>(context)
..setContext(context);
final globalModel = Provider.of<GlobalModel>(context); final globalModel = Provider.of<GlobalModel>(context);
final size = MediaQuery.of(context).size; final size = MediaQuery
.of(context)
.size;
final minSize = min(size.width, size.height); final minSize = min(size.width, size.height);
final itemHeight = minSize / 4;
final textSize = itemHeight / 10;
final textColor = globalModel.logic.getWhiteInDark(); final textColor = globalModel.logic.getWhiteInDark();
@ -24,14 +30,18 @@ class DoneTaskPage extends StatelessWidget {
globalModel.currentThemeBean.themeType == MyTheme.darkTheme; globalModel.currentThemeBean.themeType == MyTheme.darkTheme;
final bgColor = isDartNow final bgColor = isDartNow
? ColorBean.fromBean(globalModel.currentThemeBean.colorBean) ? ColorBean.fromBean(globalModel.currentThemeBean.colorBean)
: Theme.of(context).primaryColor; : Theme
.of(context)
.primaryColor;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
backgroundColor: globalModel.logic.getBgInDark(), backgroundColor: globalModel.logic.getBgInDark(),
title: Text( title: Text(
DemoLocalizations.of(context).doneList, DemoLocalizations
.of(context)
.doneList,
style: TextStyle( style: TextStyle(
color: bgColor, color: bgColor,
), ),
@ -54,22 +64,82 @@ class DoneTaskPage extends StatelessWidget {
? Colors.black.withOpacity(0.2) ? Colors.black.withOpacity(0.2)
: ColorBean.fromBean(colorBean); : ColorBean.fromBean(colorBean);
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
SizedBox(width: 20,), InkWell(
onTap: () => model.logic.onTaskTap(index, task),
child: Container(
height: itemHeight,
width: itemHeight * 1.3,
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
bottomRight: Radius.circular(30)),
child: Container(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: itemHeight,
child: Text(
task.taskName,
maxLines: 3,
style: TextStyle(
fontSize: textSize + 8,
fontWeight: FontWeight.bold,
color: textColor,
),
overflow: TextOverflow.ellipsis,
),
),
Text(
"${DemoLocalizations
.of(context)
.taskNum}:${task.taskDetailNum}",
style: TextStyle(
fontSize: textSize,
color: textColor,
),
overflow: TextOverflow.ellipsis,
),
Text(
"${DemoLocalizations
.of(context)
.createDate}:${model.logic.getTimeText(
task.createDate)}",
style: TextStyle(
fontSize: textSize,
color: textColor,
),
overflow: TextOverflow.ellipsis,
),
],
),
color: color,
),
),
),
),
Container(
height: 1,
width: 20,
color: color,
),
Column( Column(
children: <Widget>[ children: <Widget>[
index == 0 index == 0
? SizedBox( ? SizedBox(
height: 50, height: itemHeight / 2,
) )
: Container( : Container(
color: color, color: color,
width: 2, width: 2,
height: 50, height: itemHeight / 2,
), ),
Container( Container(
width: 40, width: itemHeight / 3,
height: 40, height: itemHeight / 3,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: color, color: color,
@ -82,12 +152,12 @@ class DoneTaskPage extends StatelessWidget {
), ),
index == model.doneTasks.length - 1 index == model.doneTasks.length - 1
? SizedBox( ? SizedBox(
height: 50, height: itemHeight / 2,
) )
: Container( : Container(
color: color, color: color,
width: 2, width: 2,
height: 50, height: itemHeight / 2,
), ),
], ],
), ),
@ -96,57 +166,56 @@ class DoneTaskPage extends StatelessWidget {
width: 20, width: 20,
color: color, color: color,
), ),
Column(
children: <Widget>[
InkWell( InkWell(
onTap: () => model.logic.onTaskTap(index, task), onTap: () => model.logic.onTaskTap(index, task),
child: Container( child: Container(
height: 120, height: itemHeight,
width: itemHeight * 1.3,
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(30), topRight: Radius.circular(30),
bottomRight: Radius.circular(30)), bottomLeft: Radius.circular(30)),
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Container(
task.taskName, width: itemHeight,
child: Text(
"${DemoLocalizations
.of(context)
.spendTime}:${model.logic.getDiffTimeText(
task.finishDate, task.createDate)}",
maxLines: 3,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: textSize,
fontWeight: FontWeight.bold,
color: textColor, color: textColor,
fontWeight: FontWeight.bold
),
overflow: TextOverflow.ellipsis,
), ),
), ),
Text( Text(
"任务数:${task.taskDetailNum}", "${DemoLocalizations
.of(context)
.changedTimes}:${task.changeTimes}",
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: textSize,
color: textColor, color: textColor,
), ),
overflow: TextOverflow.ellipsis,
), ),
Text( Text(
"创建日期:${model.logic.getTimeText(task.createDate)}", "${DemoLocalizations
.of(context)
.completeDate}:${model.logic.getTimeText(
task.finishDate)}",
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: textSize,
color: textColor,
),
),
Text(
"完成日期:${model.logic.getTimeText(task.finishDate)}",
style: TextStyle(
fontSize: 12,
color: textColor,
),
),
Text(
"用时:${model.logic.getDiffTimeText(task.finishDate, task.createDate)}",
style: TextStyle(
fontSize: 12,
color: textColor, color: textColor,
), ),
overflow: TextOverflow.ellipsis,
), ),
], ],
), ),
@ -156,14 +225,14 @@ class DoneTaskPage extends StatelessWidget {
), ),
), ),
], ],
),
],
); );
}) })
: LoadingWidget( : LoadingWidget(
flag: model.loadingFlag, flag: model.loadingFlag,
errorCallBack: () {}, errorCallBack: () {},
emptyText: DemoLocalizations.of(context).toFinishTask, emptyText: DemoLocalizations
.of(context)
.toFinishTask,
), ),
), ),
); );

View File

@ -108,7 +108,7 @@ class MainPage extends StatelessWidget {
margin: EdgeInsets.only(top: 40,bottom: 40), margin: EdgeInsets.only(top: 40,bottom: 40),
child: CarouselSlider( child: CarouselSlider(
items: model.logic.getCards(context), items: model.logic.getCards(context),
aspectRatio: 1, aspectRatio: 16 / 9,
height: min(size.width, size.height) - 100, height: min(size.width, size.height) - 100,
viewportFraction: size.height >= size.width ? 0.8 : 0.5, viewportFraction: size.height >= size.width ? 0.8 : 0.5,
initialPage: 0, initialPage: 0,

View File

@ -75,17 +75,18 @@ class NavPage extends StatelessWidget {
return NavHead(); return NavHead();
} else { } else {
final url = model.currentNetPicUrl; final url = model.currentNetPicUrl;
bool isDailyPic = model.currentNavHeader == NavHeadType.dailyPic;
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
Navigator.of(context).push(new CupertinoPageRoute(builder: (ctx) { Navigator.of(context).push(new CupertinoPageRoute(builder: (ctx) {
return ImagePage( return ImagePage(
imageUrls: [url], imageUrls: [isDailyPic ?NavHeadType.dailyPicUrl : url],
); );
})); }));
}, },
child: Hero( child: Hero(
tag: "tag_0", tag: "tag_0",
child: model.currentNavHeader == NavHeadType.dailyPic child: isDailyPic
? Image.network(NavHeadType.dailyPicUrl) ? Image.network(NavHeadType.dailyPicUrl)
: CachedNetworkImage( : CachedNetworkImage(
fit: BoxFit.cover, fit: BoxFit.cover,

View File

@ -31,6 +31,7 @@ class TaskInfoWidget extends StatelessWidget {
? Theme.of(context).primaryColor ? Theme.of(context).primaryColor
: ColorBean.fromBean(taskBean.taskIconBean.colorBean); : ColorBean.fromBean(taskBean.taskIconBean.colorBean);
final taskIconData = IconBean.fromBean(taskBean.taskIconBean.iconBean); final taskIconData = IconBean.fromBean(taskBean.taskIconBean.iconBean);
debugPrint("进度:${taskBean.overallProgress}");
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -106,7 +107,7 @@ class TaskInfoWidget extends StatelessWidget {
), ),
), ),
), ),
taskBean.overallProgress == 1.0 && !isExisting taskBean.overallProgress >= 1.0 && !isExisting
? Expanded( ? Expanded(
flex: 1, flex: 1,
child: Container( child: Container(

View File

@ -18,6 +18,50 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"taskNum": "Task Number",
"@taskNum": {
"description": "任务数",
"type": "text",
"placeholders": {}
},
"createDate": "Create Date",
"@createDate": {
"description": "创建日期",
"type": "text",
"placeholders": {}
},
"completeDate": "Finish Date",
"@completeDate": {
"description": "完成日期",
"type": "text",
"placeholders": {}
},
"spendTime": "Spend Time",
"@spendTime": {
"description": "用时",
"type": "text",
"placeholders": {}
},
"changedTimes": "Changed Times",
"@changedTimes": {
"description": "修改次数",
"type": "text",
"placeholders": {}
},
"hours": "{hours,plural, =0{Too Fast}=1{1 hour}many{{hours} hours}other{{hours} hours}}",
"@hours": {
"type": "text",
"placeholders": {
"hours": {}
}
},
"days": "{days,plural, =0{Too Fast}=1{1 day}many{{days} days}other{{days} days}}",
"@days": {
"type": "text",
"placeholders": {
"days": {}
}
},
"languageTitle": "Change Language", "languageTitle": "Change Language",
"@languageTitle": { "@languageTitle": {
"description": "修改语言", "description": "修改语言",

View File

@ -1,5 +1,5 @@
{ {
"@@last_modified": "2019-07-20T19:23:09.817787", "@@last_modified": "2019-07-21T14:32:24.392430",
"appName": "One Day List", "appName": "One Day List",
"@appName": { "@appName": {
"description": "app的名字", "description": "app的名字",
@ -18,6 +18,50 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"taskNum": "Task Number",
"@taskNum": {
"description": "任务数",
"type": "text",
"placeholders": {}
},
"createDate": "Create Date",
"@createDate": {
"description": "创建日期",
"type": "text",
"placeholders": {}
},
"completeDate": "Complete Date",
"@completeDate": {
"description": "完成日期",
"type": "text",
"placeholders": {}
},
"spendTime": "Spend Time",
"@spendTime": {
"description": "用时",
"type": "text",
"placeholders": {}
},
"changedTimes": "Changed Times",
"@changedTimes": {
"description": "修改次数",
"type": "text",
"placeholders": {}
},
"hours": "{hours,plural, =0{Too Fast}=1{1 hour}many{{hours} hours}other{{hours} hours}}",
"@hours": {
"type": "text",
"placeholders": {
"hours": {}
}
},
"days": "{days,plural, =0{Too Fast}=1{1 day}many{{days} days}other{{days} days}}",
"@days": {
"type": "text",
"placeholders": {
"days": {}
}
},
"languageTitle": "Change Language", "languageTitle": "Change Language",
"@languageTitle": { "@languageTitle": {
"description": "修改语言", "description": "修改语言",

View File

@ -18,6 +18,50 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"taskNum": "任务数",
"@taskNum": {
"description": "任务数",
"type": "text",
"placeholders": {}
},
"createDate": "创建日期",
"@createDate": {
"description": "创建日期",
"type": "text",
"placeholders": {}
},
"completeDate": "完成日期",
"@completeDate": {
"description": "完成日期",
"type": "text",
"placeholders": {}
},
"spendTime": "用时",
"@spendTime": {
"description": "用时",
"type": "text",
"placeholders": {}
},
"changedTimes": "修改次数",
"@changedTimes": {
"description": "修改次数",
"type": "text",
"placeholders": {}
},
"hours": "{hours,plural, =0{太快了!}=1{1 小时}many{{hours} 小时}other{{hours} 小时}}",
"@hours": {
"type": "text",
"placeholders": {
"hours": {}
}
},
"days": "{days,plural, =0{太快了!}=1{1 天}many{{days} 天}other{{days} 天}}",
"@days": {
"type": "text",
"placeholders": {
"days": {}
}
},
"languageTitle": "切换语言", "languageTitle": "切换语言",
"@languageTitle": { "@languageTitle": {
"description": "Change Language", "description": "Change Language",