feat: 更新代码仓库全部修改
Build Android APK / 编译 libcore.aar (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Windows / build (push) Has been cancelled
Build Android APK / 编译 libcore.aar (push) Has been cancelled
Build Android APK / 编译 Android APK (release) (push) Has been cancelled
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
Build Windows / build (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_help/bindings/hi_help_binding.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_help/views/hi_help_view.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_menu/bindings/hi_menu_binding.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_menu/views/hi_menu_view.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_node_list/bindings/hi_node_list_binding.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_node_list/views/hi_page_node_view.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_user_info/bindings/hi_user_info_binding.dart';
|
||||
import 'package:kaer_with_panels/app/modules/hi_user_info/views/hi_user_info_view.dart';
|
||||
|
||||
import '../modules/kr_language_selector/bindings/kr_language_selector_binding.dart';
|
||||
import '../modules/kr_language_selector/views/kr_language_selector_view.dart';
|
||||
@@ -34,6 +42,7 @@ import '../modules/kr_splash/bindings/kr_splash_binding.dart';
|
||||
import '../modules/kr_splash/views/kr_splash_view.dart';
|
||||
import '../modules/kr_device_management/bindings/kr_device_management_binding.dart';
|
||||
import '../modules/kr_device_management/views/kr_device_management_view.dart';
|
||||
import 'package:kaer_with_panels/app/routes/transitions/slide_transparent_transition.dart';
|
||||
|
||||
part 'app_routes.dart';
|
||||
|
||||
@@ -47,6 +56,8 @@ class AppPages {
|
||||
name: Routes.KR_SPLASH,
|
||||
page: () => const KRSplashView(),
|
||||
binding: KRSplashBinding(),
|
||||
transition: Transition.fade,
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.KR_MAIN,
|
||||
@@ -57,11 +68,27 @@ class AppPages {
|
||||
name: _Paths.KR_HOME,
|
||||
page: () => const KRHomeView(),
|
||||
binding: KRHomeBinding(),
|
||||
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
|
||||
customTransition: SlideOutOnlyTransition(
|
||||
direction: SlideDirection.leftToRight,
|
||||
duration: const Duration(milliseconds: 350),
|
||||
),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.HI_MENU,
|
||||
page: () => const HIMenuView(),
|
||||
binding: HIMenuBinding(),
|
||||
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
|
||||
customTransition: ContextAwareSlideTransition(
|
||||
targetRoute: _Paths.HI_MENU,
|
||||
duration: const Duration(milliseconds: 350),
|
||||
),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.MR_LOGIN,
|
||||
page: () => const KRLoginView(),
|
||||
binding: MrLoginBinding(),
|
||||
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.KR_SETTING,
|
||||
@@ -97,6 +124,7 @@ class AppPages {
|
||||
name: _Paths.KR_PURCHASE_MEMBERSHIP,
|
||||
page: () => const KRPurchaseMembershipView(),
|
||||
binding: KRPurchaseMembershipBinding(),
|
||||
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.KR_MESSAGE,
|
||||
@@ -128,5 +156,21 @@ class AppPages {
|
||||
page: () => const KRDeviceManagementView(),
|
||||
binding: KRDeviceManagementBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.HI_NODE_LIST,
|
||||
page: () => const HINodePageView(),
|
||||
binding: HiNodeListBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.HI_HELP,
|
||||
page: () => const HIHelpView(),
|
||||
binding: HIHelpBinding(),
|
||||
),
|
||||
GetPage(
|
||||
name: _Paths.HI_USER_INFO,
|
||||
page: () => const HIUserInfoView(),
|
||||
binding: HIUserInfoBinding(),
|
||||
arguments: {'showSubscriptionButton': true}, // 显示购买按钮
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ abstract class Routes {
|
||||
static const KR_ORDER_STATUS = '/kr-order-status';
|
||||
static const KR_CRISP = _Paths.KR_CRISP;
|
||||
static const KR_DEVICE_MANAGEMENT = _Paths.KR_DEVICE_MANAGEMENT;
|
||||
static const HI_MENU = _Paths.HI_MENU;
|
||||
static const HI_NODE_LIST = _Paths.HI_NODE_LIST;
|
||||
static const HI_HELP = _Paths.HI_HELP;
|
||||
static const HI_USER_INFO = _Paths.HI_USER_INFO;
|
||||
}
|
||||
|
||||
abstract class _Paths {
|
||||
@@ -42,4 +46,8 @@ abstract class _Paths {
|
||||
static const KR_WEBVIEW = '/kr_webview';
|
||||
static const KR_CRISP = '/kr-crisp';
|
||||
static const KR_DEVICE_MANAGEMENT = '/kr-device-management';
|
||||
static const HI_MENU = '/hi_menu';
|
||||
static const HI_NODE_LIST = '/hi_node_list';
|
||||
static const HI_HELP = '/hi_help';
|
||||
static const HI_USER_INFO = '/hi-user-info';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
enum SlideDirection { leftToRight, rightToLeft }
|
||||
|
||||
/// 智能转场类,根据路由上下文决定转场方向
|
||||
class ContextAwareSlideTransition extends CustomTransition {
|
||||
final String targetRoute;
|
||||
final Duration duration;
|
||||
|
||||
ContextAwareSlideTransition({
|
||||
required this.targetRoute,
|
||||
this.duration = const Duration(milliseconds: 350),
|
||||
});
|
||||
|
||||
@override
|
||||
Widget buildTransition(
|
||||
BuildContext context,
|
||||
Curve? curve,
|
||||
Alignment? alignment,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
|
||||
// 获取当前路由信息
|
||||
final currentRoute = Get.currentRoute;
|
||||
final previousRoute = Get.previousRoute;
|
||||
|
||||
// 决定转场方向
|
||||
SlideDirection direction = _determineDirection(currentRoute, previousRoute);
|
||||
|
||||
// 确保移动距离一致:都是1.0个屏幕宽度
|
||||
const double slideDistance = 1.0;
|
||||
|
||||
// 新页面入场方向
|
||||
final newPageBeginOffset = direction == SlideDirection.rightToLeft
|
||||
? Offset(slideDistance, 0)
|
||||
: Offset(-slideDistance, 0);
|
||||
|
||||
// 旧页面滑出方向(与新页面相反,距离相同)
|
||||
final oldPageEndOffset = direction == SlideDirection.rightToLeft
|
||||
? Offset(-slideDistance, 0)
|
||||
: Offset(slideDistance, 0);
|
||||
|
||||
// 使用相同的动画曲线确保同步
|
||||
final animationCurve = curve ?? Curves.elasticOut;
|
||||
|
||||
// 新页面滑入动画:从屏幕外滑入到中心
|
||||
final newPageAnimation = Tween<Offset>(
|
||||
begin: newPageBeginOffset,
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: animationCurve,
|
||||
));
|
||||
|
||||
// 旧页面滑出动画:从中心滑出到屏幕外
|
||||
final oldPageAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: oldPageEndOffset,
|
||||
).animate(CurvedAnimation(
|
||||
parent: secondaryAnimation,
|
||||
curve: animationCurve,
|
||||
));
|
||||
|
||||
// 使用 AnimatedBuilder 来监听 secondaryAnimation 的变化
|
||||
return AnimatedBuilder(
|
||||
animation: secondaryAnimation,
|
||||
builder: (context, _) {
|
||||
// 如果 secondaryAnimation 正在运行,说明这是旧页面
|
||||
if (secondaryAnimation.status == AnimationStatus.forward ||
|
||||
secondaryAnimation.status == AnimationStatus.reverse) {
|
||||
return SlideTransition(
|
||||
position: oldPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
// 否则这是新页面
|
||||
return SlideTransition(
|
||||
position: newPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 根据路由上下文决定转场方向
|
||||
SlideDirection _determineDirection(String currentRoute, String previousRoute) {
|
||||
// 如果目标路由是 HI_MENU
|
||||
if (targetRoute == '/hi_menu') {
|
||||
// 从 home 页面来的,使用左到右(menu 从左侧进入)
|
||||
if (previousRoute == '/kr_home' || previousRoute.contains('kr_home')) {
|
||||
return SlideDirection.leftToRight;
|
||||
}
|
||||
// 去其他页面,使用右到左
|
||||
else {
|
||||
return SlideDirection.rightToLeft;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认使用右到左
|
||||
return SlideDirection.rightToLeft;
|
||||
}
|
||||
}
|
||||
|
||||
class SlideTransparentTransition extends CustomTransition {
|
||||
final SlideDirection direction;
|
||||
final Duration duration;
|
||||
|
||||
SlideTransparentTransition({
|
||||
this.direction = SlideDirection.rightToLeft,
|
||||
this.duration = const Duration(milliseconds: 4000),
|
||||
});
|
||||
|
||||
@override
|
||||
Widget buildTransition(
|
||||
BuildContext context,
|
||||
Curve? curve,
|
||||
Alignment? alignment,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
|
||||
// 确保移动距离一致:都是1.0个屏幕宽度
|
||||
const double slideDistance = 1.0;
|
||||
|
||||
// 新页面入场方向
|
||||
final newPageBeginOffset = direction == SlideDirection.rightToLeft
|
||||
? Offset(slideDistance, 0)
|
||||
: Offset(-slideDistance, 0);
|
||||
|
||||
// 旧页面滑出方向(与新页面相反,距离相同)
|
||||
final oldPageEndOffset = direction == SlideDirection.rightToLeft
|
||||
? Offset(-slideDistance, 0)
|
||||
: Offset(slideDistance, 0);
|
||||
|
||||
// 使用相同的动画曲线确保同步
|
||||
final animationCurve = curve ?? Curves.elasticOut;
|
||||
|
||||
// 新页面滑入动画:从屏幕外滑入到中心
|
||||
final newPageAnimation = Tween<Offset>(
|
||||
begin: newPageBeginOffset,
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: animationCurve,
|
||||
));
|
||||
|
||||
// 旧页面滑出动画:从中心滑出到屏幕外
|
||||
final oldPageAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: oldPageEndOffset,
|
||||
).animate(CurvedAnimation(
|
||||
parent: secondaryAnimation,
|
||||
curve: animationCurve,
|
||||
));
|
||||
|
||||
// 使用 AnimatedBuilder 来监听 secondaryAnimation 的变化
|
||||
return AnimatedBuilder(
|
||||
animation: secondaryAnimation,
|
||||
builder: (context, _) {
|
||||
// 如果 secondaryAnimation 正在运行,说明这是旧页面
|
||||
if (secondaryAnimation.status == AnimationStatus.forward ||
|
||||
secondaryAnimation.status == AnimationStatus.reverse) {
|
||||
return SlideTransition(
|
||||
position: oldPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
// 否则这是新页面
|
||||
return SlideTransition(
|
||||
position: newPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SlideOutOnlyTransition extends CustomTransition {
|
||||
final SlideDirection direction;
|
||||
final Duration duration;
|
||||
|
||||
SlideOutOnlyTransition({
|
||||
this.direction = SlideDirection.rightToLeft,
|
||||
this.duration = const Duration(milliseconds: 350),
|
||||
});
|
||||
|
||||
@override
|
||||
Widget buildTransition(
|
||||
BuildContext context,
|
||||
Curve? curve,
|
||||
Alignment? alignment,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
|
||||
const double slideDistance = 1.0;
|
||||
|
||||
// 旧页面出场动画
|
||||
final oldPageEndOffset = direction == SlideDirection.rightToLeft
|
||||
? Offset(-slideDistance, 0)
|
||||
: Offset(slideDistance, 0);
|
||||
|
||||
final oldPageAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: oldPageEndOffset,
|
||||
).animate(CurvedAnimation(
|
||||
parent: secondaryAnimation,
|
||||
curve: curve ?? Curves.easeOut,
|
||||
));
|
||||
|
||||
// 新页面入场无动画
|
||||
final newPageAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: Offset.zero,
|
||||
).animate(animation);
|
||||
|
||||
return AnimatedBuilder(
|
||||
animation: secondaryAnimation,
|
||||
builder: (context, _) {
|
||||
// secondaryAnimation 正在执行,表示旧页面在出场
|
||||
if (secondaryAnimation.status == AnimationStatus.forward ||
|
||||
secondaryAnimation.status == AnimationStatus.reverse) {
|
||||
return SlideTransition(
|
||||
position: oldPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
// 否则新页面直接显示,无动画
|
||||
return SlideTransition(
|
||||
position: newPageAnimation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'slide_transparent_transition.dart';
|
||||
|
||||
/// 全局页面过渡动画配置类
|
||||
class TransitionConfig {
|
||||
static Duration _defaultDuration = const Duration(milliseconds: 350);
|
||||
static const SlideDirection _defaultDirection = SlideDirection.rightToLeft;
|
||||
static const Curve _defaultCurve = Curves.easeOutCubic;
|
||||
|
||||
/// 默认动画持续时间
|
||||
static Duration get defaultDuration => _defaultDuration;
|
||||
|
||||
/// 默认滑动方向
|
||||
static SlideDirection get defaultDirection => _defaultDirection;
|
||||
|
||||
/// 默认动画曲线
|
||||
static Curve get defaultCurve => _defaultCurve;
|
||||
|
||||
/// 创建默认的滑动过渡动画
|
||||
static SlideTransparentTransition createDefaultTransition() {
|
||||
return SlideTransparentTransition(
|
||||
direction: _defaultDirection,
|
||||
duration: _defaultDuration,
|
||||
);
|
||||
}
|
||||
|
||||
/// 创建自定义滑动过渡动画
|
||||
static SlideTransparentTransition createCustomTransition({
|
||||
SlideDirection? direction,
|
||||
Duration? duration,
|
||||
}) {
|
||||
return SlideTransparentTransition(
|
||||
direction: direction ?? _defaultDirection,
|
||||
duration: duration ?? _defaultDuration,
|
||||
);
|
||||
}
|
||||
|
||||
/// 创建从左到右的过渡动画(通常用于返回操作)
|
||||
static SlideTransparentTransition createLeftToRightTransition({
|
||||
Duration? duration,
|
||||
}) {
|
||||
return SlideTransparentTransition(
|
||||
direction: SlideDirection.leftToRight,
|
||||
duration: duration ?? _defaultDuration,
|
||||
);
|
||||
}
|
||||
|
||||
/// 创建从右到左的过渡动画(通常用于前进操作)
|
||||
static SlideTransparentTransition createRightToLeftTransition({
|
||||
Duration? duration,
|
||||
}) {
|
||||
return SlideTransparentTransition(
|
||||
direction: SlideDirection.rightToLeft,
|
||||
duration: duration ?? _defaultDuration,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 全局路由助手类
|
||||
class RouteHelper {
|
||||
/// 使用自定义过渡动画跳转到指定页面
|
||||
static Future<T?>? toWithCustomTransition<T>(
|
||||
Widget page, {
|
||||
SlideDirection? direction,
|
||||
Duration? duration,
|
||||
bool? opaque,
|
||||
Curve? curve,
|
||||
String? routeName,
|
||||
bool fullscreenDialog = false,
|
||||
dynamic arguments,
|
||||
Bindings? binding,
|
||||
bool preventDuplicates = true,
|
||||
bool? popGesture,
|
||||
}) {
|
||||
// 使用 Get.to 并依赖全局配置的 customTransition
|
||||
return Get.to<T>(
|
||||
page,
|
||||
duration: duration ?? TransitionConfig.defaultDuration,
|
||||
opaque: opaque,
|
||||
curve: curve ?? TransitionConfig.defaultCurve,
|
||||
routeName: routeName,
|
||||
fullscreenDialog: fullscreenDialog,
|
||||
arguments: arguments,
|
||||
binding: binding,
|
||||
preventDuplicates: preventDuplicates,
|
||||
popGesture: popGesture,
|
||||
);
|
||||
}
|
||||
|
||||
/// 使用自定义过渡动画跳转到命名路由
|
||||
static Future<T?>? toNamedWithCustomTransition<T>(
|
||||
String page, {
|
||||
dynamic arguments,
|
||||
bool preventDuplicates = true,
|
||||
Map<String, String>? parameters,
|
||||
}) {
|
||||
return Get.toNamed<T>(
|
||||
page,
|
||||
arguments: arguments,
|
||||
preventDuplicates: preventDuplicates,
|
||||
parameters: parameters,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user