fix(flutter): 修复首页冷启动灰屏
This commit is contained in:
1 parent
37802b24bf
commit
0d2680e6c1
4 files changed
+19
-3
No files matched your search
@@ -16,6 +16,7 @@ class RemoteImage extends StatelessWidget {
|
|||||||
this.showFallbackIcon = false,
|
this.showFallbackIcon = false,
|
||||||
this.fallbackIconKey,
|
this.fallbackIconKey,
|
||||||
this.fallbackAspectRatio,
|
this.fallbackAspectRatio,
|
||||||
|
this.fallbackColor = AppColors.bar,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String path;
|
final String path;
|
||||||
@@ -25,6 +26,7 @@ class RemoteImage extends StatelessWidget {
|
|||||||
final bool showFallbackIcon;
|
final bool showFallbackIcon;
|
||||||
final Key? fallbackIconKey;
|
final Key? fallbackIconKey;
|
||||||
final double? fallbackAspectRatio;
|
final double? fallbackAspectRatio;
|
||||||
|
final Color fallbackColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -47,7 +49,7 @@ class RemoteImage extends StatelessWidget {
|
|||||||
final fallback = Container(
|
final fallback = Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
color: AppColors.bar,
|
color: fallbackColor,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: showFallbackIcon
|
child: showFallbackIcon
|
||||||
? Icon(
|
? Icon(
|
||||||
|
|||||||
@@ -300,6 +300,11 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
|||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
|
if (widget.homeMode)
|
||||||
|
const ColoredBox(
|
||||||
|
key: Key('home-feed-black-background'),
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
if (!ready) _PlayerFallbackBackground(posterUrl: drama.posterUrl),
|
if (!ready) _PlayerFallbackBackground(posterUrl: drama.posterUrl),
|
||||||
?video,
|
?video,
|
||||||
if (widget.homeMode && _chromeVisible && !logic.chromeHidden)
|
if (widget.homeMode && _chromeVisible && !logic.chromeHidden)
|
||||||
@@ -580,10 +585,11 @@ class _PlayerFallbackBackground extends StatelessWidget {
|
|||||||
posterUrl,
|
posterUrl,
|
||||||
key: const Key('player-fallback-cover'),
|
key: const Key('player-fallback-cover'),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
fallbackColor: Colors.black,
|
||||||
),
|
),
|
||||||
const ColoredBox(
|
const ColoredBox(
|
||||||
key: Key('player-fallback-scrim'),
|
key: Key('player-fallback-scrim'),
|
||||||
color: Color(0x66000000),
|
color: Color(0x4D000000),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ void main() {
|
|||||||
|
|
||||||
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
|
||||||
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('home-feed-black-background')), findsOneWidget);
|
||||||
expect(find.byType(PageView), findsOneWidget);
|
expect(find.byType(PageView), findsOneWidget);
|
||||||
expect(find.byKey(const Key('home-browse-page')), findsNothing);
|
expect(find.byKey(const Key('home-browse-page')), findsNothing);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
|||||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||||
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
|
||||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||||
|
import 'package:fruitshorts/core/widgets/remote_image.dart';
|
||||||
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart';
|
||||||
import 'package:fruitshorts/pages/player/widgets/seek_progress_bar.dart';
|
import 'package:fruitshorts/pages/player/widgets/seek_progress_bar.dart';
|
||||||
|
|
||||||
@@ -333,11 +334,17 @@ void main() {
|
|||||||
final fallback = find.byKey(const Key('player-fallback-background'));
|
final fallback = find.byKey(const Key('player-fallback-background'));
|
||||||
expect(fallback, findsOneWidget);
|
expect(fallback, findsOneWidget);
|
||||||
expect(find.byKey(const Key('player-fallback-cover')), findsOneWidget);
|
expect(find.byKey(const Key('player-fallback-cover')), findsOneWidget);
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widget<RemoteImage>(find.byKey(const Key('player-fallback-cover')))
|
||||||
|
.fallbackColor,
|
||||||
|
Colors.black,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
tester
|
tester
|
||||||
.widget<ColoredBox>(find.byKey(const Key('player-fallback-scrim')))
|
.widget<ColoredBox>(find.byKey(const Key('player-fallback-scrim')))
|
||||||
.color,
|
.color,
|
||||||
const Color(0x66000000),
|
const Color(0x4D000000),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
tester
|
tester
|
||||||
|
|||||||
Reference in new issue
Block a user