You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
8.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import 'package:flutter/material.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/TextMe/text_template.dart';
import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/toast/cloud_toast.dart';
import 'package:telephony/telephony.dart';
import 'package:velocity_x/velocity_x.dart';
import '../widget/plone_back_button.dart';
import 'address_book.dart';
class TextMePage extends StatefulWidget {
const TextMePage({Key? key}) : super(key: key);
@override
_TextMePageState createState() => _TextMePageState();
}
class _TextMePageState extends State<TextMePage> {
// String contentText = "";
// String phoneText = "";
String signatureText = "";
late TextEditingController _controller;
late TextEditingController _phoneController;
@override
void initState() {
_controller = TextEditingController();
_phoneController = TextEditingController();
_controller.text = "";
_phoneController.text = "";
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
elevation: 0,
title: Text(
"群发短信",
style: TextStyle(
fontSize: BaseStyle.fontSize34,
color: BaseStyle.color333333,
fontWeight: FontWeight.bold),
),
titleSpacing: 200.w,
leading: const CloudBackButton(
isSpecial: true,
isSpecials: false,
),
backgroundColor: kForeGroundColor),
backgroundColor: Colors.white,
body: ListView(
children: [
_getBox('短信内容', "选择短信模版", () {
Get.to(() => TextTemplate(
callback: (String content) {
_controller.text = content;
},
));
}, "请输入短信内容...", _controller),
32.hb,
_getBox('收信号码', "通讯录中选择", () {
Get.to(() => const AddressBook());
}, "请输入收信号码多个号码请用逗号隔开例如136xxxx6666132xxxx8888", _phoneController),
32.hb,
_getBox2(),
64.hb,
PloneBottom(
onTap: () async {
// final Telephony telephony = Telephony.instance;
if (_controller.text.isEmpty &&
_phoneController.text.isEmpty &&
signatureText.isEmpty) {
CloudToast.show("内容不可为空");
} else {
print(_controller.text);
print(_phoneController.text);
print(signatureText);
await sendSMS(
message:"$signatureText${_controller.text}",
recipients: [
"13395740386",
"13486828191",
// "18815060992",
// "18294841148"
],
sendDirect: true);
// await telephony.sendSms(
// to: "13486828191;13395740386;18815060992;18294841148",
// message: "【$signatureText】${_controller.text}"
// );
CloudToast.show("发送成功");
// Telephony.sendSms(to: phoneNum!, message: idle);
}
},
border: _controller.text.isEmpty ||
_phoneController.text.isEmpty ||
signatureText.isEmpty,
opacity: _controller.text.isEmpty ||
_phoneController.text.isEmpty ||
signatureText.isEmpty
? 0.4
: 1,
text: "发送",
)
],
),
);
}
_getBox(String title, String onTapText, VoidCallback onTap, String hitText,
TextEditingController controller) {
return Column(
children: [
GestureDetector(
onTap: onTap,
child: Container(
height: 100.w,
margin: EdgeInsets.symmetric(horizontal: 64.w),
child: Row(
children: [
Text(
title,
style: TextStyle(
fontSize: 28.sp,
color: BaseStyle.color999999,
fontWeight: FontWeight.bold),
),
290.wb,
Text(
onTapText,
style: TextStyle(
fontSize: 28.sp, color: const Color(0xFF1890FF)),
),
const Icon(
Icons.keyboard_arrow_right,
color: Color(0xFF1890FF),
),
],
),
),
),
16.hb,
Container(
height: 240.w,
decoration: BoxDecoration(
color: const Color(0xFFF9F9F9),
borderRadius: BorderRadius.circular(8.w),
),
padding: EdgeInsets.all(30.w),
margin: EdgeInsets.symmetric(
horizontal: 64.w,
),
child: TextField(
// focusNode: verifyNode,
maxLines: 100,
keyboardType: TextInputType.text,
// onChanged: (text) {
// if (title == "短信内容") {
// _controller.text = text;
// } else {
// _phoneController.text = text;
// }
// setState(() {});
// },
onSubmitted: (text){
if (title == "短信内容") {
_controller.text = text;
} else {
_phoneController.text = text;
}
setState(() {});
},
onEditingComplete: () {
setState(() {});
// _refreshController.callRefresh();
},
style: TextStyle(
color: BaseStyle.color333333,
fontSize: BaseStyle.fontSize28,
),
controller: controller,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
filled: true,
isDense: true,
fillColor: Colors.transparent,
hintText: hitText,
hintStyle: TextStyle(
color: BaseStyle.color999999,
fontSize: 28.sp,
),
border: InputBorder.none,
),
),
),
],
);
}
_getBox2() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 64.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"短信签名",
style: TextStyle(
fontSize: 28.sp,
color: const Color(0xFF999999),
fontWeight: FontWeight.w600,
),
),
15.heightBox,
TextField(
// controller: controller,
onChanged: (value) {
signatureText = value;
setState(() {});
},
decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w),
hintText: "请输入短信签名",
hintStyle: TextStyle(
fontSize: 28.sp,
// fontWeight: FontWeight.w600,
color: const Color(0xFF999999),
),
fillColor: const Color(0xFFF9F9F9),
filled: true,
enabledBorder: const OutlineInputBorder(
/*边角*/
borderRadius: BorderRadius.all(
Radius.circular(5), //边角为5
),
borderSide: BorderSide(
color: Colors.white, //边线颜色为白色
width: 1, //边线宽度为2
),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white, //边框颜色为白色
width: 1, //宽度为5
),
borderRadius: BorderRadius.all(
Radius.circular(5), //边角为30
),
),
),
),
],
),
);
}
}