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.

157 lines
4.9 KiB

2 years ago
import 'dart:async';
2 years ago
import 'dart:io';
2 years ago
import 'package:call_log/call_log.dart';
2 years ago
import 'package:flutter/material.dart';
2 years ago
import 'package:flutter/services.dart';
2 years ago
import 'package:flutter_background_service/flutter_background_service.dart';
2 years ago
import 'package:flutter_sms/flutter_sms.dart';
import 'package:get_phone_number/get_phone_number.dart';
2 years ago
import 'package:hive/hive.dart';
2 years ago
import 'package:permission_handler/permission_handler.dart';
2 years ago
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/home/content_details_page.dart';
2 years ago
import 'package:project_telephony/ui/widget/centertipsalterwidget.dart';
2 years ago
import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart';
2 years ago
import 'package:telephony/telephony.dart';
import '../user/privacy_rights_page.dart';
2 years ago
class ContentPage extends StatefulWidget {
2 years ago
final bool? isAnswer; //true接听false未接听
const ContentPage({Key? key, required this.isAnswer}) : super(key: key);
2 years ago
@override
_ContentPageState createState() => _ContentPageState();
}
2 years ago
2 years ago
class _ContentPageState extends State<ContentPage> {
2 years ago
int _select = 0;
List<String> textList = ['欢迎你的来电', '祝您生活愉快', '感谢您的来电我们会尽快处理的', '自定义短信内容'];
List<String> textList1 = ['自定义短信内容'];
2 years ago
late String phoneNum;
late String callState;
2 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2 years ago
elevation: 0,
2 years ago
title: Text(
'选择短信内容',
style: Theme.of(context).textTheme.headline6,
),
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor,
),
2 years ago
backgroundColor: Colors.white,
2 years ago
body: Column(children: [
Expanded(
child: _getList(),
),
]),
);
}
_getList() {
return ListView.builder(
itemBuilder: (context, index) {
2 years ago
return _getBox(textList[index], index == _select, index);
2 years ago
},
itemCount: textList.length,
);
}
2 years ago
_getBox(String content, bool pd, int index) {
2 years ago
return GestureDetector(
2 years ago
onTap: () async {
_select = index;
2 years ago
if (index == textList.length - 1) {
2 years ago
await Get.to(() => ContentDetailsPage(
content: "",
ploneBack: (String textContent) {
// print("这是数据" + textContent);
textList.setAll(index, {textContent});
},
));
2 years ago
} else {
2 years ago
// bool? permissionsGranted = await telephony.requestPhonePermissions;
2 years ago
// print(permissionsGranted);
// if(permissionsGranted!){
// print(content);
// // sendSms(content);
// telephony.sendSms(
// to: "13395740386",
// message: content,
// );
// }else{
// print(content);
// }
// print(content);
// // sendSms(content);
// telephony.sendSms(
// to: "13395740386",
// message: content,
// isMultipart: true
// );
2 years ago
// List<String> recipents=[
// phoneNum
// ];
// _sendSMS(content,recipents);
2 years ago
// String phoneNumber = await GetPhoneNumber().get();
// print('getPhoneNumber result: $phoneNumber');
2 years ago
}
2 years ago
setState(() {});
2 years ago
// print("这是数据" + textList[_s lect]);
// print(index);
},
onLongPress: () {
2 years ago
if (index != textList.length - 1) {
2 years ago
showDialog(
context: context,
builder: (context) {
return const Centertipsalterwidget(
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
title: '删除短信模板',
);
});
}
2 years ago
setState(() {});
2 years ago
},
child: Container(
2 years ago
// width: 686.w,
height: 135.w,
margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
padding: EdgeInsets.only(left: 40.w, top: 50.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
color: pd
? widget.isAnswer!
? Colors.blue
2 years ago
: const Color(0xFF72E4C8)
2 years ago
: const Color(0xFFF9F9F9),
),
child: Text(
content,
style: TextStyle(
fontSize: BaseStyle.fontSize28,
color: pd ? const Color(0xFFF9F9F9) : BaseStyle.color333333,
fontWeight: FontWeight.bold),
),
),
2 years ago
);
}
2 years ago
void _sendSMS(String message, List<String> recipients) async {
String _result = await sendSMS(
message: message, recipients: recipients, sendDirect: true)
.catchError((onError) {
print(onError);
});
print(_result);
}
2 years ago
}