diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index f0d0789..c94a2e8 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -521,6 +521,9 @@ "package.edit.title":"PACKAGE", "pickup.date": "Pickup Date", + "pickup.location_time": "Pickup Location / Time", + "pickup.information": "Pickup Informations", + "pickup.recipient_information": "Recipient Informations", "message.btn":"Messages", "message.title":"MESSAGES", @@ -531,5 +534,16 @@ "invoices.btn": "Invoices", "invoices.title": "INVOICES", - "term":"TERMS" + "term":"TERMS", + "term.btn":"Terms", + + "customer.list.title":"CUSTOMERS", + "customer.form.title":"CUSTOMER", + + "contact": "CONTACTS", + + "fcs.profile": "FCS PROFILE", + + "contact.usa.phone": "USA Phone", + "contact.mm.phone": "Myanmar Phone" } \ No newline at end of file diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 2447b2c..639b2da 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -539,6 +539,20 @@ "pickup.new": "New Pickup", "pickup.edit.title": "PICKUP", "pickup.date": "Pickup Date", + "pickup.location_time": "Pickup Location / Time", + "pickup.information": "Pickup Informations", + "pickup.recipient_information": "Recipient Informations", - "term":"TERMS" + "term":"စည်းကမ်းချက်များ", + "term.btn":"စည်းကမ်းချက်များ", + + "customer.list.title":"ဝယ်ယူသူများ", + "customer.form.title":"ဝယ်ယူသူ", + + "contact": "ဆက်သွယ်ရန်", + + "fcs.profile": "FCS ပရိုဖိုင်", + + "contact.usa.phone": "ယူအက်စ်အေ ဖုန်းနံပါတ်", + "contact.mm.phone": "မြန်မာ ဖုန်းနံပါတ်" } \ No newline at end of file diff --git a/lib/app.dart b/lib/app.dart index 257fb3c..d7ae2d1 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -17,6 +17,7 @@ import 'package:fcs/pages/login_page.dart'; import 'model/announcement_model.dart'; import 'model/chart_model.dart'; +import 'model/customer_model.dart'; import 'model/device_model.dart'; import 'model/do_model.dart'; import 'model/employee_model.dart'; @@ -66,8 +67,8 @@ class _AppState extends State { final PickUpModel pickUpModel = new PickUpModel(); final ShipmentRateModel shipmentRateModel = new ShipmentRateModel(); final ShipmentModel shipmentModel = new ShipmentModel(); - final PackageModel packageModel=new PackageModel(); - + final PackageModel packageModel = new PackageModel(); + final CustomerModel customerModel = new CustomerModel(); AppTranslationsDelegate _newLocaleDelegate; @@ -102,7 +103,8 @@ class _AppState extends State { ..addModel(shipmentRateModel) ..addModel(shipmentModel) ..addModel(packageModel) - ..addModel(shipmentRateModel); + ..addModel(shipmentRateModel) + ..addModel(customerModel); this.mainModel.init(); } @@ -155,6 +157,7 @@ class _AppState extends State { ChangeNotifierProvider(builder: (context) => shipmentRateModel), ChangeNotifierProvider(builder: (context) => shipmentModel), ChangeNotifierProvider(builder: (context) => packageModel), + ChangeNotifierProvider(builder: (context) => customerModel), ChangeNotifierProvider( builder: (context) => testModel, ), diff --git a/lib/model/customer_model.dart b/lib/model/customer_model.dart new file mode 100644 index 0000000..5e98367 --- /dev/null +++ b/lib/model/customer_model.dart @@ -0,0 +1,67 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:logging/logging.dart'; +import 'package:fcs/vo/user.dart'; + +import '../vo/user.dart'; +import 'base_model.dart'; +import 'constants.dart'; +import 'firebase_helper.dart'; + +class CustomerModel extends BaseModel { + final log = Logger('CustomerModel'); + + List customers = [ + User( + name: 'Ko Nyi', + phoneNumber: '+95 9 717273634', + ), + User(name: 'Ko Phyu', phoneNumber: '+1 (939) 382-3844'), + User(name: 'Ko Ye', phoneNumber: '+95 9 983734783', status: "Delivered"), + ]; + + void initUser(user) async { + super.initUser(user); + // _loadCustomer(); + } + + @override + logout() async { + customers = []; + } + + // Future _loadCustomer() async { + // if (!user.isOwnerAndAbove() && !user.hasAccount()) { + // return; + // } + + // try { + // Firestore.instance + // .collection("/$biz_collection/${setting.okEnergyId}/$user_collection") + // .where("is_employee", isEqualTo: true) + // .snapshots() + // .listen((QuerySnapshot snapshot) { + // customers.clear(); + // customers = snapshot.documents.map((documentSnapshot) { + // var user = + // User.fromMap(documentSnapshot.data, documentSnapshot.documentID); + // return user; + // }).toList(); + // notifyListeners(); + // }).onError((e) { + // log.warning("Error! $e"); + // }); + // } catch (e) { + // log.warning("Error!! $e"); + // } + // } + + // Future updatePrivileges(String userID, List privileges) async { + // try { + // await request("/employee/privileges", "PUT", + // payload: {"id": userID, "privileges": privileges}, + // token: await getToken()); + // } catch (e) { + // throw Exception(e); + // } + // } +} diff --git a/lib/model/main_model.dart b/lib/model/main_model.dart index b471d31..228c2fc 100644 --- a/lib/model/main_model.dart +++ b/lib/model/main_model.dart @@ -60,9 +60,7 @@ class MainModel extends ChangeNotifier { shippingAddress: '154-19 64th Ave.Flushing, \nNY 11367', deliveryAddress: '39 42th St. Kyaut Ta Thar Township Yangon'); - Setting setting = Setting( - terms: - '[{"insert":"Minimum shipping weight is 1lbs.\nOversized goods, Light weight/Large volume items, laptops, phones, tablets may incur extra charges based on pecifications.Please contact us for pricing.\nGoods with lithium battary needs extra packaging and declaration. Please inform us ahead of time so that we can process your package accordingly.\nLoose Batteries, Drones, and Prescription medicines are not allowed on aircraft.\nPayment: We accept money orders, any US bank transfers via Zelle, AYA, KBZ and CB. No COD except for pick-ups.\nPayments made in Myanmar will incur 2% tranfer fee\n"}]'); + Setting setting = Setting(terms: '[{"insert":"* Minimum shipping weight is 1lbs.\n* Oversized goods, Light weight/Large volume items, laptops, phones, tablets may incur extra charges based on pecifications.Please contact us for pricing.\n* Goods with lithium battary needs extra packaging and declaration. Please inform us ahead of time so that we can process your package accordingly.\n* Loose Batteries, Drones, and Prescription medicines are not allowed on aircraft.\n* Payment: We accept money orders, any US bank transfers via Zelle, AYA, KBZ and CB. No COD except for pick-ups.\n*Payments made in Myanmar will incur 2% tranfer fee\n"}]'); PackageInfo packageInfo; bool isLoaded = true; bool isOnline = true; diff --git a/lib/pages/contact.dart b/lib/pages/contact.dart index 8726d5c..6fd2967 100644 --- a/lib/pages/contact.dart +++ b/lib/pages/contact.dart @@ -1,3 +1,5 @@ +import 'package:fcs/model/pickup_model.dart'; +import 'package:fcs/widget/label_widgets.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:package_info/package_info.dart'; @@ -9,8 +11,6 @@ import 'package:fcs/theme/theme.dart'; import 'package:fcs/widget/local_text.dart'; import 'package:fcs/widget/progress.dart'; -import 'contact_editor.dart'; - class Contact extends StatefulWidget { @override _ContactState createState() => _ContactState(); @@ -21,71 +21,56 @@ class _ContactState extends State { @override Widget build(BuildContext context) { - MainModel mainModel = Provider.of(context); - bool isOwner = mainModel.user != null && mainModel.user.isOwner(); - bool hasAdmin = mainModel.user != null && mainModel.user.hasAdmin(); + var pickupModel = Provider.of(context, listen: false); + + // MainModel mainModel = Provider.of(context); + // bool isOwner = mainModel.user != null && mainModel.user.isOwner(); + // bool hasAdmin = mainModel.user != null && mainModel.user.hasAdmin(); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( - backgroundColor: Colors.white, - iconTheme: IconThemeData( - color: Colors.grey, - ), + backgroundColor: primaryColor, elevation: 0, centerTitle: true, - title: Image( - height: 30, - fit: BoxFit.scaleDown, - image: new AssetImage('assets/img/logo.png')), - actions: [ - isOwner || hasAdmin - ? IconButton( - icon: Icon(Icons.edit), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - ContactEditor(setting: mainModel.setting)), - ); - }, - ) - : Container() - ], + leading: new IconButton( + icon: new Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), + title: LocalText( + context, + "contact", + fontSize: 25, + color: Colors.white, + ), ), body: ListView( children: [ - Center( - child: Padding( - padding: EdgeInsets.only(top: 5.0, bottom: 5), - child: LocalText( - context, - "contact.title", - fontSize: 25, - )), + link(pickupModel.profile.usaContactNumber, Icons.phone_forwarded, + onTap: () => _call(pickupModel.profile.usaContactNumber), + label: LocalText( + context, + "contact.usa.phone", + color: primaryColor, + )), + link(pickupModel.profile.mmContactNumber, Icons.phone_forwarded, + onTap: () => _call( + pickupModel.profile.mmContactNumber, + ), + label: LocalText( + context, + "contact.mm.phone", + color: primaryColor, + )), + link( + pickupModel.profile.usaAddress, + Icons.location_on, ), - Padding( - padding: const EdgeInsets.only(bottom: 15.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: - List.generate(mainModel.setting.phones.length, (index) { - return link(mainModel.setting.phones[index], Icons.phone, - onTap: () => _call(mainModel.setting.phones[index])); - }), - ), - ), - link(mainModel.setting.deliveryPhone, Icons.phone_forwarded, - onTap: () => _call(mainModel.setting.deliveryPhone), - label: LocalText(context, "contact.delivery.phone")), - link(mainModel.setting.email, Icons.email, - onTap: () => _email(mainModel.setting.email)), - link(mainModel.setting.facebook, FontAwesomeIcons.facebook, - onTap: () => _openLink(mainModel.setting.facebook)), - link(mainModel.setting.website, FontAwesomeIcons.chrome, - onTap: () => _openLink(mainModel.setting.website)), - link(mainModel.setting.address, Icons.location_on), + link(pickupModel.profile.mmAddress, Icons.location_on), + link(pickupModel.profile.mail, Icons.email, + onTap: () => _email(pickupModel.profile.mail)), + link(pickupModel.profile.facebook, FontAwesomeIcons.facebook, + onTap: () => _openLink(pickupModel.profile.facebook)), ], ), ), @@ -106,17 +91,25 @@ class _ContactState extends State { padding: const EdgeInsets.all(8.0), child: Icon( iconData, - color: primaryColor, ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - label == null ? Container() : label, - Text( - text == null ? "" : text, - overflow: TextOverflow.ellipsis, - maxLines: 5, + label == null + ? Container() + : Padding( + padding: EdgeInsets.fromLTRB(10, 10, 10, 0), + child: label, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + text == null ? "" : text, + overflow: TextOverflow.ellipsis, + maxLines: 5, + style: TextStyle(fontSize: 14.0), + ), ), ], ), diff --git a/lib/pages/customer_editor.dart b/lib/pages/customer_editor.dart new file mode 100644 index 0000000..ae94389 --- /dev/null +++ b/lib/pages/customer_editor.dart @@ -0,0 +1,343 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:fcs/model/employee_model.dart'; +import 'package:fcs/model/language_model.dart'; +import 'package:fcs/model/main_model.dart'; +import 'package:fcs/model/user_model.dart'; +import 'package:fcs/theme/theme.dart'; +import 'package:fcs/vo/role.dart'; +import 'package:fcs/vo/user.dart'; +import 'package:fcs/widget/local_text.dart'; +import 'package:fcs/widget/localization/app_translations.dart'; +import 'package:fcs/widget/progress.dart'; +import 'util.dart'; + +typedef void FindCallBack(); + +class CustomerEditor extends StatefulWidget { + final User customer; + const CustomerEditor({this.customer}); + @override + _CustomerEditorState createState() => _CustomerEditorState(); +} + +class _CustomerEditorState extends State { + TextEditingController _name = new TextEditingController(); + TextEditingController _phone = new TextEditingController(); + TextEditingController _phoneInput = new TextEditingController(); + + final _formKey = GlobalKey(); + bool _isLoading = false; + String currentBizId; + bool isSend = false; + User user; + User selectedUser; + List privileges = []; + + @override + void initState() { + super.initState(); + // privileges = Provider.of(context, listen: false).privileges; + if (widget.customer != null) { + _name.text = widget.customer.name; + _phone.text = widget.customer.phone; + // privileges.forEach((p) => widget.employee.privilegeIds.contains(p.id) + // ? p.isChecked = true + // : p.isChecked = false); + } + } + + List showprivilegeList(BuildContext context, UserModel userModel) { + return privileges.map((p) { + return new ListTile( + title: new Row( + children: [ + new Checkbox( + value: p.isChecked == null ? false : p.isChecked, + activeColor: primaryColor, + onChanged: (bool value) { + setState(() { + p.isChecked = value; + }); + }), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new Text( + p.name, + style: TextStyle( + fontSize: 15.0, + ), + ), + // Container( + // width: MediaQuery.of(context).size.width * 0.5, + // child: new Text( + // userModel.getPrivileges[index].desc, + // style: + // TextStyle(fontSize: 12.0, color: Colors.grey[600]), + // ), + // ), + ], + ), + ], + )); + }).toList(); + } + + Widget phoneInputbox(BuildContext context, FindCallBack findCallBack) { + var languageModel = Provider.of(context); + return Container( + padding: EdgeInsets.only(top: 10), + child: Stack( + alignment: const Alignment(1.2, 1.0), + children: [ + TextFormField( + controller: _phoneInput, + autofocus: false, + cursorColor: primaryColor, + keyboardType: TextInputType.phone, + style: textStyle, + decoration: new InputDecoration( + labelText: AppTranslations.of(context).text('employee.phone'), + labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, + icon: Icon( + Icons.phone, + color: primaryColor, + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + ), + ), + new FlatButton( + onPressed: () { + this.isSend = true; + findCallBack(); + }, + child: new Icon( + Icons.search, + size: 25, + )) + ], + )); + } + + @override + Widget build(BuildContext context) { + var userModel = Provider.of(context); + MainModel mainModel = Provider.of(context); + + final namebox = TextFormField( + controller: _name, + autofocus: false, + readOnly: true, + cursorColor: primaryColor, + decoration: new InputDecoration( + border: InputBorder.none, + focusedBorder: InputBorder.none, + icon: Icon( + Icons.person, + color: primaryColor, + ), + ), + ); + + final displayPhoneNo = TextFormField( + controller: _phone, + autofocus: false, + readOnly: true, + cursorColor: primaryColor, + decoration: new InputDecoration( + border: InputBorder.none, + focusedBorder: InputBorder.none, + icon: Icon( + Icons.phone, + color: primaryColor, + ), + ), + ); + + var phoneNumberBox = Row( + children: [ + Expanded(child: displayPhoneNo), + Expanded( + child: InkWell( + onTap: () => call(context, _phone.text), + child: Icon( + Icons.open_in_new, + color: Colors.grey, + size: 15, + ), + ), + ), + ], + ); + + final updateButton = Container( + padding: EdgeInsets.only(top: 40), + child: Container( + height: 45.0, + decoration: BoxDecoration( + color: primaryColor, + shape: BoxShape.rectangle, + ), + child: ButtonTheme( + minWidth: 900.0, + height: 100.0, + child: FlatButton( + onPressed: () {}, + child: LocalText( + context, + 'customer.update', + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ); + + final addButton = Container( + padding: EdgeInsets.only(top: 40), + child: Container( + height: 45.0, + decoration: BoxDecoration( + color: primaryColor, + shape: BoxShape.rectangle, + ), + child: ButtonTheme( + minWidth: 900.0, + height: 100.0, + child: FlatButton( + onPressed: () {}, + child: LocalText( + context, + 'customer.add', + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ); + + return LocalProgress( + inAsyncCall: _isLoading, + child: Scaffold( + appBar: AppBar( + centerTitle: true, + leading: new IconButton( + icon: new Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), + backgroundColor: primaryColor, + title: LocalText( + context, + "customer.form.title", + fontSize: 20, + color: Colors.white, + ), + // actions: [ + // widget.customer == null || !mainModel.showHistoryBtn() + // ? Container() + // : IconButton( + // icon: Icon(Icons.history), + // onPressed: () { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => DocumentLogPage( + // docID: widget.customer.docID)), + // ); + // }, + // ), + // ], + ), + body: ListView( + shrinkWrap: true, + padding: EdgeInsets.only(left: 24.0, right: 24.0), + children: [ + widget.customer == null + ? phoneInputbox(context, () => _findUser(context)) + : phoneNumberBox, + widget.customer == null + ? this.isSend ? namebox : Container() + : namebox, + // widget.customer == null ? addButton : updateButton, + SizedBox( + height: 20, + ) + ], + ), + )); + } + + _add(BuildContext context) async { + if (selectedUser == null) return; + setState(() { + _isLoading = true; + }); + var employeeModel = Provider.of(context); + try { + await employeeModel.updatePrivileges( + this.selectedUser.docID, privilegesIDs()); + Navigator.pop(context); + } catch (e) { + showMsgDialog(context, "Error", e.toString()); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + List privilegesIDs() { + return this.privileges.where((p) => p.isChecked).map((p) => p.id).toList(); + } + + _save() async { + setState(() { + _isLoading = true; + }); + if (widget.customer == null) return; + var employeeModel = Provider.of(context); + try { + await employeeModel.updatePrivileges(widget.customer.docID, privilegesIDs()); + Navigator.pop(context); + } catch (e) { + showMsgDialog(context, "Error", e.toString()); + } finally { + setState(() { + _isLoading = false; + }); + } + } + + _findUser(BuildContext context) async { + var userModel = Provider.of(context); + setState(() { + _isLoading = true; + }); + try { + selectedUser = await userModel.findUser(_phoneInput.text); + setState(() { + isSend = true; + _name.text = selectedUser.name; + if (selectedUser.privilegeIds != null) { + privileges.forEach((p) => selectedUser.privilegeIds.contains(p.id) + ? p.isChecked = true + : p.isChecked = false); + } + }); + } catch (e) { + showMsgDialog(context, "Error", e.toString()); + } finally { + setState(() { + _isLoading = false; + }); + } + } +} diff --git a/lib/pages/customer_list.dart b/lib/pages/customer_list.dart new file mode 100644 index 0000000..e838390 --- /dev/null +++ b/lib/pages/customer_list.dart @@ -0,0 +1,131 @@ +import 'package:fcs/model/customer_model.dart'; +import 'package:fcs/pages/search_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:fcs/theme/theme.dart'; +import 'package:fcs/widget/progress.dart'; + +import '../theme/theme.dart'; +import '../vo/user.dart'; +import '../widget/local_text.dart'; +import 'customer_editor.dart'; + +class CustomerList extends StatefulWidget { + @override + _CustomerListState createState() => _CustomerListState(); +} + +class _CustomerListState extends State { + 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(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: [ + IconButton( + icon: Icon( + Icons.search, + color: Colors.white, + ), + iconSize: 30, + onPressed: () => showPlacesSearch(context), + ), + ], + backgroundColor: primaryColor, + title: LocalText( + context, + 'customer.list.title', + color: Colors.white, + fontSize: 20, + ), + ), + 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.customers.length, + itemBuilder: (BuildContext context, int index) { + User user = customerModel.customers[index]; + return Stack( + children: [ + InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + CustomerEditor(customer: user)), + ); + }, + child: Row( + children: [ + Expanded( + child: new Padding( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: new Row( + children: [ + new Padding( + padding: new EdgeInsets.symmetric( + horizontal: 32.0 - dotSize / 2), + child: Icon( + Feather.users, + color: primaryColor, + size: 40, + ), + ), + new Expanded( + child: new Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + new Text( + user.name, + style: new TextStyle( + fontSize: 15.0, + color: primaryColor), + ), + Padding( + padding: + const EdgeInsets.only(top: 8.0), + child: new Text( + user.phoneNumber, + style: new TextStyle( + fontSize: 15.0, + color: Colors.grey), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ], + ); + }), + ), + ); + } +} diff --git a/lib/pages/fcs_profile_page.dart b/lib/pages/fcs_profile_page.dart index 5bc8f5c..cd4a8ff 100644 --- a/lib/pages/fcs_profile_page.dart +++ b/lib/pages/fcs_profile_page.dart @@ -1,6 +1,9 @@ import 'package:fcs/model/pickup_model.dart'; +import 'package:fcs/pages/util.dart'; import 'package:fcs/vo/pickup.dart'; import 'package:fcs/widget/fcs_text_field.dart'; +import 'package:fcs/widget/local_text.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:flutter/material.dart'; @@ -49,67 +52,37 @@ class _FCSProfilePageState extends State { @override Widget build(BuildContext context) { - final usaAddress = Container( - child: FCSTextField( - controller: _usaAddressEditingController, - label: 'USA Delivery Address', - )); + final usaAddress = fcsInput('USA Delivery Address', Icons.location_on, + controller: _usaAddressEditingController); + final mmAddress = fcsInput('Yangon, Myanmar Office', Icons.location_on, + controller: _mmAddressEditingController); - final mmAddress = Container( - child: Row(children: [ - Expanded( - child: FCSTextField( - controller: _mmAddressEditingController, - label: 'Yangon, Myanmar Office', - )), - ]), - ); + final contactNumber = fcsInput('USA contact number', Icons.phone, + controller: _contactEditingController); + final mmContactNumber = fcsInput('Myanmar contact number', Icons.phone, + controller: _mmContactEditingController); - final contactNumber = Container( - child: Row(children: [ - Expanded( - child: FCSTextField( - controller: _contactEditingController, - label: 'USA contact number', - )), - ]), - ); - - final mmContactNumber = Container( - child: Row(children: [ - Expanded( - child: FCSTextField( - controller: _mmContactEditingController, - label: 'Myanmar contact number', - )), - ]), - ); - - final mailBox = Container( - child: Row(children: [ - Expanded( - child: FCSTextField( - controller: _mailEditingController, - label: 'Email Address', - )), - ]), - ); - - final fbLinkBox = Container( - child: Row(children: [ - Expanded( - child: FCSTextField( - controller: _fbLinkEditingController, label: ' Facebook Link')), - ]), - ); + final mailBox = fcsInput('Email Address', Icons.mail, + controller: _mailEditingController); + final fbLinkBox = fcsInput('Facebook Link', FontAwesomeIcons.facebook, + controller: _fbLinkEditingController); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, + leading: new IconButton( + icon: new Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), backgroundColor: primaryColor, - title: Text('FCS PROFILE'), + title: LocalText( + context, + 'fcs.profile', + color: Colors.white, + fontSize: 20, + ), ), body: Card( child: Column( diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 9eb5dc0..7ac0bb0 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -45,6 +45,7 @@ import 'package:provider/provider.dart'; import '../theme/theme.dart'; import 'announcement_list.dart'; import 'buying_online.dart'; +import 'customer_list.dart'; import 'do/do_list.dart'; import 'my_registeration.dart'; import 'pd/pd_list.dart'; @@ -155,13 +156,18 @@ class _HomePageState extends State { final customersBtn = _buildBtn2("customers.btn", icon: Feather.users, btnCallback: () => - Navigator.of(context).push(BottomUpPageRoute(StaffList()))); + Navigator.of(context).push(BottomUpPageRoute(CustomerList()))); final invoicesBtn = _buildBtn2("invoices.btn", icon: FontAwesomeIcons.fileInvoice, btnCallback: () => Navigator.of(context).push(BottomUpPageRoute(StaffList()))); + final termBtn = _buildBtn2("term.btn", + icon: FontAwesomeIcons.info, + btnCallback: () => + Navigator.of(context).push(BottomUpPageRoute(Term()))); + List widgets = []; widgets.add(buyingBtn); widgets.add(pickUpBtn); @@ -173,6 +179,7 @@ class _HomePageState extends State { widgets.add(packagesBtn); widgets.add(customersBtn); widgets.add(invoicesBtn); + widgets.add(termBtn); return OfflineRedirect( child: FlavorBanner( @@ -248,7 +255,7 @@ class _HomePageState extends State { "Sign In", style: siginButtonStyle, ), - ), + ), ]), body: Container( decoration: BoxDecoration( @@ -432,7 +439,10 @@ class _HomePageState extends State { Widget _buildSmallButton(String text, IconData iconData) { return InkWell( - onTap: () => {}, + onTap: () => { + Navigator.of(context) + .push(MaterialPageRoute(builder: (_) => Contact())), + }, child: Padding( padding: const EdgeInsets.all(18.0), child: Row( diff --git a/lib/pages/pickup_editor.dart b/lib/pages/pickup_editor.dart index 7325572..0ab7506 100644 --- a/lib/pages/pickup_editor.dart +++ b/lib/pages/pickup_editor.dart @@ -75,110 +75,88 @@ class _PickUpEditorState extends State { Widget build(BuildContext context) { var pickupModel = Provider.of(context); - final pickUpAddress = Container( - child: TextFormField( - maxLines: null, - controller: _addressEditingController, - cursorColor: primaryColor, - style: textStyle, - minLines: 2, - decoration: new InputDecoration( - labelText: 'Pickup Address', - disabledBorder: InputBorder.none, - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - ), - )); + final pickUpAddress = fcsInput('Pickup Address', Icons.location_on, + controller: _addressEditingController); - final pickUpAddressReadOnly = Container( - child: FCSTextFieldReadOnly( - controller: _addressEditingController, - label: 'Pickup Address', - )); + final pickUpAddressReadOnly = fcsInputReadOnly( + 'Pickup Address', Icons.location_on, + controller: _addressEditingController); - final pickupTime = Container( - height: 50.0, - child: Row(children: [ - Container( - width: 70.0, - child: TextFormField( - controller: _fromTimeEditingController, - cursorColor: primaryColor, - decoration: new InputDecoration( - labelText: 'From', - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - ), - )), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text(' - '), - ), - Container( - width: 70.0, - child: TextFormField( - controller: _toTimeEditingController, - cursorColor: primaryColor, - decoration: new InputDecoration( - labelText: 'To', - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - ), - )), - ]), + final fromTimeBox = fcsInput( + 'From', + Icons.timer, + controller: _fromTimeEditingController, ); - final pickupTimeReadOnly = Container( - height: 50.0, - child: Row(children: [ - Container( - width: 70.0, - child: FCSTextFieldReadOnly( - controller: _fromTimeEditingController, label: 'From')), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text(' - '), - ), - Container( - width: 70.0, - child: FCSTextFieldReadOnly( - controller: _toTimeEditingController, label: 'To')), - ]), + final toTimeBox = fcsInput( + 'To', + null, + controller: _toTimeEditingController, ); - final noOfPackageBox = Container( - height: 50.0, - child: Row(children: [ - Expanded( - child: TextFormField( - controller: _noOfPackageEditingController, - cursorColor: primaryColor, - textAlign: TextAlign.left, - decoration: new InputDecoration( - labelText: 'Number of Packages', - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), + final fromTimeBoxReadOnly = fcsInputReadOnly( + 'From', + Icons.timer, + controller: _fromTimeEditingController, + ); + + final toTimeBoxReadOnly = fcsInputReadOnly( + 'To', + null, + controller: _toTimeEditingController, + ); + + final pickupTime = Padding( + padding: const EdgeInsets.only(left: 20.0), + child: Row( + children: [ + Container( + child: fromTimeBox, + width: 120, ), - )), - ]), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Text('-'), + ), + Container( + child: toTimeBox, + width: 120, + ), + ], + ), ); - final noOfPackageBoxReadonly = Container( - height: 50.0, - child: Row(children: [ - Expanded( - child: FCSTextFieldReadOnly( - controller: _noOfPackageEditingController, - label: 'Number of Packages')), - ]), + final pickupTimeReadOnly = Padding( + padding: const EdgeInsets.only(left: 20.0), + child: Row( + children: [ + SizedBox(height: 5), + Container( + child: fromTimeBoxReadOnly, + width: 120, + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Text('-'), + ), + Container( + child: toTimeBoxReadOnly, + width: 120, + ), + ], + ), + ); + + final noOfPackageBox = fcsInput( + 'Number of Packages', + Octicons.package, + controller: _noOfPackageEditingController, + ); + + final noOfPackageBoxReadonly = fcsInputReadOnly( + 'Number of Packages', + Octicons.package, + controller: _noOfPackageEditingController, ); final requestDateBox = Container( @@ -212,7 +190,7 @@ class _PickUpEditorState extends State { EdgeInsets.symmetric(vertical: 10.0, horizontal: 0.0), icon: Icon( Icons.date_range, - color: Colors.black87, + color: Colors.grey, )), validator: (value) { if (value.isEmpty) { @@ -258,62 +236,22 @@ class _PickUpEditorState extends State { ), ), ), - SizedBox(height: 15), ExpansionTile( title: Text('Pickup Location / Time'), children: [ Padding( padding: const EdgeInsets.only(left: 20.0), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon(Icons.location_on), - ), - Expanded( - child: widget.pickUp == null - ? pickUpAddress - : widget.pickUp.status == 'Pending' - ? pickUpAddress - : pickUpAddressReadOnly), - ], - ), + child: widget.pickUp == null + ? pickUpAddress + : widget.pickUp.status == 'Pending' + ? pickUpAddress + : pickUpAddressReadOnly, ), - SizedBox(height: 15), - Padding( - padding: const EdgeInsets.only(left: 20.0), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon(Icons.timer), - ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Text('Pickup Time', - style: TextStyle( - color: Colors.grey, fontSize: 14)), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.only(left: 20.0), - child: Row( - children: [ - SizedBox(height: 5), - Padding( - padding: const EdgeInsets.only(left: 33), - child: widget.pickUp == null - ? pickupTime - : widget.pickUp.status == 'Pending' - ? pickupTime - : pickupTimeReadOnly, - ), - ], - ), - ), - SizedBox(height: 5), + widget.pickUp == null + ? pickupTime + : widget.pickUp.status == 'Pending' + ? pickupTime + : pickupTimeReadOnly, Padding( padding: const EdgeInsets.only(left: 20.0), child: Column( @@ -323,7 +261,6 @@ class _PickUpEditorState extends State { ], ), ), - SizedBox(height: 10), ], ), ExpansionTile( @@ -331,23 +268,11 @@ class _PickUpEditorState extends State { children: [ Padding( padding: const EdgeInsets.only(left: 20.0), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon(Octicons.package), - ), - Expanded( - child: widget.pickUp == null - ? noOfPackageBox - : widget.pickUp.status == 'Pending' - ? noOfPackageBox - : noOfPackageBoxReadonly), - ], - ), - ), - SizedBox( - height: 15, + child: widget.pickUp == null + ? noOfPackageBox + : widget.pickUp.status == 'Pending' + ? noOfPackageBox + : noOfPackageBoxReadonly, ), Padding( padding: const EdgeInsets.only(left: 20.0), @@ -363,12 +288,11 @@ class _PickUpEditorState extends State { FontAwesomeIcons.weightHanging, controller: _weightEditingController), ), - SizedBox(height: 15), Padding( padding: const EdgeInsets.only(left: 20.0), child: fcsInput("Remark", MaterialCommunityIcons.note), ), - SizedBox(height: 25), + SizedBox(height: 10.0), ], ), ExpansionTile( @@ -387,22 +311,19 @@ class _PickUpEditorState extends State { "Name", FontAwesomeIcons.user, controller: _recipientNameEditingController)), - SizedBox(height: 25), Padding( padding: const EdgeInsets.only(left: 20.0), child: widget.pickUp == null - ? fcsInput("Phone Number", FontAwesomeIcons.phone, + ? fcsInput("Phone Number", Icons.phone, controller: _recipientPhoneEditingController) : widget.pickUp.status == 'Pending' - ? fcsInput( - "Phone Number", FontAwesomeIcons.phone, + ? fcsInput("Phone Number", Icons.phone, controller: _recipientPhoneEditingController) : fcsInputReadOnly( - "Phone Number", FontAwesomeIcons.phone, + "Phone Number", Icons.phone, controller: _recipientPhoneEditingController)), - SizedBox(height: 25), Padding( padding: const EdgeInsets.only(left: 20.0), child: widget.pickUp == null @@ -417,7 +338,6 @@ class _PickUpEditorState extends State { "Address", Icons.location_on, controller: _recipientAddressEditingController)), - SizedBox(height: 25), ], ), ExpansionTile( @@ -432,9 +352,6 @@ class _PickUpEditorState extends State { ) : Container() : Container(), - SizedBox( - height: 25, - ), ], ), ]), diff --git a/lib/pages/shipment_rates.dart b/lib/pages/shipment_rates.dart index a7c8b36..8a82b15 100644 --- a/lib/pages/shipment_rates.dart +++ b/lib/pages/shipment_rates.dart @@ -116,16 +116,16 @@ class _ShipmentRatesState extends State { ), _row("Free delivery within Yangon \nfor shipments over","10","pounds"), _row("Delivery fees","\$ 5","below 10 pounds"), - Padding( - padding: const EdgeInsets.only(left: 18.0, right: 18), - child: RichText( - // overflow: TextOverflow.fade, - text: TextSpan( - style: TextStyle(color: primaryColor), - children: textList, - ), - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 18.0, right: 18), + // child: RichText( + // // overflow: TextOverflow.fade, + // text: TextSpan( + // style: TextStyle(color: primaryColor), + // children: textList, + // ), + // ), + // ), fcsButton(context, "Calculate", callack: () { Navigator.of(context) .push(MaterialPageRoute(builder: (_) => ShipmentRatesCal())); diff --git a/lib/pages/term.dart b/lib/pages/term.dart index edf23d4..4afdc8c 100644 --- a/lib/pages/term.dart +++ b/lib/pages/term.dart @@ -31,16 +31,18 @@ class _TermState extends State { void initState() { super.initState(); _controller = ZefyrController(_loadDocument()); + print("controller terms => ${_controller.document}"); _focusNode = FocusNode(); } NotusDocument _loadDocument() { MainModel mainModel = Provider.of(context, listen: false); String term = mainModel.setting.terms; - + print("terms => $term"); NotusDocument doc; try { doc = NotusDocument.fromJson(jsonDecode(term)); + print('doc=> $doc'); } catch (e) {} if (doc == null) { doc = NotusDocument(); @@ -51,7 +53,6 @@ class _TermState extends State { @override Widget build(BuildContext context) { MainModel mainModel = Provider.of(context); - print("controller terms => ${_controller.document}"); bool isOwnerAndAbove = mainModel.user != null && mainModel.user.isOwnerAndAbove(); @@ -89,21 +90,41 @@ class _TermState extends State { child: Scaffold( appBar: AppBar( centerTitle: true, - automaticallyImplyLeading: !widget.agreePage, + leading: new IconButton( + icon: new Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), + // automaticallyImplyLeading: !widget.agreePage, title: LocalText(context, 'term', color: Colors.white, fontSize: 20), backgroundColor: primaryColor, actions: [ - isOwnerAndAbove || hasAdmin - ? IconButton( - icon: Icon(Icons.edit), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => TermEdit()), - ); - }, - ) - : Container() + // isOwnerAndAbove || hasAdmin + // ? + IconButton( + icon: Icon(Icons.edit), + onPressed: () async { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => TermEdit((data) { + setState(() { + _controller = ZefyrController(data); + }); + })), + ); + // print('doc=> $doc'); + + // setState(() { + // document = doc; + // }); + // var document = await + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => TermEdit()), + // ); + }, + ) + // : Container() ], ), body: Column( diff --git a/lib/pages/term_edit.dart b/lib/pages/term_edit.dart index 523e445..744b02b 100644 --- a/lib/pages/term_edit.dart +++ b/lib/pages/term_edit.dart @@ -14,6 +14,8 @@ import '../theme/theme.dart'; typedef void ProfileCallback(); class TermEdit extends StatefulWidget { + final ValueChanged onChangedData; + TermEdit(this.onChangedData); @override _TermEditState createState() => _TermEditState(); } @@ -110,8 +112,10 @@ class _TermEditState extends State { }); try { final contents = jsonEncode(_controller.document); - MainModel mainModel = Provider.of(context, listen: false); - mainModel.updateTerms(contents); + print('contents => $contents'); + widget.onChangedData(_controller.document); + // MainModel mainModel = Provider.of(context, listen: false); + // mainModel.updateTerms(contents); } catch (e) { showMsgDialog(context, "Error", e.toString()); } finally { diff --git a/lib/pages/util.dart b/lib/pages/util.dart index 7c6e0c2..a1945e9 100644 --- a/lib/pages/util.dart +++ b/lib/pages/util.dart @@ -388,32 +388,50 @@ Widget fcsInput(String label, IconData iconData, {TextEditingController controller, String value}) { return Row( children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon(iconData), - ), + // Padding( + // padding: const EdgeInsets.only(right: 8.0), + // child: Icon(iconData), + // ), Expanded( child: Container( - child: Row(children: [ Expanded( child: TextFormField( - initialValue: value, - controller: controller, - cursorColor: primaryColor, - maxLines: null, - minLines: 1, - textAlign: TextAlign.left, - decoration: new InputDecoration( - contentPadding: EdgeInsets.only(top: 8), - labelText: label, - labelStyle: TextStyle(fontSize: 14, color: Colors.grey), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: primaryColor, width: 1.0)), - ), - )), + initialValue: value, + controller: controller, + cursorColor: primaryColor, + maxLines: null, + minLines: 1, + decoration: InputDecoration( + fillColor: Colors.white, + labelText: label, + labelStyle: TextStyle(fontSize: 16, color: Colors.grey), + filled: true, + icon: Icon( + iconData, + color: Colors.grey, + ), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0)), + )) + // TextFormField( + // initialValue: value, + // controller: controller, + // cursorColor: primaryColor, + // maxLines: null, + // minLines: 1, + // textAlign: TextAlign.left, + // decoration: new InputDecoration( + // contentPadding: EdgeInsets.only(top: 8), + // labelText: label, + // labelStyle: TextStyle(fontSize: 14, color: Colors.grey), + // enabledBorder: UnderlineInputBorder( + // borderSide: BorderSide(color: primaryColor, width: 1.0)), + // focusedBorder: UnderlineInputBorder( + // borderSide: BorderSide(color: primaryColor, width: 1.0)), + // ), + // ) + ), ]), )), ], @@ -424,28 +442,28 @@ Widget fcsInputReadOnly(String label, IconData iconData, {TextEditingController controller, String value}) { return Row( children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: Icon(iconData), - ), Expanded( child: Container( child: Row(children: [ Expanded( child: TextFormField( - initialValue: value, - controller: controller, - cursorColor: primaryColor, - maxLines: null, - minLines: 1, - readOnly: true, - textAlign: TextAlign.left, - decoration: new InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.only(top: 8), - labelText: label, - ), - )), + initialValue: value, + controller: controller, + cursorColor: primaryColor, + maxLines: null, + minLines: 1, + decoration: InputDecoration( + fillColor: Colors.white, + border: InputBorder.none, + labelText: label, + labelStyle: TextStyle(fontSize: 16, color: Colors.grey), + filled: true, + icon: Icon( + iconData, + color: Colors.grey, + ), + )) + ), ]), )), ],