import 'package:fcs/model_fcs/package_model.dart'; import 'package:fcs/theme/theme.dart'; import 'package:fcs/vo/package.dart'; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:fcs/widget/progress.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PackageAddition extends StatefulWidget { final Package package; PackageAddition({this.package}); @override _PackageAdditionState createState() => _PackageAdditionState(); } class _PackageAdditionState extends State { Package _package = new Package(); bool _isLoading = false; @override void initState() { super.initState(); if (widget.package != null) { _package = widget.package; } } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { var packageModel = Provider.of(context); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( centerTitle: true, leading: new IconButton( icon: new Icon(Icons.close), onPressed: () => Navigator.of(context).pop(), ), backgroundColor: primaryColor, title: Text(AppTranslations.of(context).text("package.edit.title")), ), body: Card( child: Column( children: [ Expanded( child: Padding( padding: const EdgeInsets.all(10.0), child: ListView(children: [ DropdownButtonFormField( decoration: InputDecoration( fillColor: Colors.white, labelText: 'Package Number', icon: Icon(Icons.pages)), items: packageModel.completed .map((e) => DropdownMenuItem( child: Text(e.packageNumber), value: e)) .toList(), onChanged: (map) => {}, ), ]), )), widget.package == null ? Align( alignment: Alignment.bottomCenter, child: Center( child: Container( width: 250, child: FlatButton( child: Text('Add package'), color: primaryColor, textColor: Colors.white, onPressed: () { Navigator.pop(context); }, ), ))) : Align( alignment: Alignment.bottomCenter, child: Center( child: Container( width: 250, child: FlatButton( child: Text('Save package'), color: primaryColor, textColor: Colors.white, onPressed: () { Navigator.pop(context); }, ), ))), SizedBox( height: 30, ) ], ), ), ), ); } }