Skip to content

Commit 292dc5b

Browse files
committed
feat: improve video screen performances on web
1 parent 2714e14 commit 292dc5b

File tree

2 files changed

+68
-85
lines changed

2 files changed

+68
-85
lines changed

lib/Screens/videos.dart

Lines changed: 67 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'package:cached_network_image/cached_network_image.dart';
2828
import 'package:flutter/foundation.dart';
2929
import 'package:flutter/material.dart';
3030
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
31+
import 'package:go_router/go_router.dart';
3132
import 'package:hive_flutter/hive_flutter.dart';
3233
import "package:story_view/story_view.dart";
3334
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
@@ -257,100 +258,82 @@ class VideoItem extends StatelessWidget {
257258
builder: (isHovered) => PhysicalModel(
258259
color: Colors.transparent,
259260
elevation: isHovered ? 16 : 0,
260-
child: Card(
261-
elevation: 5.0,
262-
color: Colors.transparent,
263-
child: OpenContainer(
264-
closedColor: Colors.transparent,
265-
openColor: Colors.transparent,
266-
transitionDuration: const Duration(milliseconds: 500),
267-
openBuilder: (context, action) => Swiper(
268-
itemBuilder: (context, index) {
269-
return VideoScreen(videos[index]);
270-
},
271-
itemCount: videos.length,
272-
scrollDirection: Axis.vertical,
273-
control: SwiperControl(
274-
disableColor: Theme.of(context).primaryColor,
275-
),
276-
index: index,
277-
loop: false,
278-
),
279-
closedBuilder: (context, action) => Stack(
280-
alignment: Alignment.bottomLeft,
281-
children: [
282-
ClipRRect(
283-
borderRadius: const BorderRadius.all(
284-
Radius.circular(10),
261+
child: GestureDetector(
262+
onTap: () => context.pushNamed(
263+
'video',
264+
pathParameters: {'id': videos[index].videoId},
265+
extra: {'video': videos[index]},
266+
),
267+
child: Stack(
268+
alignment: Alignment.bottomLeft,
269+
children: [
270+
ClipRRect(
271+
borderRadius: const BorderRadius.all(
272+
Radius.circular(10),
273+
),
274+
child: CachedNetworkImage(
275+
imageUrl: videos[index].thumbnailUrl,
276+
placeholder: (context, url) =>
277+
const LoadingIndicatorUtil(
278+
replaceImage: true,
285279
),
286-
child: CachedNetworkImage(
287-
imageUrl: videos[index].thumbnailUrl,
288-
placeholder: (context, url) => SizedBox(
289-
height:
290-
MediaQuery.of(context).size.width / (16 / 9) -
291-
7,
292-
child: const LoadingIndicatorUtil(
293-
replaceImage: true,
294-
),
295-
),
296-
errorWidget: (context, url, error) => Icon(
297-
Icons.error_outlined,
298-
),
299-
fadeOutDuration: const Duration(seconds: 1),
300-
fadeInDuration: const Duration(seconds: 1),
301-
colorBlendMode: BlendMode.darken,
302-
color: Colors.black.withOpacity(0.5),
280+
errorWidget: (context, url, error) => Icon(
281+
Icons.error_outlined,
303282
),
283+
fadeOutDuration: const Duration(seconds: 1),
284+
fadeInDuration: const Duration(seconds: 1),
285+
colorBlendMode: BlendMode.darken,
286+
color: Colors.black.withOpacity(0.5),
304287
),
305-
Padding(
306-
padding: const EdgeInsets.fromLTRB(15, 0, 20, 15),
307-
child: Column(
308-
mainAxisSize: MainAxisSize.min,
309-
mainAxisAlignment: MainAxisAlignment.end,
310-
crossAxisAlignment: CrossAxisAlignment.start,
311-
children: [
312-
const Padding(
313-
padding: EdgeInsets.only(
314-
bottom: 8,
315-
),
316-
child: Icon(
317-
Icons.play_circle_fill_rounded,
288+
),
289+
Padding(
290+
padding: const EdgeInsets.fromLTRB(15, 0, 20, 15),
291+
child: Column(
292+
mainAxisSize: MainAxisSize.min,
293+
mainAxisAlignment: MainAxisAlignment.end,
294+
crossAxisAlignment: CrossAxisAlignment.start,
295+
children: [
296+
const Padding(
297+
padding: EdgeInsets.only(
298+
bottom: 8,
299+
),
300+
child: Icon(
301+
Icons.play_circle_fill_rounded,
302+
color: Colors.white,
303+
size: 40,
304+
),
305+
),
306+
Padding(
307+
padding: const EdgeInsets.only(
308+
left: 5,
309+
bottom: 2,
310+
),
311+
child: Text(
312+
videos[index].videoDuration,
313+
style: const TextStyle(
318314
color: Colors.white,
319-
size: 40,
320315
),
321316
),
322-
Padding(
323-
padding: const EdgeInsets.only(
324-
left: 5,
325-
bottom: 2,
326-
),
327-
child: Text(
328-
videos[index].videoDuration,
329-
style: const TextStyle(
330-
color: Colors.white,
331-
),
332-
),
317+
),
318+
Padding(
319+
padding: const EdgeInsets.only(
320+
left: 5,
333321
),
334-
Padding(
335-
padding: const EdgeInsets.only(
336-
left: 5,
337-
),
338-
child: Text(
339-
videos[index].caption,
340-
maxLines: 2,
341-
overflow: TextOverflow.ellipsis,
342-
style: const TextStyle(
343-
color: Colors.white,
344-
fontWeight: FontWeight.w500,
345-
fontSize: 22,
346-
),
322+
child: Text(
323+
videos[index].caption,
324+
maxLines: 2,
325+
overflow: TextOverflow.ellipsis,
326+
style: const TextStyle(
327+
color: Colors.white,
328+
fontWeight: FontWeight.w500,
329+
fontSize: 22,
347330
),
348331
),
349-
],
350-
),
332+
),
333+
],
351334
),
352-
],
353-
),
335+
),
336+
],
354337
),
355338
),
356339
),

lib/config/router.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class RouterLocalConfig {
8383
return VideoScreen(
8484
extras['video'],
8585
update: extras['update'] ?? null,
86-
videoChampionship: extras['videoChampionship'] ?? '',
86+
videoChampionship: extras['videoChampionship'] ?? null,
8787
);
8888
} else {
8989
return VideoScreenFromId(state.pathParameters['id']!);

0 commit comments

Comments
 (0)