mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-21 19:28:27 +08:00
@@ -12,6 +12,7 @@ import 'package:PiliPlus/models_new/video/video_tag/data.dart';
|
||||
import 'package:PiliPlus/pages/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/triple_mixin.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/num_utils.dart';
|
||||
@@ -17,13 +18,13 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
with SingleTickerProviderStateMixin {
|
||||
CommonDynController get controller;
|
||||
|
||||
late final scrollController = ScrollController()..addListener(listener);
|
||||
late final ScrollController scrollController;
|
||||
|
||||
bool get horizontalPreview => !isPortrait && controller.horizontalPreview;
|
||||
|
||||
@@ -37,15 +38,27 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
|
||||
final fabOffset = const Offset(0, 1);
|
||||
|
||||
late final AnimationController fabAnimationCtr = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
)..forward();
|
||||
late final AnimationController _fabAnimationCtr;
|
||||
late final CurvedAnimation _curvedAnimation;
|
||||
late final Animation<Offset> fabAnim;
|
||||
|
||||
late final Animation<Offset> fabAnim = Tween<Offset>(
|
||||
begin: fabOffset,
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: fabAnimationCtr, curve: Curves.easeInOut));
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fabAnimationCtr = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
)..forward();
|
||||
_curvedAnimation = CurvedAnimation(
|
||||
parent: _fabAnimationCtr,
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
fabAnim = Tween<Offset>(
|
||||
begin: fabOffset,
|
||||
end: Offset.zero,
|
||||
).animate(_curvedAnimation);
|
||||
scrollController = ScrollController()..addListener(listener);
|
||||
}
|
||||
|
||||
void listener() {
|
||||
final pos = scrollController.positions;
|
||||
@@ -60,14 +73,14 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
void showFab() {
|
||||
if (!_showFab) {
|
||||
_showFab = true;
|
||||
fabAnimationCtr.forward();
|
||||
_fabAnimationCtr.forward();
|
||||
}
|
||||
}
|
||||
|
||||
void hideFab() {
|
||||
if (_showFab) {
|
||||
_showFab = false;
|
||||
fabAnimationCtr.reverse();
|
||||
_fabAnimationCtr.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +98,8 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
scrollController
|
||||
..removeListener(listener)
|
||||
..dispose();
|
||||
_curvedAnimation.dispose();
|
||||
_fabAnimationCtr.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:PiliPlus/models/common/publish_panel_type.dart';
|
||||
import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:chat_bottom_container/chat_bottom_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class CommonPublishPage<T> extends StatefulWidget {
|
||||
const CommonPublishPage({
|
||||
@@ -26,7 +26,7 @@ abstract class CommonPublishPage<T> extends StatefulWidget {
|
||||
abstract class CommonPublishPageState<T extends CommonPublishPage>
|
||||
extends State<T>
|
||||
with WidgetsBindingObserver {
|
||||
late final focusNode = FocusNode();
|
||||
late final FocusNode focusNode;
|
||||
late final controller = ChatBottomPanelContainerController<PanelType>();
|
||||
TextEditingController get editController;
|
||||
|
||||
@@ -44,6 +44,8 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
focusNode = FocusNode();
|
||||
|
||||
initPubState();
|
||||
|
||||
if (widget.autofocus) {
|
||||
|
||||
@@ -13,9 +13,13 @@ abstract class CommonTextPubPage extends CommonPublishPage<String> {
|
||||
abstract class CommonTextPubPageState<T extends CommonTextPubPage>
|
||||
extends CommonPublishPageState<T> {
|
||||
@override
|
||||
late final TextEditingController editController = TextEditingController(
|
||||
text: widget.initialValue,
|
||||
);
|
||||
late final TextEditingController editController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
editController = TextEditingController(text: widget.initialValue);
|
||||
}
|
||||
|
||||
@override
|
||||
void initPubState() {
|
||||
|
||||
72
lib/pages/common/publish/publish_route.dart
Normal file
72
lib/pages/common/publish/publish_route.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PublishRoute<T> extends PopupRoute<T> {
|
||||
PublishRoute({
|
||||
required RoutePageBuilder pageBuilder,
|
||||
bool barrierDismissible = true,
|
||||
String? barrierLabel,
|
||||
Color barrierColor = const Color(0x80000000),
|
||||
Duration transitionDuration = const Duration(milliseconds: 500),
|
||||
RouteTransitionsBuilder? transitionBuilder,
|
||||
super.settings,
|
||||
}) : widget = pageBuilder,
|
||||
_barrierDismissible = barrierDismissible,
|
||||
_barrierLabel = barrierLabel,
|
||||
_barrierColor = barrierColor,
|
||||
_transitionDuration = transitionDuration,
|
||||
_transitionBuilder = transitionBuilder;
|
||||
|
||||
final RoutePageBuilder widget;
|
||||
|
||||
@override
|
||||
bool get barrierDismissible => _barrierDismissible;
|
||||
final bool _barrierDismissible;
|
||||
|
||||
@override
|
||||
String? get barrierLabel => _barrierLabel;
|
||||
final String? _barrierLabel;
|
||||
|
||||
@override
|
||||
Color get barrierColor => _barrierColor;
|
||||
final Color _barrierColor;
|
||||
|
||||
@override
|
||||
Duration get transitionDuration => _transitionDuration;
|
||||
final Duration _transitionDuration;
|
||||
|
||||
final RouteTransitionsBuilder? _transitionBuilder;
|
||||
|
||||
@override
|
||||
Widget buildPage(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return Semantics(
|
||||
scopesRoute: true,
|
||||
explicitChildNodes: true,
|
||||
child: widget(context, animation, secondaryAnimation),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildTransitions(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
if (_transitionBuilder != null) {
|
||||
return _transitionBuilder(context, animation, secondaryAnimation, child);
|
||||
}
|
||||
return SlideTransition(
|
||||
position: animation.drive(
|
||||
Tween(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: Offset.zero,
|
||||
).chain(CurveTween(curve: Curves.linear)),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/pages/common/publish/publish_route.dart';
|
||||
import 'package:PiliPlus/pages/video/reply_new/view.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/reply_utils.dart';
|
||||
@@ -16,7 +17,6 @@ import 'package:fixnum/fixnum.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_navigation/src/dialog/dialog_route.dart';
|
||||
|
||||
abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
final RxInt count = (-1).obs;
|
||||
@@ -146,7 +146,7 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
final key = oid ?? replyItem!.oid + replyItem.id;
|
||||
Navigator.of(context)
|
||||
.push(
|
||||
GetDialogRoute(
|
||||
PublishRoute(
|
||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||
return ReplyPage(
|
||||
hint: hint,
|
||||
@@ -166,18 +166,6 @@ abstract class ReplyController<R> extends CommonListController<R, ReplyInfo> {
|
||||
},
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return SlideTransition(
|
||||
position: animation.drive(
|
||||
Tween(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: Offset.zero,
|
||||
).chain(CurveTween(curve: Curves.linear)),
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
settings: RouteSettings(
|
||||
arguments: Get.arguments,
|
||||
name: '${Get.currentRoute}-copy-${Utils.generateRandomString(3)}',
|
||||
|
||||
Reference in New Issue
Block a user