From 7cebc1d90c8ece67b61008c5dd37ee694db6739c Mon Sep 17 00:00:00 2001 From: niuhuan Date: Thu, 28 Oct 2021 18:45:43 +0800 Subject: [PATCH] fix ios init error and view log auto scroll back --- lib/basic/config/DownloadAndExportPath.dart | 7 +- lib/screens/ViewLogsScreen.dart | 85 ++++++++++++--------- 2 files changed, 57 insertions(+), 35 deletions(-) diff --git a/lib/basic/config/DownloadAndExportPath.dart b/lib/basic/config/DownloadAndExportPath.dart index 01346f0..4aab2c4 100644 --- a/lib/basic/config/DownloadAndExportPath.dart +++ b/lib/basic/config/DownloadAndExportPath.dart @@ -10,7 +10,12 @@ import '../Method.dart'; late String _downloadAndExportPath; Future initDownloadAndExportPath() async { - _downloadAndExportPath = await method.loadDownloadAndExportPath(); + if (Platform.isWindows || + Platform.isMacOS || + Platform.isAndroid || + Platform.isLinux) { + _downloadAndExportPath = await method.loadDownloadAndExportPath(); + } } Widget downloadAndExportPathSetting() { diff --git a/lib/screens/ViewLogsScreen.dart b/lib/screens/ViewLogsScreen.dart index cdbf05f..50f8ba3 100644 --- a/lib/screens/ViewLogsScreen.dart +++ b/lib/screens/ViewLogsScreen.dart @@ -164,42 +164,59 @@ class ViewLogWrap extends StatelessWidget { var size = MediaQuery.of(context).size; var min = size.width < size.height ? size.width : size.height; var width = (min - 45) / 4; - return Wrap( - alignment: WrapAlignment.spaceAround, - children: comics.map((e) { - return InkWell( - key: e.key, - 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), - ), - ], - ), + + var entries = comics.map((e) { + return InkWell( + key: e.key, + 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(), + ), + ); + }); + + Map> map = Map(); + for (var i = 0; i < entries.length; i++) { + late List list; + if (i % 4 == 0) { + list = []; + map[i ~/ 4] = list; + } else { + list = map[i ~/ 4]!; + } + list.add(entries.elementAt(i)); + } + + return Column( + children: map.values.map((e) => Wrap( + alignment: WrapAlignment.spaceAround, + children: e, + )).toList(), ); } }