Some checks failed
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
206 lines
9.2 KiB
Dart
Executable File
206 lines
9.2 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:kaer_with_panels/app/localization/app_translations.dart';
|
||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||
import '../controllers/kr_invite_controller.dart';
|
||
import 'package:flutter/services.dart';
|
||
import 'package:kaer_with_panels/app/utils/kr_common_util.dart';
|
||
import 'package:kaer_with_panels/app/widgets/hi_base_scaffold.dart';
|
||
import 'package:kaer_with_panels/app/widgets/hi_help_entrance.dart';
|
||
|
||
class KRInviteView extends GetView<KRInviteController> {
|
||
const KRInviteView({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
|
||
final isKeyboardVisible = MediaQuery.of(context).viewInsets.bottom > 0;
|
||
|
||
return HIBaseScaffold(
|
||
resizeToAvoidBottomInset: true,
|
||
// 1. child 的根组件使用 Stack,以允许绝对定位的组件(如 HIHelpEntrance)正常工作
|
||
child: Stack(
|
||
children: [
|
||
SingleChildScrollView(
|
||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||
physics: const AlwaysScrollableScrollPhysics(),
|
||
child: Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 40.w),
|
||
// 3. 使用一个内层 Column 来组织内容
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
// 🟢 第一行:奖励说明
|
||
Container(
|
||
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.w),
|
||
decoration: BoxDecoration(
|
||
color: Theme.of(context).primaryColor,
|
||
borderRadius: BorderRadius.circular(25.r),
|
||
),
|
||
child: Row(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
mainAxisSize: MainAxisSize.min, // 由内容撑开
|
||
children: [
|
||
KrLocalImage(
|
||
imageName: 'hi-home-logo',
|
||
imageType: ImageType.svg,
|
||
width: 54.w,
|
||
color: Colors.black,
|
||
),
|
||
SizedBox(width: 16.w),
|
||
Flexible(
|
||
child: Text(
|
||
'受邀用户首次付款时,他将与您分别获得3天免费使用时长',
|
||
style: TextStyle(
|
||
color: Colors.black,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500,
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
|
||
SizedBox(height: 26.w),
|
||
// 🟢 第二行:我的邀请码
|
||
Container(
|
||
padding: EdgeInsets.symmetric(horizontal: 4.w, vertical: 2.w),
|
||
decoration: BoxDecoration(
|
||
border: Border.all(color: Colors.white, width: 2.0),
|
||
borderRadius: BorderRadius.circular(1000.r),
|
||
),
|
||
child: Obx(
|
||
() => Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Container(
|
||
width: 100.w,
|
||
height: 40.w,
|
||
alignment: Alignment.center,
|
||
decoration: BoxDecoration(
|
||
color: Theme.of(context).primaryColor,
|
||
borderRadius: BorderRadius.circular(1000.r),
|
||
),
|
||
child: Text(
|
||
'邀请码',
|
||
style: TextStyle(
|
||
color: Colors.black,
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
),
|
||
),
|
||
Expanded(
|
||
child: Text(
|
||
controller.kr_referCode.value,
|
||
textAlign: TextAlign.center,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 20.sp,
|
||
fontWeight: FontWeight.bold,
|
||
),
|
||
),
|
||
),
|
||
IconButton(
|
||
icon: const KrLocalImage(
|
||
imageName: 'share-icon',
|
||
imageType: ImageType.svg,
|
||
color: Colors.white,
|
||
),
|
||
onPressed: () {
|
||
if (controller.kr_referCode.value.isNotEmpty) {
|
||
Clipboard.setData(
|
||
ClipboardData(text: controller.kr_referCode.value),
|
||
);
|
||
KRCommonUtil.kr_showToast(
|
||
AppTranslations.kr_invite.inviteCodeCopied,
|
||
);
|
||
}
|
||
},
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
SizedBox(height: 160.w),
|
||
// 🟢 第三部分:接受他人邀请
|
||
Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(
|
||
'接受他人邀请',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.bold,
|
||
),
|
||
),
|
||
SizedBox(height: 8.h),
|
||
TextField(
|
||
controller: controller.otherInviteCodeController,
|
||
textAlign: TextAlign.center,
|
||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||
decoration: InputDecoration(
|
||
hintText: '填入邀请人邀请码兑换免费时长...',
|
||
hintStyle: const TextStyle(color: Color(0xFFA6A6A6)),
|
||
filled: true,
|
||
fillColor: Colors.transparent,
|
||
contentPadding: EdgeInsets.symmetric(horizontal: 22.w),
|
||
border: OutlineInputBorder(
|
||
borderRadius: BorderRadius.circular(1000.r),
|
||
borderSide: const BorderSide(color: Colors.white, width: 2.0),
|
||
),
|
||
enabledBorder: OutlineInputBorder(
|
||
borderRadius: BorderRadius.circular(1000.r),
|
||
borderSide: const BorderSide(color: Colors.white, width: 2.0),
|
||
),
|
||
focusedBorder: OutlineInputBorder(
|
||
borderRadius: BorderRadius.circular(1000.r),
|
||
borderSide: const BorderSide(color: Colors.white, width: 2.0),
|
||
),
|
||
constraints: BoxConstraints(maxHeight: 50.h),
|
||
),
|
||
),
|
||
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,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
// 4. 在可滚动区域的末尾添加一个占位边距,防止内容被 HIHelpEntrance 遮挡
|
||
SizedBox(height: 80.w), // 这个高度可以根据 HIHelpEntrance 的实际高度进行微调
|
||
],
|
||
),
|
||
),
|
||
),
|
||
|
||
// 5. 将 HIHelpEntrance 作为 Stack 的直接子元素,它将恢复其原有的绝对定位能力
|
||
if (!isKeyboardVisible)
|
||
const HIHelpEntrance(),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
} |