Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-08-04 17:11:34 +08:00
parent 8077573c50
commit 0e9a372b82
8 changed files with 448 additions and 345 deletions

View File

@@ -43,13 +43,6 @@ class _ContactPageState extends State<ContactPage>
return SimpleScaffold( return SimpleScaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('通讯录'), title: const Text('通讯录'),
bottom: TabBar(
controller: _controller,
tabs: const [
Tab(text: '我的关注'),
Tab(text: '我的粉丝'),
],
),
actions: [ actions: [
IconButton( IconButton(
onPressed: () async { onPressed: () async {
@@ -70,7 +63,17 @@ class _ContactPageState extends State<ContactPage>
const SizedBox(width: 16), const SizedBox(width: 16),
], ],
), ),
body: tabBarView( body: Column(
children: [
TabBar(
controller: _controller,
tabs: const [
Tab(text: '我的关注'),
Tab(text: '我的粉丝'),
],
),
Expanded(
child: tabBarView(
controller: _controller, controller: _controller,
children: [ children: [
FollowChildPage( FollowChildPage(
@@ -83,6 +86,9 @@ class _ContactPageState extends State<ContactPage>
), ),
], ],
), ),
),
],
),
); );
} }
} }

View File

@@ -51,9 +51,10 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SimpleScaffold( return SimpleScaffold(
appBar: AppBar( appBar: AppBar(title: const Text('弹幕屏蔽')),
title: const Text('弹幕屏蔽'), body: Column(
bottom: TabBar( children: [
TabBar(
controller: _controller.tabController, controller: _controller.tabController,
tabs: DmBlockType.values tabs: DmBlockType.values
.map( .map(
@@ -65,19 +66,23 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
) )
.toList(), .toList(),
), ),
), Expanded(
body: tabBarView( child: tabBarView(
controller: _controller.tabController, controller: _controller.tabController,
children: DmBlockType.values children: DmBlockType.values
.map( .map(
(e) => KeepAliveWrapper( (e) => KeepAliveWrapper(
child: Obx( child: Obx(
() => tabViewBuilder(e.index, _controller.rules[e.index]), () =>
tabViewBuilder(e.index, _controller.rules[e.index]),
), ),
), ),
) )
.toList(), .toList(),
), ),
),
],
),
fab: Padding( fab: Padding(
padding: .only( padding: .only(
right: kFloatingActionButtonMargin + padding.right, right: kFloatingActionButtonMargin + padding.right,

View File

@@ -6,6 +6,7 @@ import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models_new/fav/fav_note/list.dart'; import 'package:PiliPlus/models_new/fav/fav_note/list.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart'; import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:PiliPlus/pages/fav/note/widget/item.dart'; import 'package:PiliPlus/pages/fav/note/widget/item.dart';
import 'package:PiliPlus/pages/fav/pgc/pgc_layout.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -37,11 +38,8 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
super.build(context); super.build(context);
final theme = Theme.of(context); final theme = Theme.of(context);
final padding = MediaQuery.viewPaddingOf(context); final padding = MediaQuery.viewPaddingOf(context);
final bottomH = 50 + padding.bottom; return PgcLayout(
return Stack( body: refreshIndicator(
clipBehavior: Clip.none,
children: [
refreshIndicator(
onRefresh: _favNoteController.onRefresh, onRefresh: _favNoteController.onRefresh,
child: CustomScrollView( child: CustomScrollView(
controller: _favNoteController.scrollController, controller: _favNoteController.scrollController,
@@ -56,19 +54,14 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
], ],
), ),
), ),
Positioned( toolbar: Obx(
left: 0,
right: 0,
bottom: -bottomH,
child: Obx(
() => AnimatedSlide( () => AnimatedSlide(
offset: _favNoteController.enableMultiSelect.value offset: _favNoteController.enableMultiSelect.value
? const Offset(0, -1) ? const Offset(0, -1)
: Offset.zero, : Offset.zero,
duration: const Duration(milliseconds: 150), duration: const Duration(milliseconds: 150),
child: Container( child: Container(
height: bottomH, padding: .only(bottom: padding.bottom),
padding: padding,
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.onInverseSurface, color: theme.colorScheme.onInverseSurface,
border: Border( border: Border(
@@ -138,8 +131,6 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
), ),
), ),
), ),
),
],
); );
} }

View File

@@ -6,6 +6,7 @@ import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart'; import 'package:PiliPlus/models_new/fav/fav_pgc/list.dart';
import 'package:PiliPlus/pages/fav/pgc/controller.dart'; import 'package:PiliPlus/pages/fav/pgc/controller.dart';
import 'package:PiliPlus/pages/fav/pgc/pgc_layout.dart';
import 'package:PiliPlus/pages/fav/pgc/widget/item.dart'; import 'package:PiliPlus/pages/fav/pgc/widget/item.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -43,11 +44,8 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
super.build(context); super.build(context);
final theme = Theme.of(context); final theme = Theme.of(context);
final padding = MediaQuery.viewPaddingOf(context); final padding = MediaQuery.viewPaddingOf(context);
final bottomH = 50 + padding.bottom; return PgcLayout(
return Stack( body: refreshIndicator(
clipBehavior: Clip.none,
children: [
refreshIndicator(
onRefresh: _favPgcController.onRefresh, onRefresh: _favPgcController.onRefresh,
child: CustomScrollView( child: CustomScrollView(
controller: _favPgcController.scrollController, controller: _favPgcController.scrollController,
@@ -62,19 +60,14 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
], ],
), ),
), ),
Positioned( toolbar: Obx(
left: 0,
right: 0,
bottom: -bottomH,
child: Obx(
() => AnimatedSlide( () => AnimatedSlide(
offset: _favPgcController.enableMultiSelect.value offset: _favPgcController.enableMultiSelect.value
? const Offset(0, -1) ? const Offset(0, -1)
: Offset.zero, : Offset.zero,
duration: const Duration(milliseconds: 150), duration: const Duration(milliseconds: 150),
child: Container( child: Container(
height: bottomH, padding: .only(bottom: padding.bottom),
padding: padding,
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.onInverseSurface, color: theme.colorScheme.onInverseSurface,
border: Border( border: Border(
@@ -163,8 +156,6 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
), ),
), ),
), ),
),
],
); );
} }

View File

@@ -0,0 +1,86 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show BoxHitTestResult, BoxParentData;
enum PgcType { toolbar, body }
class PgcLayout
extends SlottedMultiChildRenderObjectWidget<PgcType, RenderBox> {
const PgcLayout({
super.key,
required this.body,
required this.toolbar,
});
final Widget body;
final Widget toolbar;
@override
Iterable<PgcType> get slots => PgcType.values;
@override
Widget childForSlot(slot) => switch (slot) {
.toolbar => toolbar,
.body => body,
};
@override
SlottedContainerRenderObjectMixin<PgcType, RenderBox> createRenderObject(
BuildContext context,
) {
return _RenderPgcLayout();
}
}
class _RenderPgcLayout extends RenderBox
with SlottedContainerRenderObjectMixin<PgcType, RenderBox> {
RenderBox get body => childForSlot(.body)!;
RenderBox get toolbar => childForSlot(.toolbar)!;
Offset _getOffset(RenderBox child) {
return (child.parentData as BoxParentData).offset;
}
void _setOffset(RenderBox child, Offset offset) {
(child.parentData as BoxParentData).offset = offset;
}
@override
void performLayout() {
final constraints = this.constraints;
size = constraints.biggest;
final body = this.body..layout(constraints);
_setOffset(body, .zero);
final toolbar = this.toolbar
..layout(BoxConstraints.tightFor(width: constraints.maxWidth));
_setOffset(toolbar, Offset(0, constraints.maxHeight));
}
@override
void paint(PaintingContext context, Offset offset) {
void doPaint(RenderBox child) {
context.paintChild(child, _getOffset(child) + offset);
}
doPaint(body);
doPaint(toolbar);
}
@override
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
for (final child in children) {
final bool isHit = result.addWithPaintOffset(
offset: _getOffset(child),
position: position,
hitTest: (BoxHitTestResult result, Offset transformed) {
return child.hitTest(result, position: transformed);
},
);
if (isHit) {
return true;
}
}
return false;
}
}

View File

@@ -126,11 +126,17 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
], ],
bottom: TabBar( ),
body: ViewSafeArea(
child: Column(
children: [
TabBar(
controller: _tabController, controller: _tabController,
isScrollable: true, isScrollable: true,
tabAlignment: TabAlignment.start, tabAlignment: TabAlignment.start,
tabs: FavTabType.values.map((item) => Tab(text: item.title)).toList(), tabs: FavTabType.values
.map((item) => Tab(text: item.title))
.toList(),
onTap: (index) { onTap: (index) {
try { try {
if (!_tabController.indexIsChanging) { if (!_tabController.indexIsChanging) {
@@ -141,7 +147,8 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
Get.find<FavArticleController>().scrollController Get.find<FavArticleController>().scrollController
.animToTop(); .animToTop();
case FavTabType.topic: case FavTabType.topic:
Get.find<FavTopicController>().scrollController.animToTop(); Get.find<FavTopicController>().scrollController
.animToTop();
case FavTabType.cheese: case FavTabType.cheese:
Get.find<FavCheeseController>().scrollController Get.find<FavCheeseController>().scrollController
.animToTop(); .animToTop();
@@ -151,13 +158,15 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
} catch (_) {} } catch (_) {}
}, },
), ),
), Expanded(
body: ViewSafeArea(
child: tabBarView( child: tabBarView(
controller: _tabController, controller: _tabController,
children: FavTabType.values.map((item) => item.page).toList(), children: FavTabType.values.map((item) => item.page).toList(),
), ),
), ),
],
),
),
); );
} }
} }

