opt: code

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-03 21:23:55 +08:00
parent 1d51db0a62
commit 321b7933d7
11 changed files with 139 additions and 134 deletions

View File

@@ -4,12 +4,14 @@ class CustomSliverPersistentHeaderDelegate
extends SliverPersistentHeaderDelegate { extends SliverPersistentHeaderDelegate {
CustomSliverPersistentHeaderDelegate({ CustomSliverPersistentHeaderDelegate({
required this.child, required this.child,
required this.bgColor,
double extent = 45, double extent = 45,
}) : _minExtent = extent, }) : _minExtent = extent,
_maxExtent = extent; _maxExtent = extent;
final double _minExtent; final double _minExtent;
final double _maxExtent; final double _maxExtent;
final Widget child; final Widget child;
final Color bgColor;
@override @override
Widget build( Widget build(
@@ -17,7 +19,10 @@ class CustomSliverPersistentHeaderDelegate
//创建child子组件 //创建child子组件
//shrinkOffsetchild偏移值minExtent~maxExtent //shrinkOffsetchild偏移值minExtent~maxExtent
//overlapsContentSliverPersistentHeader覆盖其他子组件返回true否则返回false //overlapsContentSliverPersistentHeader覆盖其他子组件返回true否则返回false
return child; return ColoredBox(
color: bgColor,
child: child,
);
} }
//SliverPersistentHeader最大高度 //SliverPersistentHeader最大高度
@@ -31,6 +36,6 @@ class CustomSliverPersistentHeaderDelegate
@override @override
bool shouldRebuild( bool shouldRebuild(
covariant CustomSliverPersistentHeaderDelegate oldDelegate) { covariant CustomSliverPersistentHeaderDelegate oldDelegate) {
return true; return oldDelegate.bgColor != bgColor;
} }
} }

View File

@@ -11,35 +11,35 @@ extension BusinessTypeExtension on DynamicsType {
String get labels => ['全部', '投稿', '番剧', '专栏', 'UP'][index]; String get labels => ['全部', '投稿', '番剧', '专栏', 'UP'][index];
} }
List tabsConfig = [ List get tabsConfig => [
{ {
'tag': 'all', 'tag': 'all',
'value': DynamicsType.all, 'value': DynamicsType.all,
'label': '全部', 'label': '全部',
'enabled': true, 'enabled': true,
}, },
{ {
'tag': 'video', 'tag': 'video',
'value': DynamicsType.video, 'value': DynamicsType.video,
'label': '投稿', 'label': '投稿',
'enabled': true, 'enabled': true,
}, },
{ {
'tag': 'pgc', 'tag': 'pgc',
'value': DynamicsType.pgc, 'value': DynamicsType.pgc,
'label': '番剧', 'label': '番剧',
'enabled': true, 'enabled': true,
}, },
{ {
'tag': 'article', 'tag': 'article',
'value': DynamicsType.article, 'value': DynamicsType.article,
'label': '专栏', 'label': '专栏',
'enabled': true, 'enabled': true,
}, },
{ {
'tag': 'up', 'tag': 'up',
'value': DynamicsType.up, 'value': DynamicsType.up,
'label': 'UP', 'label': 'UP',
'enabled': true, 'enabled': true,
}, },
]; ];

View File

@@ -1,43 +1,43 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
List defaultNavigationBars = [ List get defaultNavigationBars => [
{ {
'id': 0, 'id': 0,
'icon': const Icon( 'icon': const Icon(
Icons.home_outlined, Icons.home_outlined,
size: 23, size: 23,
), ),
'selectIcon': const Icon( 'selectIcon': const Icon(
Icons.home, Icons.home,
size: 23, size: 23,
), ),
'label': "首页", 'label': "首页",
'count': 0, 'count': 0,
}, },
{ {
'id': 1, 'id': 1,
'icon': const Icon( 'icon': const Icon(
Icons.motion_photos_on_outlined, Icons.motion_photos_on_outlined,
size: 21, size: 21,
), ),
'selectIcon': const Icon( 'selectIcon': const Icon(
Icons.motion_photos_on, Icons.motion_photos_on,
size: 21, size: 21,
), ),
'label': "动态", 'label': "动态",
'count': 0, 'count': 0,
}, },
{ {
'id': 2, 'id': 2,
'icon': const Icon( 'icon': const Icon(
Icons.video_collection_outlined, Icons.video_collection_outlined,
size: 21, size: 21,
), ),
'selectIcon': const Icon( 'selectIcon': const Icon(
Icons.video_collection, Icons.video_collection,
size: 21, size: 21,
), ),
'label': "媒体库", 'label': "媒体库",
'count': 0, 'count': 0,
} }
]; ];

