490 lines
17 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/showBottomSheetTool.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
//高亮样式
2023-07-28 17:14:11 +08:00
final TextStyle highStyle =
TextStyle(color: const Color(0xFFEEDFA8), fontSize: 20.sp);
//默认样式
2023-07-28 17:14:11 +08:00
final TextStyle defaultStyle = TextStyle(color: Colors.black, fontSize: 20.sp);
//预览样式封装-密码
late InlineSpan passwardSpan = TextSpan(children: [
2023-07-28 17:14:11 +08:00
TextSpan(
text:
'${TranslationLoader.lanKeys!.hello!.tr}\n${TranslationLoader.lanKeys!.yourRoomIs!.tr}',
style: defaultStyle),
TextSpan(text: '201', style: highStyle),
2023-07-28 17:14:11 +08:00
TextSpan(
text: ' ${TranslationLoader.lanKeys!.theCodeToOpenTheDoorIs!.tr} ',
style: defaultStyle),
TextSpan(text: '332211\n', style: highStyle),
2023-07-28 17:14:11 +08:00
TextSpan(
text: '${TranslationLoader.lanKeys!.periodValidity!.tr} ',
style: defaultStyle),
TextSpan(text: '2021.12.11 12:00 - 2021.12.12 13:00。\n', style: highStyle),
2023-07-28 17:14:11 +08:00
TextSpan(
text: TranslationLoader.lanKeys!.templateTip1!.tr, style: defaultStyle),
]);
//预览样式封装-密码
late InlineSpan electronicKeySpan = TextSpan(children: [
2023-07-28 17:14:11 +08:00
TextSpan(
text:
'${TranslationLoader.lanKeys!.hello!.tr}\n${TranslationLoader.lanKeys!.templateTip2!.tr}',
style: defaultStyle),
TextSpan(text: 'https://abc.com/bcd\n', style: highStyle),
2023-07-28 17:14:11 +08:00
TextSpan(
text: '${TranslationLoader.lanKeys!.templateTip3!.tr}\n',
style: defaultStyle),
TextSpan(text: 'https://abc.com/bcd', style: highStyle),
]);
class ValueAddedServicesAddSMSTemplatePage extends StatefulWidget {
const ValueAddedServicesAddSMSTemplatePage({Key? key}) : super(key: key);
@override
2023-07-28 17:14:11 +08:00
State<ValueAddedServicesAddSMSTemplatePage> createState() =>
_ValueAddedServicesAddSMSTemplatePageState();
}
2023-07-28 17:14:11 +08:00
class _ValueAddedServicesAddSMSTemplatePageState
extends State<ValueAddedServicesAddSMSTemplatePage> {
final _templateOneTf = TextEditingController();
final _templateTwoTf = TextEditingController();
final _templateNameTf = TextEditingController();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
_templateOneTf.text = TranslationLoader.lanKeys!.hello!.tr;
_templateTwoTf.text = TranslationLoader.lanKeys!.templateTip1!.tr;
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
2023-07-28 17:14:11 +08:00
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.customSMSTemplate!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: ListView(
children: [
_buildEditTopInfo(),
2023-07-28 17:14:11 +08:00
SizedBox(
height: 10.h,
),
_buildEditTemplate(),
2023-07-28 17:14:11 +08:00
SizedBox(
height: 10.h,
),
_buildpreview(),
SizedBox(height: 42.h),
2023-07-28 17:14:11 +08:00
Container(
margin: EdgeInsets.only(left: 20.w, right: 20.w),
child: SubmitBtn(
btnName: TranslationLoader.lanKeys!.save!.tr,
borderRadius: 10.w,
margin: EdgeInsets.only(
left: 30.w, right: 30.w, top: 30.w, bottom: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {
// Navigator.pushNamed(context, Routers.sendElectronicKeyManagePage);
}),
),
SizedBox(
height: 40.h,
)
],
));
}
2023-07-28 17:14:11 +08:00
Widget _buildEditTopInfo() {
return Column(
children: [
2023-07-28 17:14:11 +08:00
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
_templateNameTf, TranslationLoader.lanKeys!.pleaseEnter!.tr)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.type!.tr,
rightTitle: TranslationLoader.lanKeys!.password!.tr,
isHaveLine: false,
action: () {
2024-01-23 17:29:18 +08:00
_showSelectTemplateType();
2023-07-28 17:14:11 +08:00
}),
],
);
}
Widget _buildEditTemplate() {
return Container(
color: Colors.white,
child: Column(
children: [
Row(
children: [
Padding(
2023-07-28 17:14:11 +08:00
padding: EdgeInsets.only(
left: 25.w, top: 25.h, bottom: 25.h, right: 25.w),
child: Text(
TranslationLoader.lanKeys!.templateContent!.tr,
style:
TextStyle(fontSize: 20.sp, fontWeight: FontWeight.w600),
),
),
],
),
Container(
margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 25.h),
height: 100,
child: TextField(
2023-07-28 17:14:11 +08:00
maxLines: 8,
// maxLength:1000,
textAlign: TextAlign.start,
controller: _templateOneTf,
2023-07-28 17:14:11 +08:00
style: TextStyle(
color: Colors.black,
fontSize: 20.sp,
),
decoration: InputDecoration(
2023-07-28 17:14:11 +08:00
contentPadding: EdgeInsets.only(
top: 20.h, left: 20.w, right: 20.w, bottom: 20.h),
border: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
2023-07-28 17:14:11 +08:00
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
2023-07-28 17:14:11 +08:00
///设置边框的粗细
width: 0.5,
),
),
2023-07-28 17:14:11 +08:00
///用来配置输入框获取焦点时的颜色
focusedBorder: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
2023-07-28 17:14:11 +08:00
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
2023-07-28 17:14:11 +08:00
///设置边框的粗细
width: 1,
),
),
),
),
),
Visibility(
visible: true,
child: Column(
2023-07-28 17:14:11 +08:00
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
children: [
Padding(
2023-07-28 17:14:11 +08:00
padding:
EdgeInsets.only(left: 25.w, top: 10.h, right: 25.w),
child: RichText(
text: TextSpan(children: [
TextSpan(
text:
'${TranslationLoader.lanKeys!.yourRoomIs!.tr} ',
style: defaultStyle),
TextSpan(
text:
'{${TranslationLoader.lanKeys!.roomName!.tr}}',
style: highStyle),
TextSpan(
text:
' ${TranslationLoader.lanKeys!.theCodeToOpenTheDoorIs!.tr} ',
style: defaultStyle),
TextSpan(
text:
'{${TranslationLoader.lanKeys!.password!.tr}}',
style: highStyle),
]))),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(left: 25.w, top: 10.h),
2023-07-28 17:14:11 +08:00
child: RichText(
text: TextSpan(children: [
TextSpan(
text:
'${TranslationLoader.lanKeys!.periodValidity!.tr} ',
style: defaultStyle),
TextSpan(
text:
'{${TranslationLoader.lanKeys!.periodValidity!.tr}}',
style: highStyle),
]))),
SizedBox(
width: 10.w,
),
GestureDetector(
2023-07-28 17:14:11 +08:00
onTap: () {},
child: Row(
children: [
Image.asset(
2024-01-23 17:29:18 +08:00
'images/icon_round_unSelect.png',
width: 26.w,
height: 26.w,
2023-07-28 17:14:11 +08:00
),
],
),
)
],
),
],
),
),
Visibility(
visible: false,
2023-07-28 17:14:11 +08:00
child: Row(
children: [
Padding(
padding:
EdgeInsets.only(left: 25.w, top: 10.h, right: 25.w),
child: RichText(
text: TextSpan(children: [
TextSpan(
text:
'${TranslationLoader.lanKeys!.templateTip2!.tr}\n',
style: defaultStyle),
TextSpan(
text: 'https://abc.com/bcd\n',
style: TextStyle(
color: const Color(0xFFEEDFA8), fontSize: 20.sp)),
TextSpan(
text:
'${TranslationLoader.lanKeys!.templateTip3!.tr}\n',
style: defaultStyle),
TextSpan(
text: 'https://abc.com/bcd\n',
style: TextStyle(
color: const Color(0xFFEEDFA8), fontSize: 20.sp)),
]))),
],
),
),
SizedBox(height: 10.h),
Container(
margin: EdgeInsets.only(left: 25.w, right: 25.w, bottom: 25.h),
height: 100,
child: Stack(
alignment: Alignment.bottomRight,
children: [
TextField(
2023-07-28 17:14:11 +08:00
maxLines: 8,
// maxLength:1000,
textAlign: TextAlign.start,
controller: _templateTwoTf,
2023-07-28 17:14:11 +08:00
style: TextStyle(
color: Colors.black,
fontSize: 20.sp,
),
decoration: InputDecoration(
2023-07-28 17:14:11 +08:00
contentPadding: EdgeInsets.only(
top: 20.h, left: 20.w, right: 20.w, bottom: 20.h),
border: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
2023-07-28 17:14:11 +08:00
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
2023-07-28 17:14:11 +08:00
///设置边框的粗细
width: 0.5,
),
),
2023-07-28 17:14:11 +08:00
///用来配置输入框获取焦点时的颜色
focusedBorder: OutlineInputBorder(
///设置边框四个角的弧度
borderRadius: BorderRadius.all(Radius.circular(20.h)),
2023-07-28 17:14:11 +08:00
///用来配置边框的样式
borderSide: const BorderSide(
///设置边框的颜色
color: Color(0xffB2B2B2),
2023-07-28 17:14:11 +08:00
///设置边框的粗细
width: 1,
),
),
),
)
],
),
),
],
),
);
}
Widget _buildpreview() {
return Column(
2023-07-28 17:14:11 +08:00
// mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
color: Colors.white,
margin: EdgeInsets.only(bottom: 20.h),
child: Column(
children: [
Column(
children: [
2023-07-28 17:14:11 +08:00
Row(
children: [
Padding(
padding: EdgeInsets.only(
left: 25.w,
top: 25.h,
bottom: 25.h,
right: 25.w),
child: Text(
TranslationLoader.lanKeys!.preview!.tr,
style: TextStyle(
fontSize: 20.sp, fontWeight: FontWeight.w600),
),
),
],
),
Container(
margin: EdgeInsets.only(left: 25.w, right: 25.w),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
borderRadius: BorderRadius.circular(10.h),
),
2023-07-28 17:14:11 +08:00
child: Padding(
padding: EdgeInsets.only(
left: 20.w,
top: 20.h,
right: 20.w,
bottom: 20.h),
child: RichText(text: passwardSpan)),
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
left: 25.w,
top: 25.h,
bottom: 25.h,
),
child: Text(
'${TranslationLoader.lanKeys!.expectedNotoCount!.tr}2',
style: TextStyle(
color: Colors.grey,
fontSize: 20.sp,
),
),
)
],
)
/*
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(
// left: 25.w,
top: 25.h,
bottom: 25.h,
),
child: Text(
'${TranslationLoader.lanKeys!.expectedNotoCount!.tr}2',
style: TextStyle(
color: Colors.grey,
fontSize: 20.sp,
),
),
),
],
),
2023-07-28 17:14:11 +08:00
*/
],
),
],
2023-07-28 17:14:11 +08:00
))
]);
}
2023-07-28 17:14:11 +08:00
Widget getTFWidget(TextEditingController tfController, String tfStr) {
return Container(
height: 50.h,
2023-07-28 17:14:11 +08:00
width: 300.w,
child: Row(
children: [
Expanded(
child: TextField(
//输入框一行
maxLines: 1,
controller: tfController,
autofocus: false,
2023-07-28 17:14:11 +08:00
textAlign: TextAlign.end,
decoration: InputDecoration(
//输入里面输入文字内边距设置
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
hintText: tfStr,
2023-07-28 17:14:11 +08:00
hintStyle: TextStyle(fontSize: 22.sp),
//不需要输入框下划线
border: InputBorder.none,
),
),
),
],
),
);
}
2024-01-23 17:29:18 +08:00
void _showSelectTemplateType() {
2023-07-28 17:14:11 +08:00
var list = [
TranslationLoader.lanKeys!.electronicKey!.tr,
TranslationLoader.lanKeys!.password!.tr
];
ShowBottomSheetTool().showSingleRowPicker(
2023-07-28 17:14:11 +08:00
//上下文
context,
//默认的索引
normalIndex: 0,
title: TranslationLoader.lanKeys!.type!.tr,
cancelTitle: TranslationLoader.lanKeys!.cancel!.tr,
sureTitle: TranslationLoader.lanKeys!.sure!.tr,
//要显示的列表
//可自定义数据适配器
//adapter: PickerAdapter(),
data: list,
//选择事件的回调
2023-07-28 17:14:11 +08:00
clickCallBack: (int index, var str) {});
}
}