starwork_flutter/lib/views/team/addRole/add_role_view.dart

158 lines
6.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:starwork_flutter/common/constant/app_colors.dart';
import 'package:starwork_flutter/common/widgets/custom_cell_list_widget.dart';
import 'package:starwork_flutter/common/widgets/custom_cell_widget.dart';
import 'package:starwork_flutter/common/widgets/custome_app_bar_wdiget.dart';
import 'package:starwork_flutter/extension/function_extension.dart';
import 'add_role_controller.dart';
class AddRoleView extends GetView<AddRoleController> {
@override
Widget build(BuildContext context) {
// 即使不使用,只是引用一下 controller 就能触发初始化
final _ = controller; // 添加这一行
return GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
},
child: Scaffold(
appBar: CustomAppBarWidget(
title: '新建角色'.tr,
backgroundColor: AppColors.scaffoldBackgroundColor,
),
backgroundColor: AppColors.scaffoldBackgroundColor,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 10.w,
vertical: 10.h,
),
child: Column(
children: [
CustomCellListWidget(
children: [
CustomCellWidget(
onTap: () {},
leftText: '角色名称'.tr,
leftIcon: Icon(
Icons.circle,
size: 4.w,
color: Colors.red,
),
rightWidget: Expanded(
flex: 3,
child: TextField(
controller: controller.roleNameInputController,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
isCollapsed: true,
hintText: '请输入角色名称'.tr,
hintStyle: TextStyle(
fontSize: 14.sp,
color: Colors.black54,
fontWeight: FontWeight.w400,
),
// 设置无边框
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
// 获取焦点时的边框
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
),
)
],
),
SizedBox(
height: 10.h,
),
CustomCellListWidget(
children: [
CustomCellWidget(
onTap: () {},
leftText: '角色描述'.tr,
leftIcon: Icon(
Icons.circle,
size: 4.w,
color: Colors.red,
),
rightWidget: Expanded(
flex: 3,
child: TextField(
controller: controller.roleDescribeInputController,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
isCollapsed: true,
hintText: '请输入角色描述'.tr,
hintStyle: TextStyle(
fontSize: 14.sp,
color: Colors.black54,
fontWeight: FontWeight.w400,
),
// 设置无边框
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
// 获取焦点时的边框
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
),
)
],
),
SizedBox(
height: 10.h,
),
Spacer(),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
if (controller.roleNameInputController.text.isEmpty) {
controller.showToast('请先输入角色名称');
return;
}
if (controller.roleDescribeInputController.text.isEmpty) {
controller.showToast('请先输入角色描述');
return;
}
controller.createTeamRole();
}.debounce(),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: EdgeInsets.symmetric(vertical: 12.h),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.r)),
),
child: Text(
'保存'.tr,
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
)
],
),
),
),
),
);
}
}