mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 16:41:19 +00:00
53 lines
1.6 KiB
Dart
53 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_api/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,
|
|
required this.configurations,
|
|
this.onChange,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_DropDownConfigState createState() => _DropDownConfigState();
|
|
}
|
|
|
|
class _DropDownConfigState extends State<DropDownConfig> {
|
|
ConfigurationDTO? selectedConfigurationDTO;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
/*final appContext = Provider.of<AppContext>(context);
|
|
Size size = MediaQuery.of(context).size;*/
|
|
|
|
return DropdownButton<ConfigurationDTO>(
|
|
value: selectedConfigurationDTO,
|
|
icon: const Icon(Icons.arrow_downward),
|
|
iconSize: 24,
|
|
elevation: 16,
|
|
style: const TextStyle(color: kMainGrey),
|
|
underline: Container(
|
|
height: 2,
|
|
color: kTestSecondColor,
|
|
),
|
|
onChanged: (ConfigurationDTO? newValue) {
|
|
setState(() {
|
|
selectedConfigurationDTO = newValue!;
|
|
widget.onChange!(selectedConfigurationDTO!);
|
|
});
|
|
},
|
|
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(),
|
|
);
|
|
}
|
|
|
|
} |