import 'package:car_for_her/config/SizeConfig.dart'; import 'package:car_for_her/config/palette.dart'; import 'package:car_for_her/config/styles.dart'; import 'package:car_for_her/singletons/profile_image.dart'; import 'package:car_for_her/widgets/profile_image_picker.dart'; import 'package:flutter/material.dart'; import 'package:toast/toast.dart'; import 'package:flutter_svg/flutter_svg.dart'; class DriverCarDetails extends StatefulWidget { DriverCarDetails({Key key}) : super(key: key); @override _DriverCarDetailsUpState createState() => _DriverCarDetailsUpState(); } class _DriverCarDetailsUpState extends State { bool isDisabled = false; bool isFood = false; bool isPackage = false; bool isPet = false; bool isBaby = false; String carColor ; Color initColor=Color(0xff000000); String carType; String carDoors; String maxPassengers; String licencePlateNumber; TextEditingController licencePlateNumberController =TextEditingController(); GlobalKey _globalKey = GlobalKey(); @override void dispose() { // TODO: implement dispose super.dispose(); imagePicked.image=null; } Widget build(BuildContext context) { return GestureDetector( onTap: () { FocusScope.of(context).requestFocus(new FocusNode()); }, child: Scaffold( resizeToAvoidBottomInset: false, body: Container( child: Column( children: [ Center( child: Padding( padding: const EdgeInsets.fromLTRB(0, 60, 0, 0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Car details", style: TextStyle(fontFamily: 'MontHeavy', fontSize: 44), ), SizedBox( height: 16*SizeConfig.heightMultiplier, width: 32*SizeConfig.widthMultiplier, child: ProfileImagePicker(), ), Text( "Your car", style: TextStyle( fontFamily: 'MontExtraLight', fontSize: 16), ), Padding( padding: const EdgeInsets.fromLTRB(30, 25, 30, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( "Car details", style: TextStyle( fontFamily: 'MontExtraLight', fontWeight: FontWeight.bold), ), Padding( padding: const EdgeInsets.only(top: 8.0), child: Form( key: _globalKey, child: Column( children: [ Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: 160, height: 60, padding: EdgeInsets.fromLTRB(15, 0, 10, 0), decoration: BoxDecoration( color: Colors.white, border: Border.all( color: (Color.fromRGBO(0, 0, 0, 0.5)))), child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, value: carType, hint: Text("Car type"), icon: const Icon(Icons.keyboard_arrow_down), iconSize: 24, elevation: 16, style: const TextStyle(color: Colors.black), onChanged: (String newValue) { setState(() { carType = newValue; }); }, //current items items: ['Van', 'Bus', 'Sport', 'Classic'] .map>((String value) { return DropdownMenuItem( value: value, child: Text(value) ); }).toList(), ), ), ), Container( width: 160, height: 60, padding: EdgeInsets.fromLTRB(15, 0, 10, 0), decoration: BoxDecoration( color: Colors.white, border: Border.all( color: (Color.fromRGBO(0, 0, 0, 0.5)))), child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, value: carColor, hint: Text("Color"), icon: const Icon(Icons.keyboard_arrow_down), iconSize: 24, elevation: 16, style: const TextStyle(color: Colors.black), onChanged: (String newValue) { setState(() { carColor = newValue; }); }, items: ['Black', 'Red', 'Grey', 'Orange'] .map>((String value) { return DropdownMenuItem( value: value, child: Row( children: [ Container( height: 16, width: 16, decoration: BoxDecoration( color: initColor, borderRadius: BorderRadius.circular(100) ), ), SizedBox(width: 5,), Text(value) ], ), ); }).toList(), ), ), ), ], ), ), SizedBox(height: 10,), TextFormField( controller: licencePlateNumberController, onChanged: (val){ setState(() { licencePlateNumber=val; }); }, validator: (val){ if(val.isEmpty){ return "Licence plate number is required"; }else if(int.tryParse(val)==null){ return "Licence plate number must contain only digits"; } return null; }, cursorColor: Palette.primary, keyboardType: TextInputType.number, decoration: InputDecoration( focusColor: Palette.primary, fillColor: Palette.primary, hoverColor: Palette.primary, hintText: "Licence plate number", errorBorder: AppTheme.textFormFieldErrorBorder, focusedErrorBorder: AppTheme.textFormFieldErrorBorder, focusedBorder: AppTheme.textFormFieldBorder, enabledBorder: AppTheme.textFormFieldBorder, hintStyle: AppTheme.hintTextStyle, ), ), SizedBox(height: 10,), Padding(padding: EdgeInsets.only(top: 8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: 160, height: 60, padding: EdgeInsets.fromLTRB(15, 0, 10, 0), decoration: BoxDecoration( color: Colors.white, border: Border.all( color: (Color.fromRGBO(0, 0, 0, 0.5)))), child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, value: maxPassengers, hint: Text("Max passenger capacity"), icon: const Icon(Icons.keyboard_arrow_down), iconSize: 24, elevation: 16, style: const TextStyle(color: Colors.black), onChanged: (String newValue) { setState(() { maxPassengers = newValue; }); }, items: ['1', '2', '3', '4','5','6','more'] .map>((String value) { return DropdownMenuItem( value: value, child: Text(value) ); }).toList(), ), ), ), Container( width: 160, height: 60, padding: EdgeInsets.fromLTRB(15, 0, 10, 0), decoration: BoxDecoration( color: Colors.white, border: Border.all( color: (Color.fromRGBO(0, 0, 0, 0.5)))), child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, value: carDoors, hint: Text("Doors"), icon: const Icon(Icons.keyboard_arrow_down), iconSize: 24, elevation: 16, style: const TextStyle(color: Colors.black), onChanged: (String newValue) { setState(() { carDoors= newValue; }); }, items: ['2', '4', '6'] .map>((String value) { return DropdownMenuItem( value: value, child: Text(value) ); }).toList(), ), ), ), ], ), ), Padding( padding: const EdgeInsets.fromLTRB(8, 18, 8, 8), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ IconButton( icon: SvgPicture.asset( "assets/icons/car_details/disabled-sign.svg", color: isDisabled ? Colors.black : Colors.grey, ), onPressed: () { setState(() { isDisabled = !isDisabled; }); }), IconButton( icon: SvgPicture.asset( "assets/icons/car_details/fast-food.svg", color: isFood ? Colors.black : Colors.grey, ), onPressed: () { setState(() { isFood = !isFood; }); }), IconButton( icon: SvgPicture.asset( "assets/icons/car_details/package.svg", color: isPackage ? Colors.black : Colors.grey, ), onPressed: () { setState(() { isPackage = !isPackage; }); }), IconButton( icon: SvgPicture.asset( "assets/icons/car_details/paw.svg", color: isPet ? Colors.black : Colors.grey, ), onPressed: () { setState(() { isPet = !isPet; }); }), IconButton( icon: SvgPicture.asset( "assets/icons/car_details/baby.svg", color: isBaby ? Colors.black : Colors.grey, ), onPressed: () { setState(() { isBaby=!isBaby; }); }), ], ), ), Container( margin: EdgeInsets.only(top: 0.0), width: 300, color: Palette.primary, child: TextButton( onPressed: () { if(imagePicked.image==null){ Toast.show("Car image is required", context, duration: Toast.LENGTH_LONG, gravity: Toast.BOTTOM, backgroundColor: Color.fromRGBO(255, 0, 0, 0.7)); }else if(!_globalKey.currentState.validate()){ } else{ Navigator.pushNamed( context, '/driver_validation'); } }, child: Text( "Continue", style: TextStyle( color: Colors.white, fontFamily: 'MontExtraLight', fontWeight: FontWeight.bold, fontSize: 18), )), ) ], )), ), ], ), ), ], ), ), ), ], ), ), ), ); } }