add invitation
This commit is contained in:
@@ -45,6 +45,22 @@
|
||||
"faq.edit.delete.confirm":"Delete this FAQ?",
|
||||
|
||||
|
||||
"language.selection.title":"Please select your language",
|
||||
|
||||
"welcome.signin":"Sign In",
|
||||
"welcome.msg":"Welcome to FCS Logistics!",
|
||||
|
||||
"sms.verify.title":"Verify your number",
|
||||
"sms.six.digit":"Enter 6 digit sms code sent to",
|
||||
"sms.resend":"Resend",
|
||||
"sms.resend.seconds":"Resend again in {0} seconds",
|
||||
|
||||
"invite.title":"You need invitation from FCS",
|
||||
"invite.name.enter":"Please enter your name",
|
||||
"invite.request":"Request Invitation",
|
||||
"invite.request.successful":"Successfully requested!",
|
||||
|
||||
"================================================================":"",
|
||||
|
||||
"btn.save": "Save",
|
||||
"btn.approve":"Approve",
|
||||
@@ -495,11 +511,6 @@
|
||||
"login": "SignIn",
|
||||
"login.title":"Sign in to FCS",
|
||||
"login.phone":"Enter phone number",
|
||||
"login.smscode.retry":"Resend again in {0} seconds",
|
||||
|
||||
"singup.verify.title":"Verify your number",
|
||||
"singup.code_sent":"Enter 6 digit sms code sent to",
|
||||
"singup.resend":"Resend",
|
||||
|
||||
"user_edit.welcome":"Welcome to FCS",
|
||||
"user_edit.name":"Please enter your name",
|
||||
|
||||
@@ -44,6 +44,25 @@
|
||||
"faq.edit.sn":"S/N",
|
||||
"faq.edit.delete.confirm":"Delete this FAQ?",
|
||||
|
||||
|
||||
"language.selection.title":"ဘာသာစကား ရွေးချယ်ပါ",
|
||||
|
||||
"welcome.signin":"ဝင်မည်",
|
||||
"welcome.msg":"FCS Logistics က ကြိုဆိုပါတယ်!",
|
||||
|
||||
"sms.verify.title":"သင့်နံပါတ်ကိုအတည်ပြုပါ",
|
||||
"sms.six.digit":"SMS ဂဏန်း ခြောက်လုံး ကိုရိုက်ထဲ့ပါ",
|
||||
"sms.resend":"ပြန်ပို့ရန်",
|
||||
"sms.resend.seconds":"SMS ပြန်ပို့ရန် {0} စက္ကန့် စောင့်ပါ",
|
||||
|
||||
"invite.title":"FCS ဖိတ်ကြားမှု လိုအပ်သည်",
|
||||
"invite.name.enter":"နာမည် ရိုက်ထည့်ပါ",
|
||||
"invite.request":"ဖိတ်ကြားမှု တောင်းဆိုမည်",
|
||||
"invite.request.successful":"တောင်းဆိုမှု အောင်မြင်သည်!",
|
||||
|
||||
"================================================================":"",
|
||||
|
||||
|
||||
"btn.save":"သိမ်းဆည်းရန်",
|
||||
"btn.approve":"အတည်ပြုရန်",
|
||||
|
||||
@@ -523,11 +542,6 @@
|
||||
"login": "SignIn",
|
||||
"login.title":"FCS သို့အကောင့်ဒ်၀င်ပါ",
|
||||
"login.phone":"ဖုန်းနံပါတ်ထည့်ပါ",
|
||||
"login.smscode.retry":"Resend again in {0} seconds",
|
||||
|
||||
"singup.verify.title":"သင့်နံပါတ်ကိုအတည်ပြုပါ",
|
||||
"singup.code_sent":"Enter 6 digit sms code sent to",
|
||||
"singup.resend":"ပြန်ပို့ရန်",
|
||||
|
||||
"user_edit.welcome":"FCS မှကြိုဆိုပါသည်",
|
||||
"user_edit.name":"ကျေးဇူးပြု၍ နာမည်ထည့်ပေးပါ",
|
||||
|
||||
15
lib/app.dart
15
lib/app.dart
@@ -6,7 +6,9 @@ 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/faq/model/faq_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/initial_language_selection.dart';
|
||||
import 'package:fcs/fcs/common/pages/model/language_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/signin/model/signin_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/term/model/term_model.dart';
|
||||
import 'package:fcs/fcs/common/services/services.dart';
|
||||
import 'package:fcs/model/buyer_model.dart';
|
||||
@@ -58,8 +60,8 @@ class App extends StatefulWidget {
|
||||
|
||||
class _AppState extends State<App> {
|
||||
final fcs.MainModel mainModel2 = new fcs.MainModel();
|
||||
final ContactModel contactModel =new ContactModel();
|
||||
final TermModel termModel=new TermModel();
|
||||
final ContactModel contactModel = new ContactModel();
|
||||
final TermModel termModel = new TermModel();
|
||||
final MainModel mainModel = new MainModel();
|
||||
final FAQModel faqModel = new FAQModel();
|
||||
|
||||
@@ -92,6 +94,7 @@ class _AppState extends State<App> {
|
||||
final InvoiceModel invoiceModel = new InvoiceModel();
|
||||
final CustomerModel customerModel = new CustomerModel();
|
||||
final DiscountModel discountModel = new DiscountModel();
|
||||
final SigninModel signinModel = new SigninModel();
|
||||
|
||||
AppTranslationsDelegate _newLocaleDelegate;
|
||||
static FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
|
||||
@@ -209,7 +212,8 @@ class _AppState extends State<App> {
|
||||
agreePage: true,
|
||||
),
|
||||
'/login': (context) => LoginPage(),
|
||||
'/email': (context) => EmailPage()
|
||||
'/email': (context) => EmailPage(),
|
||||
'/language_selection': (context) => InitialLanguageSelectionPage(),
|
||||
};
|
||||
return routes;
|
||||
}
|
||||
@@ -249,8 +253,9 @@ class _AppState extends State<App> {
|
||||
ChangeNotifierProvider.value(value: testModel),
|
||||
ChangeNotifierProvider.value(value: mainModel2),
|
||||
ChangeNotifierProvider.value(value: contactModel),
|
||||
ChangeNotifierProvider.value(value: termModel),
|
||||
ChangeNotifierProvider.value(value: faqModel),
|
||||
ChangeNotifierProvider.value(value: termModel),
|
||||
ChangeNotifierProvider.value(value: faqModel),
|
||||
ChangeNotifierProvider.value(value: signinModel),
|
||||
],
|
||||
child: Consumer<LanguageModel>(
|
||||
builder: (context, value, child) {
|
||||
|
||||
@@ -3,6 +3,7 @@ class User {
|
||||
String name;
|
||||
String phoneNumber;
|
||||
bool hasSignup;
|
||||
bool invited;
|
||||
List<String> privileges = [];
|
||||
|
||||
String fcsID;
|
||||
|
||||
@@ -29,7 +29,9 @@ Future<dynamic> requestAPI(
|
||||
if (token != null) {
|
||||
headers["Token"] = token;
|
||||
}
|
||||
headers["Device"] = devInfo.deviceID + ":" + deviceName;
|
||||
if (devInfo != null && devInfo.deviceID != null && deviceName != null) {
|
||||
headers["Device"] = devInfo.deviceID + ":" + deviceName;
|
||||
}
|
||||
headers["Project-ID"] = Config.instance.reportProjectID;
|
||||
|
||||
BaseOptions options = new BaseOptions(
|
||||
|
||||
@@ -3,11 +3,20 @@ import 'dart:convert';
|
||||
import 'package:fcs/fcs/common/domain/entities/user.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
||||
class SharedPref {
|
||||
static final SharedPref instance = SharedPref._();
|
||||
SharedPref._();
|
||||
|
||||
static Future<bool> isFirstLaunch() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getBool('first_launch');
|
||||
}
|
||||
|
||||
static Future<void> finishFirstLaunch() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
return prefs.setBool('first_launch', false);
|
||||
}
|
||||
|
||||
static Future<String> getLang() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString('language');
|
||||
|
||||
@@ -179,7 +179,7 @@ class _HomePageState extends State<HomePage> {
|
||||
// customer || owner ? widgets.add(packagesBtn) : "";
|
||||
// owner ? widgets.add(boxesBtn) : "";
|
||||
// owner ? widgets.add(deliveryBtn) : "";
|
||||
widgets.add(customersBtn) ;
|
||||
widgets.add(customersBtn);
|
||||
// customer || owner ? widgets.add(invoicesBtn) : "";
|
||||
// owner ? widgets.add(paymentMethodBtn) : "";
|
||||
// owner ? widgets.add(discountBtn) : "";
|
||||
@@ -214,6 +214,7 @@ class _HomePageState extends State<HomePage> {
|
||||
],
|
||||
onPressed: _langChange,
|
||||
isSelected: languageModel.currentState,
|
||||
selectedBorderColor: Colors.white24,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
|
||||
187
lib/fcs/common/pages/initial_language_selection.dart
Normal file
187
lib/fcs/common/pages/initial_language_selection.dart
Normal file
@@ -0,0 +1,187 @@
|
||||
import 'package:fcs/fcs/common/helpers/shared_pref.dart';
|
||||
import 'package:fcs/fcs/common/helpers/theme.dart';
|
||||
import 'package:fcs/fcs/common/localization/transalation.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/signin/signin_page.dart';
|
||||
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class InitialLanguageSelectionPage extends StatefulWidget {
|
||||
@override
|
||||
_InitialLanguageSelectionPageState createState() =>
|
||||
_InitialLanguageSelectionPageState();
|
||||
}
|
||||
|
||||
class _InitialLanguageSelectionPageState
|
||||
extends State<InitialLanguageSelectionPage> {
|
||||
static final List<String> languagesList = Translation().supportedLanguages;
|
||||
static final List<String> languageCodesList =
|
||||
Translation().supportedLanguagesCodes;
|
||||
|
||||
final Map<dynamic, dynamic> languagesMap = {
|
||||
languagesList[0]: languageCodesList[0],
|
||||
languagesList[1]: languageCodesList[1],
|
||||
};
|
||||
|
||||
String selectedLanguage;
|
||||
int selectedIndex;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
var languageModel = Provider.of<LanguageModel>(context, listen: false);
|
||||
this.selectedIndex = languageModel.isEng ? 0 : 1;
|
||||
loadLaunguage(languageModel);
|
||||
}
|
||||
|
||||
loadLaunguage(LanguageModel languageModel) async {
|
||||
var lan = await languageModel.load();
|
||||
if (this.selectedLanguage != lan) {
|
||||
setState(() {
|
||||
this.selectedLanguage = lan;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Color(0xff272282), primaryColor],
|
||||
begin: const FractionalOffset(0.8, 0.9),
|
||||
end: const FractionalOffset(0.9, 0.0),
|
||||
stops: [0.0, 1.0],
|
||||
),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 40,
|
||||
child: LocalText(context, "language.selection.title",
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w200,
|
||||
color: Colors.white),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: Card(
|
||||
color: Color(0xfff4edec),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
width: 300,
|
||||
height: 160,
|
||||
child: Column(
|
||||
children: languagesList.asMap().entries.map((e) {
|
||||
var language = e.value;
|
||||
var key = e.key;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
_select(key, language);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2),
|
||||
decoration: key == languagesList.length - 1
|
||||
? BoxDecoration()
|
||||
: BoxDecoration(
|
||||
border: Border(
|
||||
bottom:
|
||||
BorderSide(color: Colors.grey[300]),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: language == 'English'
|
||||
? Container(
|
||||
child: CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundImage: AssetImage(
|
||||
"icons/flags/png/gb.png",
|
||||
package: 'country_icons',
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
child: CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundImage: AssetImage(
|
||||
"icons/flags/png/mm.png",
|
||||
package: 'country_icons',
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text("$language"),
|
||||
trailing: Theme(
|
||||
data: Theme.of(context).copyWith(
|
||||
unselectedWidgetColor: Colors.grey[400],
|
||||
),
|
||||
child: Radio(
|
||||
value: key,
|
||||
groupValue: selectedIndex,
|
||||
onChanged: (int i) =>
|
||||
_select(key, language),
|
||||
activeColor: primaryColor,
|
||||
),
|
||||
)),
|
||||
),
|
||||
);
|
||||
}).toList()),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.0),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 230, top: 20),
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
_next();
|
||||
},
|
||||
child: CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: Colors.white,
|
||||
child: Center(
|
||||
child: Icon(FontAwesomeIcons.arrowRight,
|
||||
color: Colors.black87)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_select(int index, String lang) {
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
selectedLanguage = lang;
|
||||
Translation().onLocaleChanged(Locale(languagesMap[lang]));
|
||||
Provider.of<LanguageModel>(context, listen: false)
|
||||
.saveLanguage(selectedLanguage);
|
||||
});
|
||||
}
|
||||
|
||||
_next() {
|
||||
SharedPref.finishFirstLaunch();
|
||||
bool isLogin = Provider.of<MainModel>(context, listen: false).isLogin();
|
||||
String page = isLogin ? "/home" : "/welcome";
|
||||
Navigator.of(context).pushReplacementNamed(page);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ class LanguageModel extends BaseModel {
|
||||
}
|
||||
this.language = result;
|
||||
Translation().onLocaleChanged(Locale(languagesMap[this.language]));
|
||||
print("lang=====$result");
|
||||
notifyListeners();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:device_info/device_info.dart';
|
||||
import 'package:dio/dio.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/helpers/network_connectivity.dart';
|
||||
import 'package:fcs/fcs/common/helpers/shared_pref.dart';
|
||||
import 'package:fcs/fcs/common/pages/model/base_model.dart';
|
||||
import 'package:fcs/fcs/common/services/services.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -22,12 +19,11 @@ class MainModel extends ChangeNotifier {
|
||||
User user;
|
||||
PackageInfo packageInfo;
|
||||
|
||||
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"}]');
|
||||
Setting setting;
|
||||
|
||||
bool isLoaded = false;
|
||||
bool isOnline = false;
|
||||
bool isFirstLaunch = false;
|
||||
|
||||
MainModel() {
|
||||
NetworkConnectivity.instance.statusStream.listen((data) {
|
||||
@@ -39,23 +35,22 @@ class MainModel extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
});
|
||||
Services.instance.authService.onAuthStatus().listen((event) {
|
||||
this.user=event;
|
||||
this.user = event;
|
||||
notifyListeners();
|
||||
print("main event-->$event");
|
||||
});
|
||||
}
|
||||
|
||||
bool faqEditable(){
|
||||
return this.user != null && false;
|
||||
}
|
||||
bool termEditable(){
|
||||
return this.user != null && false;
|
||||
}
|
||||
bool contactEditable(){
|
||||
bool faqEditable() {
|
||||
return this.user != null && false;
|
||||
}
|
||||
|
||||
bool termEditable() {
|
||||
return this.user != null && false;
|
||||
}
|
||||
|
||||
bool contactEditable() {
|
||||
return this.user != null && false;
|
||||
}
|
||||
|
||||
bool isLogin() {
|
||||
return this.user != null;
|
||||
@@ -69,13 +64,15 @@ class MainModel extends ChangeNotifier {
|
||||
return this.user != null && this.user.hasSysAdmin();
|
||||
}
|
||||
|
||||
|
||||
bool isAdmin() {
|
||||
return this.user != null && this.user.hasAdmin();
|
||||
}
|
||||
|
||||
init() async {
|
||||
await _loadSetting();
|
||||
this.isFirstLaunch = await SharedPref.isFirstLaunch();
|
||||
this.isFirstLaunch = this.isFirstLaunch ?? true;
|
||||
|
||||
_loadUser();
|
||||
this.packageInfo = await PackageInfo.fromPlatform();
|
||||
}
|
||||
@@ -126,7 +123,6 @@ class MainModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
bool isSupport() {
|
||||
return true;
|
||||
if (packageInfo == null || setting == null) return false;
|
||||
return int.parse(packageInfo.buildNumber) >= setting.supportBuildNum;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:fcs/pages_fcs/shipping_address_row.dart';
|
||||
import 'package:fcs/vo/role.dart';
|
||||
import 'package:fcs/vo/shipping_address.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -128,7 +129,6 @@ class _ProfileState extends State<Profile> {
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
final logoutbutton = Container(
|
||||
padding: EdgeInsets.only(left: 20.0, right: 24.0),
|
||||
@@ -183,6 +183,13 @@ class _ProfileState extends State<Profile> {
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
CupertinoIcons.back,
|
||||
size: 30,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
title: Text(
|
||||
AppTranslations.of(context).text("profile.title"),
|
||||
),
|
||||
|
||||
122
lib/fcs/common/pages/signin/invitation_request_page.dart
Normal file
122
lib/fcs/common/pages/signin/invitation_request_page.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'package:fcs/fcs/common/pages/model/main_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/signin/model/signin_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../../widget/local_text.dart';
|
||||
import '../../../../widget/progress.dart';
|
||||
import '../../helpers/theme.dart';
|
||||
|
||||
class RequestInvitationPage extends StatefulWidget {
|
||||
@override
|
||||
_RequestInvitationPageState createState() => _RequestInvitationPageState();
|
||||
}
|
||||
|
||||
class _RequestInvitationPageState extends State<RequestInvitationPage> {
|
||||
bool _isLoading = false;
|
||||
TextEditingController nameCtl;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
nameCtl = new TextEditingController();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: new Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.close),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor: primaryColor,
|
||||
),
|
||||
body: _buildBody(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.only(top: 5, left: 10, right: 10),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 40),
|
||||
child: LocalText(
|
||||
context,
|
||||
'invite.title',
|
||||
fontSize: 21,
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 25),
|
||||
child: LocalText(
|
||||
context,
|
||||
'invite.name.enter',
|
||||
color: labelColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 0, bottom: 10),
|
||||
child: TextFormField(
|
||||
controller: nameCtl,
|
||||
cursorColor: primaryColor,
|
||||
textAlign: TextAlign.left,
|
||||
keyboardType: TextInputType.text,
|
||||
autofocus: true,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
),
|
||||
decoration: new InputDecoration(
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
onPressed: _request,
|
||||
child: Text(getLocalString(context, "invite.request")),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_request() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
await context.read<SigninModel>().requestInvitation(nameCtl.text);
|
||||
await showMsgDialog(context, "Successful",
|
||||
getLocalString(context, "invite.request.successful"));
|
||||
} catch (e) {
|
||||
await showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
Navigator.pushNamedAndRemoveUntil(context, "/welcome", (r) => false);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
lib/fcs/common/pages/signin/model/signin_model.dart
Normal file
22
lib/fcs/common/pages/signin/model/signin_model.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fcs/fcs/common/pages/model/base_model.dart';
|
||||
import 'package:fcs/fcs/common/services/services.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class SigninModel extends BaseModel {
|
||||
final log = Logger('SigninModel');
|
||||
|
||||
Future<bool> checkInvatation() async {
|
||||
var invited = await request("/check_invitation", "GET",
|
||||
token: await Services.instance.authService.getToken());
|
||||
return invited["invited"];
|
||||
}
|
||||
|
||||
Future<void> requestInvitation(String name) async {
|
||||
await request("/request_invitation", "POST",
|
||||
payload: {"user_name": name},
|
||||
token: await Services.instance.authService.getToken());
|
||||
await Services.instance.authService.signout();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../helpers/theme.dart';
|
||||
import '../../../../widget/progress.dart';
|
||||
import 'code_page.dart';
|
||||
import 'sms_code_page.dart';
|
||||
import '../util.dart';
|
||||
|
||||
class SigninPage extends StatefulWidget {
|
||||
@@ -87,7 +87,7 @@ class _SigninPageState extends State<SigninPage> {
|
||||
child: CountryCodePicker(
|
||||
onChanged: _countryChange,
|
||||
initialSelection: dialCode,
|
||||
countryFilter: ['+95', '+65', '+66'],
|
||||
countryFilter: ['+95', '+1'],
|
||||
showCountryOnly: false,
|
||||
showOnlyCountryWhenClosed: false,
|
||||
alignLeft: false,
|
||||
@@ -176,7 +176,7 @@ class _SigninPageState extends State<SigninPage> {
|
||||
AuthResult auth = await context.read<MainModel>().sendSms(phoneNumber);
|
||||
if (auth.authStatus == AuthStatus.SMS_SENT) {
|
||||
await Navigator.of(context)
|
||||
.push(BottomUpPageRoute(CodePage(phoneNumber: phoneNumber)));
|
||||
.push(BottomUpPageRoute(SmsCodePage(phoneNumber: phoneNumber)));
|
||||
Navigator.pop(context);
|
||||
} else if (auth.authStatus == AuthStatus.AUTH_VERIFIED) {
|
||||
User user = context.read<MainModel>().user;
|
||||
|
||||
@@ -4,6 +4,8 @@ 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/user.dart';
|
||||
import 'package:fcs/fcs/common/pages/model/main_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/signin/model/signin_model.dart';
|
||||
import 'package:fcs/fcs/common/pages/signin/invitation_request_page.dart';
|
||||
import 'package:fcs/fcs/common/pages/util.dart';
|
||||
import 'package:fcs/fcs/common/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
@@ -15,16 +17,16 @@ import 'signup_page.dart';
|
||||
import '../../helpers/theme.dart';
|
||||
import '../../../../widget/progress.dart';
|
||||
|
||||
const resend_count_sec = 5;
|
||||
const resend_count_sec = 30;
|
||||
|
||||
class CodePage extends StatefulWidget {
|
||||
class SmsCodePage extends StatefulWidget {
|
||||
final String phoneNumber;
|
||||
const CodePage({Key key, this.phoneNumber}) : super(key: key);
|
||||
const SmsCodePage({Key key, this.phoneNumber}) : super(key: key);
|
||||
@override
|
||||
_CodePageState createState() => _CodePageState();
|
||||
_SmsCodePageState createState() => _SmsCodePageState();
|
||||
}
|
||||
|
||||
class _CodePageState extends State<CodePage> {
|
||||
class _SmsCodePageState extends State<SmsCodePage> {
|
||||
bool _isLoading = false;
|
||||
String pin;
|
||||
bool allNumberEntered;
|
||||
@@ -87,7 +89,7 @@ class _CodePageState extends State<CodePage> {
|
||||
padding: EdgeInsets.only(left: 20, right: 20, top: 40),
|
||||
child: LocalText(
|
||||
context,
|
||||
'singup.verify.title',
|
||||
'sms.verify.title',
|
||||
fontSize: 21,
|
||||
color: primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -98,7 +100,7 @@ class _CodePageState extends State<CodePage> {
|
||||
left: 20,
|
||||
top: 20,
|
||||
),
|
||||
child: LocalText(context, 'singup.code_sent',
|
||||
child: LocalText(context, 'sms.six.digit',
|
||||
fontSize: 15, color: labelColor),
|
||||
),
|
||||
Container(
|
||||
@@ -130,7 +132,7 @@ class _CodePageState extends State<CodePage> {
|
||||
RaisedButton(
|
||||
onPressed: canResend ? _resend : null,
|
||||
color: canResend ? Colors.white : Colors.grey,
|
||||
child: LocalText(context, 'singup.resend',
|
||||
child: LocalText(context, 'sms.resend',
|
||||
fontSize: 16,
|
||||
color:
|
||||
canResend ? primaryColor : Colors.grey[400]),
|
||||
@@ -165,7 +167,7 @@ class _CodePageState extends State<CodePage> {
|
||||
children: <Widget>[
|
||||
LocalText(
|
||||
context,
|
||||
'login.smscode.retry',
|
||||
'sms.resend.seconds',
|
||||
fontSize: 15,
|
||||
translationVariables: [_start.toString()],
|
||||
color: primaryColor,
|
||||
@@ -198,10 +200,17 @@ class _CodePageState extends State<CodePage> {
|
||||
});
|
||||
try {
|
||||
AuthResult auth = await context.read<MainModel>().signin(this.pin);
|
||||
|
||||
if (auth.authStatus == AuthStatus.AUTH_VERIFIED) {
|
||||
User user = context.read<MainModel>().user;
|
||||
if (user != null && !user.hasSignup) {
|
||||
await Navigator.of(context).push(BottomUpPageRoute(SignupPage()));
|
||||
bool invited = await context.read<SigninModel>().checkInvatation();
|
||||
if (invited) {
|
||||
await Navigator.of(context).push(BottomUpPageRoute(SignupPage()));
|
||||
} else {
|
||||
await Navigator.of(context)
|
||||
.push(BottomUpPageRoute(RequestInvitationPage()));
|
||||
}
|
||||
} else {
|
||||
Navigator.pushNamedAndRemoveUntil(context, "/home", (r) => false);
|
||||
}
|
||||
@@ -14,32 +14,21 @@ class SplashScreen extends StatefulWidget {
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
final log = Logger('_SplashScreenState');
|
||||
|
||||
String page = "/language_selection";
|
||||
bool _loaded = false;
|
||||
bool _isSupport = false;
|
||||
bool _isLogin = false;
|
||||
bool _isOnline = true;
|
||||
Timer timer;
|
||||
|
||||
startTime() async {
|
||||
var _duration = new Duration(milliseconds: 1000);
|
||||
var _duration = new Duration(milliseconds: 3000);
|
||||
this.timer = new Timer.periodic(_duration, navigationPage);
|
||||
}
|
||||
|
||||
void navigationPage(Timer timer) async {
|
||||
if (!_isOnline) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_loaded) {
|
||||
if (_loaded && _isOnline && _isSupport) {
|
||||
timer.cancel();
|
||||
if (_isSupport) {
|
||||
if (this._isLogin) {
|
||||
Navigator.of(context).pushReplacementNamed('/home');
|
||||
} else {
|
||||
Navigator.of(context).pushReplacementNamed('/welcome');
|
||||
}
|
||||
}
|
||||
Navigator.of(context).pushReplacementNamed(page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +47,18 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
|
||||
this._loaded = mainModel.isLoaded;
|
||||
this._isSupport = mainModel.isSupport();
|
||||
this._isLogin = mainModel.isLogin();
|
||||
this._isOnline = mainModel.isOnline;
|
||||
if (mainModel.isLoaded) {
|
||||
if (mainModel.isFirstLaunch) {
|
||||
page = "/language_selection";
|
||||
} else if (mainModel.isLogin() && mainModel.user.hasSignup) {
|
||||
page = "/home";
|
||||
} else {
|
||||
page = "/welcome";
|
||||
}
|
||||
this._loaded = mainModel.isLoaded;
|
||||
}
|
||||
|
||||
return new Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
@@ -77,11 +74,7 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"Cargo Services",
|
||||
style: welcomeLabelStyle,
|
||||
),
|
||||
Text(
|
||||
"by FCS Logistics",
|
||||
"FCS Logistics",
|
||||
style: welcomeSubLabelStyle,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -28,8 +28,8 @@ import '../../../pages/user_editor.dart';
|
||||
|
||||
final log = Logger('Util');
|
||||
|
||||
void showMsgDialog(BuildContext context, String title, String msg) {
|
||||
showDialog(
|
||||
Future showMsgDialog(BuildContext context, String title, String msg) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return AlertDialog(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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';
|
||||
import 'package:fcs/widget/bottom_up_page_route.dart';
|
||||
@@ -14,7 +15,6 @@ import 'package:provider/provider.dart';
|
||||
import '../helpers/theme.dart';
|
||||
import 'profile_page.dart';
|
||||
import 'signin/signin_page.dart';
|
||||
import '../../../pages/term.dart';
|
||||
|
||||
final msgLog = Logger('backgroundMessageHandler');
|
||||
|
||||
@@ -27,103 +27,30 @@ typedef BtnCallback();
|
||||
|
||||
class _WelcomePageState extends State<WelcomePage> {
|
||||
final log = Logger('_HomePageWelcomeState');
|
||||
bool login = false;
|
||||
bool customer = true;
|
||||
double length = 10;
|
||||
double width = 10;
|
||||
double height = 10;
|
||||
|
||||
String pin;
|
||||
List<bool> isSelected = [true, false];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadLang();
|
||||
}
|
||||
|
||||
void _loadLang() {
|
||||
isSelected =
|
||||
Provider.of<LanguageModel>(context, listen: false).currentState;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
int actualChart = 0;
|
||||
final numberFormatter = new intl.NumberFormat("#,###");
|
||||
|
||||
String pin;
|
||||
List<bool> isSelected = [true, false];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
login = Provider.of<MainModel>(context).isLogin();
|
||||
|
||||
return OfflineRedirect(
|
||||
child: FlavorBanner(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: primaryColor,
|
||||
title: ClipRRect(
|
||||
child: Image.asset("assets/logo.jpg", height: 40),
|
||||
borderRadius: new BorderRadius.circular(30.0),
|
||||
),
|
||||
actions: login
|
||||
? <Widget>[
|
||||
ToggleButtons(
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'icons/flags/png/us.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
),
|
||||
Image.asset(
|
||||
'icons/flags/png/mm.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
)
|
||||
],
|
||||
onPressed: _langChange,
|
||||
isSelected: isSelected,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Profile()),
|
||||
);
|
||||
},
|
||||
iconSize: 30,
|
||||
icon: Icon(Icons.account_circle),
|
||||
),
|
||||
]
|
||||
: <Widget>[
|
||||
ToggleButtons(
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'icons/flags/png/us.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
),
|
||||
Image.asset(
|
||||
'icons/flags/png/mm.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
)
|
||||
],
|
||||
onPressed: _langChange,
|
||||
isSelected: isSelected,
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.push(BottomUpPageRoute(SigninPage()));
|
||||
},
|
||||
// iconSize: 30,
|
||||
child: Text(
|
||||
"Sign In",
|
||||
style: siginButtonStyle,
|
||||
),
|
||||
),
|
||||
]),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
@@ -137,52 +64,78 @@ class _WelcomePageState extends State<WelcomePage> {
|
||||
)),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ToggleButtons(
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'icons/flags/png/us.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
),
|
||||
Image.asset(
|
||||
'icons/flags/png/mm.png',
|
||||
package: 'country_icons',
|
||||
fit: BoxFit.fitWidth,
|
||||
width: 25,
|
||||
)
|
||||
],
|
||||
selectedBorderColor: Colors.white12,
|
||||
borderColor: Colors.transparent,
|
||||
onPressed: _langChange,
|
||||
isSelected: isSelected,
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.push(BottomUpPageRoute(SigninPage()));
|
||||
},
|
||||
child: Text(
|
||||
getLocalString(context, "welcome.signin"),
|
||||
style: siginButtonStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(80.0),
|
||||
child: Text(
|
||||
"Welcome!",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontFamily: "Roboto"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 0.0),
|
||||
child: Text(
|
||||
"Cargo Services",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 28,
|
||||
fontFamily: "Roboto"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(
|
||||
"by FCS Trading",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontFamily: "Roboto"),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
getLocalString(context, "welcome.msg"),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontFamily: "Roboto"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 30),
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: CircleAvatar(
|
||||
radius: (50),
|
||||
radius: (25),
|
||||
backgroundColor: Colors.white,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
child: Image.asset("assets/logo.jpg"),
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 10.0, top: 5),
|
||||
child: Text(
|
||||
"by FCS Logistics",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 11,
|
||||
fontFamily: "Roboto"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -9,7 +9,7 @@ void main() {
|
||||
Config(
|
||||
flavor: Flavor.DEV,
|
||||
color: Colors.blue,
|
||||
apiURL: "http://192.168.1.155:7777",
|
||||
apiURL: "http://192.168.100.11:7777",
|
||||
level: Level.ALL);
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
@@ -81,9 +81,7 @@ class MainModel extends ChangeNotifier {
|
||||
// notifyListeners();
|
||||
// });
|
||||
_loadFcs();
|
||||
Services.instance.authService.onAuthStatus().listen((event) {
|
||||
print("main event-->$event");
|
||||
});
|
||||
Services.instance.authService.onAuthStatus().listen((event) {});
|
||||
}
|
||||
|
||||
List<PaymentMethod> get paymentMethods {
|
||||
|
||||
Reference in New Issue
Block a user