2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:fcs/pages/customer/model/customer_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/util.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/display_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-09-13 21:49:39 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
typedef void FindCallBack();
|
|
|
|
|
|
|
|
|
|
class InvitationEditor extends StatefulWidget {
|
|
|
|
|
final User customer;
|
|
|
|
|
const InvitationEditor({this.customer});
|
|
|
|
|
@override
|
|
|
|
|
_InvitationEditorState createState() => _InvitationEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InvitationEditorState extends State<InvitationEditor> {
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var phoneNumberBox = Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DisplayText(
|
|
|
|
|
text: widget.customer.phoneNumber,
|
2020-10-08 03:32:52 +06:30
|
|
|
labelTextKey: getLocalString(context, "customer.phone"),
|
2020-09-13 21:49:39 +06:30
|
|
|
iconData: Icons.phone,
|
|
|
|
|
)),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(Icons.open_in_new, color: primaryColor),
|
|
|
|
|
onPressed: () => call(context, widget.customer.phoneNumber)),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
shadowColor: Colors.transparent,
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoIcons.back,
|
2020-09-13 21:49:39 +06:30
|
|
|
color: primaryColor,
|
|
|
|
|
size: 30,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
widget.customer.name,
|
|
|
|
|
style: TextStyle(fontSize: 20, color: primaryColor),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: ListView(
|
|
|
|
|
children: [phoneNumberBox],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
fcsButton(context, getLocalString(context, "btn.delete"),
|
|
|
|
|
callack: _delete)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_delete() async {
|
|
|
|
|
showConfirmDialog(context, "invitation.confirm.delete", () async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
if (widget.customer == null) return;
|
|
|
|
|
CustomerModel customerModel =
|
|
|
|
|
Provider.of<CustomerModel>(context, listen: false);
|
|
|
|
|
try {
|
|
|
|
|
await customerModel.deleteInvite(widget.customer.phoneNumber);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|