Commit 5bc84efff2a8b34553ae4b6d8d27b7419970d017
1 parent
3154647c
Revert "feat: 优化视频专区列表布局与沉浸体验"
This reverts commit 9475aa49.
Showing
1 changed file
with
9 additions
and
48 deletions
lib/pages/video/zone/video_zone_page.dart
| 1 | -import 'dart:async'; | |
| 2 | - | |
| 3 | 1 | import 'package:cached_network_image/cached_network_image.dart'; |
| 4 | 2 | import 'package:flutter/material.dart'; |
| 5 | -import 'package:flutter/services.dart'; | |
| 6 | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 7 | 4 | import 'package:wow_english/common/dialogs/show_dialog.dart'; |
| 8 | 5 | import 'package:wow_english/common/request/dao/video_dao.dart'; |
| ... | ... | @@ -24,20 +21,9 @@ class _VideoZonePageState extends State<VideoZonePage> { |
| 24 | 21 | @override |
| 25 | 22 | void initState() { |
| 26 | 23 | super.initState(); |
| 27 | - unawaited( | |
| 28 | - SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky), | |
| 29 | - ); | |
| 30 | 24 | _itemsFuture = VideoDao.list(); |
| 31 | 25 | } |
| 32 | 26 | |
| 33 | - @override | |
| 34 | - void dispose() { | |
| 35 | - unawaited( | |
| 36 | - SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky), | |
| 37 | - ); | |
| 38 | - super.dispose(); | |
| 39 | - } | |
| 40 | - | |
| 41 | 27 | void _reload() { |
| 42 | 28 | setState(() { |
| 43 | 29 | _itemsFuture = VideoDao.list(); |
| ... | ... | @@ -46,10 +32,7 @@ class _VideoZonePageState extends State<VideoZonePage> { |
| 46 | 32 | |
| 47 | 33 | @override |
| 48 | 34 | Widget build(BuildContext context) { |
| 49 | - return MediaQuery.removePadding( | |
| 50 | - context: context, | |
| 51 | - removeTop: true, | |
| 52 | - child: Scaffold( | |
| 35 | + return Scaffold( | |
| 53 | 36 | backgroundColor: Colors.white, |
| 54 | 37 | appBar: const WEAppBar( |
| 55 | 38 | titleText: '视频专区', |
| ... | ... | @@ -81,34 +64,20 @@ class _VideoZonePageState extends State<VideoZonePage> { |
| 81 | 64 | }, |
| 82 | 65 | child: LayoutBuilder( |
| 83 | 66 | builder: (context, constraints) { |
| 84 | - final horizontalPadding = 30.w; | |
| 85 | - final crossAxisSpacing = 12.w; | |
| 86 | 67 | final titleStyle = _VideoCard.createTitleStyle(context); |
| 87 | - final titlePainter = TextPainter( | |
| 88 | - text: TextSpan(text: '视频标题', style: titleStyle), | |
| 89 | - maxLines: 1, | |
| 90 | - textDirection: Directionality.of(context), | |
| 91 | - textScaler: MediaQuery.textScalerOf(context), | |
| 92 | - )..layout(); | |
| 93 | - final cardWidth = (constraints.maxWidth - | |
| 94 | - horizontalPadding * 2 - | |
| 95 | - crossAxisSpacing * 2) / | |
| 96 | - 3; | |
| 97 | - final cardHeight = | |
| 98 | - cardWidth * 9 / 16 + 5.h + titlePainter.height; | |
| 99 | 68 | return GridView.builder( |
| 100 | 69 | physics: const AlwaysScrollableScrollPhysics(), |
| 101 | 70 | padding: EdgeInsets.fromLTRB( |
| 102 | - horizontalPadding, | |
| 71 | + 14.w, | |
| 103 | 72 | 10.h, |
| 104 | - horizontalPadding, | |
| 73 | + 14.w, | |
| 105 | 74 | 16.h, |
| 106 | 75 | ), |
| 107 | 76 | gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
| 108 | - crossAxisCount: 3, | |
| 77 | + crossAxisCount: 4, | |
| 109 | 78 | mainAxisSpacing: 14.h, |
| 110 | - crossAxisSpacing: crossAxisSpacing, | |
| 111 | - mainAxisExtent: cardHeight, | |
| 79 | + crossAxisSpacing: 12.w, | |
| 80 | + childAspectRatio: 1.55, | |
| 112 | 81 | ), |
| 113 | 82 | itemCount: items.length, |
| 114 | 83 | itemBuilder: (context, index) => _VideoCard( |
| ... | ... | @@ -122,8 +91,7 @@ class _VideoZonePageState extends State<VideoZonePage> { |
| 122 | 91 | ); |
| 123 | 92 | }, |
| 124 | 93 | ), |
| 125 | - ), | |
| 126 | - ); | |
| 94 | + ); | |
| 127 | 95 | } |
| 128 | 96 | |
| 129 | 97 | void _openVideo(List<VideoZoneItem> items, int index) { |
| ... | ... | @@ -144,13 +112,7 @@ class _VideoZonePageState extends State<VideoZonePage> { |
| 144 | 112 | .toList(), |
| 145 | 113 | 'initialVideoId': item.id, |
| 146 | 114 | }, |
| 147 | - ).then((_) { | |
| 148 | - if (!mounted) return; | |
| 149 | - unawaited( | |
| 150 | - SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky), | |
| 151 | - ); | |
| 152 | - _reload(); | |
| 153 | - }); | |
| 115 | + ).then((_) => _reload()); | |
| 154 | 116 | } |
| 155 | 117 | } |
| 156 | 118 | |
| ... | ... | @@ -203,8 +165,7 @@ class _VideoCard extends StatelessWidget { |
| 203 | 165 | child: Column( |
| 204 | 166 | crossAxisAlignment: CrossAxisAlignment.start, |
| 205 | 167 | children: [ |
| 206 | - AspectRatio( | |
| 207 | - aspectRatio: 16 / 9, | |
| 168 | + Expanded( | |
| 208 | 169 | child: ClipRRect( |
| 209 | 170 | borderRadius: BorderRadius.circular(12.r), |
| 210 | 171 | child: CachedNetworkImage( | ... | ... |