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.

138 lines
4.3 KiB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
2 years ago
import 'package:provider/provider.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';
2 years ago
import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart';
import '../user/content_details_page.dart';
import '../widget/plone_back_button.dart';
import '../widget/plone_bottom.dart';
class AddSmsPage extends StatefulWidget {
final int status;
final TextCallback ploneBack;
final bool qfBool;
const AddSmsPage({Key? key, required this.status, required this.ploneBack,this.qfBool=false}) : super(key: key);
@override
_AddSmsPageState createState() => _AddSmsPageState();
}
class _AddSmsPageState extends State<AddSmsPage> {
late TextEditingController _controller;
2 years ago
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
2 years ago
String contant="";
2 years ago
@override
void initState() {
super.initState();
_controller = TextEditingController();
}
2 years ago
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@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: Align(
alignment: Alignment.topCenter,
child: Container(
height: 800.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(
maxLines: 100,
keyboardType: TextInputType.text,
onEditingComplete: () {
setState(() {});
// _refreshController.callRefresh();
},
style: TextStyle(
color: BaseStyle.color333333,
fontSize: BaseStyle.fontSize28,
),
2 years ago
onChanged: (text) async{
contant=text;
setState((){});
},
controller: _controller,
decoration: const InputDecoration(
fillColor: Colors.transparent,
contentPadding: EdgeInsets.zero,
filled: true,
isDense: true,
hintText: "请输入所需短信标签",
border: InputBorder.none,
),
),
),
),
bottomNavigationBar: PloneBottom(
border: _controller.text.isEmpty,
2 years ago
opacity: contant.isEmpty ? 0.4 : 1,
onTap: () async {
final prefs = await SharedPreferences.getInstance();
List<String>? contentList=prefs.getStringList("dxText");
if(widget.qfBool){
contentList?.add(contant);
await prefs.setStringList("dxText", contentList!);
Get.back();
}else{
BaseModel res = await apiClient.request(API.content.content, data: {
'content': _controller.text,
'status': widget.status,
});
if (res.code == 0) {
setState(() {});
widget.ploneBack(_controller.text);
2 years ago
switch (widget.status) {
case 1:
await userProvider.updateConSms();
break;
case 2:
await userProvider.updateRefSms();
break;
case 3:
await userProvider.updateCallSms();
break;
case 4:
await userProvider.updateIdleSms();
break;
}
} else {
CloudToast.show(res.msg);
}
Get.back();}
},
text: "保存",
).paddingOnly(bottom: 30.w),
);
}
}