Skip to content

Commit

Permalink
todo function add loading
Browse files Browse the repository at this point in the history
  • Loading branch information
maoqitian committed Mar 8, 2020
1 parent c509693 commit 8fa0c78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions flutter_wanandroid/lib/http/data_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ class DataUtils{
// date: 2018-08-01 预定完成时间(不传默认当天,建议传)
// type: 大于0的整数(可选);
// priority 大于0的整数(可选);
Future<TodoData> getAddTodoData(Map<String, dynamic> params) async{
Future<TodoData> getAddTodoData(Map<String, dynamic> params,BuildContext context) async{
String path = 'lg/todo/add/json';
Response response = await httpUtils.post(path,queryParameters: params);
Response response = await httpUtils.post(path,queryParameters: params,isAddLoading: true,loadingText: "正在新增清单",context: context);
BaseTodoData baseTodoData = BaseTodoData.fromJson(response.data);
return baseTodoData.data;
}
Expand All @@ -386,9 +386,9 @@ class DataUtils{
// type: ;
// priority:

Future<TodoData> getUpdateTodoData(int id,Map<String, dynamic> params) async{
Future<TodoData> getUpdateTodoData(int id,Map<String, dynamic> params,BuildContext context) async{
String path = 'lg/todo/update/$id/json';
Response response = await httpUtils.post(path,queryParameters: params);
Response response = await httpUtils.post(path,queryParameters: params,isAddLoading: true,loadingText: "正在更新",context: context);
BaseTodoData baseTodoData = BaseTodoData.fromJson(response.data);
return baseTodoData.data;
}
Expand All @@ -397,9 +397,9 @@ class DataUtils{
//方法:POST
//参数:
//id: 拼接在链接上,为唯一标识
Future<String> getDeleteTodoData(int id) async{
Future<String> getDeleteTodoData(int id,BuildContext context) async{
String path = 'lg/todo/delete/$id/json';
Response response = await httpUtils.post(path);
Response response = await httpUtils.post(path,isAddLoading: true,loadingText: "正在删除",context: context);
return response.data["data"];
}

Expand All @@ -408,9 +408,9 @@ class DataUtils{
//参数:
// id: 拼接在链接上,为唯一标识
// status: 0或1,传1代表未完成到已完成,反之则反之。
Future<TodoData> getUpdateDoneTodo(int id,Map<String, dynamic> params) async{
Future<TodoData> getUpdateDoneTodo(int id,Map<String, dynamic> params,BuildContext context) async{
String path = 'lg/todo/done/$id/json';
Response response = await httpUtils.post(path,queryParameters: params);
Response response = await httpUtils.post(path,queryParameters: params,isAddLoading: true,loadingText: "正在处理",context: context);
BaseTodoData baseTodoData = BaseTodoData.fromJson(response.data);
return baseTodoData.data;
}
Expand Down
6 changes: 3 additions & 3 deletions flutter_wanandroid/lib/views/todo/item/todo_item_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _TodoItemViewState extends State<TodoItemView> {
activeColor: ToolUtils.getPrimaryColor(context),
value: isDone,
onChanged:(isCheck) async {
await dataUtils.getUpdateDoneTodo(tododata.id,{"status":isCheck ? 1 : 0}).then((TodoData todoData){
await dataUtils.getUpdateDoneTodo(tododata.id,{"status":isCheck ? 1 : 0},context).then((TodoData todoData){
setState(() {
});
Application.eventBus.fire(new TodoChangeEvent());
Expand Down Expand Up @@ -119,7 +119,7 @@ class _TodoItemViewState extends State<TodoItemView> {
todoData: tododata,
confirmCallback3: (params)async{
//编辑收藏网站
await dataUtils.getUpdateTodoData(tododata.id,params).then((TodoData todoData){
await dataUtils.getUpdateTodoData(tododata.id,params,context).then((TodoData todoData){
ToolUtils.showToast(msg: "修改成功");
Application.eventBus.fire(new TodoChangeEvent());
});
Expand All @@ -139,7 +139,7 @@ class _TodoItemViewState extends State<TodoItemView> {
ToolUtils.showAlertDialog(context, "确定删除清单"+widget.todoData.title+"?",
confirmCallback: ()async{
// 删除收藏网站
await dataUtils.getDeleteTodoData(widget.todoData.id).then((String s){
await dataUtils.getDeleteTodoData(widget.todoData.id,context).then((String s){
Application.eventBus.fire(new TodoChangeEvent());
ToolUtils.showToast(msg: "删除成功");
});
Expand Down
2 changes: 1 addition & 1 deletion flutter_wanandroid/lib/views/todo/todo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class _TodoPageState extends State<TodoPage> with SingleTickerProviderStateMixin
isDIYText: true,
confirmCallback3: (params)async{
//编辑收藏网站
await dataUtils.getAddTodoData(params).then((TodoData todoData){
await dataUtils.getAddTodoData(params,context).then((TodoData todoData){
ToolUtils.showToast(msg: "添加成功");
Application.eventBus.fire(new TodoChangeEvent());
});
Expand Down

0 comments on commit 8fa0c78

Please sign in to comment.