149 lines
5.2 KiB
Dart
149 lines
5.2 KiB
Dart
import 'package:fcs/fcs/common/pages/model/main_model.dart';
|
|
import 'package:share/share.dart';
|
|
import 'package:fcs/fcs/common/domain/entities/user.dart';
|
|
import 'package:fcs/fcs/common/localization/app_translations.dart';
|
|
import 'package:fcs/fcs/common/pages/customers/invitation_create.dart';
|
|
import 'package:fcs/fcs/common/pages/customers/model/customer_model.dart';
|
|
import 'package:fcs/fcs/common/pages/util.dart';
|
|
import 'package:fcs/fcs/common/pages/widgets/bottom_up_page_route.dart';
|
|
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
|
|
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
|
|
|
import 'invitation_editor.dart';
|
|
|
|
class InvitationList extends StatefulWidget {
|
|
@override
|
|
_InvitationListState createState() => _InvitationListState();
|
|
}
|
|
|
|
class _InvitationListState extends State<InvitationList> {
|
|
var dateFormatter = new DateFormat('dd MMM yyyy - hh:mm:ss a');
|
|
final double dotSize = 15.0;
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
var customerModel = Provider.of<CustomerModel>(context);
|
|
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
centerTitle: true,
|
|
leading: new IconButton(
|
|
icon: new Icon(Icons.close),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
actions: <Widget>[],
|
|
backgroundColor: primaryColor,
|
|
title: LocalText(
|
|
context,
|
|
'invitation.list',
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: () {
|
|
Navigator.of(context).push(BottomUpPageRoute(InvitationCreate()));
|
|
},
|
|
icon: Icon(Icons.add),
|
|
label: LocalText(context, "invitation.new", color: Colors.white),
|
|
backgroundColor: primaryColor,
|
|
),
|
|
body: new ListView.separated(
|
|
separatorBuilder: (context, index) => Divider(
|
|
color: Colors.black,
|
|
),
|
|
scrollDirection: Axis.vertical,
|
|
padding: EdgeInsets.only(left: 15, right: 15, top: 15),
|
|
shrinkWrap: true,
|
|
itemCount: customerModel.invitations.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
User customer = customerModel.invitations[index];
|
|
return _item(customer);
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _item(User customer) {
|
|
return Stack(
|
|
children: <Widget>[
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.of(context)
|
|
.push(BottomUpPageRoute(InvitationEditor(customer: customer)));
|
|
},
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: new Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
child: new Row(
|
|
children: <Widget>[
|
|
new Padding(
|
|
padding: new EdgeInsets.symmetric(
|
|
horizontal: 32.0 - dotSize / 2),
|
|
child: Icon(
|
|
Feather.user,
|
|
color: primaryColor,
|
|
size: 40,
|
|
),
|
|
),
|
|
new Expanded(
|
|
child: new Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
new Text(
|
|
customer.name,
|
|
style: new TextStyle(
|
|
fontSize: 15.0, color: primaryColor),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: new Text(
|
|
customer.phoneNumber,
|
|
style: new TextStyle(
|
|
fontSize: 15.0, color: Colors.grey),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
FlatButton(
|
|
onPressed: () => _share(customer),
|
|
child: Row(
|
|
children: [
|
|
Text("Share"),
|
|
Icon(Icons.share),
|
|
],
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
_share(User user) async {
|
|
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
|
String appUrl = mainModel.setting.appUrl;
|
|
final RenderBox box = context.findRenderObject();
|
|
await Share.share(
|
|
user.share + "\n Please join us from this link:\n $appUrl",
|
|
subject: "Invitation to FCS App",
|
|
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
|
|
}
|
|
}
|