Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

feat: redesign bangumi info page (#844)

ErBW_sb7a3dc661dff
diff --git a/lib/bean/appbar/sys_app_bar.dart b/lib/bean/appbar/sys_app_bar.dart
index 16f59cad..43b1f87e 100644
--- a/lib/bean/appbar/sys_app_bar.dart
+++ b/lib/bean/appbar/sys_app_bar.dart
@@ -58,34 +58,55 @@ class SysAppBar extends StatelessWidget implements PreferredSizeWidget {
}
acs.add(const SizedBox(width: 8));
}
- return EmbeddedNativeControlArea(
- requireOffset: needTopOffset,
- child: GestureDetector(
- // behavior: HitTestBehavior.translucent,
- onPanStart: (_) =>
- (Utils.isDesktop()) ? windowManager.startDragging() : null,
- child: AppBar(
- toolbarHeight: preferredSize.height,
- scrolledUnderElevation: 0.0,
- title: title,
- centerTitle: Platform.isIOS ? true : false,
- actions: acs,
- leading: leading,
- leadingWidth: leadingWidth,
- backgroundColor: backgroundColor,
- elevation: elevation,
- shape: shape,
- bottom: bottom,
- forceMaterialTransparency: Platform.isMacOS ? true : false,
- systemOverlayStyle: SystemUiOverlayStyle(
- statusBarColor: Colors.transparent,
- statusBarIconBrightness:
- Theme.of(context).brightness == Brightness.light
- ? Brightness.dark
- : Brightness.light,
- systemNavigationBarColor: Colors.transparent,
- systemNavigationBarDividerColor: Colors.transparent,
- ),
+ return GestureDetector(
+ onPanStart: (_) =>
+ (Utils.isDesktop()) ? windowManager.startDragging() : null,
+ child: AppBar(
+ toolbarHeight: preferredSize.height,
+ scrolledUnderElevation: 0.0,
+ title: title != null
+ ? EmbeddedNativeControlArea(
+ requireOffset: needTopOffset,
+ child: title!,
+ )
+ : null,
+ centerTitle: Platform.isIOS ? true : false,
+ actions: acs.map((e) {
+ return EmbeddedNativeControlArea(
+ requireOffset: needTopOffset,
+ child: e,
+ );
+ }).toList(),
+ leading: leading != null
+ ? EmbeddedNativeControlArea(
+ requireOffset: needTopOffset,
+ child: leading!,
+ )
+ : Navigator.canPop(context)
+ ? EmbeddedNativeControlArea(
+ requireOffset: needTopOffset,
+ child: IconButton(
+ onPressed: () {
+ Navigator.maybePop(context);
+ },
+ icon: Icon(Icons.arrow_back),
+ ),
+ )
+ : null,
+ leadingWidth: leadingWidth,
+ backgroundColor: backgroundColor,
+ elevation: elevation,
+ shape: shape,
+ bottom: bottom,
+ automaticallyImplyLeading: false,
+ systemOverlayStyle: SystemUiOverlayStyle(
+ statusBarColor: Colors.transparent,
+ statusBarIconBrightness:
+ Theme.of(context).brightness == Brightness.light
+ ? Brightness.dark
+ : Brightness.light,
+ systemNavigationBarColor: Colors.transparent,
+ systemNavigationBarDividerColor: Colors.transparent,
),
),
);
diff --git a/lib/bean/card/bangumi_info_card.dart b/lib/bean/card/bangumi_info_card.dart
index bf5fbd0b..e1cba67b 100644
--- a/lib/bean/card/bangumi_info_card.dart
+++ b/lib/bean/card/bangumi_info_card.dart
@@ -1,198 +1,271 @@
import 'package:flutter/material.dart';
+import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:kazumi/bean/widget/collect_button.dart';
import 'package:kazumi/utils/constants.dart';
-import 'package:kazumi/utils/utils.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/bean/card/network_img_layer.dart';
+import 'package:fl_chart/fl_chart.dart';
+import 'package:skeletonizer/skeletonizer.dart';
// 视频卡片 - 水平布局
class BangumiInfoCardV extends StatefulWidget {
- const BangumiInfoCardV({super.key, required this.bangumiItem});
+ const BangumiInfoCardV({
+ super.key,
+ required this.bangumiItem,
+ required this.isLoading,
+ });
final BangumiItem bangumiItem;
+ final bool isLoading;
@override
State<BangumiInfoCardV> createState() => _BangumiInfoCardVState();
}
class _BangumiInfoCardVState extends State<BangumiInfoCardV> {
- @override
- Widget build(BuildContext context) {
- TextStyle style =
- TextStyle(fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize);
- return SizedBox(
- height: Utils.isCompact() ? 240 : 300,
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- StyleString.safeSpace, 7, StyleString.safeSpace, 7),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ClipRRect(
- borderRadius: const BorderRadius.only(
- topLeft: StyleString.imgRadius,
- topRight: StyleString.imgRadius,
- bottomLeft: StyleString.imgRadius,
- bottomRight: StyleString.imgRadius,
- ),
- child: AspectRatio(
- aspectRatio: 0.65,
- child: LayoutBuilder(builder: (context, boxConstraints) {
- final double maxWidth = boxConstraints.maxWidth;
- final double maxHeight = boxConstraints.maxHeight;
- return Hero(
- transitionOnUserGestures: true,
- tag: widget.bangumiItem.id,
- child: Stack(
- children: [
- NetworkImgLayer(
- src: widget.bangumiItem.images['large'] ?? '',
- width: maxWidth,
- height: maxHeight,
- fadeInDuration: const Duration(milliseconds: 0),
- fadeOutDuration: const Duration(milliseconds: 0),
- ),
- Positioned(
- right: 5,
- bottom: 5,
- child: Container(
- width: 40,
- height: 40,
- decoration: BoxDecoration(
- color: Theme.of(context)
- .colorScheme
- .secondaryContainer,
- shape: BoxShape.circle,
- ),
- child: CollectButton(
- bangumiItem: widget.bangumiItem,
- color: Theme.of(context)
- .colorScheme
- .onSecondaryContainer,
- ),
- ),
- ),
- ],
+ int touchedIndex = -1;
+
+ Widget get voteBarChart {
+ return Flexible(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ ' 评分透视:',
+ ),
+ SizedBox(height: 16),
+ AspectRatio(
+ aspectRatio: 2,
+ child: BarChart(
+ duration: Duration(milliseconds: 80),
+ BarChartData(
+ // alignment: BarChartAlignment.spaceEvenly,
+ borderData: FlBorderData(show: false),
+ gridData: FlGridData(show: false),
+ barTouchData: BarTouchData(
+ touchCallback: (FlTouchEvent event, barTouchResponse) {
+ setState(() {
+ if (!event.isInterestedForInteractions ||
+ barTouchResponse == null ||
+ barTouchResponse.spot == null) {
+ touchedIndex = -1;
+ return;
+ }
+ touchedIndex =
+ barTouchResponse.spot!.touchedBarGroupIndex;
+ });
+ },
+ touchTooltipData: BarTouchTooltipData(
+ getTooltipColor: (_) =>
+ Theme.of(context).colorScheme.inverseSurface,
+ getTooltipItem: (group, groupIndex, rod, rodIndex) {
+ var percentage =
+ widget.bangumiItem.votesCount[groupIndex] /
+ widget.bangumiItem.votes *
+ 100;
+ return BarTooltipItem(
+ '${percentage.toStringAsFixed(2)}% (${widget.bangumiItem.votesCount[groupIndex]}人)',
+ TextStyle(
+ color:
+ Theme.of(context).colorScheme.onInverseSurface),
+ );
+ },
+ ),
+ ),
+ barGroups: List<BarChartGroupData>.generate(
+ 10,
+ (i) => BarChartGroupData(
+ x: i + 1,
+ barRods: [
+ BarChartRodData(
+ toY: widget.bangumiItem.votesCount[i].toDouble(),
+ color: touchedIndex == i
+ ? Theme.of(context).colorScheme.primary
+ : Theme.of(context).disabledColor,
+ width: 20,
+ borderRadius:
+ BorderRadius.vertical(top: Radius.circular(5)),
+ )
+ ],
+ // showingTooltipIndicators: [0],
+ ),
+ ),
+ titlesData: FlTitlesData(
+ bottomTitles: AxisTitles(
+ sideTitles: SideTitles(
+ showTitles: true,
+ reservedSize: 30,
+ getTitlesWidget: (value, meta) => SideTitleWidget(
+ meta: meta,
+ space: 10,
+ child: Text(value.toInt().toString()),
+ ),
),
- );
- }),
+ ),
+ topTitles: const AxisTitles(),
+ leftTitles: const AxisTitles(),
+ rightTitles: const AxisTitles(),
+ ),
),
),
- const SizedBox(width: 10),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- RichText(
- maxLines: 4,
- overflow: TextOverflow.ellipsis,
- text: TextSpan(
- style: TextStyle(
- color: Theme.of(context).colorScheme.onSurface),
- children: [
- TextSpan(
- text: widget.bangumiItem.nameCn == ''
- ? widget.bangumiItem.name
- : (widget.bangumiItem.nameCn),
- style: TextStyle(
- fontSize: MediaQuery.textScalerOf(context).scale(
- Theme.of(context)
- .textTheme
- .titleLarge!
- .fontSize!),
- fontWeight: FontWeight.bold,
+ ),
+ ],
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ height: 300,
+ constraints: BoxConstraints(maxWidth: 950),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ widget.bangumiItem.nameCn == ''
+ ? widget.bangumiItem.name
+ : (widget.bangumiItem.nameCn),
+ maxLines: 4,
+ overflow: TextOverflow.ellipsis,
+ style: Theme.of(context).textTheme.headlineSmall,
+ ),
+ SizedBox(height: 16),
+ Expanded(
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Flexible(
+ child: ClipRRect(
+ borderRadius: const BorderRadius.only(
+ topLeft: StyleString.imgRadius,
+ topRight: StyleString.imgRadius,
+ bottomLeft: StyleString.imgRadius,
+ bottomRight: StyleString.imgRadius,
+ ),
+ child: AspectRatio(
+ aspectRatio: 0.65,
+ child: LayoutBuilder(builder: (context, boxConstraints) {
+ final double maxWidth = boxConstraints.maxWidth;
+ final double maxHeight = boxConstraints.maxHeight;
+ return Hero(
+ transitionOnUserGestures: true,
+ tag: widget.bangumiItem.id,
+ child: Stack(
+ children: [
+ NetworkImgLayer(
+ src: widget.bangumiItem.images['large'] ?? '',
+ width: maxWidth,
+ height: maxHeight,
+ fadeInDuration: const Duration(milliseconds: 0),
+ fadeOutDuration:
+ const Duration(milliseconds: 0),
+ ),
+ ],
),
- ),
- ],
+ );
+ }),
),
),
- Utils.isCompact() ? Container() : const SizedBox(height: 10),
- Expanded(
- child: Row(
+ ),
+ SizedBox(width: 16),
+ Flexible(
+ child: Skeletonizer(
+ enabled: widget.isLoading,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- FilledButton.tonal(
- onPressed: () {},
- style: OutlinedButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
- ),
- side: const BorderSide(
- // width: 2,
- ),
- backgroundColor: Colors.transparent,
+ Text(
+ '放送开始:',
+ ),
+ Text(
+ widget.bangumiItem.airDate == ''
+ ? '2000-11-11' // Skeleton Loader 占位符
+ : widget.bangumiItem.airDate,
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color: Theme.of(context).colorScheme.primary,
),
- child: Text('#${widget.bangumiItem.rank}',
- style: style),
),
- Utils.isCompact()
- ? Container()
- : const SizedBox(height: 7),
- FilledButton.tonal(
- onPressed: () {},
- style: OutlinedButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
+ SizedBox(height: 8),
+ Text(
+ '${widget.bangumiItem.votes} 人评分:',
+ ),
+ if (widget.isLoading)
+ // Skeleton Loader 占位符
+ Text(
+ '10.0 ********',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color: Theme.of(context).colorScheme.primary,
),
- side: const BorderSide(
- // width: 2,
- ),
- backgroundColor: Colors.transparent,
),
- child: Text(
- widget.bangumiItem.ratingScore.toString(),
- style: style),
- ),
- Utils.isCompact()
- ? Container()
- : const SizedBox(height: 7),
- Utils.isCompact()
- ? Container()
- : FilledButton.tonal(
- onPressed: () {},
- style: OutlinedButton.styleFrom(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(16),
- ),
- side: const BorderSide(
- // width: 2,
- ),
- backgroundColor: Colors.transparent,
+ if (!widget.isLoading)
+ Row(
+ children: [
+ Text(
+ '${widget.bangumiItem.ratingScore}',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color:
+ Theme.of(context).colorScheme.primary,
),
- child: Text(
- widget.bangumiItem.type == 2
- ? '番剧'
- : '其他',
- style: style),
),
- ],
- ),
- Utils.isCompact()
- ? Container()
- : const SizedBox(width: 10),
- // why there will overflow in the bottom?
- Utils.isCompact()
- ? Container()
- : Expanded(
- child: SingleChildScrollView(
- child: Text(
- widget.bangumiItem.summary,
- style: style,
- softWrap: true,
+ const SizedBox(width: 8),
+ RatingBarIndicator(
+ itemCount: 5,
+ rating: widget.bangumiItem.ratingScore
+ .toDouble() /
+ 2,
+ itemBuilder: (context, index) => Icon(
+ Icons.star_rounded,
+ color:
+ Theme.of(context).colorScheme.primary,
+ ),
+ itemSize: 20.0,
),
- ),
+ ],
),
+ SizedBox(height: 8),
+ Text(
+ 'Bangumi Ranked:',
+ ),
+ Text(
+ '#${widget.bangumiItem.rank}',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color: Theme.of(context).colorScheme.primary,
+ ),
+ ),
+ ],
+ ),
+ SizedBox(
+ width: 120,
+ height: 40,
+ child: CollectButton.extend(
+ bangumiItem: widget.bangumiItem,
+ ),
+ ),
],
),
),
- ],
- ),
+ ),
+ if (MediaQuery.sizeOf(context).width >=
+ LayoutBreakpoint.compact['width']! &&
+ !widget.isLoading)
+ voteBarChart,
+ ],
),
- ],
- ),
+ ),
+ ],
),
);
}
diff --git a/lib/bean/card/comments_card.dart b/lib/bean/card/comments_card.dart
index 4557be0f..8139bc71 100644
--- a/lib/bean/card/comments_card.dart
+++ b/lib/bean/card/comments_card.dart
@@ -2,19 +2,57 @@ import 'package:flutter/material.dart';
import 'package:kazumi/modules/comments/comment_item.dart';
import 'package:kazumi/utils/utils.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
+import 'package:skeletonizer/skeletonizer.dart';
class CommentsCard extends StatelessWidget {
- const CommentsCard({
+ CommentsCard({
super.key,
required this.commentItem,
- });
+ }) {
+ isBone = false;
+ }
- final CommentItem commentItem;
+ CommentsCard.bone({
+ super.key,
+ }) {
+ isBone = true;
+ commentItem = null;
+ }
+
+ late final CommentItem? commentItem;
+ late final bool isBone;
@override
Widget build(BuildContext context) {
- return Card(
- color: Theme.of(context).colorScheme.secondaryContainer,
+ if (isBone) {
+ return Skeletonizer.zone(
+ enabled: true,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const Bone.circle(size: 36),
+ const SizedBox(width: 8),
+ const Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Bone.text(width: 80),
+ SizedBox(height: 8),
+ Bone.text(width: 60),
+ ],
+ ),
+ ],
+ ),
+ SizedBox(height: 8),
+ const Bone.multiText(lines: 2),
+ Divider(thickness: 0.5, indent: 10, endIndent: 10),
+ ],
+ ),
+ );
+ }
+ return SelectionArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
@@ -24,20 +62,20 @@ class CommentsCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
- backgroundImage: NetworkImage(commentItem.user.avatar.large),
+ backgroundImage: NetworkImage(commentItem!.user.avatar.large),
),
const SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(commentItem.user.nickname),
- Text(Utils.dateFormat(commentItem.comment.updatedAt)),
+ Text(commentItem!.user.nickname),
+ Text(Utils.dateFormat(commentItem!.comment.updatedAt)),
],
),
Expanded(child: Container(height: 10)),
RatingBarIndicator(
itemCount: 5,
- rating: commentItem.comment.rate.toDouble() / 2,
+ rating: commentItem!.comment.rate.toDouble() / 2,
itemBuilder: (context, index) => const Icon(
Icons.star_rounded,
),
@@ -46,7 +84,7 @@ class CommentsCard extends StatelessWidget {
],
),
const SizedBox(height: 8),
- Text(commentItem.comment.comment),
+ Text(commentItem!.comment.comment),
],
),
),
diff --git a/lib/bean/widget/collect_button.dart b/lib/bean/widget/collect_button.dart
index 8dfbffce..c5fe83d5 100644
--- a/lib/bean/widget/collect_button.dart
+++ b/lib/bean/widget/collect_button.dart
@@ -4,16 +4,30 @@ import 'package:kazumi/pages/collect/collect_controller.dart';
import 'package:flutter_modular/flutter_modular.dart';
class CollectButton extends StatefulWidget {
- const CollectButton({
+ CollectButton({
super.key,
required this.bangumiItem,
this.color = Colors.white,
this.onOpen,
this.onClose,
- });
+ }) {
+ isExtended = false;
+ }
+
+ CollectButton.extend({
+ super.key,
+ required this.bangumiItem,
+ this.color = Colors.white,
+ // this.isExtended = false,
+ this.onOpen,
+ this.onClose,
+ }) {
+ isExtended = true;
+ }
final BangumiItem bangumiItem;
final Color color;
+ late final bool isExtended;
final void Function()? onOpen;
final void Function()? onClose;
@@ -78,19 +92,33 @@ class _CollectButtonState extends State<CollectButton> {
onOpen: widget.onOpen,
builder:
(BuildContext context, MenuController controller, Widget? child) {
- return IconButton(
- onPressed: () {
- if (controller.isOpen) {
- controller.close();
- } else {
- controller.open();
- }
- },
- icon: Icon(
- getIconByInt(collectType),
- color: widget.color,
- ),
- );
+ if (widget.isExtended) {
+ return FilledButton.icon(
+ onPressed: () {
+ if (controller.isOpen) {
+ controller.close();
+ } else {
+ controller.open();
+ }
+ },
+ icon: Icon(getIconByInt(collectType)),
+ label: Text(getTypeStringByInt(collectType)),
+ );
+ } else {
+ return IconButton(
+ onPressed: () {
+ if (controller.isOpen) {
+ controller.close();
+ } else {
+ controller.open();
+ }
+ },
+ icon: Icon(
+ getIconByInt(collectType),
+ color: widget.color,
+ ),
+ );
+ }
},
menuChildren: List<MenuItemButton>.generate(
6,
diff --git a/lib/bean/widget/embedded_native_control_area.dart b/lib/bean/widget/embedded_native_control_area.dart
index 839d42c7..98090faa 100644
--- a/lib/bean/widget/embedded_native_control_area.dart
+++ b/lib/bean/widget/embedded_native_control_area.dart
@@ -2,10 +2,10 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:kazumi/utils/storage.dart';
-/// The widget won't draw anything, just a placeholder for native window control.
-/// It only works on macOS at the moment.
-/// windows and linux have no way to embed native window control into flutter view.
class EmbeddedNativeControlArea extends StatefulWidget {
+ /// The widget won't draw anything, just a placeholder for native window control.
+ /// It only works on macOS at the moment.
+ /// windows and linux have no way to embed native window control into flutter view.
const EmbeddedNativeControlArea({
super.key,
required this.child,
diff --git a/lib/modules/bangumi/bangumi_item.dart b/lib/modules/bangumi/bangumi_item.dart
index efa7836d..a8c12f79 100644
--- a/lib/modules/bangumi/bangumi_item.dart
+++ b/lib/modules/bangumi/bangumi_item.dart
@@ -30,20 +30,27 @@ class BangumiItem {
List<String> alias;
@HiveField(11, defaultValue: 0.0)
double ratingScore;
+ @HiveField(12, defaultValue: 0)
+ int votes;
+ @HiveField(13, defaultValue: [])
+ List<int> votesCount;
- BangumiItem(
- {required this.id,
- required this.type,
- required this.name,
- required this.nameCn,
- required this.summary,
- required this.airDate,
- required this.airWeekday,
- required this.rank,
- required this.images,
- required this.tags,
- required this.alias,
- required this.ratingScore});
+ BangumiItem({
+ required this.id,
+ required this.type,
+ required this.name,
+ required this.nameCn,
+ required this.summary,
+ required this.airDate,
+ required this.airWeekday,
+ required this.rank,
+ required this.images,
+ required this.tags,
+ required this.alias,
+ required this.ratingScore,
+ required this.votes,
+ required this.votesCount,
+ });
factory BangumiItem.fromJson(Map<String, dynamic> json) {
List<String> parseBangumiAliases(Map<String, dynamic> jsonData) {
@@ -70,32 +77,53 @@ class BangumiItem {
return [];
}
+ List<int> parseBangumiVoteCount(Map<String, dynamic> jsonData) {
+ if (!jsonData.containsKey('rating')) {
+ return [];
+ }
+ final json = jsonData['rating']['count'];
+ // For api.bgm.tv
+ if (json is Map<String, dynamic>) {
+ return List<int>.generate(10, (i) => json['${i+1}'] as int);
+ }
+ // For next.bgm.tv
+ if (json is List<dynamic>) {
+ return json.map((e) => e as int).toList();
+ }
+ return [];
+ }
+
List list = json['tags'] ?? [];
List<String> bangumiAlias = parseBangumiAliases(json);
List<BangumiTag> tagList = list.map((i) => BangumiTag.fromJson(i)).toList();
+ List<int> voteList = parseBangumiVoteCount(json);
return BangumiItem(
- id: json['id'],
- type: json['type'] ?? 2,
- name: json['name'] ?? '',
- nameCn: (json['name_cn'] ?? '') == ''
- ? (((json['nameCN'] ?? '') == '') ? json['name'] : json['nameCN'])
- : json['name_cn'],
- summary: json['summary'] ?? '',
- airDate: json['date'] ?? '',
- airWeekday: Utils.dateStringToWeekday(json['date'] ?? '2000-11-11'),
- rank: json['rating']['rank'] ?? 0,
- images: Map<String, String>.from(
- json['images'] ??
- {
- "large": json['image'],
- "common": "",
- "medium": "",
- "small": "",
- "grid": ""
- },
- ),
- tags: tagList,
- alias: bangumiAlias,
- ratingScore: double.parse((json['rating']['score'] ?? 0.0).toDouble().toStringAsFixed(1)));
+ id: json['id'],
+ type: json['type'] ?? 2,
+ name: json['name'] ?? '',
+ nameCn: (json['name_cn'] ?? '') == ''
+ ? (((json['nameCN'] ?? '') == '') ? json['name'] : json['nameCN'])
+ : json['name_cn'],
+ summary: json['summary'] ?? '',
+ airDate: json['date'] ?? '',
+ airWeekday: Utils.dateStringToWeekday(json['date'] ?? '2000-11-11'),
+ rank: json['rating']['rank'] ?? 0,
+ images: Map<String, String>.from(
+ json['images'] ??
+ {
+ "large": json['image'],
+ "common": "",
+ "medium": "",
+ "small": "",
+ "grid": ""
+ },
+ ),
+ tags: tagList,
+ alias: bangumiAlias,
+ ratingScore: double.parse(
+ (json['rating']['score'] ?? 0.0).toDouble().toStringAsFixed(1)),
+ votes: json['rating']['total'] ?? 0,
+ votesCount: voteList,
+ );
}
}
diff --git a/lib/modules/bangumi/bangumi_item.g.dart b/lib/modules/bangumi/bangumi_item.g.dart
index 0fd34183..ad4ac66e 100644
--- a/lib/modules/bangumi/bangumi_item.g.dart
+++ b/lib/modules/bangumi/bangumi_item.g.dart
@@ -29,13 +29,15 @@ class BangumiItemAdapter extends TypeAdapter<BangumiItem> {
tags: fields[9] == null ? [] : (fields[9] as List).cast<BangumiTag>(),
alias: fields[10] == null ? [] : (fields[10] as List).cast<String>(),
ratingScore: fields[11] == null ? 0.0 : fields[11] as double,
+ votes: fields[12] == null ? 0 : fields[12] as int,
+ votesCount: fields[13] == null ? [] : (fields[13] as List).cast<int>(),
);
}
@override
void write(BinaryWriter writer, BangumiItem obj) {
writer
- ..writeByte(12)
+ ..writeByte(14)
..writeByte(0)
..write(obj.id)
..writeByte(1)
@@ -59,7 +61,11 @@ class BangumiItemAdapter extends TypeAdapter<BangumiItem> {
..writeByte(10)
..write(obj.alias)
..writeByte(11)
- ..write(obj.ratingScore);
+ ..write(obj.ratingScore)
+ ..writeByte(12)
+ ..write(obj.votes)
+ ..writeByte(13)
+ ..write(obj.votesCount);
}
@override
diff --git a/lib/modules/characters/actor_item.dart b/lib/modules/characters/actor_item.dart
index a81e495b..7e26bf42 100644
--- a/lib/modules/characters/actor_item.dart
+++ b/lib/modules/characters/actor_item.dart
@@ -34,14 +34,12 @@ class ActorItem {
final int id;
final int type;
final String name;
- final String shortSummary;
final ActorAvator avator;
ActorItem({
required this.id,
required this.type,
required this.name,
- required this.shortSummary,
required this.avator,
});
@@ -50,7 +48,6 @@ class ActorItem {
id: json['id'] ?? 0,
type: json['type'] ?? 0,
name: json['name'] ?? '',
- shortSummary: json['short_summary'] ?? '',
avator: ActorAvator.fromJson(json['images'] as Map<String, dynamic>),
);
}
@@ -60,7 +57,6 @@ class ActorItem {
'id': id,
'type': type,
'name': name,
- 'short_summary': shortSummary,
'images': avator.toJson(),
};
}
diff --git a/lib/modules/characters/character_item.dart b/lib/modules/characters/character_item.dart
index 484edd2f..3c0129b6 100644
--- a/lib/modules/characters/character_item.dart
+++ b/lib/modules/characters/character_item.dart
@@ -32,6 +32,25 @@ class CharacterAvator {
}
}
+class CharacterExtraInfo {
+ String nameCn;
+ String summary;
+
+ CharacterExtraInfo({required this.nameCn, required this.summary});
+
+ factory CharacterExtraInfo.fromJson(Map<String, dynamic> json) {
+ String nameCn = '';
+ final String hasNameCn = json['infobox'][0]['key'];
+ if (hasNameCn == '简体中文名') {
+ nameCn = json['infobox'][0]['value'];
+ }
+ return CharacterExtraInfo(
+ nameCn: nameCn,
+ summary: json['summary']
+ );
+ }
+}
+
class CharacterItem {
final int id;
final int type;
@@ -39,6 +58,7 @@ class CharacterItem {
final String relation;
final CharacterAvator avator;
final List<ActorItem> actorList;
+ CharacterExtraInfo info;
CharacterItem({
required this.id,
@@ -47,6 +67,7 @@ class CharacterItem {
required this.relation,
required this.avator,
required this.actorList,
+ required this.info
});
factory CharacterItem.fromJson(Map<String, dynamic> json) {
@@ -60,6 +81,7 @@ class CharacterItem {
relation: json['relation'] ?? '未知',
avator: CharacterAvator.fromJson(json['images'] as Map<String, dynamic>),
actorList: resActorList,
+ info: CharacterExtraInfo(nameCn: '', summary: '')
);
}
diff --git a/lib/pages/info/comments_sheet.dart b/lib/pages/info/comments_sheet.dart
deleted file mode 100644
index a0c2b406..00000000
--- a/lib/pages/info/comments_sheet.dart
+++ /dev/null
@@ -1,206 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_mobx/flutter_mobx.dart';
-import 'package:flutter_modular/flutter_modular.dart';
-import 'package:kazumi/pages/info/info_controller.dart';
-import 'package:kazumi/bean/card/comments_card.dart';
-import 'package:kazumi/bean/card/character_card.dart';
-import 'package:kazumi/utils/logger.dart';
-import 'package:logger/logger.dart';
-import 'package:kazumi/utils/utils.dart';
-
-class CommentsBottomSheet extends StatefulWidget {
- const CommentsBottomSheet({super.key});
-
- @override
- State<CommentsBottomSheet> createState() => _CommentsBottomSheetState();
-}
-
-class _CommentsBottomSheetState extends State<CommentsBottomSheet> {
- late ScrollController scrollController;
- final infoController = Modular.get<InfoController>();
- bool commentsIsLoading = false;
- bool charactersIsLoading = false;
- bool commentsQueryTimeout = false;
- bool charactersQueryTimeout = false;
-
- @override
- void initState() {
- super.initState();
- if (infoController.commentsList.isEmpty) {
- loadMoreComments();
- }
- if (infoController.characterList.isEmpty) {
- loadCharacters();
- }
- scrollController = ScrollController();
- scrollController.addListener(scrollListener);
- }
-
- void scrollListener() {
- if (scrollController.position.pixels >=
- scrollController.position.maxScrollExtent - 200 &&
- !commentsIsLoading &&
- mounted) {
- setState(() {
- commentsIsLoading = true;
- });
- loadMoreComments(offset: infoController.commentsList.length);
- KazumiLogger().log(Level.info, 'Popular is loading more');
- }
- }
-
- Future<void> loadCharacters() async {
- infoController
- .queryBangumiCharactersByID(infoController.bangumiItem.id)
- .then((_) {
- if (infoController.characterList.isEmpty && mounted) {
- setState(() {
- charactersQueryTimeout = true;
- });
- }
- if (infoController.characterList.isNotEmpty && mounted) {
- setState(() {
- charactersIsLoading = false;
- });
- }
- });
- }
-
- Future<void> loadMoreComments({int offset = 0}) async {
- infoController
- .queryBangumiCommentsByID(infoController.bangumiItem.id, offset: offset)
- .then((_) {
- if (infoController.commentsList.isEmpty && mounted) {
- setState(() {
- commentsQueryTimeout = true;
- });
- }
- if (infoController.commentsList.isNotEmpty && mounted) {
- setState(() {
- commentsIsLoading = false;
- });
- }
- });
- }
-
- @override
- void dispose() {
- scrollController.removeListener(scrollListener);
- scrollController.dispose();
- super.dispose();
- }
-
- Widget get infoBody {
- return SelectionArea(
- child: Padding(
- padding: const EdgeInsets.all(10.0),
- child: SingleChildScrollView(
- child:
- Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
- Text(infoController.bangumiItem.summary),
- const SizedBox(height: 8),
- Wrap(
- spacing: 8.0,
- runSpacing: Utils.isDesktop() ? 8 : 0,
- children: List<Widget>.generate(
- infoController.bangumiItem.tags.length, (int index) {
- return Chip(
- label: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text('${infoController.bangumiItem.tags[index].name} '),
- Text(
- '${infoController.bangumiItem.tags[index].count}',
- style: TextStyle(color: Theme.of(context).colorScheme.primary),
- ),
- ],
- ),
- );
- }).toList())
- ]),
- ),
- ),
- );
- }
-
- Widget get commentsListBody {
- return SelectionArea(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(4.0, 4.0, 4.0, 0.0),
- child: Observer(builder: (context) {
- if (infoController.commentsList.isEmpty && !commentsQueryTimeout) {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- if (commentsQueryTimeout) {
- return const Center(
- child: Text('空空如也'),
- );
- }
- return ListView.builder(
- controller: scrollController,
- itemCount: infoController.commentsList.length,
- itemBuilder: (context, index) {
- return CommentsCard(
- commentItem: infoController.commentsList[index]);
- });
- }),
- ));
- }
-
- Widget get charactersListBody {
- return SelectionArea(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(4.0, 4.0, 4.0, 4.0),
- child: Observer(builder: (context) {
- if (infoController.characterList.isEmpty && !charactersQueryTimeout) {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- if (charactersQueryTimeout) {
- return const Center(
- child: Text('空空如也'),
- );
- }
- return ListView.builder(
- itemCount: infoController.characterList.length,
- itemBuilder: (context, index) {
- return CharacterCard(
- characterItem: infoController.characterList[index]);
- });
- }),
- ));
- }
-
- @override
- Widget build(BuildContext context) {
- return DefaultTabController(
- length: 3,
- child: Scaffold(
- body: Column(
- children: [
- const PreferredSize(
- preferredSize: Size.fromHeight(kToolbarHeight),
- child: Material(
- child: TabBar(
- tabs: [
- Tab(text: '详情'),
- Tab(text: '吐槽箱'),
- Tab(text: '声优表'),
- ],
- ),
- ),
- ),
- Expanded(
- child: TabBarView(
- children: [infoBody, commentsListBody, charactersListBody],
- ),
- ),
- ],
- ),
- ),
- );
- }
-}
diff --git a/lib/pages/info/info_controller.dart b/lib/pages/info/info_controller.dart
index 924dac24..b1e7b02c 100644
--- a/lib/pages/info/info_controller.dart
+++ b/lib/pages/info/info_controller.dart
@@ -23,6 +23,9 @@ abstract class _InfoController with Store {
late BangumiItem bangumiItem;
EpisodeInfo episodeInfo = EpisodeInfo.fromTemplate();
+ @observable
+ bool isLoading = false;
+
@observable
var pluginSearchResponseList = ObservableList<PluginSearchResponse>();
@@ -39,6 +42,7 @@ abstract class _InfoController with Store {
var characterList = ObservableList<CharacterItem>();
Future<void> queryBangumiInfoByID(int id, {String type = "init"}) async {
+ isLoading = true;
await BangumiHTTP.getBangumiInfoByID(id).then((value) {
if (value != null) {
if (type == "init") {
@@ -51,8 +55,11 @@ abstract class _InfoController with Store {
bangumiItem.airWeekday = value.airWeekday;
bangumiItem.alias = value.alias;
bangumiItem.ratingScore = value.ratingScore;
+ bangumiItem.votes = value.votes;
+ bangumiItem.votesCount = value.votesCount;
}
collectController.updateLocalCollect(bangumiItem);
+ isLoading = false;
}
});
}
diff --git a/lib/pages/info/info_controller.g.dart b/lib/pages/info/info_controller.g.dart
index bd1a4e65..f0144b8e 100644
--- a/lib/pages/info/info_controller.g.dart
+++ b/lib/pages/info/info_controller.g.dart
@@ -9,6 +9,22 @@ part of 'info_controller.dart';
// ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic, no_leading_underscores_for_local_identifiers
mixin _$InfoController on _InfoController, Store {
+ late final _$isLoadingAtom =
+ Atom(name: '_InfoController.isLoading', context: context);
+
+ @override
+ bool get isLoading {
+ _$isLoadingAtom.reportRead();
+ return super.isLoading;
+ }
+
+ @override
+ set isLoading(bool value) {
+ _$isLoadingAtom.reportWrite(value, super.isLoading, () {
+ super.isLoading = value;
+ });
+ }
+
late final _$pluginSearchResponseListAtom =
Atom(name: '_InfoController.pluginSearchResponseList', context: context);
@@ -93,6 +109,7 @@ mixin _$InfoController on _InfoController, Store {
@override
String toString() {
return '''
+isLoading: ${isLoading},
pluginSearchResponseList: ${pluginSearchResponseList},
pluginSearchStatus: ${pluginSearchStatus},
commentsList: ${commentsList},
diff --git a/lib/pages/info/info_page.dart b/lib/pages/info/info_page.dart
index 019eb3da..c3b92e74 100644
--- a/lib/pages/info/info_page.dart
+++ b/lib/pages/info/info_page.dart
@@ -1,22 +1,24 @@
+import 'dart:io';
import 'dart:ui';
+import 'package:flutter_mobx/flutter_mobx.dart';
+import 'package:kazumi/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
-import 'package:kazumi/bean/dialog/dialog_helper.dart';
-import 'package:kazumi/bean/widget/error_widget.dart';
-import 'package:kazumi/pages/collect/collect_controller.dart';
+import 'package:kazumi/bean/widget/collect_button.dart';
+import 'package:kazumi/bean/widget/embedded_native_control_area.dart';
+import 'package:kazumi/utils/constants.dart';
+import 'package:kazumi/utils/storage.dart';
import 'package:kazumi/pages/info/info_controller.dart';
import 'package:kazumi/bean/card/bangumi_info_card.dart';
-import 'package:flutter_mobx/flutter_mobx.dart';
+import 'package:kazumi/pages/info/source_sheet.dart';
import 'package:kazumi/plugins/plugins_controller.dart';
import 'package:kazumi/pages/video/video_controller.dart';
import 'package:kazumi/bean/card/network_img_layer.dart';
-import 'package:kazumi/bean/appbar/sys_app_bar.dart';
-import 'package:kazumi/request/query_manager.dart';
-import 'package:kazumi/utils/utils.dart';
import 'package:logger/logger.dart';
import 'package:kazumi/utils/logger.dart';
-import 'package:kazumi/pages/info/comments_sheet.dart';
+import 'package:kazumi/pages/info/info_tabview.dart';
import 'package:url_launcher/url_launcher.dart';
+import 'package:window_manager/window_manager.dart';
class InfoPage extends StatefulWidget {
const InfoPage({super.key});
@@ -28,41 +30,30 @@ class InfoPage extends StatefulWidget {
class _InfoPageState extends State<InfoPage>
with SingleTickerProviderStateMixin {
final InfoController infoController = Modular.get<InfoController>();
- final CollectController collectController = Modular.get<CollectController>();
final VideoPageController videoPageController =
Modular.get<VideoPageController>();
final PluginsController pluginsController = Modular.get<PluginsController>();
late TabController tabController;
- late String keyword;
-
- /// Concurrent query manager
- late QueryManager queryManager;
@override
void initState() {
super.initState();
- // Because the gap between different bangumi API reponse is too large, sometimes we need to query the bangumi info again
+ // Because the gap between different bangumi API response is too large, sometimes we need to query the bangumi info again
// We need the type parameter to determine whether to attach the new data to the old data
- // We can't generally replace the old data with the new data, because the old data containes images url, update them will cause the image to reload and flicker
+ // We can't generally replace the old data with the new data, because the old data contains images url, update them will cause the image to reload and flicker
if (infoController.bangumiItem.summary == '' ||
- infoController.bangumiItem.tags.isEmpty ||
- infoController.bangumiItem.ratingScore == 0.0) {
+ infoController.bangumiItem.votesCount.isEmpty) {
queryBangumiInfoByID(infoController.bangumiItem.id, type: 'attach');
}
- keyword = infoController.bangumiItem.nameCn == ''
- ? infoController.bangumiItem.name
- : infoController.bangumiItem.nameCn;
- queryManager = QueryManager();
- queryManager.queryAllSource(keyword);
tabController =
TabController(length: pluginsController.pluginList.length, vsync: this);
}
@override
void dispose() {
- queryManager.cancel();
infoController.characterList.clear();
infoController.commentsList.clear();
+ infoController.pluginSearchResponseList.clear();
videoPageController.currentEpisode = 1;
tabController.dispose();
super.dispose();
@@ -77,338 +68,193 @@ class _InfoPageState extends State<InfoPage>
}
}
- void showAliasSearchDialog(String pluginName) {
- if (infoController.bangumiItem.alias.isEmpty) {
- KazumiDialog.showToast(message: '无可用别名,试试手动检索');
- return;
- }
- final aliasNotifier =
- ValueNotifier<List<String>>(infoController.bangumiItem.alias);
- KazumiDialog.show(builder: (context) {
- return Dialog(
- clipBehavior: Clip.antiAlias,
- child: ValueListenableBuilder<List<String>>(
- valueListenable: aliasNotifier,
- builder: (context, aliasList, child) {
- return ListView(
- shrinkWrap: true,
- children: aliasList.asMap().entries.map((entry) {
- final index = entry.key;
- final alias = entry.value;
- return ListTile(
- title: Text(alias),
- trailing: IconButton(
- onPressed: () {
- KazumiDialog.show(
- builder: (context) {
- return AlertDialog(
- title: const Text('删除确认'),
- content: const Text('删除后无法恢复,确认要永久删除这个别名吗?'),
- actions: [
- TextButton(
- onPressed: () {
- KazumiDialog.dismiss();
- },
- child: Text(
- '取消',
- style: TextStyle(
- color: Theme.of(context)
- .colorScheme
- .outline),
- ),
- ),
- TextButton(
- onPressed: () {
- KazumiDialog.dismiss();
- aliasList.removeAt(index);
- aliasNotifier.value = List.from(aliasList);
- collectController.updateLocalCollect(
- infoController.bangumiItem);
- if (aliasList.isEmpty) {
- // pop whole dialog when empty
- Navigator.of(context).pop();
- }
- },
- child: const Text('确认'),
- ),
- ],
- );
- },
- );
- },
- icon: Icon(Icons.delete),
- ),
- onTap: () {
- KazumiDialog.dismiss();
- queryManager.querySource(alias, pluginName);
- },
- );
- }).toList(),
- );
- },
- ),
- );
- });
- }
-
- void showCustomSearchDialog(String pluginName) {
- KazumiDialog.show(
- builder: (context) {
- final TextEditingController textController = TextEditingController();
- return AlertDialog(
- title: const Text('输入别名'),
- content: TextField(
- controller: textController,
- onSubmitted: (keyword) {
- if (textController.text != '') {
- infoController.bangumiItem.alias.add(textController.text);
- KazumiDialog.dismiss();
- queryManager.querySource(textController.text, pluginName);
- }
- },
- ),
- actions: [
- TextButton(
- onPressed: () {
- KazumiDialog.dismiss();
- },
- child: Text(
- '取消',
- style: TextStyle(color: Theme.of(context).colorScheme.outline),
- ),
- ),
- TextButton(
- onPressed: () {
- if (textController.text != '') {
- infoController.bangumiItem.alias.add(textController.text);
- collectController
- .updateLocalCollect(infoController.bangumiItem);
- KazumiDialog.dismiss();
- queryManager.querySource(textController.text, pluginName);
- }
- },
- child: const Text(
- '确认',
- ),
- ),
- ],
- );
- },
- );
- }
-
@override
Widget build(BuildContext context) {
- return PopScope(
- canPop: true,
- child: Stack(
- children: [
- Positioned.fill(
- child: IgnorePointer(
- child: Container(
- color: Theme.of(context).brightness == Brightness.light
- ? Colors.white
- : Colors.black,
- child: Opacity(
- opacity: 0.2,
- child: LayoutBuilder(builder: (context, boxConstraints) {
- return ImageFiltered(
- imageFilter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
- child: NetworkImgLayer(
- src: infoController.bangumiItem.images['large'] ?? '',
- width: boxConstraints.maxWidth,
- height: boxConstraints.maxHeight,
- fadeInDuration: const Duration(milliseconds: 0),
- fadeOutDuration: const Duration(milliseconds: 0),
+ final List<String> tabs = <String>['概览', '吐槽', '角色', '评论', '制作人员'];
+ final bool showWindowButton = GStorage.setting
+ .get(SettingBoxKey.showWindowButton, defaultValue: false);
+ return Observer(builder: (context) {
+ return PopScope(
+ canPop: true,
+ child: DefaultTabController(
+ length: tabs.length,
+ child: Scaffold(
+ body: NestedScrollView(
+ headerSliverBuilder:
+ (BuildContext context, bool innerBoxIsScrolled) {
+ return <Widget>[
+ SliverOverlapAbsorber(
+ handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
+ context),
+ sliver: SliverAppBar.medium(
+ title: EmbeddedNativeControlArea(
+ child: Text(
+ infoController.bangumiItem.nameCn == ''
+ ? infoController.bangumiItem.name
+ : infoController.bangumiItem.nameCn,
+ ),
),
- );
- }),
- ),
- ),
- ),
- ),
- Scaffold(
- backgroundColor: Colors.transparent,
- appBar: SysAppBar(
- backgroundColor: Colors.transparent,
- actions: [
- IconButton(
- onPressed: () {
- int currentIndex = tabController.index;
- KazumiDialog.show(builder: (context) {
- return AlertDialog(
- title: const Text('退出确认'),
- content: const Text('您想要离开 Kazumi 并在浏览器中打开此视频源吗?'),
- actions: [
- TextButton(
- onPressed: () => KazumiDialog.dismiss(),
- child: const Text('取消')),
- TextButton(
- onPressed: () {
- KazumiDialog.dismiss();
- launchUrl(Uri.parse(pluginsController
- .pluginList[currentIndex].baseUrl));
- },
- child: const Text('确认')),
- ],
- );
- });
- },
- icon: const Icon(Icons.open_in_browser))
- ],
- ),
- body: Column(
- children: [
- BangumiInfoCardV(bangumiItem: infoController.bangumiItem),
- TabBar(
- isScrollable: true,
- tabAlignment: TabAlignment.center,
- controller: tabController,
- tabs: pluginsController.pluginList
- .map((plugin) => Observer(
- builder: (context) => Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- plugin.name,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: Theme.of(context)
- .textTheme
- .titleMedium!
- .fontSize,
- color: Theme.of(context)
- .colorScheme
- .onSurface),
+ automaticallyImplyLeading: false,
+ scrolledUnderElevation: 0.0,
+ leading: EmbeddedNativeControlArea(
+ child: IconButton(
+ onPressed: () {
+ Navigator.maybePop(context);
+ },
+ icon: Icon(Icons.arrow_back),
+ ),
+ ),
+ actions: [
+ if (innerBoxIsScrolled)
+ EmbeddedNativeControlArea(
+ child: CollectButton(
+ bangumiItem: infoController.bangumiItem,
+ color: Theme.of(context)
+ .colorScheme
+ .onSurfaceVariant,
+ ),
+ ),
+ EmbeddedNativeControlArea(
+ child: IconButton(
+ onPressed: () {
+ launchUrl(
+ Uri.parse(
+ 'https://bangumi.tv/subject/${infoController.bangumiItem.id}'),
+ mode: LaunchMode.externalApplication,
+ );
+ },
+ icon: const Icon(Icons.open_in_browser_rounded),
+ ),
+ ),
+ if (!showWindowButton && Utils.isDesktop())
+ CloseButton(onPressed: () => windowManager.close()),
+ SizedBox(width: 8),
+ ],
+ toolbarHeight: (Platform.isMacOS && showWindowButton)
+ ? kToolbarHeight + 22
+ : kToolbarHeight,
+ stretch: true,
+ centerTitle: false,
+ expandedHeight: (Platform.isMacOS && showWindowButton)
+ ? 308 + kTextTabBarHeight + kToolbarHeight + 22
+ : 308 + kTextTabBarHeight + kToolbarHeight,
+ collapsedHeight: (Platform.isMacOS && showWindowButton)
+ ? kTextTabBarHeight +
+ kToolbarHeight +
+ MediaQuery.paddingOf(context).top +
+ 22
+ : kTextTabBarHeight +
+ kToolbarHeight +
+ MediaQuery.paddingOf(context).top,
+ flexibleSpace: FlexibleSpaceBar(
+ collapseMode: CollapseMode.pin,
+ background: Stack(
+ children: [
+ // No background image when loading to make loading looks better
+ if (!infoController.isLoading)
+ Positioned.fill(
+ bottom: kTextTabBarHeight,
+ child: IgnorePointer(
+ child: Opacity(
+ opacity: 0.4,
+ child: LayoutBuilder(
+ builder: (context, boxConstraints) {
+ return ImageFiltered(
+ imageFilter: ImageFilter.blur(
+ sigmaX: 15.0, sigmaY: 15.0),
+ child: ShaderMask(
+ shaderCallback: (Rect bounds) {
+ return const LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Colors.white,
+ Colors.transparent,
+ ],
+ stops: [0.8, 1],
+ ).createShader(bounds);
+ },
+ child: NetworkImgLayer(
+ src: infoController.bangumiItem
+ .images['large'] ??
+ '',
+ width: boxConstraints.maxWidth,
+ height: boxConstraints.maxHeight,
+ fadeInDuration: const Duration(
+ milliseconds: 0),
+ fadeOutDuration: const Duration(
+ milliseconds: 0),
+ ),
+ ),
+ );
+ },
+ ),
+ ),
),
- const SizedBox(width: 5.0),
- Container(
- width: 8.0,
- height: 8.0,
- decoration: BoxDecoration(
- color: infoController.pluginSearchStatus[
- plugin.name] ==
- 'success'
- ? Colors.green
- : (infoController.pluginSearchStatus[
- plugin.name] ==
- 'pending')
- ? Colors.grey
- : Colors.red,
- shape: BoxShape.circle,
+ ),
+ SafeArea(
+ left: false,
+ right: false,
+ bottom: false,
+ child: EmbeddedNativeControlArea(
+ child: Align(
+ alignment: Alignment.topCenter,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ 16, kToolbarHeight, 16, 0),
+ child: BangumiInfoCardV(
+ bangumiItem: infoController.bangumiItem,
+ isLoading: infoController.isLoading,
+ ),
),
),
- ],
+ ),
),
- ))
- .toList(),
- ),
- Expanded(
- child: Observer(
- builder: (context) => TabBarView(
- controller: tabController,
- children: List.generate(
- pluginsController.pluginList.length, (pluginIndex) {
- var plugin = pluginsController.pluginList[pluginIndex];
- var cardList = <Widget>[];
- for (var searchResponse
- in infoController.pluginSearchResponseList) {
- if (searchResponse.pluginName == plugin.name) {
- for (var searchItem in searchResponse.data) {
- cardList.add(Card(
- color: Colors.transparent,
- child: ListTile(
- tileColor: Colors.transparent,
- title: Text(searchItem.name),
- onTap: () async {
- KazumiDialog.showLoading(msg: '获取中');
- videoPageController.currentPlugin = plugin;
- videoPageController.title = searchItem.name;
- videoPageController.src = searchItem.src;
- try {
- await infoController.queryRoads(
- searchItem.src, plugin.name);
- KazumiDialog.dismiss();
- Modular.to.pushNamed('/video/');
- } catch (e) {
- KazumiLogger()
- .log(Level.error, e.toString());
- KazumiDialog.dismiss();
- }
- },
- ),
- ));
- }
- }
- }
- return infoController.pluginSearchStatus[plugin.name] ==
- 'pending'
- ? const Center(child: CircularProgressIndicator())
- : (infoController.pluginSearchStatus[plugin.name] ==
- 'error'
- ? GeneralErrorWidget(
- errMsg:
- '${plugin.name} 检索失败 重试或左右滑动以切换到其他视频来源',
- actions: [
- GeneralErrorButton(
- onPressed: () {
- queryManager.querySource(
- keyword, plugin.name);
- },
- text: '重试',
- ),
- ],
- )
- : cardList.isEmpty
- ? GeneralErrorWidget(
- errMsg:
- '${plugin.name} 无结果 使用别名或左右滑动以切换到其他视频来源',
- actions: [
- GeneralErrorButton(
- onPressed: () {
- showAliasSearchDialog(
- plugin.name,
- );
- },
- text: '别名检索',
- ),
- GeneralErrorButton(
- onPressed: () {
- showCustomSearchDialog(
- plugin.name,
- );
- },
- text: '手动检索',
- ),
- ],
- )
- : ListView(children: cardList));
- }),
+ ],
+ ),
+ ),
+ forceElevated: innerBoxIsScrolled,
+ bottom: TabBar(
+ isScrollable: true,
+ tabAlignment: TabAlignment.center,
+ dividerHeight: 0,
+ tabs: tabs.map((name) => Tab(text: name)).toList(),
+ ),
),
),
- )
- ],
+ ];
+ },
+ body: InfoTabView(),
),
- floatingActionButton: FloatingActionButton(
- child: const Icon(Icons.widgets_rounded),
+ floatingActionButton: FloatingActionButton.extended(
+ icon: const Icon(Icons.play_arrow_rounded),
+ label: Text('开始观看'),
onPressed: () async {
showModalBottomSheet(
- isScrollControlled: true,
- constraints: BoxConstraints(
- maxHeight: MediaQuery.of(context).size.height * 3 / 4,
- maxWidth: (Utils.isDesktop() || Utils.isTablet())
- ? MediaQuery.of(context).size.width * 9 / 16
- : MediaQuery.of(context).size.width),
- clipBehavior: Clip.antiAlias,
- context: context,
- builder: (context) {
- return const CommentsBottomSheet();
- });
+ isScrollControlled: true,
+ constraints: BoxConstraints(
+ maxHeight: (MediaQuery.sizeOf(context).height >=
+ LayoutBreakpoint.compact['height']!)
+ ? MediaQuery.of(context).size.height * 3 / 4
+ : MediaQuery.of(context).size.height,
+ maxWidth: (MediaQuery.sizeOf(context).width >=
+ LayoutBreakpoint.medium['width']!)
+ ? MediaQuery.of(context).size.width * 9 / 16
+ : MediaQuery.of(context).size.width,
+ ),
+ clipBehavior: Clip.antiAlias,
+ backgroundColor: Theme.of(context).scaffoldBackgroundColor,
+ showDragHandle: true,
+ context: context,
+ builder: (context) {
+ return SourceSheet(tabController: tabController);
+ },
+ );
},
),
),
- ],
- ),
- );
+ ),
+ );
+ });
}
}
diff --git a/lib/pages/info/info_tabview.dart b/lib/pages/info/info_tabview.dart
new file mode 100644
index 00000000..c5048d0a
--- /dev/null
+++ b/lib/pages/info/info_tabview.dart
@@ -0,0 +1,485 @@
+import 'dart:ui' as ui;
+import 'package:flutter/material.dart';
+import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/bean/widget/error_widget.dart';
+import 'package:kazumi/pages/info/info_controller.dart';
+import 'package:kazumi/bean/card/comments_card.dart';
+import 'package:kazumi/bean/card/character_card.dart';
+import 'package:kazumi/utils/utils.dart';
+import 'package:skeletonizer/skeletonizer.dart';
+
+class InfoTabView extends StatefulWidget {
+ const InfoTabView({super.key});
+
+ @override
+ State<InfoTabView> createState() => _InfoTabViewState();
+}
+
+class _InfoTabViewState extends State<InfoTabView> {
+ final infoController = Modular.get<InfoController>();
+ final maxWidth = 950.0;
+ bool commentsIsLoading = false;
+ bool charactersIsLoading = false;
+ bool commentsQueryTimeout = false;
+ bool charactersQueryTimeout = false;
+ bool fullIntro = false;
+ bool fullTag = false;
+
+ @override
+ void initState() {
+ super.initState();
+ if (infoController.commentsList.isEmpty) {
+ loadMoreComments();
+ }
+ if (infoController.characterList.isEmpty) {
+ loadCharacters();
+ }
+ }
+
+ Future<void> loadCharacters() async {
+ infoController
+ .queryBangumiCharactersByID(infoController.bangumiItem.id)
+ .then((_) {
+ if (infoController.characterList.isEmpty && mounted) {
+ setState(() {
+ charactersQueryTimeout = true;
+ });
+ }
+ if (infoController.characterList.isNotEmpty && mounted) {
+ setState(() {
+ charactersIsLoading = false;
+ });
+ }
+ });
+ }
+
+ Future<void> loadMoreComments({int offset = 0}) async {
+ infoController
+ .queryBangumiCommentsByID(infoController.bangumiItem.id, offset: offset)
+ .then((_) {
+ if (infoController.commentsList.isEmpty && mounted) {
+ setState(() {
+ commentsQueryTimeout = true;
+ });
+ }
+ if (infoController.commentsList.isNotEmpty && mounted) {
+ setState(() {
+ commentsIsLoading = false;
+ });
+ }
+ });
+ }
+
+ @override
+ void dispose() {
+ super.dispose();
+ }
+
+ Widget get infoBody {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('简介', style: TextStyle(fontSize: 18)),
+ const SizedBox(height: 8),
+ // https://stackoverflow.com/questions/54091055/flutter-how-to-get-the-number-of-text-lines
+ // only show expand button when line > 7
+ LayoutBuilder(builder: (context, constraints) {
+ final span = TextSpan(text: infoController.bangumiItem.summary);
+ final tp =
+ TextPainter(text: span, textDirection: TextDirection.ltr);
+ tp.layout(maxWidth: constraints.maxWidth);
+ final numLines = tp.computeLineMetrics().length;
+ if (numLines > 7) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ SizedBox(
+ // make intro expandable
+ height: fullIntro ? null : 120,
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: SelectableText(
+ infoController.bangumiItem.summary,
+ textAlign: TextAlign.start,
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ scrollPhysics: NeverScrollableScrollPhysics(),
+ selectionHeightStyle: ui.BoxHeightStyle.max,
+ ),
+ ),
+ TextButton(
+ onPressed: () {
+ setState(() {
+ fullIntro = !fullIntro;
+ });
+ },
+ child: Text(fullIntro ? '加载更少' : '加载更多'),
+ ),
+ ],
+ );
+ } else {
+ return SelectableText(
+ infoController.bangumiItem.summary,
+ textAlign: TextAlign.start,
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ scrollPhysics: NeverScrollableScrollPhysics(),
+ selectionHeightStyle: ui.BoxHeightStyle.max,
+ );
+ }
+ }),
+ const SizedBox(height: 16),
+ Text('标签', style: TextStyle(fontSize: 18)),
+ const SizedBox(height: 8),
+ Wrap(
+ spacing: 8.0,
+ runSpacing: Utils.isDesktop() ? 8 : 0,
+ children: List<Widget>.generate(
+ fullTag || infoController.bangumiItem.tags.length < 13
+ ? infoController.bangumiItem.tags.length
+ : 13, (int index) {
+ if (!fullTag && index == 12) {
+ // make tag expandable
+ return ActionChip(
+ label: Text(
+ '更多 +',
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.primary),
+ ),
+ onPressed: () {
+ setState(() {
+ fullTag = !fullTag;
+ });
+ },
+ );
+ }
+ return ActionChip(
+ label: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text('${infoController.bangumiItem.tags[index].name} '),
+ Text(
+ '${infoController.bangumiItem.tags[index].count}',
+ style: TextStyle(
+ color: Theme.of(context).colorScheme.primary),
+ ),
+ ],
+ ),
+ onPressed: () {
+ // TODO: Search with selected tag.
+ },
+ );
+ }).toList(),
+ )
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ /// Bone for Skeleton Loader
+ Widget get infoBodyBone {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Skeletonizer.zone(child: Bone.text(fontSize: 18, width: 50)),
+ const SizedBox(height: 8),
+ Skeletonizer.zone(child: Bone.multiText(lines: 7)),
+ const SizedBox(height: 16),
+ Skeletonizer.zone(child: Bone.text(fontSize: 18, width: 50)),
+ const SizedBox(height: 8),
+ if (infoController.isLoading)
+ Skeletonizer.zone(
+ child: Wrap(
+ spacing: 8.0,
+ runSpacing: 8.0,
+ children: List.generate(
+ 4, (_) => Bone.button(uniRadius: 8, height: 32)),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget get commentsListBody {
+ return Builder(
+ builder: (BuildContext context) {
+ return NotificationListener<ScrollEndNotification>(
+ onNotification: (scrollEnd) {
+ final metrics = scrollEnd.metrics;
+ if (metrics.pixels >= metrics.maxScrollExtent - 200) {
+ if (!commentsIsLoading) {
+ setState(() {
+ commentsIsLoading = true;
+ });
+ loadMoreComments(offset: infoController.commentsList.length);
+ }
+ }
+ return true;
+ },
+ child: CustomScrollView(
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ key: PageStorageKey<String>('吐槽'),
+ slivers: <Widget>[
+ SliverOverlapInjector(
+ handle:
+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),
+ ),
+ SliverLayoutBuilder(builder: (context, _) {
+ if (infoController.commentsList.isEmpty && commentsIsLoading) {
+ return SliverList.builder(
+ itemCount: 4,
+ itemBuilder: (context, _) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: CommentsCard.bone(),
+ ),
+ ),
+ );
+ },
+ );
+ }
+ if (commentsQueryTimeout) {
+ return SliverFillRemaining(
+ child: GeneralErrorWidget(
+ errMsg: '获取失败,请重试',
+ actions: [
+ GeneralErrorButton(
+ onPressed: () {
+ setState(() {
+ commentsIsLoading = true;
+ commentsQueryTimeout = false;
+ });
+ loadMoreComments(
+ offset: infoController.commentsList.length);
+ },
+ text: '重试',
+ ),
+ ],
+ ),
+ );
+ }
+ return SliverList.separated(
+ addAutomaticKeepAlives: false,
+ itemCount: infoController.commentsList.length,
+ itemBuilder: (context, index) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: CommentsCard(
+ commentItem: infoController.commentsList[index],
+ ),
+ ),
+ ),
+ );
+ },
+ separatorBuilder: (BuildContext context, int index) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: Divider(
+ thickness: 0.5, indent: 10, endIndent: 10),
+ ),
+ ),
+ );
+ },
+ );
+ })
+ ],
+ ),
+ );
+ },
+ );
+ }
+
+ Widget get charactersListBody {
+ return Builder(
+ builder: (BuildContext context) {
+ return CustomScrollView(
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ key: PageStorageKey<String>('角色'),
+ slivers: <Widget>[
+ SliverOverlapInjector(
+ handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
+ ),
+ SliverLayoutBuilder(builder: (context, _) {
+ if (infoController.characterList.isEmpty && charactersIsLoading) {
+ return SliverList.builder(
+ itemCount: 4,
+ itemBuilder: (context, _) {
+ return Align(
+ alignment: Alignment.topCenter,
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: Skeletonizer.zone(
+ child: ListTile(
+ leading: Bone.circle(size: 36),
+ title: Bone.text(width: 100),
+ subtitle: Bone.text(width: 80),
+ ),
+ ),
+ ),
+ );
+ },
+ );
+ }
+ if (charactersQueryTimeout) {
+ return SliverFillRemaining(
+ child: GeneralErrorWidget(
+ errMsg: '获取失败,请重试',
+ actions: [
+ GeneralErrorButton(
+ onPressed: () {
+ setState(() {
+ charactersIsLoading = true;
+ charactersQueryTimeout = false;
+ });
+ loadCharacters();
+ },
+ text: '重试',
+ ),
+ ],
+ ),
+ );
+ }
+ return SliverList.builder(
+ itemCount: infoController.characterList.length,
+ itemBuilder: (context, index) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16.0),
+ child: SizedBox(
+ width: MediaQuery.sizeOf(context).width > maxWidth
+ ? maxWidth
+ : MediaQuery.sizeOf(context).width - 32,
+ child: CharacterCard(
+ characterItem: infoController.characterList[index],
+ ),
+ ),
+ ),
+ );
+ },
+ );
+ }),
+ ],
+ );
+ },
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return TabBarView(
+ children: [
+ Builder(
+ // This Builder is needed to provide a BuildContext that is
+ // "inside" the NestedScrollView, so that
+ // sliverOverlapAbsorberHandleFor() can find the
+ // NestedScrollView.
+ builder: (BuildContext context) {
+ return CustomScrollView(
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ // The PageStorageKey should be unique to this ScrollView;
+ // it allows the list to remember its scroll position when
+ // the tab view is not on the screen.
+ key: PageStorageKey<String>('概览'),
+ slivers: <Widget>[
+ SliverOverlapInjector(
+ handle:
+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),
+ ),
+ SliverToBoxAdapter(
+ child: infoController.isLoading ? infoBodyBone : infoBody,
+ ),
+ ],
+ );
+ },
+ ),
+ commentsListBody,
+ charactersListBody,
+ Builder(
+ builder: (BuildContext context) {
+ return CustomScrollView(
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ key: PageStorageKey<String>('评论'),
+ slivers: <Widget>[
+ SliverOverlapInjector(
+ handle:
+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),
+ ),
+ // TODO: 评论区
+ SliverFillRemaining(
+ child: Center(child: Text('施工中')),
+ ),
+ ],
+ );
+ },
+ ),
+ Builder(
+ builder: (BuildContext context) {
+ return CustomScrollView(
+ scrollBehavior: const ScrollBehavior().copyWith(
+ scrollbars: false,
+ ),
+ key: PageStorageKey<String>('制作人员'),
+ slivers: <Widget>[
+ SliverOverlapInjector(
+ handle:
+ NestedScrollView.sliverOverlapAbsorberHandleFor(context),
+ ),
+ // TODO: 制作人员
+ SliverFillRemaining(
+ child: Center(child: Text('施工中')),
+ ),
+ ],
+ );
+ },
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/pages/info/source_sheet.dart b/lib/pages/info/source_sheet.dart
new file mode 100644
index 00000000..8ebd2c52
--- /dev/null
+++ b/lib/pages/info/source_sheet.dart
@@ -0,0 +1,346 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_mobx/flutter_mobx.dart';
+import 'package:flutter_modular/flutter_modular.dart';
+import 'package:kazumi/pages/info/info_controller.dart';
+import 'package:kazumi/utils/logger.dart';
+import 'package:logger/logger.dart';
+import 'package:kazumi/bean/dialog/dialog_helper.dart';
+import 'package:kazumi/plugins/plugins_controller.dart';
+import 'package:kazumi/pages/video/video_controller.dart';
+import 'package:url_launcher/url_launcher.dart';
+import 'package:kazumi/request/query_manager.dart';
+import 'package:kazumi/pages/collect/collect_controller.dart';
+import 'package:kazumi/bean/widget/error_widget.dart';
+
+class SourceSheet extends StatefulWidget {
+ const SourceSheet({
+ super.key,
+ required this.tabController,
+ });
+
+ final TabController tabController;
+
+ @override
+ State<SourceSheet> createState() => _SourceSheetState();
+}
+
+class _SourceSheetState extends State<SourceSheet>
+ with SingleTickerProviderStateMixin {
+ final infoController = Modular.get<InfoController>();
+ final VideoPageController videoPageController =
+ Modular.get<VideoPageController>();
+ final CollectController collectController = Modular.get<CollectController>();
+ final PluginsController pluginsController = Modular.get<PluginsController>();
+ late String keyword;
+
+ /// Concurrent query manager
+ late QueryManager queryManager;
+
+ @override
+ void initState() {
+ keyword = infoController.bangumiItem.nameCn == ''
+ ? infoController.bangumiItem.name
+ : infoController.bangumiItem.nameCn;
+ queryManager = QueryManager();
+ if (infoController.pluginSearchResponseList.isEmpty) {
+ queryManager.queryAllSource(keyword);
+ }
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ queryManager.cancel();
+ super.dispose();
+ }
+
+ void showAliasSearchDialog(String pluginName) {
+ if (infoController.bangumiItem.alias.isEmpty) {
+ KazumiDialog.showToast(message: '无可用别名,试试手动检索');
+ return;
+ }
+ final aliasNotifier =
+ ValueNotifier<List<String>>(infoController.bangumiItem.alias);
+ KazumiDialog.show(builder: (context) {
+ return Dialog(
+ clipBehavior: Clip.antiAlias,
+ child: ValueListenableBuilder<List<String>>(
+ valueListenable: aliasNotifier,
+ builder: (context, aliasList, child) {
+ return ListView(
+ shrinkWrap: true,
+ children: aliasList.asMap().entries.map((entry) {
+ final index = entry.key;
+ final alias = entry.value;
+ return ListTile(
+ title: Text(alias),
+ trailing: IconButton(
+ onPressed: () {
+ KazumiDialog.show(
+ builder: (context) {
+ return AlertDialog(
+ title: const Text('删除确认'),
+ content: const Text('删除后无法恢复,确认要永久删除这个别名吗?'),
+ actions: [
+ TextButton(
+ onPressed: () {
+ KazumiDialog.dismiss();
+ },
+ child: Text(
+ '取消',
+ style: TextStyle(
+ color: Theme.of(context)
+ .colorScheme
+ .outline),
+ ),
+ ),
+ TextButton(
+ onPressed: () {
+ KazumiDialog.dismiss();
+ aliasList.removeAt(index);
+ aliasNotifier.value = List.from(aliasList);
+ collectController.updateLocalCollect(
+ infoController.bangumiItem);
+ if (aliasList.isEmpty) {
+ // pop whole dialog when empty
+ Navigator.of(context).pop();
+ }
+ },
+ child: const Text('确认'),
+ ),
+ ],
+ );
+ },
+ );
+ },
+ icon: Icon(Icons.delete),
+ ),
+ onTap: () {
+ KazumiDialog.dismiss();
+ queryManager.querySource(alias, pluginName);
+ },
+ );
+ }).toList(),
+ );
+ },
+ ),
+ );
+ });
+ }
+
+ void showCustomSearchDialog(String pluginName) {
+ KazumiDialog.show(
+ builder: (context) {
+ final TextEditingController textController = TextEditingController();
+ return AlertDialog(
+ title: const Text('输入别名'),
+ content: TextField(
+ controller: textController,
+ onSubmitted: (keyword) {
+ if (textController.text != '') {
+ infoController.bangumiItem.alias.add(textController.text);
+ KazumiDialog.dismiss();
+ queryManager.querySource(textController.text, pluginName);
+ }
+ },
+ ),
+ actions: [
+ TextButton(
+ onPressed: () {
+ KazumiDialog.dismiss();
+ },
+ child: Text(
+ '取消',
+ style: TextStyle(color: Theme.of(context).colorScheme.outline),
+ ),
+ ),
+ TextButton(
+ onPressed: () {
+ if (textController.text != '') {
+ infoController.bangumiItem.alias.add(textController.text);
+ collectController
+ .updateLocalCollect(infoController.bangumiItem);
+ KazumiDialog.dismiss();
+ queryManager.querySource(textController.text, pluginName);
+ }
+ },
+ child: const Text(
+ '确认',
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return DefaultTabController(
+ length: 3,
+ child: Scaffold(
+ body: Column(
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: TabBar(
+ isScrollable: true,
+ tabAlignment: TabAlignment.center,
+ dividerHeight: 0,
+ controller: widget.tabController,
+ tabs: pluginsController.pluginList
+ .map(
+ (plugin) => Observer(
+ builder: (context) => Tab(
+ child: Row(
+ children: [
+ Text(
+ plugin.name,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontSize: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .fontSize,
+ color: Theme.of(context)
+ .colorScheme
+ .onSurface),
+ ),
+ const SizedBox(width: 5.0),
+ Container(
+ width: 8.0,
+ height: 8.0,
+ decoration: BoxDecoration(
+ color: infoController.pluginSearchStatus[
+ plugin.name] ==
+ 'success'
+ ? Colors.green
+ : (infoController.pluginSearchStatus[
+ plugin.name] ==
+ 'pending')
+ ? Colors.grey
+ : Colors.red,
+ shape: BoxShape.circle,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ )
+ .toList(),
+ ),
+ ),
+ IconButton(
+ onPressed: () {
+ int currentIndex = widget.tabController.index;
+ launchUrl(
+ Uri.parse(pluginsController
+ .pluginList[currentIndex].searchURL
+ .replaceFirst('@keyword', keyword)),
+ mode: LaunchMode.externalApplication,
+ );
+ },
+ icon: const Icon(Icons.open_in_browser_rounded),
+ ),
+ const SizedBox(width: 4),
+ ],
+ ),
+ const Divider(height: 1),
+ Expanded(
+ child: Observer(
+ builder: (context) => TabBarView(
+ controller: widget.tabController,
+ children: List.generate(pluginsController.pluginList.length,
+ (pluginIndex) {
+ var plugin = pluginsController.pluginList[pluginIndex];
+ var cardList = <Widget>[];
+ for (var searchResponse
+ in infoController.pluginSearchResponseList) {
+ if (searchResponse.pluginName == plugin.name) {
+ for (var searchItem in searchResponse.data) {
+ cardList.add(
+ Card(
+ elevation: 0,
+ margin: const EdgeInsets.only(
+ left: 10, right: 10, top: 10),
+ child: InkWell(
+ borderRadius: BorderRadius.circular(12),
+ onTap: () async {
+ KazumiDialog.showLoading(msg: '获取中');
+ videoPageController.currentPlugin = plugin;
+ videoPageController.title = searchItem.name;
+ videoPageController.src = searchItem.src;
+ try {
+ await infoController.queryRoads(
+ searchItem.src, plugin.name);
+ KazumiDialog.dismiss();
+ Modular.to.pushNamed('/video/');
+ } catch (e) {
+ KazumiLogger()
+ .log(Level.error, e.toString());
+ KazumiDialog.dismiss();
+ }
+ },
+ child: Padding(
+ padding: const EdgeInsets.all(20),
+ child: Text(searchItem.name),
+ ),
+ ),
+ ),
+ );
+ }
+ }
+ }
+ return infoController.pluginSearchStatus[plugin.name] ==
+ 'pending'
+ ? const Center(child: CircularProgressIndicator())
+ : (infoController.pluginSearchStatus[plugin.name] ==
+ 'error'
+ ? GeneralErrorWidget(
+ errMsg: '${plugin.name} 检索失败 重试或左右滑动以切换到其他视频来源',
+ actions: [
+ GeneralErrorButton(
+ onPressed: () {
+ queryManager.querySource(
+ keyword, plugin.name);
+ },
+ text: '重试',
+ ),
+ ],
+ )
+ : cardList.isEmpty
+ ? GeneralErrorWidget(
+ errMsg:
+ '${plugin.name} 无结果 使用别名或左右滑动以切换到其他视频来源',
+ actions: [
+ GeneralErrorButton(
+ onPressed: () {
+ showAliasSearchDialog(
+ plugin.name,
+ );
+ },
+ text: '别名检索',
+ ),
+ GeneralErrorButton(
+ onPressed: () {
+ showCustomSearchDialog(
+ plugin.name,
+ );
+ },
+ text: '手动检索',
+ ),
+ ],
+ )
+ : ListView(children: cardList));
+ }),
+ ),
+ ),
+ )
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/player/episode_comments_sheet.dart b/lib/pages/player/episode_comments_sheet.dart
index 49b89d21..3c995084 100644
--- a/lib/pages/player/episode_comments_sheet.dart
+++ b/lib/pages/player/episode_comments_sheet.dart
@@ -83,6 +83,7 @@ class _EpisodeCommentsSheetState extends State<EpisodeCommentsSheet> {
dragDevices: {
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
+ PointerDeviceKind.trackpad
},
),
slivers: [
diff --git a/pubspec.lock b/pubspec.lock
index 387cebc2..ea14f82d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -383,6 +383,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.7.0"
+ equatable:
+ dependency: transitive
+ description:
+ name: equatable
+ sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.7"
expressions:
dependency: transitive
description:
@@ -423,6 +431,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
+ fl_chart:
+ dependency: "direct main"
+ description:
+ name: fl_chart
+ sha256: "5276944c6ffc975ae796569a826c38a62d2abcf264e26b88fa6f482e107f4237"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.70.2"
flutter:
dependency: "direct main"
description: flutter
@@ -1179,6 +1195,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.2"
+ skeletonizer:
+ dependency: "direct main"
+ description:
+ name: skeletonizer
+ sha256: "0dcacc51c144af4edaf37672072156f49e47036becbc394d7c51850c5c1e884b"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.3"
sky_engine:
dependency: transitive
description: flutter
diff --git a/pubspec.yaml b/pubspec.yaml
index b18a7919..1f0d2cf4 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -83,6 +83,8 @@ dependencies:
synchronized: any
flutter_svg: ^2.0.17
antlr4: ^4.13.2
+ fl_chart: ^0.70.2
+ skeletonizer: ^1.4.3
webview_windows:
git:
url: https://github.com/Predidit/flutter-webview-windows.git