From 11988a4f8e0248683b7df73443a2b968b9ce331f Mon Sep 17 00:00:00 2001 From: orz12 Date: Mon, 26 Feb 2024 09:38:11 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E8=A1=A8=E6=83=85=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/api.dart | 7 - lib/models/video/reply/emote.dart | 382 +++++++++++++----- lib/pages/emote/controller.dart | 2 +- lib/pages/emote/view.dart | 17 +- lib/pages/subscription/controller.dart | 6 +- lib/pages/subscription/view.dart | 2 +- lib/pages/subscription/widgets/item.dart | 6 +- lib/pages/subscription_detail/controller.dart | 2 +- lib/pages/subscription_detail/view.dart | 8 +- .../widget/sub_video_card.dart | 14 +- lib/pages/video/detail/reply/view.dart | 3 - .../detail/reply/widgets/reply_item.dart | 1 - lib/pages/video/detail/reply_new/view.dart | 20 +- 13 files changed, 322 insertions(+), 148 deletions(-) diff --git a/lib/http/api.dart b/lib/http/api.dart index 774bd453f..02c797a51 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -512,13 +512,6 @@ class Api { /// 我的订阅详情 static const userSubFolderDetail = '/x/space/fav/season/list'; - /// 表情 - static const emojiList = '/x/emote/user/panel/web'; - - /// 已读标记 - static const String ackSessionMsg = - '${HttpString.tUrl}/session_svr/v1/session_svr/update_ack'; - /// 发送私信 static const String sendMsg = '${HttpString.tUrl}/web_im/v1/web_im/send_msg'; } diff --git a/lib/models/video/reply/emote.dart b/lib/models/video/reply/emote.dart index b40718266..cb0c3c613 100644 --- a/lib/models/video/reply/emote.dart +++ b/lib/models/video/reply/emote.dart @@ -1,120 +1,300 @@ class EmoteModelData { - final List? packages; + Setting? setting; + List? packages; - EmoteModelData({ - required this.packages, - }); + EmoteModelData({this.setting, this.packages}); - factory EmoteModelData.fromJson(Map jsonRes) { - final List? packages = - jsonRes['packages'] is List ? [] : null; + EmoteModelData.fromJson(Map json) { + setting = + json['setting'] != null ? Setting.fromJson(json['setting']) : null; + if (json['packages'] != null) { + packages = []; + json['packages'].forEach((v) { + packages!.add(Packages.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (setting != null) { + data['setting'] = setting!.toJson(); + } if (packages != null) { - for (final dynamic item in jsonRes['packages']!) { - if (item != null) { - try { - packages.add(PackageItem.fromJson(item)); - } catch (_) {} - } - } + data['packages'] = packages!.map((v) => v.toJson()).toList(); } - return EmoteModelData( - packages: packages, - ); + return data; + } +} + +class Setting { + int? recentLimit; + int? attr; + int? focusPkgId; + String? schema; + + Setting({this.recentLimit, this.attr, this.focusPkgId, this.schema}); + + Setting.fromJson(Map json) { + recentLimit = json['recent_limit']; + attr = json['attr']; + focusPkgId = json['focus_pkg_id']; + schema = json['schema']; + } + + Map toJson() { + final Map data = {}; + data['recent_limit'] = recentLimit; + data['attr'] = attr; + data['focus_pkg_id'] = focusPkgId; + data['schema'] = schema; + return data; } } -class PackageItem { - final int? id; - final String? text; - final String? url; - final int? mtime; - final int? type; - final int? attr; - final Meta? meta; - final List? emote; - - PackageItem({ - required this.id, - required this.text, - required this.url, - required this.mtime, - required this.type, - required this.attr, - required this.meta, - required this.emote, - }); - - factory PackageItem.fromJson(Map jsonRes) { - final List? emote = jsonRes['emote'] is List ? [] : null; +class Packages { + int? id; + String? text; + String? url; + int? mtime; + int? type; + int? attr; + PackagesMeta? meta; + List? emote; + PackagesFlags? flags; + Label? label; + String? packageSubTitle; + int? refMid; + + Packages( + {this.id, + this.text, + this.url, + this.mtime, + this.type, + this.attr, + this.meta, + this.emote, + this.flags, + this.label, + this.packageSubTitle, + this.refMid}); + + Packages.fromJson(Map json) { + id = json['id']; + text = json['text']; + url = json['url']; + mtime = json['mtime']; + type = json['type']; + attr = json['attr']; + meta = json['meta'] != null ? PackagesMeta.fromJson(json['meta']) : null; + if (json['emote'] != null) { + emote = []; + json['emote'].forEach((v) { + emote!.add(Emote.fromJson(v)); + }); + } + flags = + json['flags'] != null ? PackagesFlags.fromJson(json['flags']) : null; + label = json['label'] != null ? Label.fromJson(json['label']) : null; + packageSubTitle = json['package_sub_title']; + refMid = json['ref_mid']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['text'] = text; + data['url'] = url; + data['mtime'] = mtime; + data['type'] = type; + data['attr'] = attr; + if (meta != null) { + data['meta'] = meta!.toJson(); + } if (emote != null) { - for (final dynamic item in jsonRes['emote']!) { - if (item != null) { - try { - emote.add(Emote.fromJson(item)); - } catch (_) {} - } - } + data['emote'] = emote!.map((v) => v.toJson()).toList(); + } + if (flags != null) { + data['flags'] = flags!.toJson(); } - return PackageItem( - id: jsonRes['id'], - text: jsonRes['text'], - url: jsonRes['url'], - mtime: jsonRes['mtime'], - type: jsonRes['type'], - attr: jsonRes['attr'], - meta: Meta.fromJson(jsonRes['meta']), - emote: emote, - ); + if (label != null) { + data['label'] = label!.toJson(); + } + data['package_sub_title'] = packageSubTitle; + data['ref_mid'] = refMid; + return data; + } +} + +class Label { + String? fontColor; + String? backgroundColor; + String? text; + + Label({this.fontColor, this.backgroundColor, this.text}); + + Label.fromJson(Map json) { + fontColor = json['font_color']; + backgroundColor = json['background_color']; + text = json['text']; + } + + Map toJson() { + final Map data = {}; + data['font_color'] = fontColor; + data['background_color'] = backgroundColor; + data['text'] = text; + return data; } } -class Meta { - final int? size; - final List? suggest; +class PackagesMeta { + int? size; + int? itemId; + String? itemUrl; + int? assetId; + + PackagesMeta({this.size, this.itemId, this.itemUrl, this.assetId}); - Meta({ - required this.size, - required this.suggest, - }); + PackagesMeta.fromJson(Map json) { + size = json['size']; + itemId = json['item_id']; + itemUrl = json['item_url']; + assetId = json['asset_id']; + } - factory Meta.fromJson(Map jsonRes) => Meta( - size: jsonRes['size'], - suggest: jsonRes['suggest'] is List ? [] : null, - ); + Map toJson() { + final Map data = {}; + data['size'] = size; + data['item_id'] = itemId; + data['item_url'] = itemUrl; + data['asset_id'] = assetId; + return data; + } } class Emote { - final int? id; - final int? packageId; - final String? text; - final String? url; - final int? mtime; - final int? type; - final int? attr; - final Meta? meta; - final dynamic activity; - - Emote({ - required this.id, - required this.packageId, - required this.text, - required this.url, - required this.mtime, - required this.type, - required this.attr, - required this.meta, - required this.activity, - }); - - factory Emote.fromJson(Map jsonRes) => Emote( - id: jsonRes['id'], - packageId: jsonRes['package_id'], - text: jsonRes['text'], - url: jsonRes['url'], - mtime: jsonRes['mtime'], - type: jsonRes['type'], - attr: jsonRes['attr'], - meta: Meta.fromJson(jsonRes['meta']), - activity: jsonRes['activity'], - ); + int? id; + int? packageId; + String? text; + String? url; + int? mtime; + int? type; + int? attr; + EmoteMeta? meta; + EmoteFlags? flags; + dynamic activity; + String? gifUrl; + + Emote( + {this.id, + this.packageId, + this.text, + this.url, + this.mtime, + this.type, + this.attr, + this.meta, + this.flags, + this.activity, + this.gifUrl}); + + Emote.fromJson(Map json) { + id = json['id']; + packageId = json['package_id']; + text = json['text']; + url = json['url']; + mtime = json['mtime']; + type = json['type']; + attr = json['attr']; + meta = json['meta'] != null ? EmoteMeta.fromJson(json['meta']) : null; + flags = json['flags'] != null ? EmoteFlags.fromJson(json['flags']) : null; + activity = json['activity']; + gifUrl = json['gif_url']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['package_id'] = packageId; + data['text'] = text; + data['url'] = url; + data['mtime'] = mtime; + data['type'] = type; + data['attr'] = attr; + if (meta != null) { + data['meta'] = meta!.toJson(); + } + if (flags != null) { + data['flags'] = flags!.toJson(); + } + data['activity'] = activity; + data['gif_url'] = gifUrl; + return data; + } +} + +class EmoteMeta { + int? size; + List? suggest; + String? alias; + String? gifUrl; + + EmoteMeta({this.size, this.suggest, this.alias, this.gifUrl}); + + EmoteMeta.fromJson(Map json) { + size = json['size']; + suggest = json['suggest'] == null + ? null + : List.from(json['suggest'].map((x) => x)); + alias = json['alias']; + gifUrl = json['gif_url']; + } + + Map toJson() { + final Map data = {}; + data['size'] = size; + data['suggest'] = suggest; + data['alias'] = alias; + data['gif_url'] = gifUrl; + return data; + } +} + +class EmoteFlags { + bool? unlocked; + bool? recentUseForbid; + + EmoteFlags({this.unlocked, this.recentUseForbid}); + EmoteFlags.fromJson(Map json) { + unlocked = json['unlocked']; + recentUseForbid = json['recent_use_forbid']; + } + + Map toJson() { + final Map data = {}; + data['unlocked'] = unlocked; + data['recent_use_forbid'] = recentUseForbid; + return data; + } +} + +class PackagesFlags { + bool? added; + bool? preview; + + PackagesFlags({this.added, this.preview}); + + PackagesFlags.fromJson(Map json) { + added = json['added']; + preview = json['preview']; + } + + Map toJson() { + final Map data = {}; + data['added'] = added; + data['preview'] = preview; + return data; + } } diff --git a/lib/pages/emote/controller.dart b/lib/pages/emote/controller.dart index c1a4c5049..6a3462420 100644 --- a/lib/pages/emote/controller.dart +++ b/lib/pages/emote/controller.dart @@ -6,7 +6,7 @@ import '../../models/video/reply/emote.dart'; class EmotePanelController extends GetxController with GetTickerProviderStateMixin { - late List emotePackage; + late List emotePackage; late TabController tabController; Future getEmote() async { diff --git a/lib/pages/emote/view.dart b/lib/pages/emote/view.dart index d30767c34..51a20728e 100644 --- a/lib/pages/emote/view.dart +++ b/lib/pages/emote/view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import '../../common/widgets/network_img_layer.dart'; import '../../models/video/reply/emote.dart'; import 'controller.dart'; @@ -35,8 +36,7 @@ class _EmotePanelState extends State if (snapshot.connectionState == ConnectionState.done) { Map data = snapshot.data as Map; if (data['status']) { - List emotePackage = - _emotePanelController.emotePackage; + List emotePackage = _emotePanelController.emotePackage; return Column( children: [ @@ -52,9 +52,11 @@ class _EmotePanelState extends State child: GridView.builder( gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: size == 1 ? 40 : 60, + maxCrossAxisExtent: + type == 4 ? 100 : (size == 1 ? 40 : 60), crossAxisSpacing: 8, mainAxisSpacing: 8, + mainAxisExtent: size == 1 ? 40 : 60, ), itemCount: e.emote!.length, itemBuilder: (context, index) { @@ -99,7 +101,14 @@ class _EmotePanelState extends State dividerColor: Colors.transparent, isScrollable: true, tabs: _emotePanelController.emotePackage - .map((e) => Tab(text: e.text)) + .map( + (e) => NetworkImgLayer( + width: 36, + height: 36, + type: 'emote', + src: e.url, + ), + ) .toList(), ), SizedBox(height: MediaQuery.of(context).padding.bottom + 20), diff --git a/lib/pages/subscription/controller.dart b/lib/pages/subscription/controller.dart index bf0c593c8..ec53f5490 100644 --- a/lib/pages/subscription/controller.dart +++ b/lib/pages/subscription/controller.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; -import 'package:pilipala/http/user.dart'; -import 'package:pilipala/models/user/info.dart'; -import 'package:pilipala/utils/storage.dart'; +import 'package:PiliPalaX/http/user.dart'; +import 'package:PiliPalaX/models/user/info.dart'; +import 'package:PiliPalaX/utils/storage.dart'; import '../../models/user/sub_folder.dart'; diff --git a/lib/pages/subscription/view.dart b/lib/pages/subscription/view.dart index 1eee4a4f7..44fa0db79 100644 --- a/lib/pages/subscription/view.dart +++ b/lib/pages/subscription/view.dart @@ -1,7 +1,7 @@ import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:pilipala/common/widgets/http_error.dart'; +import 'package:PiliPalaX/common/widgets/http_error.dart'; import 'controller.dart'; import 'widgets/item.dart'; diff --git a/lib/pages/subscription/widgets/item.dart b/lib/pages/subscription/widgets/item.dart index fd08ffa5b..206d791ac 100644 --- a/lib/pages/subscription/widgets/item.dart +++ b/lib/pages/subscription/widgets/item.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:pilipala/common/constants.dart'; -import 'package:pilipala/common/widgets/network_img_layer.dart'; -import 'package:pilipala/utils/utils.dart'; +import 'package:PiliPalaX/common/constants.dart'; +import 'package:PiliPalaX/common/widgets/network_img_layer.dart'; +import 'package:PiliPalaX/utils/utils.dart'; import '../../../models/user/sub_folder.dart'; diff --git a/lib/pages/subscription_detail/controller.dart b/lib/pages/subscription_detail/controller.dart index 6ecb894e4..a15a4ae2e 100644 --- a/lib/pages/subscription_detail/controller.dart +++ b/lib/pages/subscription_detail/controller.dart @@ -1,5 +1,5 @@ import 'package:get/get.dart'; -import 'package:pilipala/http/user.dart'; +import 'package:PiliPalaX/http/user.dart'; import '../../models/user/sub_detail.dart'; import '../../models/user/sub_folder.dart'; diff --git a/lib/pages/subscription_detail/view.dart b/lib/pages/subscription_detail/view.dart index d56125cdb..e27415f0b 100644 --- a/lib/pages/subscription_detail/view.dart +++ b/lib/pages/subscription_detail/view.dart @@ -3,10 +3,10 @@ import 'dart:async'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'package:pilipala/common/skeleton/video_card_h.dart'; -import 'package:pilipala/common/widgets/http_error.dart'; -import 'package:pilipala/common/widgets/network_img_layer.dart'; -import 'package:pilipala/common/widgets/no_data.dart'; +import 'package:PiliPalaX/common/skeleton/video_card_h.dart'; +import 'package:PiliPalaX/common/widgets/http_error.dart'; +import 'package:PiliPalaX/common/widgets/network_img_layer.dart'; +import 'package:PiliPalaX/common/widgets/no_data.dart'; import '../../models/user/sub_folder.dart'; import '../../utils/utils.dart'; diff --git a/lib/pages/subscription_detail/widget/sub_video_card.dart b/lib/pages/subscription_detail/widget/sub_video_card.dart index 11aebc396..389a2a75c 100644 --- a/lib/pages/subscription_detail/widget/sub_video_card.dart +++ b/lib/pages/subscription_detail/widget/sub_video_card.dart @@ -1,12 +1,12 @@ import 'package:get/get.dart'; import 'package:flutter/material.dart'; -import 'package:pilipala/common/constants.dart'; -import 'package:pilipala/common/widgets/stat/danmu.dart'; -import 'package:pilipala/common/widgets/stat/view.dart'; -import 'package:pilipala/http/search.dart'; -import 'package:pilipala/models/common/search_type.dart'; -import 'package:pilipala/utils/utils.dart'; -import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:PiliPalaX/common/constants.dart'; +import 'package:PiliPalaX/common/widgets/stat/danmu.dart'; +import 'package:PiliPalaX/common/widgets/stat/view.dart'; +import 'package:PiliPalaX/http/search.dart'; +import 'package:PiliPalaX/models/common/search_type.dart'; +import 'package:PiliPalaX/utils/utils.dart'; +import 'package:PiliPalaX/common/widgets/network_img_layer.dart'; import '../../../common/widgets/badge.dart'; import '../../../models/user/sub_detail.dart'; diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 30bad39a3..61e59c825 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -1,11 +1,8 @@ -import 'dart:async'; - import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:get/get.dart'; import 'package:PiliPalaX/common/skeleton/video_reply.dart'; -import 'package:PiliPalaX/common/widgets/http_error.dart'; import 'package:PiliPalaX/models/common/reply_type.dart'; import 'package:PiliPalaX/pages/video/detail/index.dart'; import 'package:PiliPalaX/pages/video/detail/reply_new/index.dart'; diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index b8ef29114..53d8373d8 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -951,7 +951,6 @@ class MorePanel extends StatelessWidget { @override Widget build(BuildContext context) { - Color errorColor = Theme.of(context).colorScheme.error; return Container( padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), child: Column( diff --git a/lib/pages/video/detail/reply_new/view.dart b/lib/pages/video/detail/reply_new/view.dart index 9aac77b23..63235cef5 100644 --- a/lib/pages/video/detail/reply_new/view.dart +++ b/lib/pages/video/detail/reply_new/view.dart @@ -102,7 +102,7 @@ class _VideoReplyNewDialogState extends State _replyContentController.value = TextEditingValue( text: newText, selection: - TextSelection.collapsed(offset: cursorPosition + emote.text!.length), + TextSelection.collapsed(offset: cursorPosition + emote.text!.length), ); } @@ -118,7 +118,7 @@ class _VideoReplyNewDialogState extends State if (keyboardHeight == 0 && emoteHeight == 0) { setState(() { emoteHeight = keyboardHeight = - keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; + keyboardHeight == 0.0 ? viewInsets.bottom : keyboardHeight; }); } } @@ -221,15 +221,11 @@ class _VideoReplyNewDialogState extends State ], ), ), - AnimatedSize( - curve: Curves.easeInOut, - duration: const Duration(milliseconds: 300), - child: SizedBox( - width: double.infinity, - height: toolbarType == 'input' ? keyboardHeight : emoteHeight, - child: EmotePanel( - onChoose: (package, emote) => onChooseEmote(package, emote), - ), + SizedBox( + width: double.infinity, + height: toolbarType == 'input' ? keyboardHeight : emoteHeight, + child: EmotePanel( + onChoose: (package, emote) => onChooseEmote(package, emote), ), ), ], @@ -255,4 +251,4 @@ class Debouncer { callback(); }); } -} \ No newline at end of file +}