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/widget/centertipsalterwidget.dart

76 lines
2.0 KiB

2 years ago
import 'package:flutter/cupertino.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.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';
2 years ago
typedef Callback = Function(bool status);
2 years ago
class Centertipsalterwidget extends StatefulWidget {
final String title;
final String desText;
final int id;
final Callback callback;
2 years ago
const Centertipsalterwidget(
{Key? key, required this.desText, required this.title, required this.id, required this.callback})
2 years ago
: super(key: key);
@override
_CentertipsalterwidgetState createState() => _CentertipsalterwidgetState();
}
class _CentertipsalterwidgetState extends State<Centertipsalterwidget> {
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
2 years ago
@override
Widget build(BuildContext context) {
return CupertinoAlertDialog(
title: Text(widget.title),
content: Column(children: [
SizedBox(
height: 10.w,
),
Align(
alignment: const Alignment(0, 0),
2 years ago
child: Text(widget.desText),
2 years ago
)
]),
actions: [
CupertinoDialogAction(
child: const Text(
'取消',
style: TextStyle(color: Color(0xFF999999)),
),
onPressed: () {
widget.callback(false);
2 years ago
Navigator.pop(context);
},
),
CupertinoDialogAction(
child: const Text('确定'),
onPressed: () async {
BaseModel res = await apiClient.request(API.content.delete, data: {
'id': widget.id,
});
if (res.code == 0) {
setState(() {});
userProvider.updateUserInfo();
} else {
CloudToast.show(res.msg);
}
widget.callback(true);
2 years ago
Navigator.pop(context);
},
)
],
);
}
}