diff --git a/lib/models/dynamics/opus_detail/paragraph.dart b/lib/models/dynamics/opus_detail/paragraph.dart index 86a04b71..8ea2e1f6 100644 --- a/lib/models/dynamics/opus_detail/paragraph.dart +++ b/lib/models/dynamics/opus_detail/paragraph.dart @@ -7,8 +7,16 @@ class Paragraph { ParagraphText? text; Pic? pic; Line? line; + LinkCard? linkCard; - Paragraph({this.align, this.paraType, this.text, this.pic, this.line}); + Paragraph({ + this.align, + this.paraType, + this.text, + this.pic, + this.line, + this.linkCard, + }); factory Paragraph.fromJson(Map json) => Paragraph( align: json['align'] as int?, @@ -20,6 +28,9 @@ class Paragraph { ? null : Pic.fromJson(json['pic'] as Map), line: json['line'] == null ? null : Line.fromJson(json['line']), + linkCard: json['link_card'] == null + ? null + : LinkCard.fromJson(json['link_card']), ); Map toJson() => { @@ -30,6 +41,56 @@ class Paragraph { }; } +class Ugc { + String? cover; + String? descSecond; + String? duration; + String? headText; + String? idStr; + String? jumpUrl; + bool? multiLine; + String? title; + + Ugc.fromJson(Map json) { + cover = json['cover']; + descSecond = json['desc_second']; + duration = json['duration']; + headText = json['head_text']; + idStr = json['id_str']; + jumpUrl = json['jump_url']; + multiLine = json['multi_line']; + title = json['title']; + } +} + +class Card { + Card({ + this.oid, + this.type, + this.ugc, + }); + String? oid; + String? type; + Ugc? ugc; + + Card.fromJson(Map json) { + oid = json['oid']; + type = json['type']; + ugc = json['ugc'] == null ? null : Ugc.fromJson(json['ugc']); + } +} + +class LinkCard { + LinkCard({ + this.card, + }); + Card? card; + + LinkCard.fromJson(Map json) { + card = json['card'] == null ? null : Card.fromJson(json['card']); + } +} + class Line { Line({ this.pic, diff --git a/lib/pages/article/widgets/opus_content.dart b/lib/pages/article/widgets/opus_content.dart index 8635161e..908256df 100644 --- a/lib/pages/article/widgets/opus_content.dart +++ b/lib/pages/article/widgets/opus_content.dart @@ -174,11 +174,69 @@ Widget opusContent({ if (element.paraType == 3) { return CachedNetworkImage( - imageUrl: Utils.thumbnailImgUrl(element.line!.pic!.url!), + width: maxWidth, + fit: BoxFit.contain, height: element.line?.pic?.height, + imageUrl: Utils.thumbnailImgUrl(element.line!.pic!.url!), ); } + if (element.paraType == 6) { + if (element.linkCard?.card?.ugc != null) { + return Card( + margin: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: + const BorderRadius.all(Radius.circular(8)), + ), + color: Theme.of(context).colorScheme.onInverseSurface, + child: InkWell( + onTap: () { + try { + PiliScheme.videoPush( + int.parse(element.linkCard!.card!.oid!), + null, + ); + } catch (_) {} + }, + borderRadius: + const BorderRadius.all(Radius.circular(8)), + child: Padding( + padding: const EdgeInsets.all(8), + child: Row( + children: [ + NetworkImgLayer( + radius: 6, + width: 65 * 16 / 10, + height: 65, + src: element.linkCard!.card!.ugc!.cover, + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(element.linkCard!.card!.ugc!.title!), + Text( + element.linkCard!.card!.ugc!.descSecond!, + style: TextStyle( + fontSize: 13, + color: Theme.of(context) + .colorScheme + .outline, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } + } + return const SizedBox.shrink(); }, separatorBuilder: (BuildContext context, int index) =>