|
|
|
|
@ -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() ??
|
|
|
|
|
[],
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|