import 'package:counters/counters.dart'; import 'package:counters/datbase.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class NewCounterPage extends StatelessWidget { final int addressId; final nameController = TextEditingController(); CounterType counterType = CounterType.coldWater; NewCounterPage({super.key, required this.addressId}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(AppLocalizations.of(context)!.new_counter_title)), body: Center( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ DropdownMenu( enableFilter: true, hintText: AppLocalizations.of(context)!.choose_type_of_counter, expandedInsets: EdgeInsets.zero, dropdownMenuEntries: CounterType.values.map>( (CounterType icon) { return DropdownMenuEntry( value: icon, labelWidget: Text(icon.getLabel(context)), label: icon.getLabel(context) //leadingIcon: Icon(icon.icon), ); }, ).toList(), onSelected: (value) => counterType = value!, ), const SizedBox(height: 50), TextField( controller: nameController, decoration: InputDecoration( hintStyle: const TextStyle(color: Colors.blue), hintText: AppLocalizations.of(context)!.enter_counter_name), ), const SizedBox(height: 50), TextButton( onPressed: () { DBProvider.db .newCounter(Counter( addressId: addressId, counterType: counterType, name: nameController.text)) .then((value) => Navigator.pop(context)); }, child: Text( AppLocalizations.of(context)!.add_new_address_button)) ]), ), ), ); } }