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.
project_telephony/lib/ui/user/content_details_page.dart

124 lines
3.9 KiB

import 'package:flutter/material.dart';
import 'package:project_telephony/utils/headers.dart';
2 years ago
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import '../../base/base_style.dart';
import '../../constants/api.dart';
import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart';
import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.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;
2 years ago
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
2 years ago
String cText="";
final FocusNode verifyNode=FocusNode();
@override
void initState() {
super.initState();
_controller = TextEditingController(text: widget.content);
}
2 years ago
@override
void dispose(){
super.dispose();
// verifyNode.unfocus();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
elevation: 0,
title: Text(
2 years ago
'编辑短信标签',
style: TextStyle(
fontSize: BaseStyle.fontSize34,
color: BaseStyle.color333333,
fontWeight: FontWeight.bold),
),
titleSpacing: 162.w,
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor),
backgroundColor: Colors.white,
2 years ago
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(
2 years ago
focusNode: verifyNode,
maxLines: 100,
keyboardType: TextInputType.text,
2 years ago
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,
2 years ago
opacity: cText.isNotEmpty ? 1 : 0.4,
onTap: () async {
2 years ago
// print(_controller.text);
BaseModel res =
await apiClient.request(API.app.addTag, data: {'tag': _controller.text});
if (res.code == 0) {
setState(() {});
widget.ploneBack(_controller.text);
2 years ago
UserTool.userProvider.updateUserInfo();
Get.back();
} else {
CloudToast.show(res.msg);
}
},
text: "保存",
).paddingOnly(bottom: 30.w),
);
}
}