Conflicts:
	lib/config/config.dart
	lib/widgets/others/app_scaffold_widget.dart
merge-requests/4/head
Mohammad Aljammal 4 years ago
commit 3a68e0e092

@ -5,6 +5,9 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
const MAX_SMALL_SCREEN = 660; const MAX_SMALL_SCREEN = 660;
const BASE_URL = 'https://uat.hmgwebservices.com/Services';
const GET_PROJECT = '/Lists.svc/REST/GetProject';
const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment
//const BASE_URL = 'https://uat.hmgwebservices.com/'; // UAT Environment //const BASE_URL = 'https://uat.hmgwebservices.com/'; // UAT Environment

@ -0,0 +1 @@
enum ViewState { Idle, Busy, Error }

@ -0,0 +1,76 @@
class HospitalsModel {
String desciption;
Null desciptionN;
int iD;
String legalName;
String legalNameN;
String name;
Null nameN;
String phoneNumber;
String setupID;
int distanceInKilometers;
bool isActive;
String latitude;
String longitude;
int mainProjectID;
Null projectOutSA;
bool usingInDoctorApp;
HospitalsModel(
{this.desciption,
this.desciptionN,
this.iD,
this.legalName,
this.legalNameN,
this.name,
this.nameN,
this.phoneNumber,
this.setupID,
this.distanceInKilometers,
this.isActive,
this.latitude,
this.longitude,
this.mainProjectID,
this.projectOutSA,
this.usingInDoctorApp});
HospitalsModel.fromJson(Map<String, dynamic> json) {
desciption = json['Desciption'];
desciptionN = json['DesciptionN'];
iD = json['ID'];
legalName = json['LegalName'];
legalNameN = json['LegalNameN'];
name = json['Name'];
nameN = json['NameN'];
phoneNumber = json['PhoneNumber'];
setupID = json['SetupID'];
distanceInKilometers = json['DistanceInKilometers'];
isActive = json['IsActive'];
latitude = json['Latitude'];
longitude = json['Longitude'];
mainProjectID = json['MainProjectID'];
projectOutSA = json['ProjectOutSA'];
usingInDoctorApp = json['UsingInDoctorApp'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['Desciption'] = this.desciption;
data['DesciptionN'] = this.desciptionN;
data['ID'] = this.iD;
data['LegalName'] = this.legalName;
data['LegalNameN'] = this.legalNameN;
data['Name'] = this.name;
data['NameN'] = this.nameN;
data['PhoneNumber'] = this.phoneNumber;
data['SetupID'] = this.setupID;
data['DistanceInKilometers'] = this.distanceInKilometers;
data['IsActive'] = this.isActive;
data['Latitude'] = this.latitude;
data['Longitude'] = this.longitude;
data['MainProjectID'] = this.mainProjectID;
data['ProjectOutSA'] = this.projectOutSA;
data['UsingInDoctorApp'] = this.usingInDoctorApp;
return data;
}
}

@ -0,0 +1,56 @@
class RequestGetHospitalsModel {
int latitude;
int longitude;
double versionID;
int channel;
int languageID;
String iPAdress;
String generalid;
int patientOutSA;
String sessionID;
bool isDentalAllowedBackend;
int deviceTypeID;
RequestGetHospitalsModel(
{this.latitude,
this.longitude,
this.versionID,
this.channel,
this.languageID,
this.iPAdress,
this.generalid,
this.patientOutSA,
this.sessionID,
this.isDentalAllowedBackend,
this.deviceTypeID});
RequestGetHospitalsModel.fromJson(Map<String, dynamic> json) {
latitude = json['Latitude'];
longitude = json['Longitude'];
versionID = json['VersionID'];
channel = json['Channel'];
languageID = json['LanguageID'];
iPAdress = json['IPAdress'];
generalid = json['generalid'];
patientOutSA = json['PatientOutSA'];
sessionID = json['SessionID'];
isDentalAllowedBackend = json['isDentalAllowedBackend'];
deviceTypeID = json['DeviceTypeID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['Latitude'] = this.latitude;
data['Longitude'] = this.longitude;
data['VersionID'] = this.versionID;
data['Channel'] = this.channel;
data['LanguageID'] = this.languageID;
data['IPAdress'] = this.iPAdress;
data['generalid'] = this.generalid;
data['PatientOutSA'] = this.patientOutSA;
data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
data['DeviceTypeID'] = this.deviceTypeID;
return data;
}
}

@ -0,0 +1,9 @@
import 'client/base_app_client.dart';
class BaseService{
String error;
bool hasError = false;
BaseAppClient baseAppClient = BaseAppClient();
}

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
@ -13,7 +14,7 @@ AppSharedPreferences sharedPref = new AppSharedPreferences();
/// body: null); /// body: null);
class BaseAppClient { class BaseAppClient {
static post( post(
String endPoint, { String endPoint, {
Map<String, dynamic> body, Map<String, dynamic> body,
Function(dynamic response, int statusCode) onSuccess, Function(dynamic response, int statusCode) onSuccess,

@ -0,0 +1,36 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/request_get_hospitals_model.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
class HospitalService extends BaseService {
List<HospitalsModel> _hospitals = List();
List<HospitalsModel> get hospitals => _hospitals;
RequestGetHospitalsModel _requestGetHospitalsModel = RequestGetHospitalsModel(
latitude: 0,
longitude: 0,
versionID: 5.2,
channel: 3,
languageID: 2,
iPAdress: '10.20.10.20',
generalid: 'Cs2020@2016\$2958',
patientOutSA: 0,
sessionID: 'JUWuiMBCEGkAAxQpakQ',
isDentalAllowedBackend: false,
deviceTypeID: 2);
Future getHospitals() async {
await baseAppClient.post(GET_PROJECT,
onSuccess: (dynamic response, int statusCode) {
_hospitals.clear();
response['ListProject'].forEach((hospital) {
_hospitals.add(HospitalsModel.fromJson(hospital));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: _requestGetHospitalsModel.toJson());
}
}

@ -0,0 +1,16 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:flutter/material.dart';
class BaseViewModel extends ChangeNotifier {
ViewState _state = ViewState.Idle;
bool isInternetConnection = true;
ViewState get state => _state;
String error = "";
void setState(ViewState viewState) {
_state = viewState;
notifyListeners();
}
}

@ -0,0 +1,22 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/service/hospital_service.dart';
import '../../locator.dart';
import 'base_view_model.dart';
class HospitalViewModel extends BaseViewModel {
HospitalService _hospitalService = locator<HospitalService>();
List<HospitalsModel> get hospitals => _hospitalService.hospitals;
Future getHospitals() async {
setState(ViewState.Busy);
await _hospitalService.getHospitals();
if (_hospitalService.hasError) {
error = _hospitalService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
}

@ -5,7 +5,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
class ProjectProvider with ChangeNotifier { class ProjectViewModel with ChangeNotifier {
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
Locale _appLocale; Locale _appLocale;
String currentLanguage = 'ar'; String currentLanguage = 'ar';
@ -20,7 +20,7 @@ class ProjectProvider with ChangeNotifier {
bool get isArabic => _isArabic; bool get isArabic => _isArabic;
StreamSubscription subscription; StreamSubscription subscription;
ProjectProvider() { ProjectViewModel() {
loadSharedPrefLanguage(); loadSharedPrefLanguage();
subscription = Connectivity() subscription = Connectivity()

@ -0,0 +1,15 @@
import 'package:get_it/get_it.dart';
import 'core/service/hospital_service.dart';
import 'core/viewModels/hospital_view_model.dart';
GetIt locator = GetIt.instance;
///di
void setupLocator() {
/// Services
locator.registerLazySingleton(() => HospitalService());
/// View Model
locator.registerFactory(() => HospitalViewModel());
}

@ -1,14 +1,14 @@
import 'package:diplomaticquarterapp/pages/home_page.dart';
import 'package:diplomaticquarterapp/pages/landing_page.dart';
import 'package:diplomaticquarterapp/providers/project_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'config/size_config.dart'; import 'config/size_config.dart';
import 'core/viewModels/project_view_model.dart';
import 'locator.dart';
import 'pages/landing/landing_page.dart';
void main() { void main() {
setupLocator();
runApp(MyApp()); runApp(MyApp());
} }
@ -22,11 +22,11 @@ class MyApp extends StatelessWidget {
SizeConfig().init(constraints, orientation); SizeConfig().init(constraints, orientation);
return MultiProvider( return MultiProvider(
providers: [ providers: [
ChangeNotifierProvider<ProjectProvider>( ChangeNotifierProvider<ProjectViewModel>(
create: (context) => ProjectProvider(), create: (context) => ProjectViewModel(),
), ),
], ],
child: Consumer<ProjectProvider>( child: Consumer<ProjectViewModel>(
builder: (context, projectProvider, child) => MaterialApp( builder: (context, projectProvider, child) => MaterialApp(
showSemanticsDebugger: false, showSemanticsDebugger: false,
title: 'Diplomatic Quarter App', title: 'Diplomatic Quarter App',
@ -61,11 +61,9 @@ class MyApp extends StatelessWidget {
splashColor: Colors.transparent, splashColor: Colors.transparent,
primaryColor: Colors.grey, primaryColor: Colors.grey,
cursorColor: Color.fromRGBO(78, 62, 253, 1.0), cursorColor: Color.fromRGBO(78, 62, 253, 1.0),
iconTheme:IconThemeData( iconTheme: IconThemeData(),
) ,
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
color: Color.fromRGBO(247, 248, 251, 1), color: Colors.grey,
brightness: Brightness.light, brightness: Brightness.light,
elevation: 0.0, elevation: 0.0,
actionsIconTheme: IconThemeData( actionsIconTheme: IconThemeData(
@ -74,9 +72,7 @@ class MyApp extends StatelessWidget {
), ),
), ),
initialRoute: '/', initialRoute: '/',
routes: { routes: {'/': (context) => LandingPage()},
'/': (context) => LandingPage()
},
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
), ),
), ),

@ -0,0 +1,38 @@
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../locator.dart';
class BaseView<T extends BaseViewModel> extends StatefulWidget {
final Widget Function(BuildContext context, T model, Widget child) builder;
final Function(T) onModelReady;
BaseView({
this.builder,
this.onModelReady,
});
@override
_BaseViewState<T> createState() => _BaseViewState<T>();
}
class _BaseViewState<T extends BaseViewModel> extends State<BaseView<T>> {
T model = locator<T>();
@override
void initState() {
if (widget.onModelReady != null) {
widget.onModelReady(model);
}
super.initState();
}
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<T>(
create: (BuildContext context) => model,
child: Consumer<T>(builder: widget.builder),
);
}
}

@ -1,49 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

@ -0,0 +1,69 @@
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/hospital_view_model.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../base/base_view.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return BaseView<HospitalViewModel>(
onModelReady: (model) => model.getHospitals(),
builder: (BuildContext context, HospitalViewModel model, Widget child) =>
AppScaffold(
baseViewModel: model,
body: Column(
children: <Widget>[
InkWell(
onTap: () {
model.getHospitals();
},
child: Container(
child: Texts('call api '),
),
),
Expanded(
child: _getHospitals(model.hospitals),
)
// BaseView<DoctorViewModel>(
// onModelReady: (dctorViewModel) => dctorViewModel.getHospitals(),
// builder: (BuildContext context, DoctorViewModel dctorViewModel,
// Widget child) =>
// InkWell(
// onTap: () {
// dctorViewModel.getHospitals();
// },
// child: Container(
// width: double.infinity,
// height: 150,
// child: NetworkBaseView(
// baseViewModel: dctorViewModel,
// child: Container(
// child: Texts('The API 2'),
// ),
// ),
// ),
// ),
// ),
],
),
),
);
}
Widget _getHospitals(List<HospitalsModel> hospitals) => ListView.builder(
itemCount: hospitals.length,
itemBuilder: (BuildContext context, int index) => Container(
child: Texts(hospitals[index].name),
),
);
}

@ -1,9 +1,12 @@
import 'package:diplomaticquarterapp/pages/landing/replay_page.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart';
import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'home_page.dart';
class LandingPage extends StatefulWidget { class LandingPage extends StatefulWidget {
@override @override
_LandingPageState createState() => _LandingPageState(); _LandingPageState createState() => _LandingPageState();
@ -52,7 +55,7 @@ class _LandingPageState extends State<LandingPage> {
body: PageView( body: PageView(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
controller: pageController, controller: pageController,
children: [Container(), Container(), Container(), Container()], children: [HomePage(), ReplayPage(), Container(), Container()],
), ),
bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab), bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab),
); );

@ -0,0 +1,15 @@
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ReplayPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AppScaffold(
body: Center(
child: InkWell(onTap: () {}, child: Texts('Replay Page')),
),
);
}
}

@ -1,12 +1,12 @@
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'app_shared_preferences.dart'; import 'app_shared_preferences.dart';
import 'app_toast.dart'; import 'app_toast.dart';
AppSharedPreferences sharedPref = new AppSharedPreferences(); AppSharedPreferences sharedPref = new AppSharedPreferences();
class Utils { class Utils {
///show custom Error Toast ///show custom Error Toast
/// [message] to show for user /// [message] to show for user
static showErrorToast([String message]) { static showErrorToast([String message]) {
@ -37,4 +37,9 @@ class Utils {
} }
return localMsg; return localMsg;
} }
/// hides the keyboard if its already open
static hideKeyboard(BuildContext context) {
FocusScope.of(context).unfocus();
}
} }

@ -0,0 +1,148 @@
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:flutter/material.dart';
/// [label] button label
/// [icon] button icon its optional
/// [color] the background color
/// [textColor] the text color
/// [onTap] button function
/// [loading] show the progress indicator
/// [disabled] disabled the button
/// [borderColor] the button border color
/// [child] the child inside the button
/// [disabledPadding] remove padding
class BottomButton extends StatelessWidget {
final bool loading;
final bool disabled;
final String label;
final Widget icon;
final Color color;
final Color textColor;
final Color borderColor;
final Function onTap;
final Widget child;
final bool disabledPadding;
BottomButton(
{Key key,
this.loading = false,
this.disabled = false,
this.label,
this.icon,
this.color,
this.textColor,
this.disabledPadding = false,
this.borderColor,
this.onTap,
this.child})
: super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
stops: [
0.0,
0.9
],
colors: [
Theme.of(context).backgroundColor,
Theme.of(context).backgroundColor.withOpacity(0)
]),
),
alignment: Alignment.center,
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: child != null
? EdgeInsets.only(
left: 14.0, right: 14.0, top: 14.0, bottom: 14)
: EdgeInsets.only(
left: 30.0, right: 30.0, top: 14.0, bottom: 14),
decoration: BoxDecoration(
color: child != null
? Theme.of(context).backgroundColor
: null,
border: child != null
? Border.all(
color: Theme.of(context).dividerColor, width: 2.0)
: Border.all(color: Colors.transparent, width: 0.0),
borderRadius: child != null
? BorderRadius.circular(16.0)
: BorderRadius.circular(0.0),
boxShadow: child != null
? [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.04),
spreadRadius: -0.0,
offset: Offset(0, 4.0),
blurRadius: 18.0)
]
: []),
child: Column(
children: <Widget>[
if (child != null)
Padding(
padding: disabledPadding
? EdgeInsets.only(
left: 0.0,
right: 0.0,
top: 14.0,
bottom: label != null ? 0.0 : 14)
: EdgeInsets.only(
left: 18.0,
right: 18.0,
top: 14.0,
bottom: label != null ? 0.0 : 14),
child: child,
),
if (child != null)
Padding(
padding: EdgeInsets.only(top: 14.0, bottom: 14),
child: Divider(),
),
if (label != null)
label == null
? SizedBox(height: 50.0)
: Padding(
padding: child != null
? EdgeInsets.only(
bottom: 16.0, left: 16.0, right: 16.0)
: EdgeInsets.zero,
child: SecondaryButton(
borderColor: borderColor,
onTap: () {
if (onTap != null) onTap();
},
loading: loading,
disabled: disabled,
label: label,
icon: icon,
color: color,
textColor: textColor),
),
],
),
),
if (label == null && child == null)
Padding(
padding: EdgeInsets.only(
left: 30.0, right: 30.0, top: 14.0, bottom: 14),
),
],
),
),
),
],
);
}
}

@ -1,4 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
/// Button widget /// Button widget
/// [label] button label /// [label] button label
/// [icon] button icon its optional /// [icon] button icon its optional
@ -100,24 +102,12 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
? 22.0 ? 22.0
: 19), : 19),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(100.0)), borderRadius: BorderRadius.all(Radius.circular(10.0)),
gradient: LinearGradient( color: Hexcolor('#515b5d'),
begin: Alignment(-1.2, 2),
end: Alignment(1, -1),
stops: [
0.1,
0.8,
1.0
],
colors: [
Color.fromRGBO(113, 99, 255, 1.0),
Color.fromRGBO(78, 40, 253, 1.0),
Color.fromRGBO(78, 62, 253, 1.0)
]),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Color.fromRGBO( color: Color.fromRGBO(
47, 0, 244, widget.elevation ? 0.28 : 0.0), 120, 71, 80, widget.elevation ? 0.28 : 0.0),
spreadRadius: spreadRadius:
_buttonSize < 1.0 ? -(1 - _buttonSize) * 50 : 0.0, _buttonSize < 1.0 ? -(1 - _buttonSize) * 50 : 0.0,
offset: Offset(0, 7.0), offset: Offset(0, 7.0),
@ -136,9 +126,11 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
height: 19.0, height: 19.0,
width: 19.0, width: 19.0,
child: CircularProgressIndicator( child: CircularProgressIndicator(
backgroundColor: Colors.white, backgroundColor: Colors.white,
valueColor: AlwaysStoppedAnimation<Color>( valueColor: AlwaysStoppedAnimation<Color>(
Color.fromRGBO(113, 99, 255, 1.0))), Colors.grey[300],
),
),
), ),
) )
: Padding( : Padding(
@ -148,7 +140,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
color: Colors.white, color: Colors.white,
fontSize: 17.0, fontSize: 17.0,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
fontFamily: "HKGrotesk")), fontFamily: "WorkSans")),
) )
], ],
), ),