View File

@@ -104,6 +104,10 @@ class _HistoryPageState extends State<HistoryPage>
left: padding.left, left: padding.left,
right: padding.right, right: padding.right,
), ),
child: Column(
children: [
?_buildPauseTip,
Expanded(
child: Obx(() { child: Obx(() {
final tabs = _historyController.tabs; final tabs = _historyController.tabs;
if (tabs.isEmpty) { if (tabs.isEmpty) {
@@ -122,7 +126,9 @@ class _HistoryPageState extends State<HistoryPage>
} else { } else {
if (enableMultiSelect) { if (enableMultiSelect) {
currCtr( currCtr(
_historyController.tabController!.previousIndex, _historyController
.tabController!
.previousIndex,
).handleSelect(); ).handleSelect();
} }
} }
@@ -142,7 +148,9 @@ class _HistoryPageState extends State<HistoryPage>
CustomHorizontalDragGestureRecognizer.new, CustomHorizontalDragGestureRecognizer.new,
children: [ children: [
KeepAliveWrapper(child: child), KeepAliveWrapper(child: child),
...tabs.map((item) => HistoryPage(type: item.type)), ...tabs.map(
(item) => HistoryPage(type: item.type),
),
], ],
), ),
), ),
@@ -150,6 +158,9 @@ class _HistoryPageState extends State<HistoryPage>
); );
}), }),
), ),
],
),
),
), ),
); );
}, },
@@ -158,7 +169,6 @@ class _HistoryPageState extends State<HistoryPage>
AppBar get _buildAppBar => AppBar( AppBar get _buildAppBar => AppBar(
title: const Text('观看记录'), title: const Text('观看记录'),
bottom: _buildPauseTip,
actions: [ actions: [
IconButton( IconButton(
tooltip: '搜索', tooltip: '搜索',

View File

@@ -569,8 +569,11 @@ class _LoginPageState extends State<LoginPage> {
), ),
], ],
), ),
bottom: !isLandscape ),
? TabBar( body: Column(
children: [
if (!isLandscape)
TabBar(
tabs: const [ tabs: const [
Tab(icon: Icon(Icons.password), text: '密码'), Tab(icon: Icon(Icons.password), text: '密码'),
Tab(icon: Icon(Icons.sms_outlined), text: '短信'), Tab(icon: Icon(Icons.sms_outlined), text: '短信'),
@@ -578,10 +581,9 @@ class _LoginPageState extends State<LoginPage> {
Tab(icon: Icon(Icons.cookie_outlined), text: 'Cookie'), Tab(icon: Icon(Icons.cookie_outlined), text: 'Cookie'),
], ],
controller: _loginPageCtr.tabController, controller: _loginPageCtr.tabController,
)
: null,
), ),
body: NotificationListener<ScrollStartNotification>( Expanded(
child: NotificationListener<ScrollStartNotification>(
onNotification: (notification) { onNotification: (notification) {
if (notification.metrics.axis == Axis.horizontal) { if (notification.metrics.axis == Axis.horizontal) {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
@@ -600,6 +602,9 @@ class _LoginPageState extends State<LoginPage> {
), ),
), ),
), ),
),
],
),
); );
} }