Skip to content

Commit

Permalink
feat(*): fix some display bugs, update some ui details, wait for fina…
Browse files Browse the repository at this point in the history
…l check to release
  • Loading branch information
Aoi-hosizora committed Nov 19, 2022
1 parent ca23997 commit 4a732f6
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 183 deletions.
1 change: 1 addition & 0 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const DB_NAME = 'db_manhuagui';
const DL_NTFC_ID = 'com.aoihosizora.manhuagui:download';
const DL_NTFC_NAME = '漫画下载通知';
const DL_NTFC_DESCRIPTION = '显示当前的漫画下载进度';
const LOG_CONSOLE_BUFFER = 200;

const DEBUG_ERROR = true;
const CONNECT_TIMEOUT = 5000; // 5.0s (local -> my server)
Expand Down
2 changes: 1 addition & 1 deletion lib/page/download_select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class _DownloadSelectPageState extends State<DownloadSelectPage> {
physics: AlwaysScrollableScrollPhysics(),
children: [
WarningTextView(
text: '本应用为第三方漫画柜客户端,请不要连续下载过多章节,避免因短时间内的频繁访问而导致当前的IP被漫画柜封禁。',
text: '本应用为第三方漫画柜客户端,请不要连续下载过多章节,避免因短时间内的频繁访问而导致当前IP被漫画柜封禁。',
isWarning: true,
),
MangaTocView(
Expand Down
1 change: 0 additions & 1 deletion lib/page/manga_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ class _MangaViewerPageState extends State<MangaViewerPage> with AutomaticKeepAli
),
ActionRowView.four(
compact: true,
shrink: false,
textColor: Colors.white,
iconColor: Colors.white,
action1: ActionItem(
Expand Down
12 changes: 8 additions & 4 deletions lib/page/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:manhuagui_flutter/service/dio/retrofit.dart';
import 'package:manhuagui_flutter/service/dio/wrap_error.dart';
import 'package:manhuagui_flutter/service/prefs/message.dart';

/// 历史消息页
/// 历史消息页,网络请求并展示 [Message] 信息
class MessagePage extends StatefulWidget {
const MessagePage({Key? key}) : super(key: key);

Expand Down Expand Up @@ -42,16 +42,18 @@ class _MessagePageState extends State<MessagePage> {

_total = result.data.data.length;
if (mounted) setState(() {});
await _loadReadMangas();
await _loadReadMangas(data: result.data.data);

return result.data.data;
}

Future<void> _loadReadMangas() async {
Future<void> _loadReadMangas({List<Message>? data}) async {
var messages = await MessagePrefs.getReadMessages();
_readMessages.clear();
_readMessages.addAll(messages);
_unreadCount = _data.length - _data.where((el) => _readMessages.contains(el.mid)).length;

data ??= _data;
_unreadCount = data.length - data.where((msg) => _readMessages.contains(msg.mid)).length;
if (mounted) setState(() {});
}

Expand All @@ -69,6 +71,7 @@ class _MessagePageState extends State<MessagePage> {
var r = await MessagePrefs.addReadMessages(_data.map((m) => m.mid).toList());
_readMessages.clear();
_readMessages.addAll(r);
_unreadCount = 0;
if (mounted) setState(() {});
},
),
Expand All @@ -94,6 +97,7 @@ class _MessagePageState extends State<MessagePage> {
Navigator.of(c).pop();
await MessagePrefs.clearReadMessages();
_readMessages.clear();
_unreadCount = _data.length;
if (mounted) setState(() {});
},
),
Expand Down
4 changes: 2 additions & 2 deletions lib/page/page/dl_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _DlSettingSubPageState extends State<DlSettingSubPage> with SettingSubPage
),
SettingComboBoxView<int>(
title: '同时下载的页面数量',
hint: '本应用为第三方漫画柜客户端,请不要同时下载过多页面,避免因短时间内的频繁访问而导致当前的IP被漫画柜封禁。',
hint: '本应用为第三方漫画柜客户端,请不要同时下载过多页面,避免因短时间内的频繁访问而导致当前IP被漫画柜封禁。',
width: 75,
value: _downloadPagesTogether.clamp(1, 8),
values: List.generate(8, (i) => i + 1),
Expand All @@ -118,7 +118,7 @@ class _DlSettingSubPageState extends State<DlSettingSubPage> with SettingSubPage
),
SettingButtonView(
title: '漫画下载存储路径',
hint: _lowerThanAndroidR == null
hint: _lowerThanAndroidR == null || _lowerThanAndroidR == true
? null //
: '当前设备搭载着 Android 11 或以上版本的系统。\n\n由于 Android 系统限制,漫画将被下载至应用私有沙盒存储中。当卸载本应用时,若需要保留已下载的漫画,请选择保留本应用的数据。',
buttonChild: Text('查看'),
Expand Down
4 changes: 2 additions & 2 deletions lib/page/page/glb_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GlbSetting {
if (!s.enableLogger) {
LogConsolePage.finalize();
} else if (!LogConsolePage.initialized) {
LogConsolePage.initialize(globalLogger, bufferSize: 100);
LogConsolePage.initialize(globalLogger, bufferSize: LOG_CONSOLE_BUFFER);
globalLogger.i('initialize LogConsolePage');
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ class _GlbSettingSubPageState extends State<GlbSettingSubPage> with SettingSubPa
hint: '当前设置对应的漫画下载超时时间为:' +
(_dlTimeoutBehavior == TimeoutBehavior.normal
? '${DOWNLOAD_HEAD_TIMEOUT / 1000}s + ${DOWNLOAD_IMAGE_TIMEOUT / 1000}s'
: _timeoutBehavior == TimeoutBehavior.long
: _dlTimeoutBehavior == TimeoutBehavior.long
? '${DOWNLOAD_HEAD_LTIMEOUT / 1000}s + ${DOWNLOAD_IMAGE_LTIMEOUT / 1000}s'
: '无超时时间设置'),
width: 75,
Expand Down
103 changes: 42 additions & 61 deletions lib/page/page/view_extra.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:manhuagui_flutter/model/chapter.dart';
import 'package:manhuagui_flutter/page/view/action_row.dart';
import 'package:manhuagui_flutter/page/view/network_image.dart';

/// 漫画章节阅读页-额外页
Expand Down Expand Up @@ -118,67 +119,47 @@ class ViewExtraSubPage extends StatelessWidget {
}

Widget _buildActions(BuildContext context) {
Widget _buildAction({required String text, required IconData icon, required void Function() action, bool enable = true}) {
return InkWell(
onTap: enable ? action : null,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 6),
child: Column(
children: [
Container(
height: 48,
width: 48,
decoration: BoxDecoration(
border: Border.all(width: 0.8, color: Colors.grey[400]!),
shape: BoxShape.circle,
),
child: Icon(
icon,
size: 22,
color: enable ? Colors.grey[800] : Colors.grey,
),
),
SizedBox(height: 10),
Text(
text,
style: TextStyle(color: enable ? Colors.black : Colors.grey),
),
],
),
),
);
}

return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_buildAction(
text: '结束阅读',
icon: Icons.arrow_back,
action: () => toPop.call(),
return ActionRowView.five(
iconBuilder: (action) => Container(
height: 45,
width: 45,
margin: EdgeInsets.only(bottom: 3),
decoration: BoxDecoration(
border: Border.all(width: 0.8, color: Colors.grey[400]!),
shape: BoxShape.circle,
),
_buildAction(
text: !subscribed ? '订阅漫画' : '取消订阅',
icon: !subscribed ? Icons.star_border : Icons.star,
action: () => toSubscribe.call(),
enable: !subscribing,
child: Icon(
action.icon,
size: 22,
color: action.enable ? Colors.grey[800] : Colors.grey,
),
_buildAction(
text: '下载漫画',
icon: Icons.download,
action: () => toDownload.call(),
),
_buildAction(
text: '漫画目录',
icon: Icons.menu,
action: () => toShowToc.call(),
),
_buildAction(
text: '查看评论',
icon: Icons.forum,
action: () => toShowComments.call(),
),
],
),
action1: ActionItem(
text: '结束阅读',
icon: Icons.arrow_back,
action: () => toPop.call(),
),
action2: ActionItem(
text: !subscribed ? '订阅漫画' : '取消订阅',
icon: !subscribed ? Icons.star_border : Icons.star,
action: () => toSubscribe.call(),
enable: !subscribing,
),
action3: ActionItem(
text: '下载漫画',
icon: Icons.download,
action: () => toDownload.call(),
),
action4: ActionItem(
text: '漫画目录',
icon: Icons.menu,
action: () => toShowToc.call(),
),
action5: ActionItem(
text: '查看评论',
icon: Icons.forum,
action: () => toShowComments.call(),
),
);
}

Expand Down Expand Up @@ -336,10 +317,10 @@ class ViewExtraSubPage extends StatelessWidget {
SizedBox(height: 18),
Container(
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 18 - 6),
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 18 - 6 - 8),
child: Material(
color: Colors.transparent,
child: _buildActions(context), // InkWell vertical padding: 6
child: _buildActions(context), // InkWell vertical padding: 6, ActionRowView vertical padding: 8
),
),
],
Expand Down
39 changes: 20 additions & 19 deletions lib/page/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:manhuagui_flutter/config.dart';
import 'package:manhuagui_flutter/model/message.dart';
import 'package:manhuagui_flutter/page/page/glb_setting.dart';
import 'package:manhuagui_flutter/page/view/message_dialog.dart';
import 'package:manhuagui_flutter/service/db/db_manager.dart';
Expand Down Expand Up @@ -35,6 +34,9 @@ class SplashPage extends StatefulWidget {
static void remove() => FlutterNativeSplash.remove();

static Future<void> prepare() async {
// 0. fake delay
await Future.delayed(Duration(milliseconds: 500));

// 1. check permission
var ok = await _checkPermission();
if (!ok) {
Expand Down Expand Up @@ -63,8 +65,14 @@ class SplashPage extends StatefulWidget {
// 1. register context for notification
NotificationManager.instance.registerContext(context);

// 2. check message asynchronously
_checkLatestMessage(context);
// 2. check latest message asynchronously
Future.microtask(() async {
try {
await _checkLatestMessage(context);
} catch (e, s) {
wrapError(e, s); // ignored
}
});

// 3. check auth asynchronously
Future.microtask(() async {
Expand All @@ -78,26 +86,19 @@ class SplashPage extends StatefulWidget {
static Future<void> _checkLatestMessage(BuildContext context) async {
var readMessages = await MessagePrefs.getReadMessages();
final client = RestClient(DioManager.instance.dio);
LatestMessage lm;
try {
var result = await client.getLatestMessage();
lm = result.data;
} catch (e, s) {
wrapError(e, s); // ignored
return;
}
var m = (await client.getLatestMessage()).data;

if (lm.mustUpgradeNewVersion != null && isVersionNewer(lm.mustUpgradeNewVersion!.newVersion!.version, APP_VERSION) == true) {
await showNewVersionDialog(context: context, newVersion: lm.mustUpgradeNewVersion!);
if (m.mustUpgradeNewVersion != null && isVersionNewer(m.mustUpgradeNewVersion!.newVersion!.version, APP_VERSION) == true) {
await showNewVersionDialog(context: context, newVersion: m.mustUpgradeNewVersion!);
}
if (lm.notDismissibleNotification != null && !readMessages.contains(lm.notDismissibleNotification!.mid)) {
await showNotificationDialog(context: context, notification: lm.notDismissibleNotification!);
if (m.notDismissibleNotification != null && !readMessages.contains(m.notDismissibleNotification!.mid)) {
await showNotificationDialog(context: context, notification: m.notDismissibleNotification!);
}
if (lm.newVersion != null && !readMessages.contains(lm.newVersion!.mid) && isVersionNewer(lm.newVersion!.newVersion!.version, APP_VERSION) == true) {
await showNewVersionDialog(context: context, newVersion: lm.newVersion!);
if (m.newVersion != null && !readMessages.contains(m.newVersion!.mid) && isVersionNewer(m.newVersion!.newVersion!.version, APP_VERSION) == true) {
await showNewVersionDialog(context: context, newVersion: m.newVersion!);
}
if (lm.notification != null && !readMessages.contains(lm.notification!.mid)) {
await showNotificationDialog(context: context, notification: lm.notification!);
if (m.notification != null && !readMessages.contains(m.notification!.mid)) {
await showNotificationDialog(context: context, notification: m.notification!);
}
}
}
Expand Down
41 changes: 19 additions & 22 deletions lib/page/view/action_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class ActionRowView extends StatelessWidget {
required this.action3,
required this.action4,
this.compact = false,
this.shrink = true,
this.textColor,
this.iconColor,
this.disabledTextColor,
this.disabledIconColor,
this.iconBuilder,
}) : action5 = null,
super(key: key);

Expand All @@ -53,11 +53,11 @@ class ActionRowView extends StatelessWidget {
required this.action4,
required ActionItem this.action5,
this.compact = false,
this.shrink = true,
this.textColor,
this.iconColor,
this.disabledTextColor,
this.disabledIconColor,
this.iconBuilder,
}) : super(key: key);

final ActionItem action1;
Expand All @@ -66,11 +66,11 @@ class ActionRowView extends StatelessWidget {
final ActionItem action4;
final ActionItem? action5;
final bool compact;
final bool shrink;
final Color? textColor;
final Color? iconColor;
final Color? disabledTextColor;
final Color? disabledIconColor;
final Widget Function(ActionItem action)? iconBuilder;

Widget _buildAction(BuildContext context, ActionItem action) {
return InkWell(
Expand All @@ -84,18 +84,17 @@ class ActionRowView extends StatelessWidget {
alignment: IconTextAlignment.t2b,
space: compact
? 2 // compact
: action5 == null
? 8 // four
: 5 /* five */,
icon: Transform.rotate(
angle: action.rotateAngle,
child: Icon(
action.icon,
color: action.enable
? (textColor ?? Colors.black54) // enabled
: (disabledTextColor ?? Colors.grey) /* disabled */,
),
),
: 8 /* normal */,
icon: iconBuilder?.call(action) ??
Transform.rotate(
angle: action.rotateAngle,
child: Icon(
action.icon,
color: action.enable
? (textColor ?? Colors.black54) // enabled
: (disabledTextColor ?? Colors.grey) /* disabled */,
),
),
text: Text(
action.text,
style: Theme.of(context).textTheme.bodyText1!.copyWith(
Expand All @@ -115,14 +114,12 @@ class ActionRowView extends StatelessWidget {
color: Colors.transparent,
child: Padding(
padding: compact
? EdgeInsets.zero // compact
: action5 == null // normal
? EdgeInsets.symmetric(horizontal: 25, vertical: 8) // four
: EdgeInsets.symmetric(horizontal: 15, vertical: 5) /* five */,
? EdgeInsets.symmetric(horizontal: 0, vertical: 0) // compact
: EdgeInsets.symmetric(horizontal: 0, vertical: 8) /* normal */,
child: Row(
mainAxisAlignment: shrink
? MainAxisAlignment.spaceBetween // shrink
: MainAxisAlignment.spaceAround /* normal */,
mainAxisAlignment: compact
? MainAxisAlignment.spaceAround // compact
: MainAxisAlignment.spaceEvenly /* normal */,
children: [
_buildAction(context, action1),
_buildAction(context, action2),
Expand Down
Loading

0 comments on commit 4a732f6

Please sign in to comment.