View File

@@ -13,55 +13,55 @@ extension TabTypeDesc on TabType {
String get id => ['live', 'rcmd', 'hot', 'rank', 'bangumi'][index]; String get id => ['live', 'rcmd', 'hot', 'rank', 'bangumi'][index];
} }
List tabsConfig = [ List get tabsConfig => [
{ {
'icon': const Icon( 'icon': const Icon(
Icons.live_tv_outlined, Icons.live_tv_outlined,
size: 15, size: 15,
), ),
'label': '直播', 'label': '直播',
'type': TabType.live, 'type': TabType.live,
'ctr': Get.find<LiveController>, 'ctr': Get.find<LiveController>,
'page': const RcmdPage(tabType: TabType.live), 'page': const RcmdPage(tabType: TabType.live),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.thumb_up_off_alt_outlined, Icons.thumb_up_off_alt_outlined,
size: 15, size: 15,
), ),
'label': '推荐', 'label': '推荐',
'type': TabType.rcmd, 'type': TabType.rcmd,
'ctr': Get.find<RcmdController>, 'ctr': Get.find<RcmdController>,
'page': const RcmdPage(tabType: TabType.rcmd), 'page': const RcmdPage(tabType: TabType.rcmd),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.whatshot_outlined, Icons.whatshot_outlined,
size: 15, size: 15,
), ),
'label': '热门', 'label': '热门',
'type': TabType.hot, 'type': TabType.hot,
'ctr': Get.find<HotController>, 'ctr': Get.find<HotController>,
'page': const HotPage(), 'page': const HotPage(),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.category_outlined, Icons.category_outlined,
size: 15, size: 15,
), ),
'label': '分区', 'label': '分区',
'type': TabType.rank, 'type': TabType.rank,
'ctr': Get.find<RankController>, 'ctr': Get.find<RankController>,
'page': const RankPage(), 'page': const RankPage(),
}, },
{ {
'icon': const Icon( 'icon': const Icon(
Icons.play_circle_outlined, Icons.play_circle_outlined,
size: 15, size: 15,
), ),
'label': '番剧', 'label': '番剧',
'type': TabType.bangumi, 'type': TabType.bangumi,
'ctr': Get.find<BangumiController>, 'ctr': Get.find<BangumiController>,
'page': const BangumiPage(), 'page': const BangumiPage(),
}, },
]; ];

View File

@@ -400,8 +400,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
SliverPersistentHeader replyPersistentHeader(BuildContext context) { SliverPersistentHeader replyPersistentHeader(BuildContext context) {
return SliverPersistentHeader( return SliverPersistentHeader(
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
color: Theme.of(context).colorScheme.surface,
height: 45, height: 45,
padding: const EdgeInsets.only(left: 12, right: 6), padding: const EdgeInsets.only(left: 12, right: 6),
child: Row( child: Row(

View File

@@ -73,10 +73,10 @@ class _MemberVideoState extends State<MemberVideo>
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 40, extent: 40,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 40, height: 40,
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0), padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
color: Theme.of(context).colorScheme.surface,
child: Row( child: Row(
children: [ children: [
Obx( Obx(

View File

@@ -28,9 +28,9 @@ Widget searchArticlePanel(context, searchPanelCtr, LoadingState loadingState) {
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 40, extent: 40,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 40, height: 40,
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.only(left: 25, right: 12), padding: const EdgeInsets.only(left: 25, right: 12),
child: Row( child: Row(
children: [ children: [

View File

@@ -26,9 +26,9 @@ Widget searchUserPanel(context, searchPanelCtr, LoadingState loadingState) {
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 40, extent: 40,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 40, height: 40,
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.only(left: 25, right: 12), padding: const EdgeInsets.only(left: 25, right: 12),
child: Row( child: Row(
children: [ children: [

View File

@@ -24,9 +24,9 @@ Widget searchVideoPanel(context, ctr, LoadingState loadingState) {
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 34, extent: 34,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 34, height: 34,
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.symmetric(horizontal: 12), padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row( child: Row(
children: [ children: [

View File

@@ -112,10 +112,10 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 40, extent: 40,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 40, height: 40,
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0), padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
color: Theme.of(context).colorScheme.surface,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [

View File

@@ -134,10 +134,10 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
floating: true, floating: true,
delegate: CustomSliverPersistentHeaderDelegate( delegate: CustomSliverPersistentHeaderDelegate(
extent: 40, extent: 40,
bgColor: Theme.of(context).colorScheme.surface,
child: Container( child: Container(
height: 40, height: 40,
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0), padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
color: Theme.of(context).colorScheme.surface,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [