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.

118 lines
3.5 KiB

import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/home/content_details_page.dart';
import 'package:project_telephony/ui/widget/centertipsalterwidget.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart';
class ContentPage extends StatefulWidget {
final bool? isAnswer; //true接听false未接听
const ContentPage({Key? key, required this.isAnswer}) : super(key: key);
@override
_ContentPageState createState() => _ContentPageState();
}
class _ContentPageState extends State<ContentPage> {
int _select = 0;
List<String> textList = ['欢迎你的来电', '祝您生活愉快', '感谢您的来电我们会尽快处理的', '自定义短信内容'];
List<String> textList1 = ['自定义短信内容'];
late String phoneNum;
late String callState;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(
'选择短信内容',
style: Theme.of(context).textTheme.headline6,
),
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor,
),
backgroundColor: Colors.white,
body: Column(children: [
Expanded(
child: _getList(),
),
]),
);
}
_getList() {
return ListView.builder(
itemBuilder: (context, index) {
return _getBox(textList[index], index == _select, index);
},
itemCount: textList.length,
);
}
_getBox(String content, bool pd, int index) {
return GestureDetector(
onTap: () async {
_select = index;
if (index == textList.length - 1) {
await Get.to(() => ContentDetailsPage(
content: "",
ploneBack: (String textContent) {
// print("这是数据" + textContent);
textList.setAll(index, {textContent});
},
));
} else {
final Iterable<CallLogEntry> result = await CallLog.query();
phoneNum = result.first.number!;
}
setState(() {});
// print("这是数据" + textList[_s lect]);
// print(index);
},
onLongPress: () {
if (index != textList.length - 1) {
showDialog(
context: context,
builder: (context) {
return const Centertipsalterwidget(
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
title: '删除短信模板',
);
});
}
setState(() {});
},
child: Container(
// 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
: const Color(0xFF72E4C8)
: const Color(0xFFF9F9F9),
),
child: Text(
content,
style: TextStyle(
fontSize: BaseStyle.fontSize28,
color: pd ? const Color(0xFFF9F9F9) : BaseStyle.color333333,
fontWeight: FontWeight.bold),
),
),
);
}
}