add payment methods

This commit is contained in:
Sai Naw Wun
2020-09-18 04:04:21 +06:30
parent 33f0c4fd98
commit 00f647e915
47 changed files with 1344 additions and 1043 deletions

View File

@@ -3,7 +3,7 @@ import 'dart:io';
import 'package:fcs/fcs/common/localization/app_translations_delegate.dart';
import 'package:fcs/fcs/common/localization/transalation.dart';
import 'package:fcs/fcs/common/pages/contact/model/contact_model.dart';
import 'package:fcs/fcs/common/pages/customers/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/customer/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/faq/model/faq_model.dart';
import 'package:fcs/fcs/common/pages/initial_language_selection.dart';
import 'package:fcs/fcs/common/pages/market/model/market_model.dart';
@@ -11,6 +11,7 @@ import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart' as fcs;
import 'package:fcs/fcs/common/pages/package/model/package_model.dart';
import 'package:fcs/fcs/common/pages/package/model/shipment_model.dart';
import 'package:fcs/fcs/common/pages/payment_methods/model/payment_method_model.dart';
import 'package:fcs/fcs/common/pages/staff/model/staff_model.dart';
import 'package:fcs/fcs/common/pages/term/model/term_model.dart';
import 'package:fcs/fcs/common/services/services.dart';
@@ -64,6 +65,7 @@ class _AppState extends State<App> {
final TermModel termModel = new TermModel();
final MainModel mainModel = new MainModel();
final FAQModel faqModel = new FAQModel();
final PaymentMethodModel paymentMethodModel = new PaymentMethodModel();
final UserModel userModel = new UserModel();
final ProductModel productModel = new ProductModel();
@@ -259,6 +261,7 @@ class _AppState extends State<App> {
ChangeNotifierProvider.value(value: contactModel),
ChangeNotifierProvider.value(value: termModel),
ChangeNotifierProvider.value(value: faqModel),
ChangeNotifierProvider.value(value: paymentMethodModel),
ChangeNotifierProvider.value(value: marketModel),
],
child: Consumer<LanguageModel>(

View File

@@ -0,0 +1,23 @@
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
import 'package:fcs/fcs/common/helpers/api_helper.dart';
import 'package:fcs/fcs/common/helpers/firebase_helper.dart';
import 'package:logging/logging.dart';
class CommonDataProvider {
final log = Logger('CommonDataProvider');
Future<void> createPaymentMethod(PaymentMethod paymentMethod) async {
return await requestAPI("/payment_methods", "POST",
payload: paymentMethod.toMap(), token: await getToken());
}
Future<void> updatePaymentMethod(PaymentMethod paymentMethod) async {
return await requestAPI("/payment_methods", "PUT",
payload: paymentMethod.toMap(), token: await getToken());
}
Future<void> deletePaymentMethod(String id) async {
return await requestAPI("/payment_methods", "DELETE",
payload: {"id": id}, token: await getToken());
}
}

View File

@@ -9,25 +9,23 @@ class FAQ {
String question(bool isEng) => isEng ? questionEng : questionMm;
String answer(bool isEng) => isEng ? answerEng : answerMm;
Map<String, String> imageUrls;
FAQ(
{this.id,
this.sn,
this.questionEng,
this.questionMm,
this.answerEng,
this.answerMm,
this.imageUrls});
FAQ({
this.id,
this.sn,
this.questionEng,
this.questionMm,
this.answerEng,
this.answerMm,
});
Map<String, dynamic> toMap() {
return {
'id': id,
'sn':sn,
'sn': sn,
'question_eng': questionEng,
'answer_eng': answerEng,
'question_mm': questionMm,
'answer_mm': answerMm,
'images': imageUrls,
};
}
@@ -39,7 +37,6 @@ class FAQ {
answerEng: map['answer_eng'],
questionMm: map['question_mm'],
answerMm: map['answer_mm'],
imageUrls: Map.from(map['images'] ?? Map<String, String>()),
);
}

View File

@@ -0,0 +1,42 @@
class PaymentMethod {
String id;
String name;
String accountName;
String account;
String phone;
String email;
String link;
PaymentMethod(
{this.id,
this.name,
this.accountName,
this.account,
this.phone,
this.email,
this.link});
factory PaymentMethod.fromMap(Map<String, dynamic> map, String id) {
return PaymentMethod(
id: id,
name: map['name'],
accountName: map['account_name'],
account: map['account'],
phone: map['phone'],
email: map['email'],
link: map['link'],
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'name': name,
"account_name": accountName,
"account": account,
"phone": phone,
"email": email,
"link": link,
};
}
}

View File

@@ -24,10 +24,11 @@ class Setting {
String facebookLink;
bool inviteRequired;
String appUrl;
final String termsEng;
final String termsMm;
final String okEnergyId;
final String about;
final String terms;
int poExpireInHours;
int doExpireInHours;
int poOpenAt;
@@ -88,9 +89,10 @@ class Setting {
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.okEnergyId,
this.terms,
this.poExpireInHours,
this.doExpireInHours,
this.poOpenAt,
@@ -136,7 +138,8 @@ class Setting {
emailAddress: map['email_address'],
facebookLink: map['facebook_link'],
about: map['about'],
terms: map['terms'],
termsEng: map['terms_eng'],
termsMm: map['terms_mm'],
priceLastUpdate: ts?.toDate(),
okEnergyId: map['ok_energy_id'],
poExpireInHours: map['po_expire_hours'],
@@ -161,7 +164,8 @@ class Setting {
Map<String, dynamic> toMap() {
return {
'terms': terms,
'terms_eng': termsEng,
'terms_mm': termsMm,
};
}

View File

@@ -1,25 +1,24 @@
import 'package:fcs/fcs/common/domain/entities/setting.dart';
class Term {
String term;
String termEng;
String termMm;
Term({
this.term,
});
Term({this.termEng, this.termMm});
factory Term.fromSetting(Setting setting) {
return Term(
term: setting.terms,);
return Term(termEng: setting.termsEng, termMm: setting.termsMm);
}
Map<String, dynamic> toMap() {
return {
'terms': term,
'terms_eng': termEng,
'terms_mm': termMm,
};
}
@override
String toString() {
return 'Contact{terms:$term}';
return 'Contact{terms_eng:$termEng}';
}
}

View File

@@ -0,0 +1,130 @@
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class BuyingOnlinePage extends StatefulWidget {
@override
_BuyingOnlinePagetate createState() => _BuyingOnlinePagetate();
}
class _BuyingOnlinePagetate extends State<BuyingOnlinePage>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
_tabController = TabController(vsync: this, length: 2);
super.initState();
}
@override
Widget build(BuildContext context) {
MainModel mainModel = Provider.of<MainModel>(context);
final phoneNumberBox = DisplayText(
text: mainModel.user.phone,
labelText: getLocalString(context, "contact.phone"),
iconData: Icons.location_on,
);
final nameBox = Center(
child: Text(
mainModel.user.name,
style: TextStyle(fontSize: 18, color: primaryColor),
));
final fcsIdBox = DisplayText(
text: mainModel.user.fcsID,
labelText: getLocalString(context, "customer.fcs.id"),
icon: FcsIDIcon(),
);
final shippingAddressBox = DisplayText(
text: mainModel.setting.usaAddress,
labelText: getLocalString(context, "profile.usa.shipping.address"),
iconData: Icons.location_on,
);
final instructionBox = Container(
padding: EdgeInsets.only(left: 10, top: 30, bottom: 10),
child: Center(
child: Wrap(
children: <Widget>[
LocalText(
context,
'buy_online.buying_instruction',
color: labelColor,
fontSize: 15,
)
],
),
),
);
return Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
title: LocalText(
context,
"buy_online.title",
fontSize: 20,
color: primaryColor,
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
),
body: ListView(
shrinkWrap: true,
padding: EdgeInsets.only(top: 10, left: 10, right: 10),
children: <Widget>[
nameBox,
phoneNumberBox,
fcsIdBox,
shippingAddressBox,
instructionBox,
new Container(
decoration: new BoxDecoration(color: Colors.white),
child: new TabBar(
// indicatorColor: primaryColor,
labelColor: primaryColor,
labelStyle: TextStyle(fontWeight: FontWeight.bold),
unselectedLabelColor: Colors.grey,
controller: _tabController,
tabs: [
LocalText(context, "buy_online.fullname"),
LocalText(context, "buy_online.first.last"),
],
),
),
new Container(
padding: EdgeInsets.only(top: 10),
height: 500,
width: 500,
child: new TabBarView(
controller: _tabController,
children: <Widget>[
Container(
child:
Image.asset('assets/Fullname.png', fit: BoxFit.contain),
),
Container(
child: Image.asset('assets/FirstName&LastName.png',
fit: BoxFit.contain),
),
],
),
),
SizedBox(height: 10)
],
),
);
}
}

View File

@@ -4,6 +4,7 @@ import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/contact/model/contact_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/input_text.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -27,7 +28,6 @@ class _ContactEditorState extends State<ContactEditor> {
TextEditingController _email = new TextEditingController();
TextEditingController _facebook = new TextEditingController();
final _formKey = GlobalKey<FormState>();
bool _isLoading = false;
@override
@@ -76,61 +76,51 @@ class _ContactEditorState extends State<ContactEditor> {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
body: CustomScrollView(slivers: [
SliverAppBar(
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 30,
),
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
expandedHeight: 150.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title:
Text(AppTranslations.of(context).text('contact.edit.title'),
style: TextStyle(
color: Colors.white,
)),
),
),
SliverList(
delegate: SliverChildListDelegate([
Padding(
padding: const EdgeInsets.only(left: 18.0, right: 18),
child: Column(
children: [
itemTitle(context, "contact.callus"),
usaPhoneBox,
mmPhoneBox,
Divider(),
itemTitle(context, "contact.findus"),
usaAddreesBox,
mmAddressBox,
Divider(),
itemTitle(context, "contact.emailus"),
emailBox,
Divider(),
itemTitle(context, "contact.visitus"),
faceBookBox,
SizedBox(
height: 10,
),
saveBox,
SizedBox(
height: 20,
)
],
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
'contact.edit.title',
color: primaryColor,
fontSize: 20,
)),
body: ListView(
children: [
Padding(
padding: const EdgeInsets.only(left: 18.0, right: 18),
child: Column(
children: [
itemTitle(context, "contact.callus"),
usaPhoneBox,
mmPhoneBox,
Divider(),
itemTitle(context, "contact.findus"),
usaAddreesBox,
mmAddressBox,
Divider(),
itemTitle(context, "contact.emailus"),
emailBox,
Divider(),
itemTitle(context, "contact.visitus"),
faceBookBox,
SizedBox(
height: 10,
),
saveBox,
SizedBox(
height: 20,
)
],
),
]),
)
]),
),
],
),
));
}

