mirror of
https://github.com/asjqkkkk/flutter-todos.git
synced 2025-08-06 14:19:24 +08:00
解决一个小bug,同时详情页面不会出现边框遮拦动画的事件了
This commit is contained in:
@ -32,32 +32,41 @@ class ProviderConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChangeNotifierProvider<TaskDetailPageModel> getTaskDetailPage(
|
ChangeNotifierProvider<TaskDetailPageModel> getTaskDetailPage(
|
||||||
int index, TaskBean taskBean,) {
|
int index,
|
||||||
|
TaskBean taskBean,
|
||||||
|
) {
|
||||||
return ChangeNotifierProvider<TaskDetailPageModel>(
|
return ChangeNotifierProvider<TaskDetailPageModel>(
|
||||||
builder: (context) => TaskDetailPageModel(taskBean),
|
builder: (context) => TaskDetailPageModel(taskBean),
|
||||||
child: TaskDetailPage(index,),
|
child: TaskDetailPage(
|
||||||
|
index,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeNotifierProvider<EditTaskPageModel> getEditTaskPage(TaskIconBean taskIcon,{MainPageModel mainPageModel, TaskBean taskBean}){
|
ChangeNotifierProvider<EditTaskPageModel> getEditTaskPage(
|
||||||
return ChangeNotifierProvider<EditTaskPageModel>(
|
TaskIconBean taskIcon,
|
||||||
builder:(context) => EditTaskPageModel(oldTaskBean: taskBean),
|
{MainPageModel mainPageModel,
|
||||||
child: EditTaskPage(taskIcon,mainPageModel: mainPageModel,),
|
TaskBean taskBean}) {
|
||||||
);
|
return ChangeNotifierProvider<EditTaskPageModel>(
|
||||||
|
builder: (context) => EditTaskPageModel(oldTaskBean: taskBean),
|
||||||
|
child: EditTaskPage(
|
||||||
|
taskIcon,
|
||||||
|
mainPageModel: mainPageModel,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeNotifierProvider<IconSettingPageModel> getIconSettingPage(){
|
ChangeNotifierProvider<IconSettingPageModel> getIconSettingPage() {
|
||||||
return ChangeNotifierProvider<IconSettingPageModel>(
|
return ChangeNotifierProvider<IconSettingPageModel>(
|
||||||
builder:(context) => IconSettingPageModel(),
|
builder: (context) => IconSettingPageModel(),
|
||||||
child: IconSettingPage(),
|
child: IconSettingPage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeNotifierProvider<ThemePageModel> getThemePage(){
|
|
||||||
return ChangeNotifierProvider<ThemePageModel>(
|
|
||||||
builder:(context) => ThemePageModel(),
|
|
||||||
child: ThemePage(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ChangeNotifierProvider<ThemePageModel> getThemePage() {
|
||||||
|
return ChangeNotifierProvider<ThemePageModel>(
|
||||||
|
builder: (context) => ThemePageModel(),
|
||||||
|
child: ThemePage(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:todo_list/json/color_bean.dart';
|
import 'package:todo_list/json/color_bean.dart';
|
||||||
export 'package:todo_list/json/color_bean.dart';
|
export 'package:todo_list/json/color_bean.dart';
|
||||||
|
|
||||||
|
|
||||||
class TaskIconBean {
|
class TaskIconBean {
|
||||||
String taskName;
|
String taskName;
|
||||||
IconBean iconBean;
|
IconBean iconBean;
|
||||||
@ -30,7 +29,6 @@ class TaskIconBean {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<dynamic, dynamic> toMap() {
|
Map<dynamic, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
'taskName': taskName,
|
'taskName': taskName,
|
||||||
@ -40,7 +38,6 @@ class TaskIconBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class IconBean {
|
class IconBean {
|
||||||
int codePoint;
|
int codePoint;
|
||||||
String fontFamily;
|
String fontFamily;
|
||||||
@ -50,13 +47,13 @@ class IconBean {
|
|||||||
|
|
||||||
IconBean(
|
IconBean(
|
||||||
{this.codePoint,
|
{this.codePoint,
|
||||||
this.fontFamily,
|
this.fontFamily,
|
||||||
this.fontPackage,
|
this.fontPackage,
|
||||||
this.iconName,
|
this.iconName,
|
||||||
this.matchTextDirection});
|
this.matchTextDirection});
|
||||||
|
|
||||||
static IconData fromBean(IconBean bean) =>
|
static IconData fromBean(IconBean bean) => IconData(bean.codePoint,
|
||||||
IconData(bean.codePoint, fontFamily: bean.fontFamily, fontPackage: bean.fontPackage == "null" ? null : bean.fontPackage);
|
fontFamily: bean.fontFamily,);
|
||||||
|
|
||||||
static IconBean fromMap(Map<String, dynamic> map) {
|
static IconBean fromMap(Map<String, dynamic> map) {
|
||||||
IconBean bean = new IconBean();
|
IconBean bean = new IconBean();
|
||||||
@ -64,7 +61,7 @@ class IconBean {
|
|||||||
bean.fontFamily = map['fontFamily'];
|
bean.fontFamily = map['fontFamily'];
|
||||||
bean.fontPackage = map['fontPackage'];
|
bean.fontPackage = map['fontPackage'];
|
||||||
bean.iconName = map['iconName'];
|
bean.iconName = map['iconName'];
|
||||||
bean.matchTextDirection = map['taskStatus'] == 'ture';
|
bean.matchTextDirection = map['matchTextDirection'] == 'ture';
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,10 +90,10 @@ class IconBean {
|
|||||||
Map<dynamic, dynamic> toMap() {
|
Map<dynamic, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
'codePoint': codePoint.toString(),
|
'codePoint': codePoint.toString(),
|
||||||
'fontFamily': fontFamily??"",
|
'fontFamily': fontFamily ?? "",
|
||||||
'fontPackage': fontPackage??"",
|
'fontPackage': fontPackage ?? "",
|
||||||
'iconName': iconName??"",
|
'iconName': iconName ?? "",
|
||||||
'matchTextDirection': matchTextDirection.toString()
|
'matchTextDirection': matchTextDirection.toString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,13 +197,22 @@ class EditTaskPageLogic {
|
|||||||
|
|
||||||
//修改旧的任务
|
//修改旧的任务
|
||||||
void submitOldTask() async{
|
void submitOldTask() async{
|
||||||
TaskBean taskBean = await transformDataToBean(id: _model.oldTaskBean.id);
|
TaskBean taskBean = await transformDataToBean(id: _model.oldTaskBean.id,overallProgress: _getOverallProgress());
|
||||||
DBProvider.db.updateTask(taskBean);
|
DBProvider.db.updateTask(taskBean);
|
||||||
_model.mainPageModel.logic.getTasks();
|
_model.mainPageModel.logic.getTasks();
|
||||||
Navigator.of(_model.context).popUntil((route) => route.isFirst);
|
Navigator.of(_model.context).popUntil((route) => route.isFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<TaskBean> transformDataToBean({int id}) async {
|
double _getOverallProgress(){
|
||||||
|
int length = _model.taskDetails.length;
|
||||||
|
double overallProgress = 0.0;
|
||||||
|
for(int i = 0; i < length;i++){
|
||||||
|
overallProgress += _model.taskDetails[i].itemProgress / length;
|
||||||
|
}
|
||||||
|
return overallProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<TaskBean> transformDataToBean({int id, double overallProgress = 0.0}) async {
|
||||||
final account = await SharedUtil.instance.getString(Keys.account) ?? "default";
|
final account = await SharedUtil.instance.getString(Keys.account) ?? "default";
|
||||||
final taskName = _model.currentTaskName.isEmpty ? _model.taskIcon.taskName : _model.currentTaskName;
|
final taskName = _model.currentTaskName.isEmpty ? _model.taskIcon.taskName : _model.currentTaskName;
|
||||||
TaskBean taskBean = TaskBean(
|
TaskBean taskBean = TaskBean(
|
||||||
@ -216,6 +225,7 @@ class EditTaskPageLogic {
|
|||||||
deadLine: _model.deadLine?.toIso8601String(),
|
deadLine: _model.deadLine?.toIso8601String(),
|
||||||
detailList: _model.taskDetails,
|
detailList: _model.taskDetails,
|
||||||
taskIconBean: _model.taskIcon,
|
taskIconBean: _model.taskIcon,
|
||||||
|
overallProgress: overallProgress,
|
||||||
);
|
);
|
||||||
if(id != null){
|
if(id != null){
|
||||||
taskBean.id = id;
|
taskBean.id = id;
|
||||||
|
@ -23,10 +23,12 @@ class TaskDetailPage extends StatelessWidget {
|
|||||||
final globalModel = Provider.of<GlobalModel>(context);
|
final globalModel = Provider.of<GlobalModel>(context);
|
||||||
final mainPageModel = globalModel.mainPageModel;
|
final mainPageModel = globalModel.mainPageModel;
|
||||||
model.setContext(context);
|
model.setContext(context);
|
||||||
final taskColor = globalModel.isCardChangeWithBg ? Theme.of(context).primaryColor : ColorBean.fromBean(model.taskBean.taskIconBean.colorBean);
|
final taskColor = globalModel.isCardChangeWithBg
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: ColorBean.fromBean(model.taskBean.taskIconBean.colorBean);
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: (){
|
onWillPop: () {
|
||||||
model.logic.exitPage();
|
model.logic.exitPage();
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
@ -45,8 +47,11 @@ class TaskDetailPage extends StatelessWidget {
|
|||||||
iconTheme: IconThemeData(color: taskColor),
|
iconTheme: IconThemeData(color: taskColor),
|
||||||
leading: model.isAnimationComplete && !model.isExiting
|
leading: model.isAnimationComplete && !model.isExiting
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: Icon(Platform.isAndroid ? Icons.arrow_back : Icons.arrow_back_ios),
|
icon: Icon(Platform.isAndroid
|
||||||
onPressed: model.logic.exitPage,)
|
? Icons.arrow_back
|
||||||
|
: Icons.arrow_back_ios),
|
||||||
|
onPressed: model.logic.exitPage,
|
||||||
|
)
|
||||||
: SizedBox(),
|
: SizedBox(),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
@ -73,32 +78,55 @@ class TaskDetailPage extends StatelessWidget {
|
|||||||
)),
|
)),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(
|
margin: EdgeInsets.only(top: 20),
|
||||||
left: 50, top: 20, right: 50, bottom: 20),
|
|
||||||
child: !model.isExiting
|
child: !model.isExiting
|
||||||
? ListView(
|
? NotificationListener<
|
||||||
children: List.generate(
|
OverscrollIndicatorNotification>(
|
||||||
|
onNotification: (overScroll) {
|
||||||
|
overScroll.disallowGlow();
|
||||||
|
},
|
||||||
|
child: ListView(
|
||||||
|
children: List.generate(
|
||||||
model?.taskBean?.detailList?.length ?? 0,
|
model?.taskBean?.detailList?.length ?? 0,
|
||||||
(index) {
|
(index) {
|
||||||
TaskDetailBean taskDetailBean =
|
TaskDetailBean taskDetailBean =
|
||||||
model.taskBean.detailList[index];
|
model.taskBean.detailList[index];
|
||||||
return TaskDetailItem(
|
return Container(
|
||||||
index: index,
|
margin: EdgeInsets.only(
|
||||||
itemProgress: taskDetailBean.itemProgress,
|
bottom: index ==
|
||||||
itemName: taskDetailBean.taskDetailName,
|
model.taskBean.detailList
|
||||||
iconColor: taskColor,
|
.length -
|
||||||
onProgressChanged: (progress) {
|
1
|
||||||
model.logic.refreshProgress(
|
? 20
|
||||||
taskDetailBean, progress, mainPageModel);
|
: 0,
|
||||||
model.refresh();
|
left: 50,right: 50
|
||||||
},
|
),
|
||||||
onChecked: (progress) {
|
child: TaskDetailItem(
|
||||||
model.logic.refreshProgress(
|
index: index,
|
||||||
taskDetailBean, progress, mainPageModel);
|
itemProgress:
|
||||||
model.refresh();
|
taskDetailBean.itemProgress,
|
||||||
},
|
itemName:
|
||||||
);
|
taskDetailBean.taskDetailName,
|
||||||
}))
|
iconColor: taskColor,
|
||||||
|
onProgressChanged: (progress) {
|
||||||
|
model.logic.refreshProgress(
|
||||||
|
taskDetailBean,
|
||||||
|
progress,
|
||||||
|
mainPageModel);
|
||||||
|
model.refresh();
|
||||||
|
},
|
||||||
|
onChecked: (progress) {
|
||||||
|
model.logic.refreshProgress(
|
||||||
|
taskDetailBean,
|
||||||
|
progress,
|
||||||
|
mainPageModel);
|
||||||
|
model.refresh();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
))
|
||||||
: SizedBox(),
|
: SizedBox(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ class IconUtil {
|
|||||||
List<IconData> get icons => _icons;
|
List<IconData> get icons => _icons;
|
||||||
|
|
||||||
|
|
||||||
|
List<String> get iconNames => _iconNames;
|
||||||
|
|
||||||
|
|
||||||
List<IconData> _icons = [
|
List<IconData> _icons = [
|
||||||
@ -1007,7 +1007,7 @@ class IconUtil {
|
|||||||
Icons.zoom_out_map
|
Icons.zoom_out_map
|
||||||
];
|
];
|
||||||
|
|
||||||
List<String> iconNames = [
|
List<String> _iconNames = [
|
||||||
"threesixty",
|
"threesixty",
|
||||||
"threed_rotation",
|
"threed_rotation",
|
||||||
"four_k",
|
"four_k",
|
||||||
|
Reference in New Issue
Block a user