view log del action +

This commit is contained in:
niuhuan 2021-10-23 10:59:18 +08:00
parent b939cf1258
commit 3591c316ba
4 changed files with 23 additions and 49 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 309 KiB

View File

@ -1,6 +1,7 @@
const ERROR_TYPE_NETWORK = "NETWORK_ERROR"; const ERROR_TYPE_NETWORK = "NETWORK_ERROR";
const ERROR_TYPE_PERMISSION = "PERMISSION_ERROR"; const ERROR_TYPE_PERMISSION = "PERMISSION_ERROR";
const ERROR_TYPE_TIME = "TIME_ERROR"; const ERROR_TYPE_TIME = "TIME_ERROR";
const ERROR_TYPE_UNDER_VIEW = "UNDER_VIEW_ERROR";
// , 便 // , 便
String errorType(String error) { String errorType(String error) {
@ -19,5 +20,8 @@ String errorType(String error) {
if (error.contains("time is not synchronize")) { if (error.contains("time is not synchronize")) {
return ERROR_TYPE_TIME; return ERROR_TYPE_TIME;
} }
if (error.contains("under view")) {
return ERROR_TYPE_UNDER_VIEW;
}
return ""; return "";
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapi/basic/Common.dart'; import 'package:pikapi/basic/Common.dart';
import 'package:pikapi/basic/Method.dart'; import 'package:pikapi/basic/Method.dart';
@ -51,13 +50,8 @@ class _ViewLogsScreenState extends State<ViewLogsScreen> {
setState(() { setState(() {
for (var i = 0; i < _comicList.length; i++) { for (var i = 0; i < _comicList.length; i++) {
if (_comicList[i].id == id) { if (_comicList[i].id == id) {
_comicList[i] = ViewLogWrapEntity( _comicList.removeAt(i);
_comicList[i].id, _offset--;
_comicList[i].title,
_comicList[i].fileServer,
_comicList[i].path,
deleted: true,
);
break; break;
} }
} }
@ -153,7 +147,6 @@ class _ViewLogsScreenState extends State<ViewLogsScreen> {
} }
} }
class ViewLogWrap extends StatelessWidget { class ViewLogWrap extends StatelessWidget {
final Function(String) onTapComic; final Function(String) onTapComic;
final List<ViewLogWrapEntity> comics; final List<ViewLogWrapEntity> comics;
@ -174,8 +167,15 @@ class ViewLogWrap extends StatelessWidget {
return Wrap( return Wrap(
alignment: WrapAlignment.spaceAround, alignment: WrapAlignment.spaceAround,
children: comics.map((e) { children: comics.map((e) {
if (e.deleted) { return InkWell(
return Card( key: e.key,
onTap: () {
onTapComic(e.id);
},
onLongPress: () {
onDelete(e.id);
},
child: Card(
child: Container( child: Container(
width: width, width: width,
child: Column( child: Column(
@ -188,7 +188,7 @@ class ViewLogWrap extends StatelessWidget {
path: e.path); path: e.path);
}), }),
Text( Text(
'已删除\n', e.title + '\n',
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(height: 1.4), style: TextStyle(height: 1.4),
@ -197,52 +197,19 @@ class ViewLogWrap extends StatelessWidget {
], ],
), ),
), ),
); ),
} else { );
return InkWell(
onTap: () {
onTapComic(e.id);
},
onLongPress: () {
onDelete(e.id);
},
child: Card(
child: Container(
width: width,
child: Column(
children: [
LayoutBuilder(builder:
(BuildContext context, BoxConstraints constraints) {
return RemoteImage(
width: constraints.maxWidth,
fileServer: e.fileServer,
path: e.path);
}),
Text(
e.title + '\n',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(height: 1.4),
strutStyle: StrutStyle(height: 1.4),
),
],
),
),
),
);
}
}).toList(), }).toList(),
); );
} }
} }
class ViewLogWrapEntity { class ViewLogWrapEntity {
final Key key = UniqueKey();
final String id; final String id;
final String title; final String title;
final String fileServer; final String fileServer;
final String path; final String path;
final bool deleted;
ViewLogWrapEntity(this.id, this.title, this.fileServer, this.path, ViewLogWrapEntity(this.id, this.title, this.fileServer, this.path);
{this.deleted = false});
} }

View File

@ -30,6 +30,9 @@ class ContentError extends StatelessWidget {
case ERROR_TYPE_TIME: case ERROR_TYPE_TIME:
message = "请检查设备时间"; message = "请检查设备时间";
break; break;
case ERROR_TYPE_UNDER_VIEW:
message = "资源未审核或不可用";
break;
default: default:
message = "啊哦, 被玩坏了"; message = "啊哦, 被玩坏了";
break; break;