clean up
This commit is contained in:
120
lib/pages/customer/customer_editor.dart
Normal file
120
lib/pages/customer/customer_editor.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
typedef void FindCallBack();
|
||||
|
||||
class CustomerEditor extends StatefulWidget {
|
||||
final User customer;
|
||||
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(
|
||||
child: DisplayText(
|
||||
text: widget.customer.phoneNumber,
|
||||
labelText: getLocalString(context, "customer.phone"),
|
||||
iconData: Icons.phone,
|
||||
)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.open_in_new, color: primaryColor),
|
||||
onPressed: () => call(context, widget.customer.phoneNumber)),
|
||||
],
|
||||
);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
shadowColor: Colors.transparent,
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(
|
||||
Icons.close,
|
||||
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: ListView(
|
||||
children: <Widget>[
|
||||
phoneNumberBox,
|
||||
DisplayText(
|
||||
text: widget.customer.fcsID,
|
||||
labelText: getLocalString(context, "customer.fcs.id"),
|
||||
icon: FcsIDIcon(),
|
||||
),
|
||||
DisplayText(
|
||||
text: widget.customer.status,
|
||||
labelText: getLocalString(context, "customer.status"),
|
||||
iconData: Icons.add_alarm,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
widget.customer.requested
|
||||
? fcsButton(
|
||||
context,
|
||||
getLocalString(
|
||||
context, "customer.invitation.request.confirm"),
|
||||
callack: _add)
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
_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;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user