Skip to content

Commit

Permalink
fix: detail page some error (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint authored Sep 24, 2023
1 parent ea539a0 commit 05522af
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 22 deletions.
24 changes: 17 additions & 7 deletions lib/pages/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class DetailPage extends StatefulWidget {
Key? key,
required this.url,
required this.package,
this.heroTag,
this.tag,
}) : super(key: key);
final String url;
final String package;
final String? heroTag;
final String? tag;

@override
State<DetailPage> createState() => _DetailPageState();
Expand All @@ -46,15 +46,18 @@ class _DetailPageState extends State<DetailPage> {
DetailPageController(
package: widget.package,
url: widget.url,
heroTag: widget.heroTag,
heroTag: widget.tag,
),
tag: widget.tag,
);
super.initState();
}

@override
void dispose() {
Get.delete<DetailPageController>();
Get.delete<DetailPageController>(
tag: widget.tag,
);
super.dispose();
}

Expand Down Expand Up @@ -95,7 +98,9 @@ class _DetailPageState extends State<DetailPage> {
c.detail?.title ?? '',
controller: c.scrollController,
),
flexibleSpace: const DetailAppbarflexibleSpace(),
flexibleSpace: DetailAppbarflexibleSpace(
tag: widget.tag,
),
bottom: TabBar(
tabs: tabs,
),
Expand Down Expand Up @@ -139,8 +144,13 @@ class _DetailPageState extends State<DetailPage> {
padding: const EdgeInsets.all(8),
child: TabBarView(
children: [
if (!LayoutUtils.isTablet) const DetailEpisodes(),
const DetailOverView(),
if (!LayoutUtils.isTablet)
DetailEpisodes(
tag: widget.tag,
),
DetailOverView(
tag: widget.tag,
),
if (c.type == ExtensionType.bangumi)
Obx(() {
if (c.tmdbDetail == null || c.tmdbDetail!.casts.isEmpty) {
Expand Down
21 changes: 15 additions & 6 deletions lib/pages/detail/widgets/detail_appbar_flexible_space.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import 'package:miru_app/widgets/cover.dart';
class DetailAppbarflexibleSpace extends StatefulWidget {
const DetailAppbarflexibleSpace({
Key? key,
this.tag,
}) : super(key: key);

final String? tag;

@override
State<DetailAppbarflexibleSpace> createState() =>
_DetailAppbarflexibleSpaceState();
}

class _DetailAppbarflexibleSpaceState extends State<DetailAppbarflexibleSpace> {
final DetailPageController c = Get.find();
late DetailPageController c = Get.find(tag: widget.tag);

double _offset = 1;

Expand Down Expand Up @@ -122,15 +125,17 @@ class _DetailAppbarflexibleSpaceState extends State<DetailAppbarflexibleSpace> {
style: Get.theme.textTheme.titleLarge,
),
const SizedBox(height: 10),
const DetailExtensionTile(),
DetailExtensionTile(
tag: widget.tag,
),
],
),
),
)
],
),
),
const Positioned(
Positioned(
top: null,
left: 20,
right: 20,
Expand All @@ -139,14 +144,18 @@ class _DetailAppbarflexibleSpaceState extends State<DetailAppbarflexibleSpace> {
children: [
Expanded(
flex: 4,
child: DetailContinuePlay(),
child: DetailContinuePlay(
tag: widget.tag,
),
),
SizedBox(
const SizedBox(
width: 10,
),
Expanded(
flex: 3,
child: DetailFavoriteButton(),
child: DetailFavoriteButton(
tag: widget.tag,
),
)
],
),
Expand Down
5 changes: 4 additions & 1 deletion lib/pages/detail/widgets/detail_continue_play.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import 'package:miru_app/widgets/platform_widget.dart';
class DetailContinuePlay extends StatefulWidget {
const DetailContinuePlay({
Key? key,
this.tag,
}) : super(key: key);
final String? tag;

@override
State<DetailContinuePlay> createState() => _DetailContinuePlayState();
}

class _DetailContinuePlayState extends State<DetailContinuePlay> {
late DetailPageController c = Get.find<DetailPageController>();
late DetailPageController c = Get.find<DetailPageController>(tag: widget.tag);

Widget _buildAndroid(BuildContext context) {
return Obx(() {
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/detail/widgets/detail_episodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import 'package:miru_app/widgets/platform_widget.dart';
class DetailEpisodes extends StatefulWidget {
const DetailEpisodes({
Key? key,
this.tag,
}) : super(key: key);
final String? tag;

@override
State<DetailEpisodes> createState() => _DetailEpisodesState();
}

class _DetailEpisodesState extends State<DetailEpisodes> {
late DetailPageController c = Get.find<DetailPageController>();
late DetailPageController c = Get.find<DetailPageController>(tag: widget.tag);
List<fluent.ComboBoxItem<int>>? comboBoxItems;
List<DropdownMenuItem<int>>? dropdownItems;
late List<ExtensionEpisodeGroup> episodes = [];
Expand Down
9 changes: 7 additions & 2 deletions lib/pages/detail/widgets/detail_extension_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import 'package:miru_app/utils/extension.dart';
import 'package:miru_app/widgets/cache_network_image.dart';

class DetailExtensionTile extends StatelessWidget {
const DetailExtensionTile({Key? key}) : super(key: key);
const DetailExtensionTile({
Key? key,
this.tag,
}) : super(key: key);

final String? tag;

@override
Widget build(BuildContext context) {
final c = Get.find<DetailPageController>();
final c = Get.find<DetailPageController>(tag: tag);
return Obx(() {
if (c.extension == null) {
return Text(FlutterI18n.translate(
Expand Down
8 changes: 6 additions & 2 deletions lib/pages/detail/widgets/detail_favorite_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/widgets/platform_widget.dart';

class DetailFavoriteButton extends StatefulWidget {
const DetailFavoriteButton({Key? key}) : super(key: key);
const DetailFavoriteButton({
Key? key,
this.tag,
}) : super(key: key);
final String? tag;

@override
fluent.State<DetailFavoriteButton> createState() =>
_DetailFavoriteButtonState();
}

class _DetailFavoriteButtonState extends State<DetailFavoriteButton> {
final c = Get.find<DetailPageController>();
late DetailPageController c = Get.find<DetailPageController>(tag: widget.tag);

Widget _buildAndroid(BuildContext context) {
return Obx(
Expand Down
9 changes: 7 additions & 2 deletions lib/pages/detail/widgets/detail_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import 'package:miru_app/utils/i18n.dart';
import 'package:miru_app/widgets/cache_network_image.dart';

class DetailOverView extends StatelessWidget {
const DetailOverView({Key? key}) : super(key: key);
const DetailOverView({
Key? key,
this.tag,
}) : super(key: key);

final String? tag;

@override
Widget build(BuildContext context) {
final c = Get.find<DetailPageController>();
final c = Get.find<DetailPageController>(tag: tag);
return Padding(
padding: const EdgeInsets.only(
left: 16,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/extension_item_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _ExtensionItemCardState extends State<ExtensionItemCard> {
Get.to(DetailPage(
url: widget.url,
package: widget.package,
heroTag: widget.url,
tag: widget.url,
));
},
),
Expand Down

0 comments on commit 05522af

Please sign in to comment.