Merge branch 'fix-seasonChange'

This commit is contained in:
guozhigq
2024-11-11 22:28:33 +08:00

View File

@ -105,7 +105,8 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
List<ScrollController>? _listScrollControllerList; List<ScrollController>? _listScrollControllerList;
final String heroTag = Get.arguments['heroTag']; final String heroTag = Get.arguments['heroTag'];
VideoDetailController? _videoDetailController; VideoDetailController? _videoDetailController;
late RxInt isSubscribe = (-1).obs; RxInt isSubscribe = (-1).obs;
bool isVisible = false;
@override @override
void initState() { void initState() {
@ -224,6 +225,13 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
} }
} }
// 更改展开状态
void _changeVisible() {
setState(() {
isVisible = !isVisible;
});
}
@override @override
void dispose() { void dispose() {
try { try {
@ -255,7 +263,9 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
UgcSeasonBuild( UgcSeasonBuild(
ugcSeason: widget.ugcSeason!, ugcSeason: widget.ugcSeason!,
isSubscribe: isSubscribe, isSubscribe: isSubscribe,
isVisible: isVisible,
changeFucCall: _changeSubscribeStatus, changeFucCall: _changeSubscribeStatus,
changeVisible: _changeVisible,
), ),
], ],
Expanded( Expanded(
@ -325,7 +335,10 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
Widget buildTabBar() { Widget buildTabBar() {
return Column( return Column(
children: [ children: [
TabBar( // 背景色
Container(
color: Theme.of(context).colorScheme.surface,
child: TabBar(
controller: tabController, controller: tabController,
isScrollable: true, isScrollable: true,
indicatorSize: TabBarIndicatorSize.label, indicatorSize: TabBarIndicatorSize.label,
@ -339,6 +352,7 @@ class _PagesBottomSheetState extends State<PagesBottomSheet>
}).toList() }).toList()
], ],
), ),
),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
controller: tabController, controller: tabController,
@ -678,46 +692,52 @@ class EpisodeGridItem extends StatelessWidget {
class UgcSeasonBuild extends StatelessWidget { class UgcSeasonBuild extends StatelessWidget {
final UgcSeason ugcSeason; final UgcSeason ugcSeason;
final RxInt isSubscribe; final RxInt isSubscribe;
final bool isVisible;
final Function changeFucCall; final Function changeFucCall;
final Function changeVisible;
const UgcSeasonBuild({ const UgcSeasonBuild({
Key? key, Key? key,
required this.ugcSeason, required this.ugcSeason,
required this.isSubscribe, required this.isSubscribe,
required this.isVisible,
required this.changeFucCall, required this.changeFucCall,
required this.changeVisible,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData t = Theme.of(context); final ThemeData theme = Theme.of(context);
final Color outline = t.colorScheme.outline; final Color outline = theme.colorScheme.outline;
return Container( final Color surface = theme.colorScheme.surface;
final Color primary = theme.colorScheme.primary;
final Color onPrimary = theme.colorScheme.onPrimary;
final Color onInverseSurface = theme.colorScheme.onInverseSurface;
final TextStyle titleMedium = theme.textTheme.titleMedium!;
final TextStyle labelMedium = theme.textTheme.labelMedium!;
final Color dividerColor = theme.dividerColor.withOpacity(0.1);
return isVisible
? Container(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 0), padding: const EdgeInsets.fromLTRB(12, 0, 12, 0),
color: Theme.of(context).colorScheme.surface, color: surface,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Divider( Divider(height: 1, thickness: 1, color: dividerColor),
height: 1,
thickness: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
const SizedBox(height: 10), const SizedBox(height: 10),
Text(
'合集:${ugcSeason.title}',
style: Theme.of(context).textTheme.titleMedium,
overflow: TextOverflow.ellipsis,
),
if (ugcSeason.intro != null && ugcSeason.intro != '') ...[
const SizedBox(height: 4),
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Text(ugcSeason.intro ?? '', child: Text(
style: TextStyle( '合集:${ugcSeason.title}',
color: Theme.of(context).colorScheme.outline)), style: titleMedium,
maxLines: 2,
overflow: TextOverflow.ellipsis,
), ),
),
const SizedBox(width: 10),
Obx( Obx(
() => isSubscribe.value == -1 () => isSubscribe.value == -1
? const SizedBox(height: 32) ? const SizedBox(height: 32)
@ -726,47 +746,79 @@ class UgcSeasonBuild extends StatelessWidget {
child: FilledButton.tonal( child: FilledButton.tonal(
onPressed: () => changeFucCall.call(), onPressed: () => changeFucCall.call(),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: const EdgeInsets.only( padding:
left: 8, const EdgeInsets.only(left: 8, right: 8),
right: 8,
),
foregroundColor: isSubscribe.value == 1 foregroundColor: isSubscribe.value == 1
? outline ? outline
: t.colorScheme.onPrimary, : onPrimary,
backgroundColor: isSubscribe.value == 1 backgroundColor: isSubscribe.value == 1
? t.colorScheme.onInverseSurface ? onInverseSurface
: t.colorScheme.primary, // 设置按钮背景色 : primary,
), ),
child: Text(isSubscribe.value == 1 ? '已订阅' : '订阅'), child:
Text(isSubscribe.value == 1 ? '已订阅' : '订阅'),
), ),
), ),
), ),
const SizedBox(width: 6),
], ],
), ),
if (ugcSeason.intro != null && ugcSeason.intro != '') ...[
const SizedBox(height: 4),
Text(
ugcSeason.intro!,
style: TextStyle(color: outline, fontSize: 12),
),
], ],
const SizedBox(height: 4), const SizedBox(height: 4),
Text.rich( Text.rich(
TextSpan( TextSpan(
style: TextStyle( style: TextStyle(
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, fontSize: labelMedium.fontSize, color: outline),
color: Theme.of(context).colorScheme.outline,
),
children: [ children: [
TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'), TextSpan(
text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'),
const TextSpan(text: ' · '), const TextSpan(text: ' · '),
TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'), TextSpan(
text:
'${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'),
], ],
), ),
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
Divider( Align(
height: 1, alignment: Alignment.center,
thickness: 1, child: Material(
color: Theme.of(context).dividerColor.withOpacity(0.1), color: surface,
child: InkWell(
onTap: () => changeVisible.call(),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 10, horizontal: 0),
child: Text(
'收起简介',
style: TextStyle(color: primary, fontSize: 12),
), ),
),
),
),
),
Divider(height: 1, thickness: 1, color: dividerColor),
], ],
), ),
)
: Align(
alignment: Alignment.center,
child: InkWell(
onTap: () => changeVisible.call(),
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 0),
child: Text(
'展开简介',
style: TextStyle(color: primary, fontSize: 12),
),
),
),
); );
} }
} }