tablet-app/lib/Screens/MainView/dropDown_configuration.dart
2021-07-14 20:44:55 +02:00

52 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:managerapi/api.dart';
import 'package:provider/provider.dart';
import 'package:tablet_app/app_context.dart';
import 'package:tablet_app/constants.dart';
class DropDownConfig extends StatefulWidget {
final List<ConfigurationDTO> configurations;
final ValueChanged<ConfigurationDTO> onChange;
const DropDownConfig({
Key key,
this.configurations,
this.onChange,
}) : super(key: key);
@override
_DropDownConfigState createState() => _DropDownConfigState();
}
class _DropDownConfigState extends State<DropDownConfig> {
ConfigurationDTO configurationDTO;
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size;
return DropdownButton<ConfigurationDTO>(
value: configurationDTO,
icon: const Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: const TextStyle(color: kMainGrey),
underline: Container(
height: 2,
color: kMainRed, // TODO CHANGEEEEE
),
onChanged: (ConfigurationDTO newValue) {
setState(() {
configurationDTO = newValue;
widget.onChange(configurationDTO);
});
},
items: widget.configurations.map<DropdownMenuItem<ConfigurationDTO>>((ConfigurationDTO value) {
return DropdownMenuItem<ConfigurationDTO>(
value: value,
child: Text(value.label, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w400)),
);
}).toList(),
);
}
}