View File

@@ -4,6 +4,7 @@ import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/contact/contact_editor.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@@ -25,45 +26,40 @@ class _ContactPageState extends State<ContactPage> {
bool isEditable = context.select((MainModel m) => m.contactEditable());
return Scaffold(
body: CustomScrollView(slivers: [
SliverAppBar(
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 30,
),
onPressed: () => Navigator.of(context).pop(),
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
backgroundColor: primaryColor,
expandedHeight: 100.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title: Text(AppTranslations.of(context).text('contact.title'),
style: TextStyle(
color: Colors.white,
)),
),
actions: isEditable
? [
IconButton(
onPressed: () =>
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => ContactEditor(
contact: Contact.fromSetting(setting),
),
)),
icon: Icon(
CupertinoIcons.pen,
color: Colors.white,
))
]
: [],
onPressed: () => Navigator.of(context).pop(),
),
SliverList(
delegate: SliverChildListDelegate([
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
'contact.title',
color: primaryColor,
fontSize: 20,
),
actions: isEditable
? [
IconButton(
onPressed: () =>
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => ContactEditor(
contact: Contact.fromSetting(setting)),
)),
icon: Icon(
CupertinoIcons.pen,
color: primaryColor,
))
]
: [],
),
body: ListView(
children: [
itemTitle(context, "contact.callus"),
contactItem(context, setting.usaContactNumber, CupertinoIcons.phone,
onTap: () => _call(setting.usaContactNumber),
@@ -106,8 +102,8 @@ class _ContactPageState extends State<ContactPage> {
onTap: () => _opencontactItem(setting.facebookLink),
labelKey: "contact.facebook",
),
]))
]),
],
),
);
}

View File

