|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/user_tool.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
import '../../base/base_style.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
import '../../model/network/api_client.dart';
|
|
|
|
import '../../model/network/base_model.dart';
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
import '../home/home_page.dart';
|
|
|
|
import '../widget/plone_back_button.dart';
|
|
|
|
import '../widget/plone_bottom.dart';
|
|
|
|
|
|
|
|
typedef TextCallback = Function(String textContent);
|
|
|
|
|
|
|
|
class ContentDetailsPage extends StatefulWidget {
|
|
|
|
final TextCallback ploneBack;
|
|
|
|
final String content;
|
|
|
|
const ContentDetailsPage(
|
|
|
|
{Key? key, required this.content, required this.ploneBack})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_ContentDetailsPageState createState() => _ContentDetailsPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ContentDetailsPageState extends State<ContentDetailsPage> {
|
|
|
|
late TextEditingController _controller;
|
|
|
|
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
String cText="";
|
|
|
|
final FocusNode verifyNode=FocusNode();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_controller = TextEditingController(text: widget.content);
|
|
|
|
}
|
|
|
|
@override
|
|
|
|
void dispose(){
|
|
|
|
super.dispose();
|
|
|
|
// verifyNode.unfocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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: 162.w,
|
|
|
|
leading: const CloudBackButton(isSpecial: true),
|
|
|
|
backgroundColor: kForeGroundColor),
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
body:
|
|
|
|
Container(
|
|
|
|
height: 960.w,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: const Color(0xFFF9F9F9),
|
|
|
|
borderRadius: BorderRadius.circular(16.w),
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.all(30.w),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 40.w, vertical: 50.w),
|
|
|
|
child:
|
|
|
|
|
|
|
|
|
|
|
|
TextField(
|
|
|
|
focusNode: verifyNode,
|
|
|
|
maxLines: 100,
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
onChanged: (text){
|
|
|
|
cText=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: widget.content.isNotEmpty ? "" : "请输入所需短信",
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: widget.content != ""
|
|
|
|
? const Color(0xFF333333)
|
|
|
|
: Colors.grey.shade500,
|
|
|
|
fontSize: 28.sp,
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
border: InputBorder.none,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
bottomNavigationBar: PloneBottom(
|
|
|
|
border: _controller.text.isEmpty,
|
|
|
|
opacity: cText.isNotEmpty ? 1 : 0.4,
|
|
|
|
onTap: () async {
|
|
|
|
// print(_controller.text);
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
BaseModel res =
|
|
|
|
await apiClient.request(API.app.addTag, data: {'tag': _controller.text});
|
|
|
|
if (res.code == 0) {
|
|
|
|
setState(() {});
|
|
|
|
widget.ploneBack(_controller.text);
|
|
|
|
prefs.setString("refSms", _controller.text);
|
|
|
|
service.invoke("stopService");
|
|
|
|
if (prefs.getBool('kg') ?? false) {
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
service.startService();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// UserTool.userProvider.updateUserInfo();
|
|
|
|
// UserTool.userProvider.updateConSms();
|
|
|
|
Get.back();
|
|
|
|
} else {
|
|
|
|
CloudToast.show(res.msg);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: "保存",
|
|
|
|
).paddingOnly(bottom: 30.w),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|