@ -10,12 +10,12 @@ enum MINI_BUTTON { Secondary, Primary }
/// [variant] determine the color button /// [variant] determine the color button
class MiniButton extends StatefulWidget { class MiniButton extends StatefulWidget {
MiniButton( MiniButton(
{Key key, {
this.label: "", this.label: "",
this.icon, this.icon,
this.onTap, this.onTap,
this.variant: MINI_BUTTON.Secondary}) this.variant: MINI_BUTTON.Secondary});
: super(key: key);
final String label; final String label;
final IconData icon; final IconData icon;
@ -88,32 +88,34 @@ class _MiniButtonState extends State<MiniButton> with TickerProviderStateMixin {
onTap: Feedback.wrapForTap(widget.onTap, context), onTap: Feedback.wrapForTap(widget.onTap, context),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Transform.scale( child: Transform.scale(
scale: _buttonSize, scale: _buttonSize,
child: Container( child: Container(
margin: EdgeInsets.only(top: 18.0, bottom: 24.0), margin: EdgeInsets.only(top: 18.0, bottom: 24.0),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(60.0)), borderRadius: BorderRadius.all(Radius.circular(60.0)),
color: widget.variant == MINI_BUTTON.Primary color: widget.variant == MINI_BUTTON.Primary
? Theme.of(context).primaryColor ? Theme.of(context).primaryColor
: Theme.of(context).primaryColor.withOpacity(0.13), : Theme.of(context).primaryColor.withOpacity(0.13),
),
padding: EdgeInsets.symmetric(vertical: 7.0, horizontal: 20.0),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildIcon(),
Padding(
padding: EdgeInsets.only(bottom: 1.5),
child: Texts(widget.label,
color: widget.variant == MINI_BUTTON.Primary
? Colors.white
: Theme.of(context).primaryColor,
style: "bodyText1",
bold: true),
), ),
padding: EdgeInsets.symmetric(vertical: 7.0, horizontal: 20.0), ],
child: Row( ),
mainAxisSize: MainAxisSize.min, ),
mainAxisAlignment: MainAxisAlignment.center, ),
children: <Widget>[
_buildIcon(),
Padding(
padding: EdgeInsets.only(bottom: 1.5),
child: Texts(widget.label,
color: widget.variant == MINI_BUTTON.Primary
? Colors.white
: Theme.of(context).primaryColor,
style: "bodyText1",
bold: true),
),
],
))),
); );
} }
} }

@ -160,7 +160,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
child: ClipRRect( child: ClipRRect(
borderRadius: widget.noBorderRadius borderRadius: widget.noBorderRadius
? BorderRadius.all(Radius.circular(0.0)) ? BorderRadius.all(Radius.circular(0.0))
: BorderRadius.all(Radius.circular(48.0)), : BorderRadius.all(Radius.circular(10.0)),
child: Stack( child: Stack(
children: <Widget>[ children: <Widget>[
Positioned( Positioned(
@ -214,11 +214,9 @@ class _SecondaryButtonState extends State<SecondaryButton>
height: 19.0, height: 19.0,
width: 19.0, width: 19.0,
child: CircularProgressIndicator( child: CircularProgressIndicator(
backgroundColor: backgroundColor: Colors.white,
Color.fromRGBO(140, 130, 255, 1.0), valueColor: AlwaysStoppedAnimation<Color>(
valueColor: Colors.grey[300],
AlwaysStoppedAnimation<Color>(
Color.fromRGBO(255, 255, 255, 1.0),
), ),
), ),
), ),
@ -231,7 +229,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
color: widget.textColor, color: widget.textColor,
fontSize: 17.0, fontSize: 17.0,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
fontFamily: "HKGrotesk")), fontFamily: "WorkSans")),
) )
], ],
) )

@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/list/flexible_container.dart'; import 'package:diplomaticquarterapp/widgets/data_display/list/flexible_container.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../config/size_config.dart'; import '../../config/size_config.dart';
import 'drawer_item_widget.dart'; import 'drawer_item_widget.dart';

@ -1,4 +1,5 @@
import 'dart:ui'; import 'dart:ui';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

@ -2,11 +2,11 @@ import 'dart:async';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'button_actions.dart'; import 'button_actions.dart';
import 'era_mode.dart'; import 'era_mode.dart';

@ -58,7 +58,6 @@ class TextFields extends StatefulWidget {
this.onSubmit, this.onSubmit,
this.keepPadding = true, this.keepPadding = true,
this.textCapitalization = TextCapitalization.none, this.textCapitalization = TextCapitalization.none,
this.onTap,
this.controller, this.controller,
this.keyboardType, this.keyboardType,
this.validator, this.validator,
@ -81,7 +80,6 @@ class TextFields extends StatefulWidget {
final IconData suffixIcon; final IconData suffixIcon;
final Color suffixIconColor; final Color suffixIconColor;
final IconData prefixIcon; final IconData prefixIcon;
final VoidCallback onTap;
final TextEditingController controller; final TextEditingController controller;
final TextInputType keyboardType; final TextInputType keyboardType;
final FormFieldValidator validator; final FormFieldValidator validator;
@ -199,7 +197,7 @@ class _TextFieldsState extends State<TextFields> {
? null ? null
: BoxDecoration(boxShadow: [ : BoxDecoration(boxShadow: [
BoxShadow( BoxShadow(
color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0),
offset: Offset(0.0, 13.0), offset: Offset(0.0, 13.0),
blurRadius: focus ? 34.0 : 12.0) blurRadius: focus ? 34.0 : 12.0)
]), ]),

@ -1,28 +1,29 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/providers/project_provider.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'arrow_back.dart';
import 'network_base_view.dart';
class AppScaffold extends StatelessWidget { class AppScaffold extends StatelessWidget {
final String appBarTitle; final String appBarTitle;
final Widget body; final Widget body;
final bool isLoading; final bool isLoading;
final bool isShowAppBar; final bool isShowAppBar;
final BaseViewModel baseViewModel;
AppScaffold( AppScaffold(
{@required this.body, {@required this.body,
this.appBarTitle = '', this.appBarTitle = '',
this.isLoading = false, this.isLoading = false,
this.isShowAppBar = true}); this.isShowAppBar = false,
this.baseViewModel});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppGlobal.context = context; AppGlobal.context = context;
ProjectProvider projectProvider = Provider.of(context);
return Scaffold( return Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: isShowAppBar appBar: isShowAppBar
@ -51,25 +52,20 @@ class AppScaffold extends StatelessWidget {
], ],
) )
: null, : null,
body: projectProvider.isInternetConnection body: baseViewModel != null
? Stack(children: <Widget>[body, buildAppLoaderWidget(isLoading)]) ? NetworkBaseView(
: Center( child: buildBodyWidget(),
child: Column( baseViewModel: baseViewModel,
mainAxisAlignment: MainAxisAlignment.center, )
crossAxisAlignment: CrossAxisAlignment.center, : buildBodyWidget(),
children: <Widget>[
Image.asset(
"assets/images/undraw_connected_world_wuay.png",
height: 250,
),
Texts('No Internet Connection')
],
),
),
); );
} }
Widget buildAppLoaderWidget(bool isloading) { buildAppLoaderWidget(bool isLoading) {
return isloading ? AppLoaderWidget() : Container(); return isLoading ? AppLoaderWidget() : Container();
}
buildBodyWidget() {
return Stack(children: <Widget>[body, buildAppLoaderWidget(isLoading)]);
} }
} }

@ -0,0 +1,37 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/widgets/errors/app_embedded_error.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
class NetworkBaseView extends StatelessWidget {
final BaseViewModel baseViewModel;
final Widget child;
NetworkBaseView({Key key, this.baseViewModel, this.child});
@override
Widget build(BuildContext context) {
return Container(
child: buildBaseViewWidget(),
);
}
buildBaseViewWidget() {
switch (baseViewModel.state) {
case ViewState.Idle:
return child;
break;
case ViewState.Busy:
return AppCircularProgressIndicator();
break;
case ViewState.Error:
return Center(
child: AppEmbeddedError(
error: baseViewModel.error,
),
);
break;
}
}
}

@ -24,6 +24,9 @@ dependencies:
# State Management # State Management
provider: ^4.3.1 provider: ^4.3.1
#Dependency Injection
get_it: ^4.0.2
# Permissions # Permissions
permission_handler: ^5.0.0+hotfix.3 permission_handler: ^5.0.0+hotfix.3
device_info: ^0.4.2+4 device_info: ^0.4.2+4

Loading…
Cancel
Save