mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
feat: custom reply length limit
Closes #55 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -179,8 +179,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
content: TextFormField(
|
content: TextFormField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
initialValue: dynamicPeriod.toString(),
|
initialValue: dynamicPeriod.toString(),
|
||||||
keyboardType:
|
keyboardType: TextInputType.numberWithOptions(),
|
||||||
TextInputType.numberWithOptions(decimal: true),
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
dynamicPeriod = int.tryParse(value) ?? 5;
|
dynamicPeriod = int.tryParse(value) ?? 5;
|
||||||
},
|
},
|
||||||
@@ -280,6 +279,63 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.horizontalMemberPage,
|
setKey: SettingBoxKey.horizontalMemberPage,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text('评论折叠行数', style: titleStyle),
|
||||||
|
subtitle: Text('0行为不折叠', style: subTitleStyle),
|
||||||
|
leading: const Icon(Icons.compress),
|
||||||
|
trailing: Text(
|
||||||
|
'${GlobalData().replyLengthLimit.toString()}行',
|
||||||
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
String replyLengthLimit =
|
||||||
|
GlobalData().replyLengthLimit.toString();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('评论折叠行数', style: TextStyle(fontSize: 18)),
|
||||||
|
content: TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
initialValue: replyLengthLimit,
|
||||||
|
keyboardType: TextInputType.numberWithOptions(),
|
||||||
|
onChanged: (value) {
|
||||||
|
replyLengthLimit = value;
|
||||||
|
},
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.allow(RegExp(r'\d+')),
|
||||||
|
],
|
||||||
|
decoration: InputDecoration(suffixText: '行'),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Get.back,
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Get.back();
|
||||||
|
GlobalData().replyLengthLimit =
|
||||||
|
int.tryParse(replyLengthLimit) ?? 6;
|
||||||
|
await setting.put(
|
||||||
|
SettingBoxKey.replyLengthLimit,
|
||||||
|
GlobalData().replyLengthLimit,
|
||||||
|
);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Text('确定'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => ListTile(
|
() => ListTile(
|
||||||
enableFeedback: true,
|
enableFeedback: true,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:math';
|
|||||||
import 'package:PiliPalaX/common/widgets/imageview.dart';
|
import 'package:PiliPalaX/common/widgets/imageview.dart';
|
||||||
import 'package:PiliPalaX/http/video.dart';
|
import 'package:PiliPalaX/http/video.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -256,8 +257,11 @@ class ReplyItem extends StatelessWidget {
|
|||||||
String text = replyItem?.content?.message ?? '';
|
String text = replyItem?.content?.message ?? '';
|
||||||
var textPainter = TextPainter(
|
var textPainter = TextPainter(
|
||||||
text: TextSpan(text: text),
|
text: TextSpan(text: text),
|
||||||
maxLines:
|
maxLines: replyItem!.content!.isText! &&
|
||||||
replyItem!.content!.isText! && replyLevel == '1' ? 6 : 999,
|
replyLevel == '1' &&
|
||||||
|
GlobalData().replyLengthLimit != 0
|
||||||
|
? GlobalData().replyLengthLimit
|
||||||
|
: null,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
|||||||
import 'package:PiliPalaX/http/video.dart';
|
import 'package:PiliPalaX/http/video.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply/widgets/zan_grpc.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply/widgets/zan_grpc.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
|
import 'package:PiliPalaX/utils/global_data.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -268,7 +269,10 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
var textPainter = TextPainter(
|
var textPainter = TextPainter(
|
||||||
text: TextSpan(text: text, style: style),
|
text: TextSpan(text: text, style: style),
|
||||||
maxLines: replyLevel == '1' ? 6 : null,
|
maxLines:
|
||||||
|
replyLevel == '1' && GlobalData().replyLengthLimit != 0
|
||||||
|
? GlobalData().replyLengthLimit
|
||||||
|
: null,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
class GlobalData {
|
class GlobalData {
|
||||||
int imgQuality = 10;
|
int imgQuality = 10;
|
||||||
|
|
||||||
// int themeMode = 2;
|
|
||||||
|
|
||||||
bool grpcReply = true;
|
bool grpcReply = true;
|
||||||
|
|
||||||
|
int replyLengthLimit = 6;
|
||||||
|
|
||||||
// 私有构造函数
|
// 私有构造函数
|
||||||
GlobalData._();
|
GlobalData._();
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,12 @@ class GStorage {
|
|||||||
static bool get horizontalMemberPage =>
|
static bool get horizontalMemberPage =>
|
||||||
setting.get(SettingBoxKey.horizontalMemberPage, defaultValue: false);
|
setting.get(SettingBoxKey.horizontalMemberPage, defaultValue: false);
|
||||||
|
|
||||||
|
static int get replyLengthLimit =>
|
||||||
|
setting.get(SettingBoxKey.replyLengthLimit, defaultValue: 6);
|
||||||
|
|
||||||
|
static int get defaultPicQa =>
|
||||||
|
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
|
||||||
|
|
||||||
static List<double> get dynamicDetailRatio =>
|
static List<double> get dynamicDetailRatio =>
|
||||||
setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]);
|
setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]);
|
||||||
|
|
||||||
@@ -203,15 +209,10 @@ class GStorage {
|
|||||||
// 视频设置
|
// 视频设置
|
||||||
video = await Hive.openBox('video');
|
video = await Hive.openBox('video');
|
||||||
// 设置全局变量
|
// 设置全局变量
|
||||||
GlobalData().imgQuality = setting.get(
|
GlobalData()
|
||||||
SettingBoxKey.defaultPicQa,
|
..imgQuality = defaultPicQa
|
||||||
defaultValue: 10,
|
..grpcReply = grpcReply
|
||||||
);
|
..replyLengthLimit = replyLengthLimit;
|
||||||
// GlobalData().themeMode = setting.get(
|
|
||||||
// SettingBoxKey.themeMode,
|
|
||||||
// defaultValue: ThemeType.system.code,
|
|
||||||
// );
|
|
||||||
GlobalData().grpcReply = grpcReply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> exportAllSettings() async {
|
static Future<String> exportAllSettings() async {
|
||||||
@@ -341,6 +342,7 @@ class SettingBoxKey {
|
|||||||
exapndIntroPanelH = 'exapndIntroPanelH',
|
exapndIntroPanelH = 'exapndIntroPanelH',
|
||||||
horizontalSeasonPanel = 'horizontalSeasonPanel',
|
horizontalSeasonPanel = 'horizontalSeasonPanel',
|
||||||
horizontalMemberPage = 'horizontalMemberPage',
|
horizontalMemberPage = 'horizontalMemberPage',
|
||||||
|
replyLengthLimit = 'replyLengthLimit',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user