Skip to content

Commit 4aa8901

Browse files
authored
feat: text cover (#75)
* feat: text cover * fix(android): detail background error
1 parent 1476c58 commit 4aa8901

19 files changed

+273
-147
lines changed

lib/models/extension.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ class ExtensionListItem {
7575
ExtensionListItem({
7676
required this.title,
7777
required this.url,
78-
required this.cover,
78+
this.cover,
7979
this.update,
8080
this.headers,
8181
});
8282

8383
final String title;
8484
final String url;
85-
final String cover;
85+
final String? cover;
8686
final String? update;
8787
late Map<String, String>? headers;
8888

@@ -98,14 +98,14 @@ class ExtensionListItem {
9898
class ExtensionDetail {
9999
ExtensionDetail({
100100
required this.title,
101-
required this.cover,
101+
this.cover,
102102
this.desc,
103103
this.episodes,
104104
this.headers,
105105
});
106106

107107
final String title;
108-
final String cover;
108+
final String? cover;
109109
final String? desc;
110110
final List<ExtensionEpisodeGroup>? episodes;
111111
late Map<String, String>? headers;

lib/models/extension.g.dart

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/favorite.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class Favorite {
1212
@Enumerated(EnumType.name)
1313
late ExtensionType type;
1414
late String title;
15-
late String cover;
15+
String? cover;
1616
DateTime date = DateTime.now();
1717
}

lib/models/favorite.g.dart

Lines changed: 30 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/history.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class History {
1010
late String package;
1111
late String url;
1212
// 截图,保存封面地址
13-
late String cover;
13+
String? cover;
1414
@Enumerated(EnumType.name)
1515
late ExtensionType type;
1616
// 不同线路

lib/models/history.g.dart

Lines changed: 30 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/pages/detail/controller.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class DetailPageController extends GetxController {
5555
TMDBDetail? get tmdbDetail => tmdb.value;
5656
set tmdbDetail(TMDBDetail? value) => tmdb.value = value;
5757

58-
String get backgorund {
59-
String bg = '';
58+
String? get backgorund {
59+
String? bg;
6060
if (tmdbDetail != null && tmdbDetail!.backdrop != null) {
6161
bg = TmdbApi.getImageUrl(tmdbDetail!.backdrop!) ?? '';
6262
} else {
63-
bg = detail?.cover ?? '';
63+
bg = detail?.cover;
6464
}
6565
return bg;
6666
}

lib/pages/detail/view.dart

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'package:miru_app/utils/i18n.dart';
1717
import 'package:miru_app/utils/layout.dart';
1818
import 'package:miru_app/widgets/cache_network_image.dart';
1919
import 'package:miru_app/widgets/card_tile.dart';
20+
import 'package:miru_app/widgets/cover.dart';
2021
import 'package:miru_app/widgets/platform_widget.dart';
2122
import 'package:miru_app/widgets/progress.dart';
2223
import 'package:url_launcher/url_launcher.dart';
@@ -232,11 +233,10 @@ class _DetailPageState extends State<DetailPage> {
232233
return Stack(
233234
children: [
234235
Animate(
235-
child: CacheNetWorkImage(
236-
c.backgorund,
237-
width: double.infinity,
238-
height: double.infinity,
239-
headers: c.detail?.headers,
236+
child: Cover(
237+
alt: c.detail?.title ?? '',
238+
url: c.backgorund,
239+
noText: true,
240240
),
241241
).blur(
242242
begin: const Offset(10, 10),
@@ -260,24 +260,25 @@ class _DetailPageState extends State<DetailPage> {
260260
height: 330,
261261
child: Row(
262262
children: [
263-
if (constraints.maxWidth > 600) ...[
264-
Hero(
265-
tag: c.heroTag ?? '',
266-
child: Container(
267-
width: 230,
268-
height: double.infinity,
269-
clipBehavior: Clip.antiAlias,
270-
decoration: BoxDecoration(
271-
borderRadius: BorderRadius.circular(8),
272-
),
273-
child: CacheNetWorkImage(
274-
c.detail?.cover ?? '',
275-
headers: c.detail?.headers,
263+
if (c.detail!.cover != null)
264+
if (constraints.maxWidth > 600) ...[
265+
Hero(
266+
tag: c.heroTag ?? '',
267+
child: Container(
268+
width: 230,
269+
height: double.infinity,
270+
clipBehavior: Clip.antiAlias,
271+
decoration: BoxDecoration(
272+
borderRadius: BorderRadius.circular(8),
273+
),
274+
child: CacheNetWorkImage(
275+
c.detail?.cover ?? '',
276+
headers: c.detail?.headers,
277+
),
276278
),
277279
),
278-
),
279-
const SizedBox(width: 30),
280-
],
280+
const SizedBox(width: 30),
281+
],
281282
Expanded(
282283
child: Column(
283284
crossAxisAlignment: CrossAxisAlignment.start,

0 commit comments

Comments
 (0)