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

112 lines
3.5 KiB

import 'package:flutter/material.dart';
import 'package:project_telephony/utils/headers.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;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override
void initState() {
super.initState();
_controller = TextEditingController(text: widget.content);
}
@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: 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,
),
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: _controller.text.isNotEmpty ? 1 : 0.4,
onTap: () async {
BaseModel res =
await apiClient.request(API.app.addTag, data: {'tag': _controller.text});
if (res.code == 0) {
setState(() {});
widget.ploneBack(_controller.text);
userProvider.updateUserInfo();
Get.back();
} else {
CloudToast.show(res.msg);
}
},
text: "保存",
).paddingOnly(bottom: 30.w),
);
}
}