344 lines
10 KiB
Dart
344 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
import 'package:star_lock/main/lockDetail/lockSet/notificationMode/notificationMode_logic.dart';
|
|
import 'package:star_lock/tools/commonItem.dart';
|
|
import 'package:star_lock/tools/submitBtn.dart';
|
|
import 'package:star_lock/translations/trans_lib.dart';
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
import '../../../../../tools/titleAppBar.dart';
|
|
|
|
class NotificationModePage extends StatefulWidget {
|
|
const NotificationModePage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<NotificationModePage> createState() => _NotificationModePageState();
|
|
}
|
|
|
|
class _NotificationModePageState extends State<NotificationModePage> {
|
|
final logic = Get.put(NotificationModeLogic());
|
|
final state = Get.find<NotificationModeLogic>().state;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: '提醒方式',
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor),
|
|
body: SingleChildScrollView(
|
|
child: _buildMainView(),
|
|
));
|
|
}
|
|
|
|
Widget _buildMainView() {
|
|
return Column(
|
|
children: [
|
|
CommonItem(
|
|
leftTitel: 'APP推送',
|
|
rightTitle: '管理员',
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
action: () {}),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
CommonItem(
|
|
leftTitel: '邮件提醒',
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
isHaveRightWidget: true,
|
|
rightWidget: state.emailReceiverList.value.length < 3
|
|
? Image.asset(
|
|
'images/icon_btn_add.png',
|
|
width: 32.w,
|
|
height: 32.w,
|
|
)
|
|
: Container(),
|
|
action: () {
|
|
if (state.emailReceiverList.value.length < 3) {
|
|
setState(() {
|
|
state.emailReceiverList.value.add(1);
|
|
});
|
|
}
|
|
}),
|
|
Obx(() => SizedBox(
|
|
height: state.emailReceiverList.value.length * 62.h,
|
|
child: ListView.separated(
|
|
itemCount: state.emailReceiverList.value.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _buildReceiverItem(index, true);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1.h,
|
|
color: AppColors.greyBackgroundColor,
|
|
);
|
|
},
|
|
),
|
|
)),
|
|
SizedBox(
|
|
height: 10.h,
|
|
),
|
|
CommonItem(
|
|
leftTitel: '短信提醒',
|
|
rightTitle: '',
|
|
isHaveLine: true,
|
|
isHaveDirection: false,
|
|
isHaveRightWidget: true,
|
|
rightWidget: state.phoneReceiverList.value.length < 3
|
|
? Image.asset(
|
|
'images/icon_btn_add.png',
|
|
width: 32.w,
|
|
height: 32.w,
|
|
)
|
|
: Container(),
|
|
action: () {
|
|
if (state.phoneReceiverList.value.length < 3) {
|
|
setState(() {
|
|
state.phoneReceiverList.value.add(1);
|
|
});
|
|
}
|
|
}),
|
|
SizedBox(
|
|
height: state.phoneReceiverList.value.length * 62.h,
|
|
child: ListView.separated(
|
|
itemCount: state.phoneReceiverList.value.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _buildReceiverItem(index, false);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
return Divider(
|
|
height: 1.h,
|
|
color: AppColors.greyBackgroundColor,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 60.h,
|
|
),
|
|
SubmitBtn(
|
|
btnName: '确定',
|
|
onClick: () {},
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildReceiverItem(int index, bool isEmail) {
|
|
return Container(
|
|
color: Colors.white,
|
|
child: Row(
|
|
children: [
|
|
GestureDetector(
|
|
child: SizedBox(
|
|
// width: 40.w,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 20.w,
|
|
),
|
|
Image.asset(
|
|
'images/icon_massSend_delete.png',
|
|
width: 26.w,
|
|
height: 26.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
setState(() {
|
|
if (isEmail) {
|
|
state.emailReceiverList.value.removeAt(index);
|
|
} else {
|
|
state.phoneReceiverList.value.removeAt(index);
|
|
}
|
|
});
|
|
},
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
children: [
|
|
massSendReceiverCellWidget(
|
|
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
|
rightTitle: state.inputEmailStr.value,
|
|
isHaveLine: true,
|
|
isHaveRightWidget: true,
|
|
rightWidget: isEmail
|
|
? getEmailTFWidget('请输入Email', 1)
|
|
: getPhoneWidget('请输入手机号', 1)),
|
|
Divider(
|
|
color: AppColors.greyLineColor,
|
|
indent: 20.w,
|
|
endIndent: 20.w,
|
|
height: 1,
|
|
),
|
|
],
|
|
))
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// TextEditingController _receiverController(String getStr) {
|
|
// TextEditingController controller = TextEditingController(text: getStr);
|
|
// controller.addListener(() {
|
|
// state.inputEmailStr.value = controller.text;
|
|
// print(controller.text);
|
|
// });
|
|
|
|
// return controller;
|
|
// }
|
|
|
|
// 接受者邮箱输入框
|
|
Widget getEmailTFWidget(String tfStr, int lineIndex) {
|
|
TextEditingController emailController = TextEditingController();
|
|
return SizedBox(
|
|
height: 50.h,
|
|
width: 360.w,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextField(
|
|
controller: emailController,
|
|
//输入框一行
|
|
maxLines: 1,
|
|
autofocus: false,
|
|
textAlign: TextAlign.end,
|
|
decoration: InputDecoration(
|
|
//输入里面输入文字内边距设置
|
|
contentPadding: const EdgeInsets.only(top: -12.0, bottom: 0.0),
|
|
hintText: tfStr,
|
|
hintStyle: TextStyle(fontSize: 22.sp),
|
|
//不需要输入框下划线
|
|
border: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// 接受者手机号输入框
|
|
Widget getPhoneWidget(String tfStr, int lineIndex) {
|
|
TextEditingController phoneController = TextEditingController();
|
|
|
|
return SizedBox(
|
|
height: 50.h,
|
|
width: 360.w,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: GestureDetector(
|
|
child: Container(
|
|
width: 90.w,
|
|
color: Colors.white,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
Obx(() => Text(
|
|
'+${state.countryCode}',
|
|
style: TextStyle(
|
|
color: AppColors.darkGrayTextColor,
|
|
fontSize: 20.sp),
|
|
)),
|
|
Image.asset(
|
|
'images/icon_grayPullDown.png',
|
|
width: 20.w,
|
|
height: 20.w,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () async {
|
|
var result = await Get.toNamed(Routers.selectCountryRegionPage);
|
|
if (result != null) {
|
|
result as Map<String, dynamic>;
|
|
state.countryCode.value = result['code'];
|
|
state.countryName.value = result['countryName'];
|
|
}
|
|
},
|
|
)),
|
|
SizedBox(
|
|
width: 5.w,
|
|
),
|
|
SizedBox(
|
|
width: 180.w,
|
|
child: TextField(
|
|
controller: phoneController,
|
|
//输入框一行
|
|
maxLines: 1,
|
|
autofocus: false,
|
|
textAlign: TextAlign.end,
|
|
decoration: InputDecoration(
|
|
//输入里面输入文字内边距设置
|
|
contentPadding: const EdgeInsets.only(top: -12.0, bottom: 0.0),
|
|
hintText: tfStr,
|
|
hintStyle: TextStyle(fontSize: 22.sp),
|
|
//不需要输入框下划线
|
|
border: InputBorder.none,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget massSendReceiverCellWidget({
|
|
String? leftTitel,
|
|
String? rightTitle,
|
|
bool? isHaveDirection,
|
|
bool? isHaveLine,
|
|
bool? isHaveRightWidget,
|
|
Widget? rightWidget,
|
|
Function()? action,
|
|
double? allHeight,
|
|
}) {
|
|
return Column(
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 60.h,
|
|
color: Colors.white,
|
|
padding: EdgeInsets.only(right: 20.w), // , top: 20.w, bottom: 20.w
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 20.w),
|
|
Text(leftTitel!, style: TextStyle(fontSize: 22.sp)),
|
|
Expanded(child: SizedBox(width: 10.w)),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
isHaveRightWidget!
|
|
? rightWidget!
|
|
: Text(
|
|
rightTitle ?? "",
|
|
textAlign: TextAlign.end,
|
|
// overflow: TextOverflow.ellipsis,
|
|
// maxLines: 1,
|
|
style: TextStyle(
|
|
fontSize: 22.sp,
|
|
color: AppColors.darkGrayTextColor),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|