@@ -1,9 +1,9 @@
import 'package:fcs/fcs/common/domain/entities/user.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/customers/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/customer/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -78,7 +78,7 @@ class _CustomerEditorState extends State<CustomerEditor> {
DisplayText(
text: widget.customer.fcsID,
labelText: getLocalString(context, "customer.fcs.id"),
iconData: Icons.account_circle,
icon: FcsIDIcon(),
),
SizedBox(
height: 20,

View File

@@ -1,20 +1,20 @@
import 'package:fcs/fcs/common/domain/constants.dart';
import 'package:fcs/fcs/common/domain/entities/user.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/customers/customer_editor.dart';
import 'package:fcs/fcs/common/pages/customers/invitation_list.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/customer/customer_editor.dart';
import 'package:fcs/fcs/common/pages/customer/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.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/widget/progress.dart';
import 'package:flutter/cupertino.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:share/share.dart';
import 'invitation_create.dart';
import 'invitation_editor.dart';
class CustomerList extends StatefulWidget {
@override
@@ -36,7 +36,7 @@ class _CustomerListState extends State<CustomerList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
actions: <Widget>[
@@ -52,9 +52,9 @@ class _CustomerListState extends State<CustomerList> {
backgroundColor: primaryColor,
title: LocalText(
context,
'customer.list.title',
color: Colors.white,
"customer.list.title",
fontSize: 20,
color: Colors.white,
),
),
floatingActionButton: FloatingActionButton.extended(
@@ -89,68 +89,78 @@ class _CustomerListState extends State<CustomerList> {
}
Widget _item(User customer) {
return Stack(
children: <Widget>[
InkWell(
onTap: () => _select(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),
),
),
],
),
),
],
return InkWell(
onTap: () => _select(customer),
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: new Row(
children: <Widget>[
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),
),
),
],
),
),
],
),
),
),
Column(
children: [
Padding(
padding: const EdgeInsets.only(right: 10),
padding: const EdgeInsets.only(right: 5),
child: _status(customer.status),
),
customer.status == user_invited_status
? FlatButton(
onPressed: () => _share(customer),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(color: primaryColor)),
child: Row(
children: [
Text(
"Share",
style: TextStyle(fontSize: 12),
),
Icon(Icons.share, color: primaryColor),
],
),
)
: Container(),
],
),
),
],
],
),
);
}
Widget _status(String status) {
return Text(
(user_requested_status == status || user_invited_status == status)
? status
: "",
style: TextStyle(color: primaryColor, fontSize: 14),
);
return user_requested_status == status
? Text(status, style: TextStyle(color: primaryColor, fontSize: 14))
: Container();
}
_select(User customer) {
@@ -158,7 +168,14 @@ class _CustomerListState extends State<CustomerList> {
.push(BottomUpPageRoute(CustomerEditor(customer: customer)));
}
_invitations() {
Navigator.of(context).push(BottomUpPageRoute(InvitationList()));
_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(
"Join us on FCS Logistics App. Here is the link:\n $appUrl\n" +
user.share,
subject: "Invitation to FCS Logistics App",
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}
}

View File

@@ -1,8 +1,9 @@
import 'package:country_code_picker/country_code_picker.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/customers/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/customer/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/widget/progress.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -36,22 +37,29 @@ class _InvitationCreateState extends State<InvitationCreate> {
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
shadowColor: Colors.transparent,
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("invitation.new")),
title: LocalText(
context,
"invitation.new",
fontSize: 20,
color: primaryColor,
),
),
body: Container(
padding: EdgeInsets.all(18),
child: ListView(
children: <Widget>[
fcsInput(getLocalString(context, "customer.name"), Icons.person,
controller: _nameController, autoFocus: true),
controller: _nameController, autoFocus: false),
SizedBox(height: 10),
Row(
children: <Widget>[

View File

@@ -1,16 +1,11 @@
import 'package:fcs/fcs/common/domain/entities/customer.dart';
import 'package:fcs/fcs/common/domain/entities/role.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/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/customer/model/customer_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/display_text.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:provider/provider.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
typedef void FindCallBack();

View File

@@ -1,148 +0,0 @@
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);
}
}

View File

@@ -5,6 +5,7 @@ import 'package:fcs/fcs/common/pages/faq/model/faq_model.dart';
import 'package:fcs/fcs/common/pages/faq/widgets.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/input_text.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -89,15 +90,14 @@ class _FAQEditorState extends State<FAQEditor> {
floating: true,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title: Text(
AppTranslations.of(context)
.text(_isNew ? 'faq.add.title' : 'faq.edit.title'),
style: TextStyle(
color: Colors.white,
)),
),
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title: LocalText(
context,
_isNew ? 'faq.add.title' : 'faq.edit.title',
fontSize: 20,
color: Colors.white,
)),
),
SliverList(
delegate: SliverChildListDelegate([

View File

@@ -68,10 +68,12 @@ class _FAQListPageState extends State<FAQListPage>
centerTitle: true,
titlePadding:
EdgeInsets.symmetric(vertical: 10, horizontal: 45),
title: Text(AppTranslations.of(context).text('faq.title'),
style: TextStyle(
color: Colors.white,
)),
title: LocalText(
context,
"faq.title",
fontSize: 20,
color: Colors.white,
),
),
actions: isEditable
? [

View File

@@ -1,17 +1,18 @@
import 'package:fcs/fcs/common/domain/entities/user.dart';
import 'package:fcs/fcs/common/localization/transalation.dart';
import 'package:fcs/fcs/common/pages/customers/customer_list.dart';
import 'package:fcs/fcs/common/pages/buying_instruction/buying_online.dart';
import 'package:fcs/fcs/common/pages/customer/customer_list.dart';
import 'package:fcs/fcs/common/pages/faq/faq_list_page.dart';
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/package/package_list.dart';
import 'package:fcs/fcs/common/pages/payment_methods/payment_method_page.dart';
import 'package:fcs/fcs/common/pages/staff/staff_list.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/action_button.dart';
import 'package:fcs/fcs/common/pages/widgets/bottom_widgets.dart';
import 'package:fcs/pages/discount_list.dart';
import 'package:fcs/pages/notification_list.dart';
import 'package:fcs/pages/payment_method_page.dart';
import 'package:fcs/pages/shipment_list.dart';
import 'package:fcs/pages/term.dart';
import 'package:fcs/pages_fcs/box_list.dart';
@@ -28,7 +29,6 @@ import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import '../../../pages/buying_online.dart';
import '../../../pages/fcs_profile_page.dart';
import '../../../pages/invoice/invoce_list.dart';
import '../../../pages/pickup_list.dart';
@@ -88,8 +88,8 @@ class _HomePageState extends State<HomePage> {
final packagesBtn = _buildBtn("package.btn.name",
icon: Octicons.package,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(PackageList())));
btnCallback: () => Navigator.of(context).push<void>(
CupertinoPageRoute(builder: (context) => PackageList())));
final boxesBtn = _buildBtn("boxes.name",
icon: MaterialCommunityIcons.package,
@@ -138,22 +138,26 @@ class _HomePageState extends State<HomePage> {
);
});
final staffBtn = _buildBtn("staff.title",
icon: MaterialCommunityIcons.worker,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(StaffList())));
final staffBtn = _buildBtn(
"staff.title",
icon: MaterialCommunityIcons.worker,
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => StaffList(),
)),
);
final customersBtn = _buildBtn("customers.btn",
icon: Feather.users,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(CustomerList())));
btnCallback: () => Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => CustomerList(),
)));
final invoicesBtn = _buildBtn("invoices.btn",
icon: FontAwesomeIcons.fileInvoice,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(InvoiceList())));
final paymentMethodBtn = _buildBtn("payment.method.btn",
final paymentMethodBtn = _buildBtn("pm.btn",
icon: FontAwesomeIcons.creditCard,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(PaymentMethodPage())));
@@ -175,7 +179,7 @@ class _HomePageState extends State<HomePage> {
List<Widget> widgets = [];
widgets.add(faqBtn);
if (user != null) {
// customer ? widgets.add(buyingBtn) : "";
customer ? widgets.add(buyingBtn) : "";
// customer || owner ? widgets.add(pickUpBtn) : "";
// !customer ? widgets.add(shipmentBtn) : "";
// customer || owner ? widgets.add(notiBtn) : "";
@@ -187,7 +191,7 @@ class _HomePageState extends State<HomePage> {
// owner ? widgets.add(deliveryBtn) : "";
user.hasCustomers() ? widgets.add(customersBtn) : "";
// customer || owner ? widgets.add(invoicesBtn) : "";
// owner ? widgets.add(paymentMethodBtn) : "";
widgets.add(paymentMethodBtn);
// owner ? widgets.add(discountBtn) : "";
// widgets.add(termBtn);
}
@@ -273,6 +277,7 @@ class _HomePageState extends State<HomePage> {
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
user.requested
? Container(
@@ -287,7 +292,7 @@ class _HomePageState extends State<HomePage> {
Expanded(
child: ListView(children: [
Wrap(
alignment: WrapAlignment.center,
alignment: WrapAlignment.start,
children: widgets,
),
]),

View File

@@ -1,14 +1,7 @@
import 'package:fcs/fcs/common/domain/entities/market.dart';
import 'package:fcs/fcs/common/domain/entities/role.dart';
import 'package:fcs/fcs/common/domain/entities/user.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/market/model/market_model.dart';
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/staff/model/staff_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/input_text.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';

View File

@@ -63,6 +63,11 @@ class PackageModel extends BaseModel {
return Services.instance.userService.searchUser(term);
}
Future<List<Package>> searchPackage(String term) {
// return Services.instance.userService.searchUser(term);
return null;
}
Future<void> createPackages(User user, List<Package> packages) {
return Services.instance.packageService
.createPackages(packages, user.fcsID);

View File

@@ -1,427 +0,0 @@
import 'package:fcs/fcs/common/domain/entities/market.dart';
import 'package:fcs/fcs/common/domain/entities/package.dart';
import 'package:fcs/fcs/common/domain/vo/shipping_address.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/market/market_editor.dart';
import 'package:fcs/fcs/common/pages/market/model/market_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/package/tracking_id_page.dart';
import 'package:fcs/fcs/common/pages/package/shipping_address_editor.dart';
import 'package:fcs/fcs/common/pages/package/shipping_address_list.dart';
import 'package:fcs/fcs/common/pages/package/shipping_address_row.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/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/fcs_expansion_tile.dart';
import 'package:fcs/fcs/common/pages/widgets/image_slider.dart';
import 'package:fcs/fcs/common/pages/widgets/input_text.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/my_data_table.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:fcs/pages/barcode_screen_page.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:timeline_list/timeline.dart';
import 'package:timeline_list/timeline_model.dart';
class PackageEditorPage extends StatefulWidget {
final Package package;
PackageEditorPage({this.package});
@override
_PackageEditorPageState createState() => _PackageEditorPageState();
}
class _PackageEditorPageState extends State<PackageEditorPage> {
TextEditingController _remarkCtl = new TextEditingController();
TextEditingController _descCtl = new TextEditingController();
Package _package;
bool _isLoading = false;
List<String> images = [
"assets/photos/1.jpg",
"assets/photos/2.jpg",
"assets/photos/3.jpg"
];
ShippingAddress shippingAddress = ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247');
@override
void initState() {
super.initState();
_package = widget.package;
selectedMarket = _package.market;
}
final DateFormat dateFormat = DateFormat("d MMM yyyy");
List<TimelineModel> _models() {
if (_package.shipmentHistory == null) return [];
return _package.shipmentHistory
.map((e) => TimelineModel(
Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(e.status,
style: TextStyle(
color: e.done ? primaryColor : Colors.grey,
fontSize: 16,
fontWeight: FontWeight.bold)),
Text(dateFormat.format(e.date)),
],
),
),
iconBackground: e.done ? primaryColor : Colors.grey,
icon: Icon(
e.status == "shipped"
? Ionicons.ios_airplane
: e.status == "delivered"
? MaterialCommunityIcons.truck_fast
: e.status == "processed"
? MaterialIcons.check
: Octicons.package,
color: Colors.white,
)))
.toList();
}
bool isNew = false;
@override
Widget build(BuildContext context) {
var owner = Provider.of<MainModel>(context).user.hasPackages();
final trackingIdBox = DisplayText(
text: _package.trackingID,
labelText: getLocalString(context, "package.tracking.id"),
iconData: MaterialCommunityIcons.barcode_scan,
);
final customerNameBox = DisplayText(
text: _package.userName,
labelText: getLocalString(context, "package.create.name"),
iconData: Icons.perm_identity,
);
final completeProcessingBtn = fcsButton(
context,
getLocalString(context, 'package.edit.complete.process.btn'),
callack: _completeProcessing,
);
final descBox = fcsInput(getLocalString(context, "package.edit.desc"),
MaterialCommunityIcons.message_text_outline,
controller: _descCtl, autoFocus: true);
final remarkBox = fcsInput(
getLocalString(context, "package.edit.remark"), Entypo.new_message,
controller: _remarkCtl, autoFocus: true);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close, color: primaryColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
title: LocalText(
context,
"package.edit.title",
fontSize: 20,
color: primaryColor,
),
),
body: ListView(
children: [
trackingIdBox,
customerNameBox,
owner
? isNew
? Container()
: ExpansionTile(
title: Text(
'Processing',
style: TextStyle(
color: primaryColor, fontWeight: FontWeight.bold),
),
children: [
dropDown(),
descBox,
remarkBox,
],
)
: Container(),
getImgSlider(images),
ExpansionTile(
title: Text(
'Status',
style:
TextStyle(color: primaryColor, fontWeight: FontWeight.bold),
),
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 20),
height: 400,
child: Timeline(
children: _models(), position: TimelinePosition.Left),
),
],
),
completeProcessingBtn,
SizedBox(
height: 20,
)
],
),
),
);
}
String selectedMarket;
Widget dropDown() {
List<Market> _markets = Provider.of<MarketModel>(context).markets;
List<String> markets = _markets.map((e) => e.name).toList();
markets.insert(0, MANAGE_MARKET);
return Row(
children: [
Padding(
padding: const EdgeInsets.only(right: 18.0),
child: LocalText(
context,
"package.create.market",
color: primaryColor,
fontSize: 16,
),
),
Container(
width: 150,
child: DropdownButton<String>(
value: selectedMarket,
style: TextStyle(color: Colors.black, fontSize: 14),
underline: Container(
height: 1,
color: Colors.grey,
),
onChanged: (String newValue) {
setState(() {
if (newValue == MANAGE_MARKET) {
selectedMarket = null;
_manageMarket();
return;
}
selectedMarket = newValue;
});
},
isExpanded: true,
items: markets.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: value == MANAGE_MARKET
? secondaryColor
: primaryColor)),
);
}).toList(),
),
),
],
);
}
_manageMarket() {
Navigator.push<Package>(
context,
BottomUpPageRoute(MarketEditor()),
);
}
Widget getShippingAddressList(BuildContext context) {
return Container(
child: ExpansionTile(
title: Text(
"Shipping Addresses",
style: TextStyle(
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
color: primaryColor),
),
children: <Widget>[
// Column(
// children: getAddressList(context, shipmentModel.shippingAddresses),
// ),
Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
children: <Widget>[
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.fullName == null
? ''
: shippingAddress.fullName,
style: new TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine1 == null
? ''
: shippingAddress.addressLine1,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.addressLine2 == null
? ''
: shippingAddress.addressLine2,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.city == null
? ''
: shippingAddress.city,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.state == null
? ''
: shippingAddress.state,
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: new Text(
shippingAddress.phoneNumber == null
? ''
: "Phone:${shippingAddress.phoneNumber}",
style: new TextStyle(
fontSize: 14.0, color: Colors.grey),
),
),
],
),
],
),
),
),
],
),
],
),
),
Container(
padding: EdgeInsets.only(top: 20, bottom: 15, right: 15),
child: Align(
alignment: Alignment.bottomRight,
child: Container(
width: 130,
height: 40,
child: FloatingActionButton.extended(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () async {
var address = await Navigator.push(
context,
BottomUpPageRoute(ShippingAddressList()),
);
print('address => ${address}');
setState(() {
if (address != null) {
this.shippingAddress = address;
}
});
},
icon: Icon(Icons.add),
label: Text(
'Select \nAddress',
style: TextStyle(fontSize: 12),
),
backgroundColor: primaryColor,
),
),
),
)
],
),
);
}
List<Widget> getAddressList(
BuildContext context, List<ShippingAddress> addresses) {
return addresses.asMap().entries.map((s) {
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(ShippingAddressEditor(shippingAddress: s.value)),
);
},
child: ShippingAddressRow(shippingAddress: s.value, index: s.key),
);
}).toList();
}
List<MyDataRow> getAddressRows(List<ShippingAddress> addresses) {
return addresses.map((s) {
return MyDataRow(
onSelectChanged: (selected) {},
cells: [
MyDataCell(
new Text(
s.fullName,
style: textStyle,
),
),
MyDataCell(
new Text(
s.phoneNumber,
style: textStyle,
),
),
],
);
}).toList();
}
_completeProcessing() {}
}

View File

@@ -1,6 +1,5 @@
import 'package:fcs/fcs/common/domain/entities/market.dart';
import 'package:fcs/fcs/common/domain/entities/package.dart';
import 'package:fcs/fcs/common/domain/vo/shipping_address.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/market/market_editor.dart';
import 'package:fcs/fcs/common/pages/market/model/market_model.dart';
@@ -9,7 +8,6 @@ import 'package:fcs/fcs/common/pages/package/tracking_id_page.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/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/image_slider.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/multi_img_controller.dart';
import 'package:fcs/fcs/common/pages/widgets/multi_img_file.dart';
@@ -18,7 +16,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:timeline_list/timeline_model.dart';
class PackageEditorPage extends StatefulWidget {
final Package package;
@@ -34,13 +31,6 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
Package _package;
bool _isLoading = false;
ShippingAddress shippingAddress = ShippingAddress(
fullName: 'U Nyi Nyi',
addressLine1: '154-19 64th Ave.',
addressLine2: 'Flushing',
city: 'NY',
state: 'NY',
phoneNumber: '+1 (292)215-2247');
@override
void initState() {
@@ -54,38 +44,6 @@ class _PackageEditorPageState extends State<PackageEditorPage> {
final DateFormat dateFormat = DateFormat("d MMM yyyy");
List<TimelineModel> _models() {
if (_package.shipmentHistory == null) return [];
return _package.shipmentHistory
.map((e) => TimelineModel(
Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(e.status,
style: TextStyle(
color: e.done ? primaryColor : Colors.grey,
fontSize: 16,
fontWeight: FontWeight.bold)),
Text(dateFormat.format(e.date)),
],
),
),
iconBackground: e.done ? primaryColor : Colors.grey,
icon: Icon(
e.status == "shipped"
? Ionicons.ios_airplane
: e.status == "delivered"
? MaterialCommunityIcons.truck_fast
: e.status == "processed"
? MaterialIcons.check
: Octicons.package,
color: Colors.white,
)))
.toList();
}
bool isNew = false;
MultiImgController multiImgController = MultiImgController();

