-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Closed as not planned
Closed as not planned
Copy link
Labels
r: invalidIssue is closed as not validIssue is closed as not valid
Description
my code like this
`
//
// 人员登记 View
//
//
// @author lvqibin
// @SInCE
2025-08-09
import 'package:easy_stepper/easy_stepper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/colors/gf_color.dart';
import 'package:getwidget/components/button/gf_button.dart';
import 'package:getwidget/components/radio/gf_radio.dart';
import 'package:getwidget/size/gf_size.dart';
import '../controllers/registration_new_update_controller.dart';
class AppPlantPersonnelRegistrationNewUpdateView
extends GetView<AppPlantPersonnelRegistrationNewUpdateController> {
const AppPlantPersonnelRegistrationNewUpdateView({Key? key})
: super(key: key);
@override
Widget build(BuildContext context) {
DateTime lastPressedAt = DateTime.now(); //上次点击的时间
return WillPopScope(
onWillPop: () async {
if ((DateTime.now().difference(lastPressedAt) >
const Duration(seconds: 1))) {
//两次点击间隔超过1秒,重新计时
lastPressedAt = DateTime.now();
// print(_lastPressedAt);
// LogUtils.d(' _lastPressedAt ', _lastPressedAt);
Get.snackbar(
'提示',
'双击退出程序!',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red,
);
return false;
}
return true;
},
child: Obx(
() => Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
controller.text.value,
style: TextStyle(color: Colors.white, fontSize: 20),
),
backgroundColor: Colors.greenAccent,
foregroundColor: Colors.white,
elevation: 0,
leading: Builder(
builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.arrow_back_ios_new_sharp),
onPressed: () {
// Get.back();
Get.offAndToNamed('/login');
},
);
},
),
actions: <Widget>[
IconButton(icon: const Icon(Icons.save), onPressed: () => {}),
],
),
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
SizedBox(
// height: 200,
width: double.infinity,
child: Column(
children: [
const SizedBox(height: 80),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 标题区域
Text(
'欢迎注册华浩智慧衣服',
style: TextStyle(
color: Colors.red,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
EasyStepper(
activeStep: controller.activeStep.value,
// enableStepTapping: false,
lineStyle: const LineStyle(
lineLength: 50,
lineType: LineType.normal,
lineThickness: 3,
lineSpace: 1,
lineWidth: 10,
unreachedLineType: LineType.dashed,
),
stepShape: StepShape.rRectangle,
stepBorderRadius: 15,
borderThickness: 2,
internalPadding: 10,
padding: const EdgeInsetsDirectional.symmetric(
horizontal: 30,
vertical: 20,
),
stepRadius: 28,
finishedStepBorderColor: Colors.lightBlueAccent,
finishedStepTextColor: Colors.lightBlueAccent,
finishedStepBackgroundColor: Colors.lightBlueAccent,
activeStepIconColor: Colors.lightBlueAccent,
showLoadingAnimation: false,
steps: [
EasyStep(
customStep: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Opacity(
opacity:
controller.activeStep.value >= 0
? 1
: 0.3,
child: Image.asset(
'assets/registration/1.png',
),
),
),
customTitle: const Text(
'手机验证',
textAlign: TextAlign.center,
),
),
EasyStep(
customStep: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Opacity(
opacity:
controller.activeStep.value >= 1
? 1
: 0.3,
child: Image.asset(
'assets/registration/2.png',
),
),
),
customTitle: const Text(
'设置密码',
textAlign: TextAlign.center,
),
),
EasyStep(
customStep: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Opacity(
opacity:
controller.activeStep.value >= 2
? 1
: 0.3,
child: Image.asset(
'assets/registration/3.png',
),
),
),
customTitle: const Text(
'选择角色',
textAlign: TextAlign.center,
),
),
EasyStep(
customStep: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Opacity(
opacity:
controller.activeStep.value >= 3
? 1
: 0.3,
child: Image.asset(
'assets/registration/4.png',
),
),
),
customTitle: const Text(
'注册成功',
textAlign: TextAlign.center,
),
),
],
onStepReached:
(index) => {
controller.activeStep.value = index,
},
),
controller.activeStep.value == 0 ? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey,
width: 1,
),
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Row(
children: [
// 国家码
Text(
'电话号码',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
// 手机号输入框
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: '请输入手机号',
border: InputBorder.none,
),
),
),
],
),
),
const SizedBox(height: 20),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey,
width: 1,
),
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Row(
children: [
// 国家码
Text(
'验证码',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
// 手机号输入框
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: '请输入验证码',
border: InputBorder.none,
),
),
),
GFButton(
onPressed: (){},
text: "发送验证码",
icon: Icon(Icons.send_to_mobile),
),
],
),
),
const SizedBox(height: 20),
// 协议勾选区域
Row(
children: [
Checkbox(
value: false, // 默认未勾选
onChanged: (bool? value) {
// 处理勾选逻辑(可补充)
},
),
// Text(
// '阅读并同意《用户协议及隐私政策》',
// style: TextStyle(
// color: Colors.red,
// fontSize: 14,
// ),
// ),
Center(
child: Text.rich(
TextSpan(
text: '阅读并同意: ',
style: TextStyle(
color: Colors.red,
fontSize: 14,
),
children: <TextSpan>[
TextSpan(
text: '用户协议及隐私政策',
style: TextStyle(color: Colors.blue, decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()
..onTap = () {
// 处理点击事件,例如打开一个URL
// openURL('https://www.example.com');
Get.toNamed("/agreement_privacy_policy", arguments: 'user-agreement-privacy-policy');
},
),
],
),
),
),
],
),
const SizedBox(height: 20),
// 下一步按钮
ElevatedButton(
onPressed: () {
// 处理下一步逻辑(可补充)
++ controller.activeStep.value;
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
vertical: 12,
horizontal: 40,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
10,
),
),
),
child: const Text('下一步'),
),
],
),
) : const Column(),
controller.activeStep.value == 1 ? Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey,
width: 1,
),
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Row(
children: [
// 国家码
Text(
'密码',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
// 手机号输入框
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: '请输入密码',
border: InputBorder.none,
),
),
),
],
),
),
const SizedBox(height: 20),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey,
width: 1,
),
),
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Row(
children: [
// 国家码
Text(
'确认密码',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
// 手机号输入框
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: '请输入确认密码',
border: InputBorder.none,
),
),
)
],
),
),
const SizedBox(height: 20),
// 下一步按钮
ElevatedButton(
onPressed: () {
// 处理下一步逻辑(可补充)
++ controller.activeStep.value;
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
vertical: 12,
horizontal: 40,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
10,
),
),
),
child: const Text('下一步'),
),
],
),
) : const Column(),
controller.activeStep.value == 2 ?
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
child: Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'人员类型选择',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
RadioListTile<String>(
title: const Text('种植人员'),
value: 'plantPersonnel',
groupValue: controller.registrationType.value,
onChanged: (dynamic value) {
controller.registrationType.value = value.toString(); // 更新选中值
},
),
const SizedBox(width: 10),
RadioListTile<String>(
title: const Text('农服人员'),
value: 'agriculturalClothingPersonnel',
groupValue: controller.registrationType.value,
onChanged: (dynamic value) {
controller.registrationType.value = value.toString(); // 更新选中值
},
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'角色选择',
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
const SizedBox(width: 10),
]),
CheckboxListTile(
title: const Text('机手'),
value: controller.machinist.value,
onChanged: (bool? value) {
controller.machinist.value = value!;
},
),
CheckboxListTile(
title: const Text('飞手'),
value: controller.pilot.value,
onChanged: (bool? value) {
controller.pilot.value = value!;
},
),
CheckboxListTile(
title: const Text('农服'),
value: controller.agriculturalClothing.value,
onChanged: (bool? value) {
controller.agriculturalClothing.value = value!;
},
),
CheckboxListTile(
title: const Text('帮手'),
value: controller.assistant.value,
onChanged: (bool? value) {
controller.assistant.value = value!;
},
),
],
),
),
),
SizedBox(height: 20),
// 下一步按钮
ElevatedButton(
onPressed: () {
// 处理下一步逻辑(可补充)
++ controller.activeStep.value;
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(
vertical: 12,
horizontal: 40,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
10,
),
),
),
child: const Text('下一步'),
),
],
),
) : const Column(),
controller.activeStep.value == 3 ?
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ScaleTransition(
scale: controller.animation,
child: Icon(
Icons.check_circle,
color: Colors.yellow,
size: 100,
),
),
SizedBox(height: 30),
Text(
'注册成功!',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
SizedBox(height: 20),
Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
'欢迎加入我们的社区,现在开始探索精彩内容吧!',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
color: Colors.white70,
),
),
),
SizedBox(height: 50),
ElevatedButton(
onPressed: () {
// 跳转到主页
Navigator.pushReplacementNamed(context, '/home');
},
style: ElevatedButton.styleFrom(
foregroundColor: Colors.blueAccent,
backgroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 40, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
child: Text(
'开始探索',
style: TextStyle(fontSize: 18),
),
),
],
),
)
],
),
) : const Column(),
],
),
),
// Image.asset(
// controller.dashImages[ controller.activeStep.value],
// height: 150,
// ),
// const SizedBox(height: 5),
// Text('Dash ${ controller.activeStep.value + 1}')
],
),
),
],
),
),
),
),
),
);
}
}
`
There is no error prompt displayed normally, I don't know what the reason is!
iqfareez
Metadata
Metadata
Assignees
Labels
r: invalidIssue is closed as not validIssue is closed as not valid