Skip to content

Commit

Permalink
fix: 章节显示剧集的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Jul 20, 2023
1 parent 2b089db commit 3fe2d74
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 26 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Miru App
- [x] 扩展设置
- [ ] 漫画小说视频设置
- [ ] 漫画小说历史记录
- [ ] 影视播放记录
- [ ] 影视播放进度
- [ ] 自动搜寻字幕

## 截图

Expand Down
14 changes: 10 additions & 4 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,27 @@
"detail": {
"favorite": "Favorite",
"favorited": "Favorited",
"episodes": "Episodes",
"no-episodes": "No episodes",
"continue-watching": "Continue {episode}",
"watch-now": "Watch Now",
"total-episodes": "Total {total} episodes",
"total-episodes": "Total {total}",
"overview": "Overview",
"cast": "Cast"
},

"video": {
"episodes": "Episodes",
"watch-now": "Watch Now",
"no-episodes": "No episodes",
"already-first": "Already on the first episode",
"already-last": "Already on the last episode",
"play-complete": "Playback complete"
},

"reader": {
"chapters": "Chapters",
"read-now": "Read Now",
"no-chapters": "No chapters"
},

"upgrade": {
"check-update": "Check for Updates",
"new-version": "New version {version} detected",
Expand Down
16 changes: 11 additions & 5 deletions assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,27 @@
"detail": {
"favorite": "收藏",
"favorited": "已收藏",
"episodes": "剧集",
"no-episodes": "暂无剧集",
"continue-watching": "继续观看 {episode}",
"watch-now": "立即观看",
"total-episodes": "共 {total} 集",
"continue-watching": "继续 {episode}",
"total-episodes": "共 {total}",
"overview": "概览",
"cast": "演员"
},

"video": {
"episodes": "剧集",
"watch-now": "立即观看",
"no-episodes": "暂无剧集",
"already-first": "当前已经是第一集",
"already-last": "当前已经是最后一集",
"play-complete": "播放完成"
},

"reader": {
"chapters": "章节",
"read-now": "立即阅读",
"no-chapters": "暂无章节"
},

"upgrade": {
"check-update": "检查更新",
"new-version": "检测到新版本 {version}",
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/detail/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DetailPageController extends GetxController {
final RxString error = ''.obs;
final RxBool isLoading = true.obs;
final RxInt selectEpGroup = 0.obs;
final Rx<ExtensionType> type = ExtensionType.bangumi.obs;

@override
void onInit() {
Expand All @@ -36,6 +37,8 @@ class DetailPageController extends GetxController {
onRefresh() async {
await refreshFavorite();
try {
final runtime = ExtensionUtils.extensions[package];
type.value = runtime!.extension.type;
data.value = await ExtensionUtils.extensions[package]?.detail(url);
// 获取历史记录
final history_ = await DatabaseUtils.getHistoryByPackageAndUrl(
Expand Down
10 changes: 9 additions & 1 deletion lib/pages/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:get/get.dart';
import 'package:miru_app/models/extension.dart';
import 'package:miru_app/pages/detail/controller.dart';
import 'package:miru_app/pages/detail/widgets/detail_appbar_flexible_space.dart';
import 'package:miru_app/pages/detail/widgets/detail_appbar_title.dart';
Expand Down Expand Up @@ -66,6 +67,13 @@ class _DetailPageState extends State<DetailPage> {
}
return Scaffold(
body: Obx(() {
late String episodesString;
if (c.type.value == ExtensionType.bangumi) {
episodesString = 'video.episodes'.i18n;
} else {
episodesString = 'reader.chapters'.i18n;
}

if (c.error.value.isNotEmpty) {
return Center(
child: Text(c.error.value),
Expand All @@ -90,7 +98,7 @@ class _DetailPageState extends State<DetailPage> {
flexibleSpace: const DetailAppbarflexibleSpace(),
bottom: TabBar(
tabs: [
Tab(text: 'detail.episodes'.i18n),
Tab(text: episodesString),
Tab(text: 'detail.overview'.i18n),
Tab(text: 'detail.cast'.i18n),
],
Expand Down
37 changes: 24 additions & 13 deletions lib/pages/detail/widgets/detail_continue_play.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart' as fluent;
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:get/get.dart';
import 'package:miru_app/models/extension.dart';
import 'package:miru_app/pages/detail/controller.dart';
import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/widgets/platform_widget.dart';
Expand All @@ -18,20 +19,30 @@ class _DetailContinuePlayState extends State<DetailContinuePlay> {
late DetailPageController c = Get.find<DetailPageController>();

Widget _buildAndroid(BuildContext context) {
final noEpisodes = FilledButton.icon(
onPressed: () {},
icon: const Icon(Icons.play_arrow),
label: Text('detail.no-episodes'.i18n),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.grey),
foregroundColor: MaterialStateProperty.all(Colors.white),
minimumSize: MaterialStateProperty.all(
const Size(double.infinity, 50),
return Obx(() {
late String noEpisodesString;
late String watchNowString;
if (c.type.value == ExtensionType.bangumi) {
noEpisodesString = 'video.no-episodes'.i18n;
watchNowString = 'video.watch-now'.i18n;
} else {
noEpisodesString = 'reader.no-chapters'.i18n;
watchNowString = 'reader.read-now'.i18n;
}

final noEpisodes = FilledButton.icon(
onPressed: () {},
icon: const Icon(Icons.play_arrow),
label: Text(noEpisodesString),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.grey),
foregroundColor: MaterialStateProperty.all(Colors.white),
minimumSize: MaterialStateProperty.all(
const Size(double.infinity, 50),
),
),
),
);
);

return Obx(() {
final history = c.history.value;
final data = c.data.value;
if (c.isLoading.value) {
Expand Down Expand Up @@ -76,7 +87,7 @@ class _DetailContinuePlayState extends State<DetailContinuePlay> {
);
},
icon: const Icon(Icons.play_arrow),
label: Text('detail.watch-now'.i18n),
label: Text(watchNowString),
style: ButtonStyle(
minimumSize: MaterialStateProperty.all(
const Size(double.infinity, 50),
Expand Down
8 changes: 7 additions & 1 deletion lib/pages/detail/widgets/detail_episodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ class _DetailEpisodesState extends State<DetailEpisodes> {
}

Widget _buildDesktopEpisodes(BuildContext context) {
late String episodesString;
if (c.type.value == ExtensionType.bangumi) {
episodesString = 'video.episodes'.i18n;
} else {
episodesString = 'reader.chapters'.i18n;
}
return CardTile(
title: 'detail.episodes'.i18n,
title: episodesString,
trailing: Row(
children: [
const DetailContinuePlay(),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/watch/widgets/reader/novel/novel_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _NovelReaderState extends State<NovelReader> {
return ReadView<ExtensionFikushonWatch>(
widget.title,
content: NovelReaderContent(widget.title),
buildSettings: (context) => Card(),
buildSettings: (context) => const Card(),
);
// return Obx(
// () => Stack(
Expand Down

0 comments on commit 3fe2d74

Please sign in to comment.