Merge branch 'master' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into merge_haron
Conflicts: lib/config/config.dart lib/widgets/others/app_scaffold_widget.dartmerge-requests/4/head
commit
3a68e0e092
@ -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();
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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());
|
||||||
|
}
|
@ -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),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
@ -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')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -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),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue