diff --git a/assets/local/localization_en.json b/assets/local/localization_en.json index 0385fa4..309d9df 100644 --- a/assets/local/localization_en.json +++ b/assets/local/localization_en.json @@ -279,7 +279,7 @@ "document.by":"By", "document.desc":"Description", - "contact.title":"Contacts", + "contact.title":"Contact Us", "contact.phone.title":"Input Phone Number", "contact.phone":"Phone Number", "contact.phone.confim":"Call {0}?", @@ -295,7 +295,16 @@ "contact.open.confrim":"Open '{0}'?", "contact.bank.accounts":"Bank Accounts Info", "contact.address":"Address", + "contact.usa.address":"USA Address", + "contact.mm.address":"Myanmar Address", "contact.delivery.phone":"Delivery Phone", + "contact.fcs.email":"FCS Email", + "contact.callus":"Call Us", + "contact.findus":"Find Us", + "contact.emailus":"Email Us", + "contact.visitus":"Visit Us", + + "contact.edit.title":"Edit Contact Us", "term.title":"Terms", "manual.title":"Manual", diff --git a/assets/local/localization_mu.json b/assets/local/localization_mu.json index 5a76f64..8546cf0 100644 --- a/assets/local/localization_mu.json +++ b/assets/local/localization_mu.json @@ -277,6 +277,8 @@ "contact.title":"ဆက်သွယ်ရန်", "contact.phone.title":"ဖုန်းနံပါတ်ထည့်သွင်းရန်", "contact.phone":"ဖုန်းနံပါတ်", + "contact.usa.phone": "အမေရိကား ဖုန်းနံပါတ်", + "contact.mm.phone": "မြန်မာ ဖုန်းနံပါတ်", "contact.phone.confim":"ဖုန်းနံပါတ် '{0}' ကို ခေါ်မလား?", "contact.phone.empty":"ကျေးဇူးပြု၍ ဖုန်းနံပါတ်ထည့်ပါ", "contact.email":"အီးမေးလ်", @@ -291,7 +293,15 @@ "contact.bank.accounts":"ဘဏ်အကောင့်အချက်အလက်", "contact.address":"လိပ်စာ", "contact.delivery.phone":"သီလဝါ ဆီထုတ် ဖုန်းနံပါတ်", + "contact.usa.address":"အမေရိကား လိပ်စာ", + "contact.mm.address":"မြန်မာ လိပ်စာ", + "contact.fcs.email":"FCS အီးမေးလ်", + "contact.callus":"ခေါ်ပါ", + "contact.findus":"တည်နေရာ", + "contact.emailus":"အီးမေးလ်", + "contact.visitus":"ကြည့်ပါ", + "contact.edit.title":"ဆက်သွယ်ရန် ပြုပြင်ခြင်း", "term.title":"စည်းကမ်းချက်များ", "manual.title":"လက်စွဲစာအုပ်", @@ -594,8 +604,6 @@ "fcs.profile": "ပရိုဖိုင်", - "contact.usa.phone": "ယူအက်စ်အေ ဖုန်းနံပါတ်", - "contact.mm.phone": "မြန်မာ ဖုန်းနံပါတ်", "payment.title": "ငွေပေးချေခြင်း", "payment.date": "ရက်စွဲ", diff --git a/lib/app.dart b/lib/app.dart index 9f597ac..7ab63a3 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:fcs/fcs/common/helpers/theme.dart'; import 'package:fcs/fcs/common/localization/app_translations_delegate.dart'; import 'package:fcs/fcs/common/localization/transalation.dart'; import 'package:fcs/fcs/common/pages/model/language_model.dart'; @@ -19,6 +20,7 @@ import 'package:fcs/model_fcs/message_model.dart'; import 'package:fcs/model_fcs/package_model.dart'; import 'package:fcs/pages/email_page.dart'; import 'package:fcs/pages/login_page.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -242,18 +244,36 @@ class _AppState extends State { ChangeNotifierProvider.value(value: testModel), ChangeNotifierProvider.value(value: mainModel2), ], - child: MaterialApp( - debugShowCheckedModeBanner: false, - title: 'FCS', - routes: route(context), - theme: ThemeData(accentColor: Colors.black), - localizationsDelegates: [ - _newLocaleDelegate, - //provides localised strings - GlobalMaterialLocalizations.delegate, - //provides RTL support - GlobalWidgetsLocalizations.delegate, - ], - supportedLocales: Translation().supportedLocales())); + child: Consumer( + builder: (context, value, child) { + return CupertinoApp( + debugShowCheckedModeBanner: false, + title: 'FCS', + theme: CupertinoThemeData( + textTheme: CupertinoTextThemeData( + navActionTextStyle: TextStyle(color: Colors.white), + navTitleTextStyle: TextStyle( + color: Colors.white, + fontSize: value.isEng ? 20 : 18, + fontWeight: FontWeight.bold), + navLargeTitleTextStyle: TextStyle( + color: Colors.white, + fontSize: value.isEng ? 40 : 24, + fontWeight: FontWeight.bold), + primaryColor: primaryColor, + textStyle: TextStyle(color: Colors.white), + actionTextStyle: TextStyle(color: Colors.white), + )), + routes: route(context), + localizationsDelegates: [ + _newLocaleDelegate, + //provides localised strings + GlobalMaterialLocalizations.delegate, + //provides RTL support + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: Translation().supportedLocales()); + }, + )); } } diff --git a/lib/fcs/common/pages/contact.dart b/lib/fcs/common/pages/contact.dart index 0a8e28c..5da0215 100644 --- a/lib/fcs/common/pages/contact.dart +++ b/lib/fcs/common/pages/contact.dart @@ -1,9 +1,12 @@ import 'package:fcs/fcs/common/domain/entities/setting.dart'; import 'package:fcs/fcs/common/helpers/theme.dart'; +import 'package:fcs/fcs/common/localization/app_translations.dart'; +import 'package:fcs/fcs/common/pages/contact_editor.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:fcs/fcs/common/pages/util.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:package_info/package_info.dart'; @@ -21,53 +24,69 @@ class _ContactState extends State { @override Widget build(BuildContext context) { Setting setting = Provider.of(context).setting; - + bool isEng = Provider.of(context).isEng; return LocalProgress( inAsyncCall: _isLoading, - child: Scaffold( - appBar: AppBar( - backgroundColor: primaryColor, - elevation: 0, - centerTitle: true, - leading: new IconButton( - icon: new Icon(Icons.close), - onPressed: () => Navigator.of(context).pop(), + child: CupertinoPageScaffold( + child: NestedScrollView( + headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { + return [ + CupertinoSliverNavigationBar( + backgroundColor: primaryColor, + actionsForegroundColor: Colors.white, + largeTitle: Text( + AppTranslations.of(context).text('contact.title'), + ), + trailing: GestureDetector( + onTap: () => + Navigator.of(context).push(CupertinoPageRoute( + builder: (context) => ContactEditor( + setting: setting, + ), + )), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + CupertinoIcons.pen, + size: 23, + color: Colors.white, + ), + )), + ), + ]; + }, + body: ListView( + children: [ + itemTitle("contact.callus"), + link(setting.usaContactNumber, Icons.phone_forwarded, + onTap: () => _call(setting.usaContactNumber), + label: LocalText(context, "contact.usa.phone", + color: primaryColor, fontWeight: FontWeight.bold)), + link(setting.mmContactNumber, Icons.phone_forwarded, + onTap: () => _call( + setting.mmContactNumber, + ), + label: LocalText(context, "contact.mm.phone", + color: primaryColor, fontWeight: FontWeight.bold)), + itemTitle("contact.findus"), + link(setting.usaAddress, Icons.location_on, + label: LocalText(context, "contact.usa.address", + color: primaryColor, fontWeight: FontWeight.bold)), + link(setting.mmAddress, Icons.location_on, + label: LocalText(context, "contact.mm.address", + color: primaryColor, fontWeight: FontWeight.bold)), + itemTitle("contact.emailus"), + link(setting.emailAddress, Icons.email, + onTap: () => _email(setting.emailAddress), + label: LocalText(context, "contact.fcs.email", + color: primaryColor, fontWeight: FontWeight.bold)), + itemTitle("contact.visitus"), + link(setting.facebookLink, FontAwesomeIcons.facebook, + onTap: () => _openLink(setting.facebookLink), + label: LocalText(context, "contact.facebook", + color: primaryColor, fontWeight: FontWeight.bold)), + ], ), - title: LocalText( - context, - "contact", - fontSize: 25, - color: Colors.white, - ), - ), - body: ListView( - children: [ - link(setting.usaContactNumber, Icons.phone_forwarded, - onTap: () => _call(setting.usaContactNumber), - label: LocalText( - context, - "contact.usa.phone", - color: primaryColor, - )), - link(setting.mmContactNumber, Icons.phone_forwarded, - onTap: () => _call( - setting.mmContactNumber, - ), - label: LocalText( - context, - "contact.mm.phone", - color: primaryColor, - )), - link( - setting.usaAddress, - Icons.location_on, - ), - link(setting.mmAddress, Icons.location_on), - link(setting.emailAddress, Icons.email, - onTap: () => _email(setting.emailAddress)), - link(setting.facebookLink, FontAwesomeIcons.facebook, - onTap: () => _openLink(setting.facebookLink)), - ], ), ), ); @@ -75,53 +94,77 @@ class _ContactState extends State { Widget link(String text, IconData iconData, {Function() onTap, Widget label}) { - return Padding( - padding: const EdgeInsets.only(left: 18.0, bottom: 5), - child: InkWell( - onTap: () => onTap != null ? onTap() : null, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Icon( - iconData, - ), + return Material( + child: Padding( + padding: const EdgeInsets.only(left: 18.0, bottom: 10, right: 18), + child: Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey, width: 0.8), + borderRadius: BorderRadius.all( + Radius.circular(5.0) // <--- border radius here ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, + ), + child: InkWell( + onTap: () => onTap != null ? onTap() : null, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( children: [ - 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), + child: Icon( + iconData, + color: primaryColor, ), ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 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, + ), + ), + ), + ], + ), + SizedBox( + width: 5, + ), + onTap == null + ? Container() + : Icon( + Icons.open_in_new, + color: Colors.grey, + size: 15, + ) ], ), - SizedBox( - width: 5, - ), - onTap == null - ? Container() - : Icon( - Icons.open_in_new, - color: Colors.grey, - size: 15, - ) - ], - ), - )), + )), + ), + ), + ); + } + + Widget itemTitle(String textKey) { + return Padding( + padding: const EdgeInsets.only(left: 18.0, top: 15, bottom: 5), + child: Text( + AppTranslations.of(context).text(textKey), + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 18, color: Colors.black54), + ), ); } @@ -132,19 +175,14 @@ class _ContactState extends State { } _call(String phone) { - showConfirmDialog( - context, "contact.phone.confim", () => launch("tel:$phone"), - translationVariables: ["$phone"]); + launch("tel:$phone"); } _email(String email) { - showConfirmDialog( - context, "contact.email.configm", () => launch("mailto:$email"), - translationVariables: ["$email"]); + launch("mailto:$email"); } _openLink(String link) { - showConfirmDialog(context, "contact.open.confrim", () => launch("$link"), - translationVariables: ["$link"]); + launch("$link"); } } diff --git a/lib/fcs/common/pages/contact_editor.dart b/lib/fcs/common/pages/contact_editor.dart new file mode 100644 index 0000000..ab56dae --- /dev/null +++ b/lib/fcs/common/pages/contact_editor.dart @@ -0,0 +1,297 @@ +import 'package:fcs/fcs/common/domain/entities/setting.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/util.dart'; +import 'package:fcs/fcs/common/pages/widgets/local_text.dart'; +import 'package:fcs/fcs/common/pages/widgets/progress.dart'; +import 'package:fcs/pages/phone_input.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +class ContactEditor extends StatefulWidget { + final Setting setting; + const ContactEditor({this.setting}); + @override + _ContactEditorState createState() => _ContactEditorState(); +} + +class _ContactEditorState extends State { + TextEditingController _email = new TextEditingController(); + TextEditingController _facebook = new TextEditingController(); + TextEditingController _website = new TextEditingController(); + TextEditingController _address = new TextEditingController(); + TextEditingController _deliveryPhone = new TextEditingController(); + + final _formKey = GlobalKey(); + bool _isLoading = false; + + List phones = new List(); + List _initPhones = new List(); + + @override + void initState() { + super.initState(); + if (widget.setting != null) { + this._initPhones = widget.setting.phones; + _email.text = widget.setting.emailAddress; + _facebook.text = widget.setting.facebookLink; + _website.text = widget.setting.website; + _deliveryPhone.text = widget.setting.deliveryPhone; + _address.text = widget.setting.address; + + phones.clear(); + // _initPhones.forEach((p) { + // phones.add(p); + // }); + } + } + + @override + Widget build(BuildContext context) { + var languageModel = Provider.of(context); + + final emailBox = TextFormField( + controller: _email, + autofocus: false, + cursorColor: primaryColor, + style: textStyle, + decoration: new InputDecoration( + labelText: AppTranslations.of(context).text('contact.email'), + labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, + icon: Icon( + Icons.email, + color: primaryColor, + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + ), + validator: (value) { + if (value.isEmpty) { + return AppTranslations.of(context).text('contact.email.empty'); + } + return null; + }, + ); + + final faceBookBox = TextFormField( + controller: _facebook, + autofocus: false, + cursorColor: primaryColor, + style: textStyle, + decoration: new InputDecoration( + labelText: AppTranslations.of(context).text('contact.facebook'), + labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, + icon: Icon( + FontAwesomeIcons.facebook, + color: primaryColor, + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + ), + validator: (value) { + if (value.isEmpty) { + return AppTranslations.of(context).text('contact.facebook.empty'); + } + return null; + }, + ); + + final googleBox = TextFormField( + controller: _website, + autofocus: false, + cursorColor: primaryColor, + style: textStyle, + decoration: new InputDecoration( + labelText: AppTranslations.of(context).text('contact.google'), + labelStyle: languageModel.isEng ? labelStyle : labelStyleMM, + icon: Icon( + FontAwesomeIcons.chrome, + color: primaryColor, + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: primaryColor, width: 1.0)), + ), + validator: (value) { + if (value.isEmpty) { + return AppTranslations.of(context).text('contact.google.empty'); + } + return null; + }, + ); + + final addPhoneNumber = ListTile( + contentPadding: EdgeInsets.only(top: 15), + title: ButtonTheme( + height: 45, + child: RaisedButton( + color: Colors.white, + onPressed: () async { + var phone = await showDialog( + context: context, builder: (_) => PhoneEditor()); + _save(phone); + }, + child: Text("Add Phone", + style: TextStyle( + fontSize: 18, + )), + ), + )); + + return LocalProgress( + inAsyncCall: _isLoading, + child: CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text( + AppTranslations.of(context).text('contact.edit.title'), + style: TextStyle(color: CupertinoColors.activeBlue), + ), + ), + // child: NestedScrollView( + // headerSliverBuilder: + // (BuildContext context, bool innerBoxIsScrolled) { + // return [ + // // CupertinoNavigationBar(), + // CupertinoSliverNavigationBar( + // largeTitle: Text( + // AppTranslations.of(context).text('contact.edit.title'), + // ), + // trailing: CupertinoButton( + // onPressed: () => {}, + // child: Icon( + // CupertinoIcons.pen, + // )), + // ) + // ]; + // }, + // body: Text("text"), + // appBar: AppBar( + // backgroundColor: primaryColor, + // title: LocalText( + // context, + // "contact.title", + // fontSize: 20, + // color: Colors.white, + // ), + // actions: [ + // IconButton( + // icon: Icon(Icons.send), + // onPressed: () { + // if (!_formKey.currentState.validate()) return; + // showConfirmDialog(context, "contact.confrim", () { + // _submit(); + // }); + // }) + // ], + // ), + child: Form( + key: _formKey, + child: ListView( + shrinkWrap: true, + padding: EdgeInsets.only(left: 24.0, right: 24.0), + children: [ + // this.phones.isNotEmpty + // ? ConstrainedBox( + // constraints: BoxConstraints(maxHeight: 1000), + // child: ListView.builder( + // shrinkWrap: true, + // itemBuilder: (context, index) { + // return Stack( + // alignment: const Alignment(1.0, 1.0), + // children: [ + // new TextField( + // controller: new TextEditingController( + // text: this.phones[index]), + // cursorColor: primaryColor, + // readOnly: true, + // decoration: new InputDecoration( + // border: InputBorder.none, + // focusedBorder: InputBorder.none, + // icon: Icon( + // Icons.phone, + // color: primaryColor, + // ), + // ), + // ), + // new FlatButton( + // onPressed: () { + // setState(() { + // this.phones.remove(this.phones[index]); + // }); + // }, + // child: new Icon( + // Icons.cancel, + // size: 25, + // )) + // ], + // ); + // }, + // itemCount: this.phones.length, + // ), + // ) + // : Container(), + // addPhoneNumber, + // LocalTextField( + // textEditingController: _deliveryPhone, + // icon: Icon( + // Icons.phone_forwarded, + // color: primaryColor, + // ), + // labelKey: "contact.delivery.phone", + // ), + // emailBox, + // faceBookBox, + // googleBox, + // LocalTextField( + // textEditingController: _address, + // icon: Icon( + // Icons.location_on, + // color: primaryColor, + // ), + // labelKey: "contact.address", + // maxLines: 3, + // ), + ], + ), + ))); + } + + _save(String phone) { + if (phone == null) return; + setState(() { + this.phones.add(phone); + }); + } + + _submit() async { + setState(() { + _isLoading = true; + }); + try { + widget.setting.emailAddress = _email.text; + widget.setting.facebookLink = _facebook.text; + widget.setting.website = _website.text; + widget.setting.phones = this.phones; + widget.setting.address = _address.text; + widget.setting.deliveryPhone = _deliveryPhone.text; + var mainModel = Provider.of(context); + // await mainModel.updateContact(widget.setting); + Navigator.pop(context); + } catch (e) { + showMsgDialog(context, "Error", e.toString()); + } finally { + setState(() { + _isLoading = false; + }); + } + } +} diff --git a/lib/fcs/common/pages/widgets/bottom_widgets.dart b/lib/fcs/common/pages/widgets/bottom_widgets.dart index 81b91b0..486e0ef 100644 --- a/lib/fcs/common/pages/widgets/bottom_widgets.dart +++ b/lib/fcs/common/pages/widgets/bottom_widgets.dart @@ -2,6 +2,7 @@ import 'package:fcs/fcs/common/pages/contact.dart'; import 'package:fcs/fcs/common/pages/term.dart'; import 'package:fcs/fcs/common/helpers/theme.dart'; import 'package:fcs/widget/bottom_up_page_route.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_icons/flutter_icons.dart'; @@ -14,13 +15,18 @@ class BottomWidgets extends StatelessWidget { children: [ InkWell( onTap: () { - Navigator.of(context).push(BottomUpPageRoute(Contact())); + Navigator.of(context).push(CupertinoPageRoute( + fullscreenDialog: true, + builder: (context) => Contact(), + )); }, child: _buildSmallButton("Contact Us", SimpleLineIcons.support), ), InkWell( onTap: () { - Navigator.of(context).push(BottomUpPageRoute(Term())); + Navigator.of(context).push(CupertinoPageRoute( + builder: (context) => Term(), + )); }, child: _buildSmallButton("Terms of service", Icons.info_outline), ),