opt fab location

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-16 10:12:36 +08:00
parent e04affd0fe
commit ed66a4655b
18 changed files with 556 additions and 619 deletions

View File

@@ -3,35 +3,18 @@ import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
import 'package:PiliPlus/grpc/reply.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/common/reply_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class MainReplyController extends ReplyController<MainListReply>
with GetSingleTickerProviderStateMixin {
class MainReplyController extends ReplyController<MainListReply> {
late final int oid;
late final int replyType;
@override
int get sourceId => oid;
bool _showFab = true;
late final AnimationController _fabAnimationCtr;
late final Animation<Offset> fabAnim;
@override
void onInit() {
super.onInit();
_fabAnimationCtr = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 300),
)..forward();
fabAnim = _fabAnimationCtr.drive(
Tween<Offset>(
begin: const Offset(0.0, 2.0),
end: Offset.zero,
).chain(CurveTween(curve: Curves.easeInOut)),
);
final args = Get.arguments;
oid = args['oid'];
replyType = args['replyType'];
@@ -39,20 +22,6 @@ class MainReplyController extends ReplyController<MainListReply>
queryData();
}
void showFab() {
if (!_showFab) {
_showFab = true;
_fabAnimationCtr.forward();
}
}
void hideFab() {
if (_showFab) {
_showFab = false;
_fabAnimationCtr.reverse();
}
}
@override
Future<LoadingState<MainListReply>> customGetData() => ReplyGrpc.mainList(
type: replyType,
@@ -64,10 +33,4 @@ class MainReplyController extends ReplyController<MainListReply>
@override
List<ReplyInfo>? getDataList(MainListReply response) => response.replies;
@override
void onClose() {
_fabAnimationCtr.dispose();
super.onClose();
}
}

View File

@@ -7,6 +7,7 @@ import 'package:PiliPlus/common/widgets/view_safe_area.dart';
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
show ReplyInfo;
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/common/fab_mixin.dart';
import 'package:PiliPlus/pages/main_reply/controller.dart';
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
@@ -38,7 +39,8 @@ class MainReplyPage extends StatefulWidget {
}
}
class _MainReplyPageState extends State<MainReplyPage> {
class _MainReplyPageState extends State<MainReplyPage>
with SingleTickerProviderStateMixin, FabMixin {
final _controller = Get.put(
MainReplyController(),
tag: Utils.generateRandomString(8),
@@ -62,9 +64,9 @@ class _MainReplyPageState extends State<MainReplyPage> {
onNotification: (notification) {
final direction = notification.direction;
if (direction == .forward) {
_controller.showFab();
showFab();
} else if (direction == .reverse) {
_controller.hideFab();
hideFab();
}
return false;
},
@@ -87,22 +89,26 @@ class _MainReplyPageState extends State<MainReplyPage> {
),
).constraintWidth(),
),
floatingActionButtonLocation: const NoBottomPaddingFabLocation(),
floatingActionButton: SlideTransition(
position: _controller.fabAnim,
child: FloatingActionButton(
heroTag: null,
onPressed: () {
try {
feedBack();
_controller.onReply(
null,
oid: _controller.oid,
replyType: _controller.replyType,
);
} catch (_) {}
},
tooltip: '评论',
child: const Icon(Icons.reply),
position: fabAnimation,
child: Padding(
padding: .only(bottom: padding.bottom + kFloatingActionButtonMargin),
child: FloatingActionButton(
heroTag: null,
onPressed: () {
try {
feedBack();
_controller.onReply(
null,
oid: _controller.oid,
replyType: _controller.replyType,
);
} catch (_) {}
},
tooltip: '评论',
child: const Icon(Icons.reply),
),
),
),
);