feat: 修改hidialog弹窗位置,增加macos dmg打包配置
This commit is contained in:
@@ -11,9 +11,18 @@ import 'package:kaer_with_panels/app/widgets/dialogs/hi_dialog.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/hi_help_entrance.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/hi_base_scaffold.dart';
|
||||
import 'package:easy_refresh/easy_refresh.dart';
|
||||
class HINodePageView extends GetView<HINodeListController> {
|
||||
class HINodePageView extends StatefulWidget {
|
||||
const HINodePageView({super.key});
|
||||
|
||||
@override
|
||||
State<HINodePageView> createState() => _HINodePageViewState();
|
||||
}
|
||||
|
||||
class _HINodePageViewState extends State<HINodePageView> {
|
||||
final GlobalKey _modeSwitcherKey = GlobalKey();
|
||||
|
||||
HINodeListController get controller => Get.find<HINodeListController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return HIBaseScaffold(
|
||||
@@ -69,6 +78,7 @@ class HINodePageView extends GetView<HINodeListController> {
|
||||
// 2. 关键:移除多余的 SizedBox,让 Expanded 正确工作
|
||||
Expanded(
|
||||
child: Container(
|
||||
key: _modeSwitcherKey,
|
||||
padding: EdgeInsets.all(4.w),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
@@ -99,7 +109,19 @@ class HINodePageView extends GetView<HINodeListController> {
|
||||
SizedBox(width: 12.w),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Offset? targetOffset;
|
||||
final renderBox = _modeSwitcherKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (renderBox != null) {
|
||||
final position = renderBox.localToGlobal(Offset.zero);
|
||||
final size = renderBox.size;
|
||||
targetOffset = Offset(
|
||||
position.dx + (size.width / 2) - (HIDialog.kDialogWidth / 2),
|
||||
position.dy + size.height + 10.w,
|
||||
);
|
||||
}
|
||||
|
||||
HIDialog.show(
|
||||
targetOffset: targetOffset,
|
||||
customMessageWidget: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 0.w),
|
||||
child: Column(
|
||||
|
||||
@@ -46,6 +46,8 @@ class KRHomeView extends StatefulWidget implements HasSwipeConfig {
|
||||
class _KRHomeViewState extends State<KRHomeView> {
|
||||
late KRHomeController controller;
|
||||
|
||||
final GlobalKey _quickConnectTextKey = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -198,12 +200,15 @@ class _KRHomeViewState extends State<KRHomeView> {
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
// 2. “闪连”标签
|
||||
Text(
|
||||
'闪连',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
Container(
|
||||
key: _quickConnectTextKey,
|
||||
child: Text(
|
||||
'闪连',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -214,10 +219,26 @@ class _KRHomeViewState extends State<KRHomeView> {
|
||||
SizedBox(width: 6), // 文字和问号图标之间的间距
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Offset? targetOffset;
|
||||
final renderBox = _quickConnectTextKey
|
||||
.currentContext
|
||||
?.findRenderObject() as RenderBox?;
|
||||
if (renderBox != null) {
|
||||
final position =
|
||||
renderBox.localToGlobal(Offset.zero);
|
||||
targetOffset = Offset(
|
||||
position.dx - 26,
|
||||
position.dy +
|
||||
renderBox.size.height +
|
||||
10.w,
|
||||
);
|
||||
}
|
||||
|
||||
HIDialog.show(
|
||||
title: '闪连功能',
|
||||
message:
|
||||
'开启后,每次打开软件默认自动连接,无需点击连接按钮\n在后台关闭软件后,软件将自动断开',
|
||||
targetOffset: targetOffset,
|
||||
);
|
||||
},
|
||||
child: KrLocalImage(
|
||||
|
||||
@@ -32,7 +32,9 @@ class KRInviteView extends GetView<KRInviteController> {
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
physics: isKeyboardVisible
|
||||
? const ClampingScrollPhysics()
|
||||
: const NeverScrollableScrollPhysics(),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
||||
child: IntrinsicHeight(
|
||||
@@ -143,6 +145,7 @@ class KRInviteView extends GetView<KRInviteController> {
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 40.w),
|
||||
const Spacer(),
|
||||
|
||||
// 🟢 第三部分:接受他人邀请
|
||||
@@ -166,6 +169,8 @@ class KRInviteView extends GetView<KRInviteController> {
|
||||
RepaintBoundary(
|
||||
child: TextField(
|
||||
controller: controller.otherInviteCodeController,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => controller.kr_handleBindInviteCode(),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
decoration: InputDecoration(
|
||||
@@ -190,33 +195,36 @@ class KRInviteView extends GetView<KRInviteController> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.w),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50.w,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(1000.r),
|
||||
if (!isKeyboardVisible) ...[
|
||||
SizedBox(height: 10.w),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50.w,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(1000.r),
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () => controller.kr_handleBindInviteCode(),
|
||||
child: Text(
|
||||
'保存',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
onPressed: () =>
|
||||
controller.kr_handleBindInviteCode(),
|
||||
child: Text(
|
||||
'保存',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}),
|
||||
// 底部留白,确保键盘弹出后能滚过遮挡区域
|
||||
SizedBox(height: 90.w),
|
||||
SizedBox(height: isKeyboardVisible ? 20.w : 90.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -124,11 +124,18 @@ class GlobalOverlayService extends GetxService {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Text(
|
||||
'购买套餐',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 12.sp,
|
||||
return DefaultTextStyle(
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.none, // 核心:显式声明无装饰
|
||||
),
|
||||
child: Text(
|
||||
'购买套餐',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 12.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
decoration: TextDecoration.none, // 也可以在这里直接写
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -24,6 +24,9 @@ class HIDialog extends StatefulWidget {
|
||||
|
||||
/// 是否显示按钮 loading(autoClose=false 时自动启用)
|
||||
final bool? showLoading;
|
||||
final Offset? targetOffset;
|
||||
|
||||
static double get kDialogWidth => 245.w < 280.0 ? 280.0 : 245.w;
|
||||
|
||||
const HIDialog({
|
||||
Key? key,
|
||||
@@ -38,6 +41,7 @@ class HIDialog extends StatefulWidget {
|
||||
this.preventBackDismiss = false,
|
||||
this.autoClose = true,
|
||||
this.showLoading,
|
||||
this.targetOffset,
|
||||
}) : super(key: key);
|
||||
|
||||
static Future<void> show({
|
||||
@@ -52,6 +56,7 @@ class HIDialog extends StatefulWidget {
|
||||
bool preventBackDismiss = false,
|
||||
bool autoClose = true,
|
||||
bool? showLoading,
|
||||
Offset? targetOffset,
|
||||
}) {
|
||||
return Get.dialog(
|
||||
HIDialog(
|
||||
@@ -66,9 +71,11 @@ class HIDialog extends StatefulWidget {
|
||||
preventBackDismiss: preventBackDismiss,
|
||||
autoClose: autoClose,
|
||||
showLoading: showLoading,
|
||||
targetOffset: targetOffset,
|
||||
),
|
||||
barrierDismissible: barrierDismissible,
|
||||
barrierColor: Colors.transparent,
|
||||
useSafeArea: false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,20 +119,127 @@ class _HIDialogState extends State<HIDialog> {
|
||||
),
|
||||
child: _isLoading
|
||||
? SizedBox(
|
||||
height: 20.w,
|
||||
width: 20.w,
|
||||
child: const CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
height: 20.w,
|
||||
width: 20.w,
|
||||
child: const CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
widget.confirmText ?? (widget.cancelText == null ? '好的' : AppTranslations.kr_dialog.kr_confirm),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
widget.confirmText ??
|
||||
(widget.cancelText == null ? '好的' : AppTranslations.kr_dialog.kr_confirm),
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(34.r),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 26, sigmaY: 26), // 毛玻璃模糊
|
||||
child: Container(
|
||||
width: 245.w,
|
||||
padding: EdgeInsets.fromLTRB(30.w, 16.w, 30.w, 16.w),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDEDEDE), // 半透明底色
|
||||
borderRadius: BorderRadius.circular(34.r),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.2), // 高光边框
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.title != null) ...[
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
widget.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.w),
|
||||
],
|
||||
if (widget.message != null || widget.customMessageWidget != null) ...[
|
||||
Container(
|
||||
constraints: BoxConstraints(maxHeight: 200.h),
|
||||
child: SingleChildScrollView(
|
||||
child: widget.customMessageWidget ??
|
||||
Text(
|
||||
widget.message!,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: Colors.black,
|
||||
height: 1.4,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (widget.confirmText != null ||
|
||||
widget.cancelText != null ||
|
||||
(widget.confirmText == null && widget.cancelText == null)) ...[
|
||||
SizedBox(height: 12.w),
|
||||
if (widget.confirmText == null && widget.cancelText == null)
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 85.w,
|
||||
child: _buildConfirmButton(),
|
||||
),
|
||||
)
|
||||
else
|
||||
Row(
|
||||
children: [
|
||||
if (widget.confirmText != null) Expanded(child: _buildConfirmButton()),
|
||||
if (widget.cancelText != null && widget.confirmText != null)
|
||||
SizedBox(width: 12.w),
|
||||
if (widget.cancelText != null)
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
widget.onCancel?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFFF00B7),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
),
|
||||
minimumSize: Size(85.w, 40.w),
|
||||
padding: EdgeInsets.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
widget.cancelText!,
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -133,112 +247,31 @@ class _HIDialogState extends State<HIDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.targetOffset != null) {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Positioned(
|
||||
left: widget.targetOffset!.dx,
|
||||
top: widget.targetOffset!.dy,
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 280.0),
|
||||
child: _buildDialogContent(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final dialog = Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
insetPadding: EdgeInsets.all(20.w),
|
||||
child: Transform.translate(
|
||||
offset: Offset(0, -30.w),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(34.r),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 26, sigmaY: 26), // 毛玻璃模糊
|
||||
child: Container(
|
||||
width: 245.w,
|
||||
padding: EdgeInsets.fromLTRB(30.w, 16.w, 30.w, 16.w),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDEDEDE), // 半透明底色
|
||||
borderRadius: BorderRadius.circular(34.r),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.2), // 高光边框
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.title != null) ...[
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
widget.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.w),
|
||||
],
|
||||
if (widget.message != null || widget.customMessageWidget != null) ...[
|
||||
Container(
|
||||
constraints: BoxConstraints(maxHeight: 200.h),
|
||||
child: SingleChildScrollView(
|
||||
child: widget.customMessageWidget ??
|
||||
Text(
|
||||
widget.message!,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: Colors.black,
|
||||
height: 1.4,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
if (widget.confirmText != null || widget.cancelText != null || (widget.confirmText == null && widget.cancelText == null)) ...[
|
||||
SizedBox(height: 12.w),
|
||||
if (widget.confirmText == null && widget.cancelText == null)
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 85.w,
|
||||
child: _buildConfirmButton(),
|
||||
),
|
||||
)
|
||||
else
|
||||
Row(
|
||||
children: [
|
||||
if (widget.confirmText != null) Expanded(child: _buildConfirmButton()),
|
||||
if (widget.cancelText != null && widget.confirmText != null)
|
||||
SizedBox(width: 12.w),
|
||||
if (widget.cancelText != null)
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
widget.onCancel?.call();
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFFF00B7),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(23.r),
|
||||
),
|
||||
minimumSize: Size(85.w, 40.w),
|
||||
padding: EdgeInsets.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: Text(
|
||||
widget.cancelText!,
|
||||
style: TextStyle(
|
||||
fontSize: 16.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
fontFamily: 'AlibabaPuHuiTi-Medium',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _buildDialogContent(),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user