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

@@ -56,6 +56,8 @@ class SavePanel extends StatefulWidget {
class _SavePanelState extends State<SavePanel> {
final boundaryKey = GlobalKey();
bool showBottom = true;
// item
dynamic get _item => widget.item;
late String viewType = '查看';
@@ -222,7 +224,7 @@ class _SavePanelState extends State<SavePanel> {
ByteData? byteData = await image.toByteData(format: ImageByteFormat.png);
Uint8List pngBytes = byteData!.buffer.asUint8List();
String picName =
"plpl_reply_${DateTime.now().toString().replaceAll(RegExp(r'[- :]'), '').split('.').first}";
"plpl_reply_${DateTime.now().toString().substring(0, 19).replaceAll(RegExp(r'[- :]'), '')}";
if (isShare) {
Get.back();
SmartDialog.dismiss();
@@ -263,9 +265,7 @@ class _SavePanelState extends State<SavePanel> {
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Get.back();
},
onTap: Get.back,
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
@@ -297,6 +297,7 @@ class _SavePanelState extends State<SavePanel> {
replyLevel: '',
needDivider: false,
upMid: widget.upMid,
isSave: true,
),
)
else if (_item is DynamicItemModel)
@@ -348,10 +349,10 @@ class _SavePanelState extends State<SavePanel> {
if (pubdate != null) ...[
const Spacer(),
Text(
Utils.dateFormat(
pubdate,
formatType: 'detail',
),
DateTime.fromMillisecondsSinceEpoch(
pubdate! * 1000)
.toString()
.substring(0, 19),
style: TextStyle(
color: Theme.of(context)
.colorScheme
@@ -365,7 +366,8 @@ class _SavePanelState extends State<SavePanel> {
],
),
),
Stack(
showBottom
? Stack(
clipBehavior: Clip.none,
children: [
if (uri.isNotEmpty)
@@ -379,11 +381,13 @@ class _SavePanelState extends State<SavePanel> {
crossAxisAlignment:
CrossAxisAlignment.end,
children: [
if (uname?.isNotEmpty == true) ...[
if (uname?.isNotEmpty ==
true) ...[
Text(
'@$uname',
maxLines: 1,
overflow: TextOverflow.ellipsis,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context)
.colorScheme
@@ -428,13 +432,16 @@ class _SavePanelState extends State<SavePanel> {
: Theme.of(context)
.colorScheme
.surface,
padding: const EdgeInsets.all(3),
padding:
const EdgeInsets.all(3),
child: PrettyQrView.data(
data: uri,
decoration:
const PrettyQrDecoration(
shape: PrettyQrRoundedSymbol(
borderRadius: BorderRadius.zero,
shape:
PrettyQrRoundedSymbol(
borderRadius:
BorderRadius.zero,
),
),
),
@@ -454,7 +461,8 @@ class _SavePanelState extends State<SavePanel> {
),
),
],
),
)
: const SizedBox(height: 12),
],
),
),
@@ -468,7 +476,7 @@ class _SavePanelState extends State<SavePanel> {
right: 0,
bottom: 0,
child: Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
@@ -494,6 +502,17 @@ class _SavePanelState extends State<SavePanel> {
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 40),
iconButton(
size: 42,
tooltip: showBottom ? '隐藏' : '显示',
context: context,
icon: showBottom
? Icons.visibility_off
: Icons.visibility,
onPressed: () => setState(() {
showBottom = !showBottom;
})),
const SizedBox(width: 40),
iconButton(
size: 42,
tooltip: '分享',
@@ -507,7 +526,7 @@ class _SavePanelState extends State<SavePanel> {
tooltip: '保存',
context: context,
icon: Icons.save_alt,
onPressed: () => _onSaveOrSharePic(),
onPressed: _onSaveOrSharePic,
),
],
),

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,7 +217,9 @@ class AuthorPanel extends StatelessWidget {
);
}
Widget _moreWidget(context) => SizedBox(
Widget _moreWidget(BuildContext context) => isSave
? const SizedBox.shrink()
: SizedBox(
width: 32,
height: 32,
child: IconButton(

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,
padding: EdgeInsets.symmetric(
horizontal: 8,
vertical:
i == 0 && (extraRow || replyItem.replies.length > 1)
? 8
: 4,
8,
i == 0 && (extraRow || replyItem.replies.length > 1)
? 4
: 6,
),
child: Semantics(
label: