diff --git a/lib/pages/video/zone/video_zone_page.dart b/lib/pages/video/zone/video_zone_page.dart index 27d6279..cf57f3f 100644 --- a/lib/pages/video/zone/video_zone_page.dart +++ b/lib/pages/video/zone/video_zone_page.dart @@ -83,11 +83,19 @@ class _VideoZonePageState extends State { builder: (context, constraints) { final horizontalPadding = 30.w; final crossAxisSpacing = 12.w; + final titleStyle = _VideoCard.createTitleStyle(context); + final titlePainter = TextPainter( + text: TextSpan(text: '视频标题', style: titleStyle), + maxLines: 1, + textDirection: Directionality.of(context), + textScaler: MediaQuery.textScalerOf(context), + )..layout(); final cardWidth = (constraints.maxWidth - horizontalPadding * 2 - crossAxisSpacing * 2) / 3; - final cardHeight = cardWidth * 9 / 16 + 5.h + 24.h; + final cardHeight = + cardWidth * 9 / 16 + 5.h + titlePainter.height; return GridView.builder( physics: const AlwaysScrollableScrollPhysics(), padding: EdgeInsets.fromLTRB( @@ -106,6 +114,7 @@ class _VideoZonePageState extends State { itemBuilder: (context, index) => _VideoCard( item: items[index], onTap: () => _openVideo(items, index), + titleStyle: titleStyle, ), ); }, @@ -169,10 +178,22 @@ class _VideoLoadError extends StatelessWidget { } class _VideoCard extends StatelessWidget { - const _VideoCard({required this.item, required this.onTap}); + const _VideoCard({ + required this.item, + required this.onTap, + required this.titleStyle, + }); final VideoZoneItem item; final VoidCallback onTap; + final TextStyle titleStyle; + + static TextStyle createTitleStyle(BuildContext context) => TextStyle( + color: const Color(0xFF222222), + fontFamily: null, + fontSize: 17.sp, + fontWeight: FontWeight.w500, + ); @override Widget build(BuildContext context) { @@ -202,22 +223,11 @@ class _VideoCard extends StatelessWidget { ), ), SizedBox(height: 5.h), - SizedBox( - height: 24.h, - child: Align( - alignment: Alignment.centerLeft, - child: Text( - item.title, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: const Color(0xFF222222), - fontFamily: null, - fontSize: 17.sp, - fontWeight: FontWeight.w500, - ), - ), - ), + Text( + item.title, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: titleStyle, ), ], ),