Merge branch 'main' into feature-m3Design

This commit is contained in:
guozhigq
2023-07-22 23:36:13 +08:00
9 changed files with 70 additions and 52 deletions

View File

@ -1,13 +1,15 @@
class ReplyContent { class ReplyContent {
ReplyContent( ReplyContent({
{this.message, this.message,
this.atNameToMid, // @的用户的mid null this.atNameToMid, // @的用户的mid null
this.memebers, // 被@的用户List 如果有的话 [] this.memebers, // 被@的用户List 如果有的话 []
this.emote, // 表情包 如果有的话 null this.emote, // 表情包 如果有的话 null
this.jumpUrl, // {} this.jumpUrl, // {}
this.pictures, // {} this.pictures, // {}
this.vote, this.vote,
this.richText}); this.richText,
this.isText,
});
String? message; String? message;
Map? atNameToMid; Map? atNameToMid;
@ -17,6 +19,7 @@ class ReplyContent {
List? pictures; List? pictures;
Map? vote; Map? vote;
Map? richText; Map? richText;
bool? isText;
ReplyContent.fromJson(Map<String, dynamic> json) { ReplyContent.fromJson(Map<String, dynamic> json) {
message = json['message'] message = json['message']
@ -30,5 +33,10 @@ class ReplyContent {
pictures = json['pictures'] ?? []; pictures = json['pictures'] ?? [];
vote = json['vote'] ?? {}; vote = json['vote'] ?? {};
richText = json['rich_text'] ?? {}; richText = json['rich_text'] ?? {};
isText = emote!.isEmpty &&
atNameToMid!.isEmpty &&
jumpUrl!.isEmpty &&
vote!.isEmpty &&
pictures!.isEmpty;
} }
} }

View File

@ -71,7 +71,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
} }
} }
void replyReply(replyItem, paddingTop) { void replyReply(replyItem) {
int oid = replyItem.replies!.first.oid; int oid = replyItem.replies!.first.oid;
int rpid = replyItem.rpid!; int rpid = replyItem.rpid!;
Get.to( Get.to(
@ -83,7 +83,6 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
body: VideoReplyReplyPanel( body: VideoReplyReplyPanel(
oid: oid, oid: oid,
rpid: rpid, rpid: rpid,
paddingTop: paddingTop,
source: 'dynamic', source: 'dynamic',
replyType: ReplyType.values[type], replyType: ReplyType.values[type],
), ),
@ -216,8 +215,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage> {
_dynamicDetailController!.replyList[index], _dynamicDetailController!.replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: '1', replyLevel: '1',
replyReply: (replyItem, paddingTop) => replyReply: (replyItem) =>
replyReply(replyItem, paddingTop), replyReply(replyItem),
replyType: ReplyType.album, replyType: ReplyType.album,
); );
} }

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/pages/dynamics/index.dart'; import 'package:pilipala/pages/dynamics/index.dart';
import 'package:pilipala/pages/home/index.dart'; import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/utils/storage.dart';
import './controller.dart'; import './controller.dart';
class MainApp extends StatefulWidget { class MainApp extends StatefulWidget {
@ -87,6 +89,11 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Box localCache = GStrorage.localCache;
double sheetHeight = MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
MediaQuery.of(context).size.width * 9 / 16;
localCache.put('sheetHeight', sheetHeight);
return Scaffold( return Scaffold(
body: FadeTransition( body: FadeTransition(
opacity: _fadeAnimation!, opacity: _fadeAnimation!,

View File

@ -77,7 +77,7 @@ class VideoDetailController extends GetxController
queryVideoUrl(); queryVideoUrl();
} }
showReplyReplyPanel(paddingTop) { showReplyReplyPanel() {
PersistentBottomSheetController<void>? ctr = PersistentBottomSheetController<void>? ctr =
scaffoldKey.currentState?.showBottomSheet<void>((BuildContext context) { scaffoldKey.currentState?.showBottomSheet<void>((BuildContext context) {
return VideoReplyReplyPanel( return VideoReplyReplyPanel(
@ -87,7 +87,6 @@ class VideoDetailController extends GetxController
fRpid = 0, fRpid = 0,
}, },
firstFloor: firstFloor, firstFloor: firstFloor,
paddingTop: paddingTop,
replyType: ReplyType.video, replyType: ReplyType.video,
source: 'videoDetail', source: 'videoDetail',
); );

View File

@ -5,6 +5,7 @@ import 'package:flutter/rendering.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_reply.dart'; import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart'; import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart'; import 'package:pilipala/pages/video/detail/replyNew/index.dart';
@ -116,13 +117,13 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
} }
// 展示二级回复 // 展示二级回复
void replyReply(replyItem, paddingTop) { void replyReply(replyItem) {
VideoDetailController videoDetailCtr = VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']); Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
videoDetailCtr.oid = replyItem.replies!.first.oid; videoDetailCtr.oid = replyItem.replies!.first.oid;
videoDetailCtr.fRpid = replyItem.rpid!; videoDetailCtr.fRpid = replyItem.rpid!;
videoDetailCtr.firstFloor = replyItem; videoDetailCtr.firstFloor = replyItem;
videoDetailCtr.showReplyReplyPanel(paddingTop); videoDetailCtr.showReplyReplyPanel();
} }
@override @override
@ -134,7 +135,6 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double paddingTop = MediaQuery.of(context).padding.top;
return RefreshIndicator( return RefreshIndicator(
onRefresh: () async { onRefresh: () async {
setState(() {}); setState(() {});
@ -180,8 +180,9 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
_videoReplyController.replyList[index], _videoReplyController.replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: replyLevel, replyLevel: replyLevel,
replyReply: (replyItem, paddingTop) => replyReply: (replyItem) =>
replyReply(replyItem, paddingTop), replyReply(replyItem),
replyType: ReplyType.video,
); );
} }
}, },
@ -234,13 +235,13 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
oid: IdUtils.bv2av(Get.parameters['bvid']!), oid: IdUtils.bv2av(Get.parameters['bvid']!),
root: 0, root: 0,
parent: 0, parent: 0,
paddingTop: paddingTop, replyType: ReplyType.video,
); );
}, },
).then( ).then(
(value) => { (value) => {
// 完成评论,数据添加 // 完成评论,数据添加
if (value != null && value['data']) if (value != null && value['data'] != null)
{_videoReplyController.replyList.add(value['data'])} {_videoReplyController.replyList.add(value['data'])}
}, },
); );

View File

@ -197,11 +197,14 @@ class ReplyItem extends StatelessWidget {
selectionControls: MaterialTextSelectionControls(), selectionControls: MaterialTextSelectionControls(),
child: Text.rich( child: Text.rich(
style: const TextStyle(height: 1.65), style: const TextStyle(height: 1.65),
maxLines:
replyItem!.content!.isText! && replyLevel == '1' ? 6 : 999,
overflow: TextOverflow.ellipsis,
TextSpan( TextSpan(
children: [ children: [
if (replyItem!.isTop!) if (replyItem!.isTop!)
WidgetSpan(child: UpTag(tagText: 'TOP')), WidgetSpan(child: UpTag(tagText: 'TOP')),
buildContent(context, replyItem!.content!), buildContent(context, replyItem!, replyReply),
], ],
), ),
), ),
@ -229,7 +232,6 @@ class ReplyItem extends StatelessWidget {
// 感谢、回复、复制 // 感谢、回复、复制
Widget bottonAction(context, replyControl) { Widget bottonAction(context, replyControl) {
var color = Theme.of(context).colorScheme.outline; var color = Theme.of(context).colorScheme.outline;
double paddingTop = MediaQuery.of(context).padding.top;
return Row( return Row(
children: [ children: [
const SizedBox(width: 48), const SizedBox(width: 48),
@ -283,7 +285,6 @@ class ReplyItem extends StatelessWidget {
oid: replyItem!.oid, oid: replyItem!.oid,
root: replyItem!.rpid, root: replyItem!.rpid,
parent: replyItem!.rpid, parent: replyItem!.rpid,
paddingTop: paddingTop,
replyType: replyType, replyType: replyType,
); );
}, },
@ -347,7 +348,6 @@ class ReplyItemRow extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isShow = replyControl!.isShow!; bool isShow = replyControl!.isShow!;
int extraRow = replyControl != null && isShow ? 1 : 0; int extraRow = replyControl != null && isShow ? 1 : 0;
double paddingTop = MediaQuery.of(context).padding.top;
return Container( return Container(
margin: const EdgeInsets.only(left: 42, right: 4, top: 0), margin: const EdgeInsets.only(left: 42, right: 4, top: 0),
child: Material( child: Material(
@ -360,7 +360,7 @@ class ReplyItemRow extends StatelessWidget {
children: [ children: [
for (var i = 0; i < replies!.length; i++) ...[ for (var i = 0; i < replies!.length; i++) ...[
InkWell( InkWell(
onTap: () => replyReply!(replyItem, paddingTop), onTap: () => replyReply!(replyItem),
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
@ -401,7 +401,7 @@ class ReplyItemRow extends StatelessWidget {
WidgetSpan( WidgetSpan(
child: UpTag(), child: UpTag(),
), ),
buildContent(context, replies![i].content), buildContent(context, replies![i], replyReply),
], ],
), ),
), ),
@ -410,7 +410,7 @@ class ReplyItemRow extends StatelessWidget {
], ],
if (extraRow == 1) if (extraRow == 1)
InkWell( InkWell(
onTap: () => replyReply!(replyItem, paddingTop), onTap: () => replyReply!(replyItem),
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8), padding: const EdgeInsets.fromLTRB(8, 5, 8, 8),
@ -441,7 +441,8 @@ class ReplyItemRow extends StatelessWidget {
} }
} }
InlineSpan buildContent(BuildContext context, content) { InlineSpan buildContent(BuildContext context, replyItem, replyReply) {
var content = replyItem.content;
if (content.emote.isEmpty && if (content.emote.isEmpty &&
content.atNameToMid.isEmpty && content.atNameToMid.isEmpty &&
content.jumpUrl.isEmpty && content.jumpUrl.isEmpty &&
@ -449,7 +450,7 @@ InlineSpan buildContent(BuildContext context, content) {
content.pictures.isEmpty) { content.pictures.isEmpty) {
return TextSpan( return TextSpan(
text: content.message, text: content.message,
// recognizer: TapGestureRecognizer()..onTap = () => {print('点击')}, recognizer: TapGestureRecognizer()..onTap = () => replyReply(replyItem),
); );
} }
List<InlineSpan> spanChilds = []; List<InlineSpan> spanChilds = [];

View File

@ -3,16 +3,17 @@ import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart'; import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/utils/storage.dart';
class VideoReplyNewDialog extends StatefulWidget { class VideoReplyNewDialog extends StatefulWidget {
int? oid; int? oid;
int? root; int? root;
String? replyLevel; String? replyLevel;
int? parent; int? parent;
double? paddingTop;
ReplyType? replyType; ReplyType? replyType;
VideoReplyNewDialog({ VideoReplyNewDialog({
@ -20,7 +21,6 @@ class VideoReplyNewDialog extends StatefulWidget {
this.root, this.root,
this.replyLevel, this.replyLevel,
this.parent, this.parent,
this.paddingTop,
this.replyType, this.replyType,
}); });
@ -38,6 +38,8 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
bool ableClean = false; bool ableClean = false;
bool autoFocus = false; bool autoFocus = false;
Timer? timer; Timer? timer;
Box localCache = GStrorage.localCache;
late double sheetHeight;
@override @override
void initState() { void initState() {
@ -50,6 +52,8 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
// 自动聚焦 // 自动聚焦
_autoFocus(); _autoFocus();
sheetHeight = localCache.get('sheetHeight');
} }
_autoFocus() async { _autoFocus() async {
@ -66,7 +70,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
Future submitReplyAdd() async { Future submitReplyAdd() async {
String message = _replyContentController.text; String message = _replyContentController.text;
var result = await VideoHttp.replyAdd( var result = await VideoHttp.replyAdd(
type: widget.replyType!, type: widget.replyType ?? ReplyType.video,
oid: widget.oid!, oid: widget.oid!,
root: widget.root!, root: widget.root!,
parent: widget.parent!, parent: widget.parent!,
@ -101,11 +105,8 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print('1111111');
return Container( return Container(
height: MediaQuery.of(context).size.height - height: sheetHeight,
MediaQuery.of(context).size.width * 9 / 16 -
widget.paddingTop!,
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(

View File

@ -1,10 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/skeleton/video_reply.dart'; import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart'; import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart'; import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
import 'package:pilipala/utils/storage.dart';
import 'controller.dart'; import 'controller.dart';
@ -13,7 +15,6 @@ class VideoReplyReplyPanel extends StatefulWidget {
int? rpid; int? rpid;
Function? closePanel; Function? closePanel;
ReplyItemModel? firstFloor; ReplyItemModel? firstFloor;
double? paddingTop;
String? source; String? source;
ReplyType? replyType; ReplyType? replyType;
@ -22,7 +23,6 @@ class VideoReplyReplyPanel extends StatefulWidget {
this.rpid, this.rpid,
this.closePanel, this.closePanel,
this.firstFloor, this.firstFloor,
this.paddingTop,
this.source, this.source,
this.replyType, this.replyType,
super.key, super.key,
@ -35,6 +35,8 @@ class VideoReplyReplyPanel extends StatefulWidget {
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> { class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
late VideoReplyReplyController _videoReplyReplyController; late VideoReplyReplyController _videoReplyReplyController;
late AnimationController replyAnimationCtl; late AnimationController replyAnimationCtl;
Box localCache = GStrorage.localCache;
late double sheetHeight;
@override @override
void initState() { void initState() {
@ -57,6 +59,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
} }
}, },
); );
sheetHeight = localCache.get('sheetHeight');
} }
@override @override
@ -68,11 +72,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
height: widget.source == 'videoDetail' height: widget.source == 'videoDetail' ? sheetHeight : null,
? MediaQuery.of(context).size.height -
MediaQuery.of(context).size.width * 9 / 16 -
widget.paddingTop!
: null,
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: Column( child: Column(
children: [ children: [
@ -117,12 +117,14 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
const SliverToBoxAdapter(child: SizedBox(height: 10)), const SliverToBoxAdapter(child: SizedBox(height: 10)),
SliverToBoxAdapter( SliverToBoxAdapter(
child: ReplyItem( child: ReplyItem(
replyItem: widget.firstFloor, replyItem: widget.firstFloor,
replyLevel: '1', replyLevel: '2',
showReplyRow: false, showReplyRow: false,
addReply: (replyItem) { addReply: (replyItem) {
_videoReplyReplyController.replyList.add(replyItem); _videoReplyReplyController.replyList.add(replyItem);
}), },
replyType: ReplyType.video,
),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: Divider( child: Divider(

View File

@ -10,7 +10,7 @@ import 'dart:convert';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
class WbiSign { class WbiSign {
static Box localCache = GStrorage.user; static Box localCache = GStrorage.localCache;
List mixinKeyEncTab = [ List mixinKeyEncTab = [
46, 46,
47, 47,