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