mod: save panel use absolute time (#657)

This commit is contained in:
My-Responsitories
2025-04-10 12:34:40 +08:00
committed by GitHub
parent 1d4b08672b
commit 2a60a9b393
6 changed files with 168 additions and 135 deletions

View File

@@ -24,6 +24,7 @@ class AuthorPanel extends StatelessWidget {
final Function? addBannedList;
final String? source;
final Function? onRemove;
final bool isSave;
const AuthorPanel({
super.key,
@@ -31,6 +32,7 @@ class AuthorPanel extends StatelessWidget {
this.addBannedList,
this.source,
this.onRemove,
this.isSave = false,
});
Widget _buildAvatar(double size) => NetworkImgLayer(
@@ -43,7 +45,12 @@ class AuthorPanel extends StatelessWidget {
@override
Widget build(BuildContext context) {
String? pubTime = item.modules.moduleAuthor.pubTs != null
? Utils.dateFormat(item.modules.moduleAuthor.pubTs)
? isSave
? DateTime.fromMillisecondsSinceEpoch(
item.modules.moduleAuthor.pubTs * 1000)
.toString()
.substring(0, 19)
: Utils.dateFormat(item.modules.moduleAuthor.pubTs)
: item.modules.moduleAuthor.pubTime;
return Stack(
alignment: Alignment.center,
@@ -210,30 +217,32 @@ class AuthorPanel extends StatelessWidget {
);
}
Widget _moreWidget(context) => SizedBox(
width: 32,
height: 32,
child: IconButton(
tooltip: '更多',
style: ButtonStyle(
padding: WidgetStateProperty.all(EdgeInsets.zero),
Widget _moreWidget(BuildContext context) => isSave
? const SizedBox.shrink()
: SizedBox(
width: 32,
height: 32,
child: IconButton(
tooltip: '更多',
style: ButtonStyle(
padding: WidgetStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
constraints: BoxConstraints(
maxWidth: min(640, min(Get.width, Get.height)),
),
builder: (context) {
return morePanel(context);
},
);
},
icon: const Icon(Icons.more_vert_outlined, size: 18),
),
onPressed: () {
showModalBottomSheet(
context: context,
useSafeArea: true,
isScrollControlled: true,
constraints: BoxConstraints(
maxWidth: min(640, min(Get.width, Get.height)),
),
builder: (context) {
return morePanel(context);
},
);
},
icon: const Icon(Icons.more_vert_outlined, size: 18),
),
);
);
Widget morePanel(context) {
return Padding(

View File

@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'rich_node_panel.dart';
Widget content(isSave, context, item, source, callback) {
Widget content(bool isSave, BuildContext context, item, source, callback) {
InlineSpan picsNodes() {
return WidgetSpan(
child: LayoutBuilder(
@@ -55,7 +55,7 @@ Widget content(isSave, context, item, source, callback) {
child: Text.rich(
/// fix 默认20px高度
style: TextStyle(
fontSize: source == 'detail' && isSave != true ? 16 : 15,
fontSize: source == 'detail' && !isSave ? 16 : 15,
),
richNodes,
maxLines: source == 'detail' ? null : 6,

View File

@@ -14,14 +14,14 @@ class DynamicPanel extends StatelessWidget {
final String? source;
final Function? onRemove;
final Function(List<String>, int)? callback;
final bool? isSave;
final bool isSave;
const DynamicPanel({
required this.item,
this.source,
this.onRemove,
this.callback,
this.isSave,
this.isSave = false,
super.key,
});
@@ -31,7 +31,7 @@ class DynamicPanel extends StatelessWidget {
// padding: source == 'detail'
// ? const EdgeInsets.only(bottom: 12)
// : EdgeInsets.zero,
decoration: isSave == true ||
decoration: isSave ||
(source == 'detail' &&
Get.context!.orientation == Orientation.landscape)
? null
@@ -133,6 +133,7 @@ class DynamicPanel extends StatelessWidget {
item: item,
source: source,
onRemove: onRemove,
isSave: isSave,
),
),
if (item!.modules!.moduleDynamic!.desc != null ||
@@ -141,7 +142,7 @@ class DynamicPanel extends StatelessWidget {
forWard(isSave, item, context, source, callback),
const SizedBox(height: 2),
if (source == null) ActionPanel(item: item),
if (source == 'detail' && isSave != true) const SizedBox(height: 12),
if (source == 'detail' && !isSave) const SizedBox(height: 12),
],
);
}

View File

@@ -68,7 +68,7 @@ Widget _blockedItem(BuildContext context, item, source) {
);
}
Widget forWard(isSave, item, BuildContext context, source, callback,
Widget forWard(bool isSave, item, BuildContext context, source, callback,
{floor = 1}) {
switch (item.type) {
// 图文
@@ -125,12 +125,12 @@ Widget forWard(isSave, item, BuildContext context, source, callback,
Text.rich(
richNodes,
// 被转发状态(floor=2) 隐藏
maxLines: isSave == true
maxLines: isSave
? null
: source == 'detail' && floor != 2
? null
: 4,
overflow: isSave == true
overflow: isSave
? null
: source == 'detail' && floor != 2
? null
@@ -307,12 +307,12 @@ Widget forWard(isSave, item, BuildContext context, source, callback,
Text.rich(
richNodes,
// 被转发状态(floor=2) 隐藏
maxLines: isSave == true
maxLines: isSave
? null
: source == 'detail' && floor != 2
? null
: 4,
overflow: isSave == true
overflow: isSave
? null
: source == 'detail' && floor != 2
? null

View File

@@ -43,6 +43,7 @@ class ReplyItemGrpc extends StatelessWidget {
this.callback,
this.onCheckReply,
this.onToggleTop,
this.isSave = false,
});
final ReplyInfo replyItem;
final String replyLevel;
@@ -58,6 +59,7 @@ class ReplyItemGrpc extends StatelessWidget {
final Function(List<String>, int)? callback;
final ValueChanged<ReplyInfo>? onCheckReply;
final Function(bool isUpTop, int rpid)? onToggleTop;
final bool isSave;
@override
Widget build(BuildContext context) {
@@ -320,7 +322,12 @@ class ReplyItemGrpc extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
Utils.dateFormat(replyItem.ctime.toInt()),
isSave
? DateTime.fromMillisecondsSinceEpoch(
replyItem.ctime.toInt() * 1000)
.toString()
.substring(0, 19)
: Utils.dateFormat(replyItem.ctime.toInt()),
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
@@ -554,15 +561,12 @@ class ReplyItemGrpc extends StatelessWidget {
},
child: Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(
8,
i == 0 && (extraRow || replyItem.replies.length > 1)
? 8
: 4,
8,
i == 0 && (extraRow || replyItem.replies.length > 1)
? 4
: 6,
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical:
i == 0 && (extraRow || replyItem.replies.length > 1)
? 8
: 4,
),
child: Semantics(
label: