stop loading on null values

main_design2.0
zaid_daoud 2 years ago
parent 4cbedc0b60
commit 6c2480edd2

@ -16,7 +16,6 @@ import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/date_and_time/time_picker.dart';
import 'package:test_sa/views/widgets/gas_refill/building_type_menu.dart';
import 'package:test_sa/views/widgets/gas_refill/department_type_menu.dart';
import 'package:test_sa/views/widgets/gas_refill/floor_type_menu.dart';
@ -31,7 +30,6 @@ import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart';
import '../../../../models/enums/user_types.dart';
import '../../../widgets/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart';
@ -107,7 +105,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop(_formModel.status);
setState(() { });
setState(() {});
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
@ -255,6 +253,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
BuildingTypeMenu(
initialValue: _gasRefillProvider?.building,
building: _gasRefillProvider?.hospital?.buildings,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.building = status;
@ -266,6 +265,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
initialValue: _gasRefillProvider?.floor,
floors: _gasRefillProvider?.building?.floors,
enabled: widget.gasRefillModel == null,
loading: _firstTime,
onSelect: (status) {
_gasRefillProvider.floor = status;
setState(() {});
@ -275,6 +275,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
DepartmentTypeMenu(
initialValue: _gasRefillProvider?.department,
departments: _gasRefillProvider?.floor?.departments,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.department = status;

@ -9,9 +9,16 @@ class BuildingTypeMenu extends StatefulWidget {
final Function(Buildings) onSelect;
Buildings initialValue;
List<Buildings> building;
bool enabled;
bool enabled, loading;
BuildingTypeMenu({Key key, this.onSelect, this.initialValue, this.building = const [], this.enabled = true}) : super(key: key);
BuildingTypeMenu({
Key key,
this.onSelect,
this.initialValue,
this.building = const [],
this.enabled = true,
this.loading = false,
}) : super(key: key);
@override
_BuildingTypeMenuState createState() {
@ -50,59 +57,55 @@ class _BuildingTypeMenuState extends State<BuildingTypeMenu> {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: AColors.inputFieldBackgroundColor,
border: Border.all(
color: const Color(0xffefefef),
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: AColors.inputFieldBackgroundColor,
border: Border.all(
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
// boxShadow: const [
// AppStyle.boxShadow
// ]
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
// boxShadow: const [
// AppStyle.boxShadow
// ]
),
child: widget.enabled
? DropdownButton<Buildings>(
value: _selectedBuilding,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Building",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: const SizedBox.shrink(),
onChanged: (Buildings newValue) {
setState(() {
_selectedBuilding = newValue;
});
widget.onSelect(newValue);
},
items: _building?.map<DropdownMenuItem<Buildings>>((Buildings value) {
return DropdownMenuItem<Buildings>(
value: value,
child: Text(
value.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
child: widget.loading
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
: (widget.enabled && (_building?.isEmpty ?? false)) || (!widget.enabled)
? ListTile(
title: Center(child: Text(widget.initialValue?.name ?? "")),
)
: DropdownButton<Buildings>(
value: _selectedBuilding,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Building",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: const SizedBox.shrink(),
onChanged: (Buildings newValue) {
setState(() {
_selectedBuilding = newValue;
});
widget.onSelect(newValue);
},
items: _building?.map<DropdownMenuItem<Buildings>>((Buildings value) {
return DropdownMenuItem<Buildings>(
value: value,
child: Text(
value.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
),
),
);
})?.toList() ??
[],
)
: widget.initialValue == null
? const Padding(
padding: EdgeInsets.all(8.0),
child: ALoading(),
)
: ListTile(
title: Center(child: Text(widget.initialValue.name)),
),
);
);
})?.toList() ??
[],
));
}
}

@ -9,7 +9,7 @@ class DepartmentTypeMenu extends StatefulWidget {
final Function(Departments) onSelect;
Departments initialValue;
List<Departments> departments;
bool enabled;
bool enabled, loading;
DepartmentTypeMenu({
Key key,
@ -17,6 +17,7 @@ class DepartmentTypeMenu extends StatefulWidget {
this.initialValue,
this.departments = const [],
this.enabled = true,
this.loading = false,
}) : super(key: key);
@override
@ -67,43 +68,45 @@ class _DepartmentTypeMenuState extends State<DepartmentTypeMenu> {
// AppStyle.boxShadow
// ]
),
child: widget.enabled
? DropdownButton<Departments>(
value: _selected,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Department",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: SizedBox.shrink(),
onChanged: (Departments newValue) {
setState(() {
_selected = newValue;
});
widget.onSelect(newValue);
},
items: widget?.departments?.map<DropdownMenuItem<Departments>>((Departments value) {
return DropdownMenuItem<Departments>(
value: value,
child: Text(
value?.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
),
);
})?.toList() ??
[],
)
: widget.initialValue == null
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
: ListTile(title: Center(child: Text(widget.initialValue.name))),
child: widget.loading
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
: (widget.enabled && (_departments?.isEmpty ?? false)) || (!widget.enabled)
? ListTile(
title: Center(child: Text(widget.initialValue?.name ?? "")),
)
: DropdownButton<Departments>(
value: _selected,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Department",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: SizedBox.shrink(),
onChanged: (Departments newValue) {
setState(() {
_selected = newValue;
});
widget.onSelect(newValue);
},
items: widget?.departments?.map<DropdownMenuItem<Departments>>((Departments value) {
return DropdownMenuItem<Departments>(
value: value,
child: Text(
value?.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
),
);
})?.toList() ??
[],
),
);
}
}

@ -10,6 +10,7 @@ class FloorTypeMenu extends StatefulWidget {
Floors initialValue;
List<Floors> floors;
bool enabled;
bool loading;
FloorTypeMenu({
Key key,
@ -17,6 +18,7 @@ class FloorTypeMenu extends StatefulWidget {
this.initialValue,
this.floors = const [],
this.enabled = true,
this.loading = false,
}) : super(key: key);
@override
@ -67,47 +69,44 @@ class _FloorTypeMenuState extends State<FloorTypeMenu> {
// AppStyle.boxShadow
// ]
),
child: widget.enabled
? DropdownButton<Floors>(
value: _selected,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Floor",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: const SizedBox.shrink(),
onChanged: (Floors newValue) {
setState(() {
_selected = newValue;
});
widget.onSelect(newValue);
},
items: _floors?.map<DropdownMenuItem<Floors>>((Floors value) {
return DropdownMenuItem<Floors>(
value: value,
child: Text(
value.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
),
);
})?.toList() ??
[],
)
: widget.initialValue == null
? const Padding(
padding: EdgeInsets.all(8.0),
child: ALoading(),
child: widget.loading
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
: (widget.enabled && (_floors?.isEmpty ?? false)) || (!widget.enabled)
? ListTile(
title: Center(child: Text(widget.initialValue?.name ?? "")),
)
: ListTile(
title: Center(child: Text(widget.initialValue.name)),
: DropdownButton<Floors>(
value: _selected,
iconSize: 24,
icon: const Icon(Icons.keyboard_arrow_down_rounded),
elevation: 0,
isExpanded: true,
hint: Text(
"Select Floor",
style: Theme.of(context).textTheme.subtitle1,
),
style: TextStyle(color: Theme.of(context).primaryColor),
underline: const SizedBox.shrink(),
onChanged: (Floors newValue) {
setState(() {
_selected = newValue;
});
widget.onSelect(newValue);
},
items: _floors?.map<DropdownMenuItem<Floors>>((Floors value) {
return DropdownMenuItem<Floors>(
value: value,
child: Text(
value.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,
//fontWeight: FontWeight.bold
),
),
);
})?.toList() ??
[],
),
);
}

@ -22,7 +22,7 @@ class ServiceReportFaultDescription extends StatelessWidget {
UserProvider userProvider = Provider.of<UserProvider>(context);
ServiceRequestFaultDescriptionProvider menuProvider = Provider.of<ServiceRequestFaultDescriptionProvider>(context);
return LoadingManager(
isLoading: (menuProvider?.isLoading ?? false) || (enabled && (menuProvider.items?.isEmpty ?? true) || (!enabled && (initialValue?.defectName?.isEmpty ?? true))),
isLoading: menuProvider.isLoading,
isFailedLoading: menuProvider.items == null,
stateCode: menuProvider.stateCode,
onRefresh: () async {

Loading…
Cancel
Save