Skip to content

Commit

Permalink
bump version 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
orzogc committed Jun 19, 2023
1 parent 3dd3d43 commit fc45061
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 62 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# 更新记录
## v0.3.2(未发布)
## v0.4.0
- 可以设置点击略缩图是否直接在串内展示大图(基本设置),默认不开启
- 可以设置是否使用和浏览饼干绑定的网页版订阅(基本设置),默认不使用
- 可以设置是否同时使用左边和右边的侧边栏(界面基本设置,iOS没有此选项),默认不使用
- 可以设置右边侧边栏显示的内容(界面基本设置)
- 可以设置系统底部导航栏是否透明化(界面基本设置,仅限Android 11或以上版本),默认开启
- 可以设置系统底部导航栏是否透明化(界面基本设置,仅限Android 11或以上版本,iOS强制透明化),默认开启
- 可以清除图片缓存(高级设置)
- 可以设置在串页面右上角菜单是否增加取消订阅选项,默认不增加
- 可以设置在串页面右上角菜单是否增加取消订阅选项(高级设置),默认不增加
- 可以备份和恢复应用设置和数据(设置->应用数据备份与恢复)
- 长按串的串号会复制串号引用
- 移除Backdrop UI及其相关设置
- 移除高级设置里的“系统底部导航栏颜色跟随应用主题”
- 修复iOS保存GIF动图的问题
Expand Down
1 change: 1 addition & 0 deletions lib/app/modules/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class _TopOverlay extends StatelessWidget {
showReplyCount: false,
showPoTag: true,
showPostTags: false,
longPressPostIdToCopy: false,
),
),
),
Expand Down
13 changes: 3 additions & 10 deletions lib/app/modules/post_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@ abstract class PostListController extends ChangeNotifier {
StreamSubscription<int> listenPage(ValueChanged<int> onPage) =>
_page.listen(onPage);

// [onAppBarHeight]参数是标题栏显示的高度
/* StreamSubscription<double> listenAppBarHeight(
ValueChanged<double> onAppBarHeight) =>
_appBarHeight.listen(onAppBarHeight); */

@override
void dispose() {
save = null;
Expand Down Expand Up @@ -480,14 +475,12 @@ class _AnimatedAppBarState extends State<_AnimatedAppBar>

void _updateController([double? preHeight]) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (_scrollController?.hasClients ?? false) {
if ((_scrollController?.hasClients ?? false) && preHeight != null) {
final position = _scrollController!.position;
final offset = position.pixels - position.minScrollExtent;

if (preHeight != null) {
if (offset >= 0.0 && offset <= PostListAppBar.height) {
_height = max(preHeight, PostListAppBar.height - offset);
}
if (offset >= 0.0 && offset <= PostListAppBar.height) {
_height = max(preHeight, PostListAppBar.height - offset);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/app/modules/post_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class PostFontSettingsView extends GetView<PostFontSettingsController> {
child: PostContent(
post: _post,
showFullTime: false,
longPressPostIdToCopy: false,
contentTextStyle: TextStyle(
fontSize: controller._postContentFontSize.value,
fontWeight: FontWeightExtension.fromInt(
Expand Down
3 changes: 2 additions & 1 deletion lib/app/widgets/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,8 @@ class NumRangeDialog<T extends num> extends StatelessWidget {
labelText:
max != null ? '$text( $min - $max )' : '$text( >= $min )'),
autofocus: true,
keyboardType: TextInputType.number,
keyboardType:
const TextInputType.numberWithOptions(signed: true, decimal: true),
initialValue: '$initialValue',
onSaved: (newValue) => number = newValue,
validator: (value) {
Expand Down
9 changes: 7 additions & 2 deletions lib/app/widgets/edit_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ class _DiceDialogState extends State<_DiceDialog> {
controller: _lowerController,
decoration: const InputDecoration(hintText: '下限'),
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
keyboardType:
const TextInputType.numberWithOptions(signed: true),
validator: (value) =>
value.tryParseInt() == null ? '请输入数字' : null,
),
Expand Down Expand Up @@ -545,7 +546,8 @@ class _DiceDialogState extends State<_DiceDialog> {
controller: _upperController,
decoration: const InputDecoration(hintText: '上限'),
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
keyboardType:
const TextInputType.numberWithOptions(signed: true),
validator: (value) =>
value.tryParseInt() == null ? '请输入数字' : null,
),
Expand Down Expand Up @@ -1534,6 +1536,9 @@ class EditPostCallback {
_setPostList(postList, forumId, poUserHash);
}

// TODO: 增加选项,单独页面时可以把图片放下面
// TODO: 考虑输入法没有关闭选项的问题
// TODO: 图片压缩
class EditPost extends StatefulWidget {
static const int dutyRoomId = 18;

Expand Down
13 changes: 13 additions & 0 deletions lib/app/widgets/feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,19 @@ class _FeedBodyState extends State<FeedBody> {
final page = _pageController.page;
if (page != null) {
_controller.pageIndex = page.round();

if (page - page.truncateToDouble() == 0.0) {
final scrollController = _scrollControllerList[_controller.pageIndex];
if (scrollController.hasClients) {
final position = scrollController.position;
final offset = position.pixels - position.minScrollExtent;

if (offset >= 0.0 && offset <= PostListAppBar.height) {
_controller.appBarHeight = PostListAppBar.height - offset;
scrollController.notifyListeners();
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/app/widgets/forum_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ForumList extends StatelessWidget {
isTimeline: forum.isTimeline,
isDeprecated: forum.isDeprecated,
maxLines: 1,
isBodyLargeStyle: true,
forumNameCache: ForumNameStyle.bodyLarge,
),
);

Expand Down
71 changes: 45 additions & 26 deletions lib/app/widgets/forum_name.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:xdnmb_api/xdnmb_api.dart';
import '../data/models/forum.dart';
import '../data/services/forum.dart';
import '../utils/extensions.dart';
import '../utils/theme.dart';
import 'dialog.dart';
import 'listenable.dart';
import 'tag.dart';
Expand All @@ -30,26 +31,45 @@ class _ForumName {
int get hashCode => Object.hash(forumName, isDarkMode);
}

class _ForumNameTextSpan {
final TextSpan bodyLargeStyle;
abstract class _ForumNameCache {
static final HashMap<_ForumName, TextSpan> _bodyLarge = HashMap();

_ForumNameTextSpan(BuildContext context, String forumName)
: bodyLargeStyle = htmlToTextSpan(context, forumName,
textStyle: Theme.of(context).textTheme.bodyLarge);
static final HashMap<String, TextSpan> _bodySmallWithHeaderColor = HashMap();
}

final HashMap<_ForumName, _ForumNameTextSpan> _forumNameMap = HashMap();

TextSpan _getBodyLargeForumName(BuildContext context, String forumName) {
final key = _ForumName(forumName, Get.isDarkMode);
final text = _forumNameMap[key];
if (text != null) {
return text.bodyLargeStyle;
} else {
final span = _ForumNameTextSpan(context, forumName);
_forumNameMap[key] = span;

return span.bodyLargeStyle;
enum ForumNameStyle {
bodyLarge,
bodySmallWithHeaderColor;

TextSpan _getForumName(BuildContext context, String forumName) {
switch (this) {
case bodyLarge:
final key = _ForumName(forumName, Get.isDarkMode);
final text = _ForumNameCache._bodyLarge[key];
if (text == null) {
final span = htmlToTextSpan(context, forumName,
textStyle: Theme.of(context).textTheme.bodyLarge);
_ForumNameCache._bodyLarge[key] = span;

return span;
} else {
return text;
}
case bodySmallWithHeaderColor:
final text = _ForumNameCache._bodySmallWithHeaderColor[forumName];
if (text == null) {
final span = htmlToTextSpan(context, forumName,
textStyle: Theme.of(context)
.textTheme
.bodySmall
?.apply(color: AppTheme.headerColor));
_ForumNameCache._bodySmallWithHeaderColor[forumName] = span;

return span;
} else {
return text;
}
}
}
}

Expand All @@ -64,7 +84,7 @@ class ForumNameText extends StatelessWidget {

final int? maxLines;

final bool isBodyLargeStyle;
final ForumNameStyle? forumNameCache;

const ForumNameText(
{super.key,
Expand All @@ -73,14 +93,13 @@ class ForumNameText extends StatelessWidget {
this.trailing,
this.textStyle,
this.maxLines,
this.isBodyLargeStyle = false})
: assert(!isBodyLargeStyle || textStyle == null);
this.forumNameCache})
: assert(forumNameCache == null || textStyle == null);

@override
Widget build(BuildContext context) {
final span = isBodyLargeStyle
? _getBodyLargeForumName(context, forumName)
: htmlToTextSpan(context, forumName, textStyle: textStyle);
final span = forumNameCache?._getForumName(context, forumName) ??
htmlToTextSpan(context, forumName, textStyle: textStyle);

return (leading != null || trailing != null)
? RichText(
Expand Down Expand Up @@ -125,7 +144,7 @@ class ForumName extends StatelessWidget {

final int? maxLines;

final bool isBodyLargeStyle;
final ForumNameStyle? forumNameCache;

const ForumName(
{super.key,
Expand All @@ -138,7 +157,7 @@ class ForumName extends StatelessWidget {
this.fallbackText,
this.textStyle,
this.maxLines,
this.isBodyLargeStyle = false})
this.forumNameCache})
: assert(isDeprecated == null || (leading == null && trailing == null));

@override
Expand All @@ -157,7 +176,7 @@ class ForumName extends StatelessWidget {
trailing: trailing,
textStyle: textStyle,
maxLines: maxLines,
isBodyLargeStyle: isBodyLargeStyle)
forumNameCache: forumNameCache)
: (fallbackText != null
? Text(fallbackText!,
style: textStyle,
Expand Down
15 changes: 13 additions & 2 deletions lib/app/widgets/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ class HistoryController extends PostListController {

@override
void dispose() {
//_pageIndex.close();
//_dateRange.close();
for (final notifier in _notifiers) {
notifier.dispose();
}
Expand Down Expand Up @@ -984,6 +982,19 @@ class _HistoryBodyState extends State<HistoryBody> {
final page = _pageController.page;
if (page != null) {
_controller.pageIndex = page.round();

if (page - page.truncateToDouble() == 0.0) {
final scrollController = _scrollControllerList[_controller.pageIndex];
if (scrollController.hasClients) {
final position = scrollController.position;
final offset = position.pixels - position.minScrollExtent;

if (offset >= 0.0 && offset <= PostListAppBar.height) {
_controller.appBarHeight = PostListAppBar.height - offset;
scrollController.notifyListeners();
}
}
}
}
}

Expand Down
23 changes: 20 additions & 3 deletions lib/app/widgets/post.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'dart:async';
import 'dart:math';
import 'dart:typed_data';

import 'package:expandable_text/expandable_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:html_to_text/html_to_text.dart';
import 'package:xdnmb_api/xdnmb_api.dart';

Expand All @@ -15,6 +15,7 @@ import '../data/services/user.dart';
import '../utils/extensions.dart';
import '../utils/theme.dart';
import '../utils/time.dart';
import '../utils/toast.dart';
import 'content.dart';
import 'dialog.dart';
import 'forum_name.dart';
Expand Down Expand Up @@ -182,6 +183,8 @@ class _PostTimeState extends State<_PostTime> {
class _PostId extends StatelessWidget {
final int postId;

final bool longPressPostIdToCopy;

/// 串号被按时调用,参数是串号
final ValueSetter<int>? onTapPostId;

Expand All @@ -191,6 +194,7 @@ class _PostId extends StatelessWidget {
// ignore: unused_element
{super.key,
required this.postId,
this.longPressPostIdToCopy = true,
this.onTapPostId,
this.textStyle});

Expand All @@ -202,11 +206,18 @@ class _PostId extends StatelessWidget {
? StrutStyle.fromTextStyle(textStyle!)
: AppTheme.postHeaderStrutStyle);

return onTapPostId != null
return (longPressPostIdToCopy || onTapPostId != null)
? MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () => onTapPostId!(postId),
onTap: onTapPostId != null ? () => onTapPostId!(postId) : null,
onLongPress: longPressPostIdToCopy
? () async {
await Clipboard.setData(
ClipboardData(text: postId.toPostReference()));
showToast('已复制 ${postId.toPostReference()}');
}
: null,
child: text,
),
)
Expand Down Expand Up @@ -592,6 +603,8 @@ class PostContent extends StatelessWidget {

final bool isPinned;

final bool longPressPostIdToCopy;

final double? headerHeight;

final double? contentMaxHeight;
Expand Down Expand Up @@ -635,6 +648,7 @@ class PostContent extends StatelessWidget {
this.showPoTag = false,
this.showPostTags = true,
this.isPinned = false,
this.longPressPostIdToCopy = true,
this.headerHeight,
this.contentMaxHeight,
this.onTapPostId,
Expand Down Expand Up @@ -720,6 +734,7 @@ class PostContent extends StatelessWidget {
if (showPostId)
_PostId(
postId: post.id,
longPressPostIdToCopy: longPressPostIdToCopy,
onTapPostId: onTapPostId,
textStyle: headerTextStyle,
),
Expand Down Expand Up @@ -803,6 +818,7 @@ class PostInkWell extends StatelessWidget {
bool showPoTag = false,
bool showPostTags = true,
bool isPinned = false,
bool longPressPostIdToCopy = true,
double? headerHeight,
double? contentMaxHeight,
ValueSetter<int>? onTapPostId,
Expand Down Expand Up @@ -834,6 +850,7 @@ class PostInkWell extends StatelessWidget {
showPoTag: showPoTag,
showPostTags: showPostTags,
isPinned: isPinned,
longPressPostIdToCopy: longPressPostIdToCopy,
headerHeight: headerHeight,
contentMaxHeight: contentMaxHeight,
onTapPostId: onTapPostId,
Expand Down
Loading

0 comments on commit fc45061

Please sign in to comment.