View File

@@ -3,9 +3,12 @@ import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/package/model/package_model.dart';
import 'package:fcs/fcs/common/pages/package/package_list_row.dart';
import 'package:fcs/fcs/common/pages/package/package_new.dart';
import 'package:fcs/fcs/common/pages/package_search/package_serach.dart';
import 'package:fcs/fcs/common/pages/user_search/user_serach.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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -37,11 +40,16 @@ class _PackageListState extends State<PackageList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("package.title")),
title: LocalText(
context,
"package.title",
fontSize: 20,
color: Colors.white,
),
actions: <Widget>[
// IconButton(
// icon: Icon(
@@ -62,7 +70,7 @@ class _PackageListState extends State<PackageList> {
color: Colors.white,
),
iconSize: 30,
onPressed: () => searchUser(context),
onPressed: () => searchPackage(context),
),
],
),

View File

@@ -7,6 +7,7 @@ import 'package:fcs/fcs/common/pages/staff/model/staff_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/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/fcs_id_icon.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';
@@ -41,7 +42,7 @@ class _PackageNewState extends State<PackageNew> {
child: DisplayText(
text: user != null ? user.fcsID : "",
labelText: getLocalString(context, "package.create.fcs.id"),
iconData: Icons.perm_identity,
icon: FcsIDIcon(),
)),
IconButton(
icon: Icon(Icons.search, color: primaryColor),

View File

@@ -1,4 +1,5 @@
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/model/shipment_model.dart';
import 'package:fcs/pages/search_page.dart';
@@ -41,7 +42,12 @@ class _ShippingAddressListState extends State<ShippingAddressList> {
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("shipping_addresses")),
title: LocalText(
context,
"shipping_addresses",
fontSize: 20,
color: Colors.white,
),
actions: <Widget>[
IconButton(
icon: Icon(

View File

@@ -0,0 +1,88 @@
import 'package:fcs/fcs/common/domain/entities/package.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/package_search/package_serach.dart';
import 'package:flutter/material.dart';
class PackageSearchRow extends StatefulWidget {
final CallbackPackageSelect callbackPackageSelect;
final Package package;
const PackageSearchRow({this.package, this.callbackPackageSelect});
@override
_PackageSearchRowState createState() => _PackageSearchRowState();
}
class _PackageSearchRowState extends State<PackageSearchRow> {
final double dotSize = 15.0;
Package package;
@override
void initState() {
super.initState();
this.package = widget.package;
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 15, right: 15),
child: Card(
elevation: 10,
color: Colors.white,
child: InkWell(
onTap: () {
Navigator.pop(context);
if (widget.callbackPackageSelect != null)
widget.callbackPackageSelect(package);
},
child: Row(
children: <Widget>[
Expanded(
child: new Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: new Row(
children: <Widget>[
new Padding(
padding: new EdgeInsets.symmetric(
horizontal: 32.0 - dotSize / 2),
child: Image.asset(
"assets/buyer.png",
width: 40,
height: 40,
color: primaryColor,
),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
package.trackingID == null
? ''
: package.trackingID,
style: new TextStyle(
fontSize: 15.0, color: Colors.black),
),
new Text(
package.userName == null ? "" : package.userName,
style: new TextStyle(
fontSize: 13.0, color: Colors.grey),
),
new Text(
package.fcsID == null ? "" : package.fcsID,
style: new TextStyle(
fontSize: 13.0, color: Colors.grey),
),
],
),
),
],
),
),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,117 @@
import 'package:fcs/fcs/common/domain/entities/package.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/package/model/package_model.dart';
import 'package:fcs/fcs/common/pages/package_search/package_search_row.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
typedef CallbackPackageSelect(Package package);
Future<Package> searchPackage(BuildContext context,
{CallbackPackageSelect callbackPackageSelect}) async =>
await showSearch<Package>(
context: context,
delegate:
PackageSearchDelegate(callbackPackageSelect: callbackPackageSelect),
);
class PackageSearchDelegate extends SearchDelegate<Package> {
final CallbackPackageSelect callbackPackageSelect;
PackageSearchDelegate({this.callbackPackageSelect});
@override
String get searchFieldLabel => 'Search by FCS ID or Name';
@override
ThemeData appBarTheme(BuildContext context) {
final ThemeData theme = Theme.of(context);
return theme.copyWith(
inputDecorationTheme: InputDecorationTheme(
hintStyle: TextStyle(
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
textTheme: theme.textTheme.copyWith(
title: theme.textTheme.title.copyWith(
color: theme.primaryTextTheme.title.color, fontSize: 16)),
primaryColor: primaryColor,
);
}
@override
List<Widget> buildActions(BuildContext context) {
return [
IconButton(
icon: Icon(Icons.clear),
onPressed: () => query = '',
),
];
}
@override
Widget buildLeading(BuildContext context) {
return IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () => close(context, null),
);
}
@override
Widget buildResults(BuildContext context) {
final packageModel = Provider.of<PackageModel>(context);
return FutureBuilder(
future: packageModel.searchPackage(query),
builder: (context, AsyncSnapshot<List<Package>> snapshot) {
if (snapshot.hasData) {
if (snapshot.data.length == 0) {
return Container(
child: Center(
child: Text(
"No result found",
textAlign: TextAlign.center,
),
),
);
}
return Container(
padding: EdgeInsets.only(top: 15),
child: ListView(
children: snapshot.data
.map((u) => PackageSearchRow(
package: u,
callbackPackageSelect: callbackPackageSelect,
))
.toList(),
),
);
} else if (snapshot.hasError) {
return Container(
child: Center(
child: Text(
'${snapshot.error}',
textAlign: TextAlign.center,
),
),
);
} else {
return Container(
child: Center(
child: CircularProgressIndicator(
valueColor:
new AlwaysStoppedAnimation<Color>(primaryColor)),
),
);
}
});
}
@override
Widget buildSuggestions(BuildContext context) {
return Container(
child: Center(
child: Opacity(
opacity: 0.2,
child: Icon(Icons.perm_identity, size: 200, color: primaryColor)),
),
);
}
}

View File

@@ -0,0 +1,49 @@
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
import 'package:fcs/fcs/common/pages/model/base_model.dart';
import 'package:fcs/fcs/common/services/services.dart';
import 'package:logging/logging.dart';
class PaymentMethodModel extends BaseModel {
final log = Logger('PaymentMethodModel');
List<PaymentMethod> paymentMethods = [];
PaymentMethod getPaymentMethod(String id) {
return paymentMethods.firstWhere((e) => e.id == id, orElse: () => null);
}
StreamSubscription<QuerySnapshot> listener;
PaymentMethodModel() {
if (listener != null) listener.cancel();
try {
listener = Firestore.instance
.collection("/payment_methods")
.snapshots()
.listen((snaps) {
paymentMethods.clear();
snaps.documents.forEach((d) {
paymentMethods.add(PaymentMethod.fromMap(d.data, d.documentID));
});
notifyListeners();
});
} catch (e) {
log.warning("error:$e");
}
}
Future<void> addPaymentMethod(PaymentMethod paymentMethod) async {
Services.instance.commonService.createPaymentMethod(paymentMethod);
}
Future<void> updatePaymentMethod(PaymentMethod paymentMethod) async {
Services.instance.commonService.updatePaymentMethod(paymentMethod);
}
Future<void> deletePaymentMethod(String id) async {
Services.instance.commonService.deletePayment(id);
}
}

View File

@@ -0,0 +1,212 @@
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/payment_methods/model/payment_method_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/input_text.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:provider/provider.dart';
class PaymentMethodEditor extends StatefulWidget {
final PaymentMethod paymentMethod;
const PaymentMethodEditor({Key key, this.paymentMethod}) : super(key: key);
@override
_PaymentMethodEditorState createState() => _PaymentMethodEditorState();
}
class _PaymentMethodEditorState extends State<PaymentMethodEditor> {
bool _isLoading = false;
PaymentMethod _paymentMethod;
TextEditingController _nameController = new TextEditingController();
TextEditingController _accountNameController = new TextEditingController();
TextEditingController _accountNumberController = new TextEditingController();
TextEditingController _mailController = new TextEditingController();
TextEditingController _phoneController = new TextEditingController();
TextEditingController _linkController = new TextEditingController();
bool isNew;
@override
void initState() {
super.initState();
isNew = widget.paymentMethod == null;
if (widget.paymentMethod != null) {
_paymentMethod = widget.paymentMethod;
_nameController.text = _paymentMethod.name;
_accountNameController.text = _paymentMethod.accountName;
_accountNumberController.text = _paymentMethod.account;
_mailController.text = _paymentMethod.email;
_phoneController.text = _paymentMethod.phone;
_linkController.text = _paymentMethod.link;
} else {
_paymentMethod = new PaymentMethod();
_nameController.text = '';
}
}
@override
Widget build(BuildContext context) {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close, color: primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
title: LocalText(
context,
isNew ? "pm.new" : "pm.update",
fontSize: 20,
color: primaryColor,
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
actions: <Widget>[
isNew
? Container()
: IconButton(
icon: Icon(
Icons.delete,
color: primaryColor,
),
onPressed: _delete,
)
],
),
body: Padding(
padding: const EdgeInsets.only(left: 20.0, right: 10),
child: ListView(
children: <Widget>[
InputText(
labelTextKey: "pm.name",
iconData: Octicons.tag,
controller: _nameController,
),
InputText(
labelTextKey: "pm.account.name",
iconData: MaterialCommunityIcons.bank,
controller: _accountNameController,
),
InputText(
labelTextKey: "pm.account.no",
iconData: MaterialCommunityIcons.checkbook,
controller: _accountNumberController,
),
InputText(
labelTextKey: "pm.phone",
iconData: Icons.phone,
controller: _phoneController,
),
InputText(
labelTextKey: "pm.email",
iconData: Icons.mail,
controller: _mailController,
),
InputText(
labelTextKey: "pm.link",
iconData: Icons.link,
controller: _linkController,
),
SizedBox(
height: 20,
),
isNew
? fcsButton(context, getLocalString(context, "pm.add.btn"),
callack: _add)
: fcsButton(context, getLocalString(context, "pm.save.btn"),
callack: _save),
SizedBox(
height: 30,
)
],
),
)),
);
}
_add() async {
if (_nameController.text == "") {
showMsgDialog(context, "Error", "Need a name for a payment method");
return;
}
setState(() {
_isLoading = true;
});
try {
PaymentMethod pm = PaymentMethod(
name: _nameController.text,
accountName: _accountNameController.text,
account: _accountNumberController.text,
email: _mailController.text,
phone: _phoneController.text,
link: _linkController.text);
await Provider.of<PaymentMethodModel>(context, listen: false)
.addPaymentMethod(pm);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
_save() async {
if (_nameController.text == "") {
showMsgDialog(context, "Error", "Need a name for a payment method");
return;
}
setState(() {
_isLoading = true;
});
try {
PaymentMethod pm = PaymentMethod(
id: _paymentMethod.id,
name: _nameController.text,
accountName: _accountNameController.text,
account: _accountNumberController.text,
email: _mailController.text,
phone: _phoneController.text,
link: _linkController.text);
await Provider.of<PaymentMethodModel>(context, listen: false)
.updatePaymentMethod(pm);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
_delete() {
showConfirmDialog(context, "pm.delete.confirm", () => _deleteConfirmed());
}
_deleteConfirmed() async {
setState(() {
_isLoading = true;
});
try {
await Provider.of<PaymentMethodModel>(context, listen: false)
.deletePaymentMethod(_paymentMethod.id);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
}

View File

@@ -0,0 +1,155 @@
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/payment_methods/model/payment_method_model.dart';
import 'package:fcs/fcs/common/pages/payment_methods/payment_method_editor.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/display_text.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/services.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';
class PaymentMethodPage extends StatefulWidget {
@override
_PaymentMethodPageState createState() => _PaymentMethodPageState();
}
class _PaymentMethodPageState extends State<PaymentMethodPage> {
GlobalKey key = GlobalKey();
bool _isLoading = false;
@override
Widget build(BuildContext context) {
PaymentMethodModel mainModel = Provider.of<PaymentMethodModel>(context);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
key: key,
appBar: AppBar(
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
centerTitle: true,
title: LocalText(
context,
"pm.title",
fontSize: 20,
color: primaryColor,
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
actions: <Widget>[],
),
body: Padding(
padding: const EdgeInsets.all(12.0),
child: ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
),
itemCount: mainModel.paymentMethods.length,
itemBuilder: (BuildContext context, int index) {
var method = mainModel.paymentMethods[index];
return _item(method);
},
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.push(
context,
BottomUpPageRoute(PaymentMethodEditor()),
);
},
icon: Icon(Icons.add),
label: LocalText(context, "pm.new", color: Colors.white),
backgroundColor: primaryColor,
),
),
);
}
_item(PaymentMethod method) {
final accountName = _itemRow(method.accountName, "pm.account.name",
iconData: MaterialCommunityIcons.bank);
final accountNumber = _itemRow(method.account, "pm.account.no",
iconData: MaterialCommunityIcons.checkbook);
final phone = _itemRow(method.phone, "pm.phone", iconData: Icons.phone);
final email = _itemRow(method.email, "pm.email", iconData: Icons.mail);
final link = _itemRow(method.link, "pm.link", iconData: Icons.link);
return InkWell(
onTap: () {
Navigator.push(
context,
BottomUpPageRoute(PaymentMethodEditor(
paymentMethod: method,
)),
);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
method.name,
style: TextStyle(
color: primaryColor,
fontWeight: FontWeight.bold,
fontSize: 18),
),
),
accountName,
accountNumber,
phone,
email,
link
],
),
);
}
_itemRow(String text, String labelKey, {IconData iconData}) {
return text == null || text == ""
? Container()
: Row(
children: [
Expanded(
child: DisplayText(
text: text,
labelText: getLocalString(context, labelKey),
iconData: iconData,
),
),
IconButton(
icon: Icon(Icons.content_copy, color: Colors.grey),
onPressed: () => _copy(getLocalString(context, labelKey), text),
)
],
);
}
_copy(String title, String data) {
Clipboard.setData(ClipboardData(text: data));
_showToast(title);
}
void _showToast(String title) {
final ScaffoldState scaffold = key.currentState;
scaffold.showSnackBar(
SnackBar(
content: Text('copied "$title" data to clipboard'),
backgroundColor: secondaryColor,
duration: Duration(seconds: 1),
),
);
}
}

View File

@@ -2,6 +2,7 @@ import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -59,9 +60,11 @@ class _ProfileEditState extends State<ProfileEdit> {
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
AppTranslations.of(context).text("profile.edit_title"),
style: TextStyle(color: primaryColor),
title: LocalText(
context,
"profile.edit_title",
fontSize: 20,
color: primaryColor,
),
backgroundColor: Colors.white,
shadowColor: Colors.transparent,

View File

@@ -4,6 +4,8 @@ import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/profile/profile_edit.dart';
import 'package:fcs/fcs/common/pages/widgets/display_text.dart';
import 'package:fcs/fcs/common/pages/widgets/fcs_id_icon.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:fcs/model/shipment_model.dart';
import 'package:fcs/model/user_model.dart';
@@ -74,7 +76,7 @@ class _ProfileState extends State<Profile> {
child: DisplayText(
text: mainModel.user.fcsID,
labelText: getLocalString(context, "customer.fcs.id"),
iconData: Icons.account_circle,
icon: FcsIDIcon(),
),
),
IconButton(
@@ -120,9 +122,11 @@ class _ProfileState extends State<Profile> {
),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
AppTranslations.of(context).text("profile.title"),
style: TextStyle(color: primaryColor),
title: LocalText(
context,
"profile.title",
fontSize: 20,
color: primaryColor,
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,

View File

@@ -1,11 +1,8 @@
import 'package:country_code_picker/country_code_picker.dart';
import 'package:fcs/fcs/common/domain/entities/auth_result.dart';
import 'package:fcs/fcs/common/domain/entities/auth_status.dart';
import 'package:fcs/fcs/common/domain/entities/setting.dart';
import 'package:fcs/fcs/common/domain/entities/user.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/signin/signin_logic.dart';
import 'package:fcs/fcs/common/pages/signin/signup_page.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
import 'package:fcs/widget/bottom_up_page_route.dart';
import 'package:flutter/material.dart';
@@ -13,10 +10,10 @@ import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../../helpers/theme.dart';
import '../../../../widget/progress.dart';
import 'sms_code_page.dart';
import '../../helpers/theme.dart';
import '../util.dart';
import 'sms_code_page.dart';
class SigninPage extends StatefulWidget {
@override

View File

@@ -73,10 +73,10 @@ class _StaffEditorState extends State<StaffEditor> {
children: <Widget>[
new Text(
p.name,
style: TextStyle(
fontSize: 15.0,
),
style: TextStyle(fontSize: 15.0, color: primaryColor),
),
Text(p.desc,
style: TextStyle(fontSize: 13, color: Colors.grey[600]))
],
),
],
@@ -185,6 +185,10 @@ class _StaffEditorState extends State<StaffEditor> {
: Container(),
phoneNumberBox,
namebox,
Padding(
padding: const EdgeInsets.only(top: 18.0),
child: Text("Privileges"),
),
Column(
children: showprivilegeList(context),
),

View File

@@ -5,6 +5,7 @@ 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/helpers/theme.dart';
import 'package:fcs/fcs/common/pages/widgets/progress.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart';
@@ -33,7 +34,7 @@ class _StaffListState extends State<StaffList> {
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(Icons.close),
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,

View File

@@ -22,10 +22,12 @@ class TermEdit extends StatefulWidget {
class _TermEditState extends State<TermEdit> {
/// Allows to control the editor and the document.
ZefyrController _controller;
ZefyrController _controllerEng;
ZefyrController _controllerMm;
/// Zefyr editor like any other input field requires a focus node.
FocusNode _focusNode;
FocusNode _focusNodeEng;
FocusNode _focusNodeMm;
bool _isLoading;
@override
@@ -34,16 +36,17 @@ class _TermEditState extends State<TermEdit> {
_isLoading = false;
// Here we must load the document and pass it to Zefyr controller.
final document = _loadDocument();
_controller = ZefyrController(document);
_focusNode = FocusNode();
_controllerEng = ZefyrController(_loadDocument(widget.term.termEng));
_controllerMm = ZefyrController(_loadDocument(widget.term.termMm));
_focusNodeEng = FocusNode();
_focusNodeMm = FocusNode();
}
/// Loads the document to be edited in Zefyr.
NotusDocument _loadDocument() {
NotusDocument _loadDocument(String data) {
NotusDocument doc;
try {
doc = NotusDocument.fromJson(jsonDecode(widget.term.term));
doc = NotusDocument.fromJson(jsonDecode(data));
} catch (e) {}
if (doc == null) {
doc = NotusDocument();
@@ -55,58 +58,109 @@ class _TermEditState extends State<TermEdit> {
Widget build(BuildContext context) {
final savebtn =
fcsButton(context, getLocalString(context, "btn.save"), callack: _save);
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
title: LocalLargeTitle(
context,
"term",
color: Colors.white,
),
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 30,
return DefaultTabController(
length: 2,
child: LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
title: LocalLargeTitle(
context,
"term",
color: primaryColor,
),
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
color: primaryColor,
size: 30,
),
onPressed: () => Navigator.of(context).pop(),
),
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
bottom: TabBar(
onTap: (index) {
// Tab index when user select it, it start from zero
},
tabs: [
Tab(
icon: Image.asset(
'icons/flags/png/us.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)),
Tab(
icon: Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)),
],
),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
),
body: ListView(
children: [
Container(
height: MediaQuery.of(context).size.height - 150,
child: ZefyrScaffold(
child: ZefyrTheme(
data: ZefyrThemeData().copyWith(),
child: ZefyrEditor(
padding: EdgeInsets.all(16),
controller: _controller,
focusNode: _focusNode,
),
body: ListView(
children: [
Container(
height: MediaQuery.of(context).size.height - 200,
child: TabBarView(
children: [
textEditor(_controllerEng, _focusNodeEng),
textEditor(_controllerMm, _focusNodeMm),
],
),
),
),
savebtn,
SizedBox(
height: 10,
)
],
savebtn,
],
),
),
),
);
}
Widget textEditor(ZefyrController controller, FocusNode focusNode) {
return ListView(
children: [
Container(
height: MediaQuery.of(context).size.height - 200,
child: ZefyrScaffold(
child: ZefyrTheme(
data: ZefyrThemeData().copyWith(
defaultLineTheme: LineTheme(
padding: EdgeInsets.all(0),
textStyle: TextStyle(fontFamily: "Myanmar3"),
),
),
child: ZefyrEditor(
autofocus: false,
padding: EdgeInsets.all(16),
controller: controller,
focusNode: focusNode,
),
),
),
),
// savebtn,
SizedBox(
height: 10,
)
],
);
}
_save() async {
setState(() {
_isLoading = true;
});
try {
final contents = jsonEncode(_controller.document);
print('contents => $contents');
final contentsEng = jsonEncode(_controllerEng.document);
final contentsMm = jsonEncode(_controllerMm.document);
print('contents => $contentsEng');
TermModel termModel = Provider.of<TermModel>(context, listen: false);
await termModel.saveTerm(Term(term: contents));
await termModel.saveTerm(Term(termEng: contentsEng, termMm: contentsMm));
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {

View File

@@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:fcs/fcs/common/domain/entities/setting.dart';
import 'package:fcs/fcs/common/domain/vo/term.dart';
import 'package:fcs/fcs/common/helpers/theme.dart';
import 'package:fcs/fcs/common/localization/app_translations.dart';
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/term/term_edit.dart';
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
@@ -35,7 +35,8 @@ class _TermPageState extends State<TermPage> {
}
NotusDocument _loadDocument(Setting setting) {
String term = setting.terms;
bool isEng = Provider.of<LanguageModel>(context).isEng;
String term = isEng ? setting.termsEng : setting.termsMm;
NotusDocument doc;
try {
doc = NotusDocument.fromJson(jsonDecode(term));
@@ -52,27 +53,22 @@ class _TermPageState extends State<TermPage> {
bool isEditable = context.select((MainModel m) => m.termEditable());
return Scaffold(
body: CustomScrollView(slivers: [
SliverAppBar(
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 30,
appBar: AppBar(
shadowColor: Colors.transparent,
backgroundColor: Colors.white,
centerTitle: true,
leading: new IconButton(
icon: new Icon(
Icons.close,
color: primaryColor,
),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
expandedHeight: 100.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title: LocalLargeTitle(
context,
"term",
color: Colors.white,
),
title: LocalText(
context,
'term',
color: primaryColor,
fontSize: 20,
),
actions: isEditable
? [
@@ -84,85 +80,30 @@ class _TermPageState extends State<TermPage> {
)),
icon: Icon(
CupertinoIcons.pen,
color: Colors.white,
color: primaryColor,
))
]
: [],
),
SliverFillRemaining(
child: ZefyrTheme(
data: ZefyrThemeData().copyWith(
defaultLineTheme: LineTheme(
textStyle: TextStyle(color: Colors.black),
padding: EdgeInsets.all(0))),
child: ZefyrScaffold(
child: ZefyrEditor(
mode: ZefyrMode.view,
padding: EdgeInsets.all(16),
controller: ZefyrController(_loadDocument(setting)),
focusNode: _focusNode,
),
))),
]));
}
@override
Widget build1(BuildContext context) {
Setting setting = Provider.of<MainModel>(context).setting;
return CupertinoPageScaffold(
child: NestedScrollView(
floatHeaderSlivers: false,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
leading: IconButton(
icon: Icon(
CupertinoIcons.back,
size: 30,
),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
expandedHeight: 150.0,
floating: true,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.symmetric(vertical: 10),
title: LocalLargeTitle(
context,
"term",
color: Colors.white,
),
),
actions: [
IconButton(
onPressed: () =>
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) =>
TermEdit(term: Term.fromSetting(setting)),
)),
icon: Icon(
CupertinoIcons.pen,
color: Colors.white,
))
],
),
];
},
body: ZefyrTheme(
data: ZefyrThemeData().copyWith(
defaultLineTheme: LineTheme(
textStyle: TextStyle(color: Colors.black),
padding: EdgeInsets.all(0))),
child: ZefyrScaffold(
child: ZefyrEditor(
mode: ZefyrMode.view,
padding: EdgeInsets.all(16),
controller: ZefyrController(_loadDocument(setting)),
focusNode: _focusNode,
),
))),
body: ZefyrTheme(
data: ZefyrThemeData().copyWith(
defaultLineTheme: LineTheme(
padding: EdgeInsets.all(0),
textStyle: TextStyle(fontFamily: "Myanmar3"),
),
),
// data: ZefyrThemeData().copyWith(
// defaultLineTheme: LineTheme(
// textStyle: TextStyle(color: Colors.black),
// padding: EdgeInsets.all(0))),
child: ZefyrScaffold(
child: ZefyrEditor(
mode: ZefyrMode.view,
padding: EdgeInsets.all(16),
controller: ZefyrController(_loadDocument(setting)),
focusNode: _focusNode,
),
)),
);
}
}

View File

@@ -109,10 +109,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
child: Center(
child: Opacity(
opacity: 0.2,
child: Icon(
Icons.supervised_user_circle,
size: 200,
)),
child: Icon(Icons.perm_identity, size: 200, color: primaryColor)),
),
);
}

View File

@@ -1,5 +1,4 @@
import 'package:fcs/fcs/common/pages/model/language_model.dart';
import 'package:fcs/fcs/common/pages/model/main_model.dart';
import 'package:fcs/fcs/common/pages/util.dart';
import 'package:fcs/fcs/common/pages/widgets/bottom_widgets.dart';
import 'package:fcs/widget/banner.dart';
@@ -8,12 +7,10 @@ import 'package:fcs/widget/localization/transalation.dart';
import 'package:fcs/widget/offline_redirect.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart' as intl;
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import '../helpers/theme.dart';
import 'profile/profile_page.dart';
import 'signin/signin_page.dart';
final msgLog = Logger('backgroundMessageHandler');

View File

@@ -1,5 +1,6 @@
import 'package:fcs/fcs/common/pages/contact/contact_page.dart';
import 'package:fcs/fcs/common/pages/term/term_page.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -14,18 +15,14 @@ class BottomWidgets extends StatelessWidget {
children: <Widget>[
InkWell(
onTap: () {
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => ContactPage(),
));
Navigator.of(context).push(BottomUpPageRoute(ContactPage()));
},
child: _buildSmallButton(
context, "contact.btn", SimpleLineIcons.support),
),
InkWell(
onTap: () {
Navigator.of(context).push<void>(CupertinoPageRoute(
builder: (context) => TermPage(),
));
Navigator.of(context).push(BottomUpPageRoute(TermPage()));
},
child: _buildSmallButton(context, "term.btn", Icons.info_outline),
),

View File

@@ -11,6 +11,7 @@ class DisplayText extends StatelessWidget {
final int maxLines;
final bool withBorder;
final Color borderColor;
final Widget icon;
const DisplayText({
Key key,
@@ -20,6 +21,7 @@ class DisplayText extends StatelessWidget {
this.maxLines = 1,
this.withBorder = false,
this.borderColor,
this.icon,
}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -41,7 +43,7 @@ class DisplayText extends StatelessWidget {
child: Row(
children: [
iconData == null
? Container()
? icon == null ? Container() : icon
: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(

View File

@@ -0,0 +1,18 @@
import 'package:flutter/cupertino.dart';
class FcsIDIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: 25,
height: 25,
child: FittedBox(
child: Image.asset("assets/logo.jpg"),
fit: BoxFit.fill,
),
),
);
}
}

View File

@@ -0,0 +1,29 @@
import 'package:fcs/fcs/common/data/providers/common_data_provider.dart';
import 'package:fcs/fcs/common/data/providers/user_data_provider.dart';
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
import 'package:flutter/material.dart';
import 'common_service.dart';
class CommonServiceImp implements CommonService {
CommonServiceImp({
@required this.commonDataProvider,
});
final CommonDataProvider commonDataProvider;
@override
Future<void> createPaymentMethod(PaymentMethod paymentMethod) {
return commonDataProvider.createPaymentMethod(paymentMethod);
}
@override
Future<void> deletePayment(String id) {
return commonDataProvider.deletePaymentMethod(id);
}
@override
Future<void> updatePaymentMethod(PaymentMethod paymentMethod) {
return commonDataProvider.updatePaymentMethod(paymentMethod);
}
}

View File

@@ -0,0 +1,8 @@
import 'package:fcs/fcs/common/domain/entities/payment_method.dart';
abstract class CommonService {
// Payment Service
Future<void> createPaymentMethod(PaymentMethod paymentMethod);
Future<void> updatePaymentMethod(PaymentMethod paymentMethod);
Future<void> deletePayment(String id);
}

View File

@@ -1,7 +1,10 @@
import 'package:fcs/fcs/common/data/providers/auth_fb.dart';
import 'package:fcs/fcs/common/data/providers/common_data_provider.dart';
import 'package:fcs/fcs/common/data/providers/package_data_provider.dart';
import 'package:fcs/fcs/common/data/providers/user_data_provider.dart';
import 'package:fcs/fcs/common/services/auth_imp.dart';
import 'package:fcs/fcs/common/services/common_imp.dart';
import 'package:fcs/fcs/common/services/common_service.dart';
import 'package:fcs/fcs/common/services/messaging_imp.dart';
import 'package:fcs/fcs/common/services/messaging_service.dart';
import 'package:fcs/fcs/common/services/package_imp.dart';
@@ -18,6 +21,7 @@ class Services {
UserService _userService;
PackageService _packageService;
MessagingService _messagingService;
CommonService _commonService;
Services._() {
_authService = AuthServiceImp(
authFb: AuthFb.instance,
@@ -28,10 +32,12 @@ class Services {
_messagingService = MessagingServiceImp();
_packageService = PackageServiceImp(
connectivity: null, packageDataProvider: PackageDataProvider());
_commonService = CommonServiceImp(commonDataProvider: CommonDataProvider());
}
AuthService get authService => _authService;
UserService get userService => _userService;
MessagingService get messagingService => _messagingService;
PackageService get packageService => _packageService;
CommonService get commonService => _commonService;
}