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/fcs_id_icon.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-09-11 16:14:36 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
typedef void FindCallBack();
|
|
|
|
|
|
|
|
|
|
class CustomerEditor extends StatefulWidget {
|
2020-09-13 21:49:39 +06:30
|
|
|
final User customer;
|
2020-09-11 16:14:36 +06:30
|
|
|
const CustomerEditor({this.customer});
|
|
|
|
|
@override
|
|
|
|
|
_CustomerEditorState createState() => _CustomerEditorState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CustomerEditorState extends State<CustomerEditor> {
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var phoneNumberBox = Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Expanded(
|
2020-09-13 21:49:39 +06:30
|
|
|
child: DisplayText(
|
|
|
|
|
text: widget.customer.phoneNumber,
|
2020-10-13 07:50:25 +06:30
|
|
|
labelTextKey: "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)),
|
2020-09-11 16:14:36 +06:30
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
2020-09-13 21:49:39 +06:30
|
|
|
child: SafeArea(
|
|
|
|
|
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,
|
|
|
|
|
),
|
|
|
|
|
),
|
2020-09-11 16:14:36 +06:30
|
|
|
),
|
2020-09-13 21:49:39 +06:30
|
|
|
body: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
2020-09-15 07:13:41 +06:30
|
|
|
child: ListView(
|
2020-09-13 21:49:39 +06:30
|
|
|
children: <Widget>[
|
2020-09-15 07:13:41 +06:30
|
|
|
phoneNumberBox,
|
|
|
|
|
DisplayText(
|
|
|
|
|
text: widget.customer.fcsID,
|
2020-10-13 07:50:25 +06:30
|
|
|
labelTextKey: "customer.fcs.id",
|
2020-09-18 04:04:21 +06:30
|
|
|
icon: FcsIDIcon(),
|
2020-09-15 07:13:41 +06:30
|
|
|
),
|
2020-09-20 08:06:14 +06:30
|
|
|
DisplayText(
|
|
|
|
|
text: widget.customer.status,
|
2020-10-13 07:50:25 +06:30
|
|
|
labelTextKey: "customer.status",
|
2020-09-20 08:06:14 +06:30
|
|
|
iconData: Icons.add_alarm,
|
|
|
|
|
),
|
2020-09-15 07:13:41 +06:30
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
2020-09-13 21:49:39 +06:30
|
|
|
),
|
|
|
|
|
widget.customer.requested
|
|
|
|
|
? fcsButton(
|
|
|
|
|
context,
|
|
|
|
|
getLocalString(
|
|
|
|
|
context, "customer.invitation.request.confirm"),
|
|
|
|
|
callack: _add)
|
|
|
|
|
: Container()
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-09-11 16:14:36 +06:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 21:49:39 +06:30
|
|
|
_add() async {
|
|
|
|
|
showConfirmDialog(context, "customer.invitation.request.confirm", () async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
if (widget.customer == null) return;
|
|
|
|
|
CustomerModel customerModel =
|
|
|
|
|
Provider.of<CustomerModel>(context, listen: false);
|
|
|
|
|
try {
|
|
|
|
|
await customerModel.acceptRequest(widget.customer.id);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-09-11 16:14:36 +06:30
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|