import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:hexcolor/hexcolor.dart'; import '../../lookups/patient_lookup.dart'; import '../../models/patient_model.dart'; import '../../routes.dart'; import '../../widgets/patients/dynamic_elements.dart'; class PatientSearchScreen extends StatefulWidget { @override _PatientSearchScreenState createState() => _PatientSearchScreenState(); } class _PatientSearchScreenState extends State { String _selectedType = '1'; String _selectedLocation = '1'; final _patientSearchForm = GlobalKey(); var _patientSearchFormValues = PatientModel( ProjectID: 12, ClinicID: 17, DoctorID: 98129, FirstName: "0", MiddleName: "0", LastName: "0", PatientMobileNumber: "0", PatientIdentificationID: "0", PatientID: 0, From: "0", To: "0", LanguageID: 2, stamp: "2020-03-02T13:56:39.170Z", IPAdress: "11.11.11.11", VersionID: 1.2, Channel: 9, TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", SessionID: "5G0yXn0Jnq", IsLoginForDoctorApp: true, PatientOutSA: false); void _saveForm() { _patientSearchForm.currentState.save(); // Navigator.pushNamed(context,routeName) print(_patientSearchFormValues.From); print(_patientSearchFormValues.To); Navigator.of(context).pushNamed(PATIENTS, arguments: { 'patientSearchForm': _patientSearchFormValues, 'selectedType': _selectedType }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Search Patient"), ), body: SingleChildScrollView( child: LayoutBuilder(builder: (ctx, constraints) { var smallScreenSize = 660; bool isSmallScreen = constraints.maxWidth <= smallScreenSize; return Container( padding: EdgeInsets.all(15), width: constraints.maxWidth * 0.9, child: Form( key: _patientSearchForm, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Patiant Type', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10.0)), border: Border.all(color: Theme.of(context).primaryColor), ), width: double.infinity, child: DropdownButton( value: _selectedType, iconSize: 24, elevation: 16, selectedItemBuilder: (BuildContext context) { return PATIENT_TYPE.map((item) { return Text(item['text'], textAlign: TextAlign.end); }).toList(); }, onChanged: (String newValue) => { setState(() { _selectedType = newValue; }) }, items: PATIENT_TYPE.map((item) { return DropdownMenuItem( child: Text( '${item['text']}', textAlign: TextAlign.end, ), value: item['val'], ); }).toList(), ), ), SizedBox( height: 10, ), Text( 'First Name', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( decoration: InputDecoration( hintText: 'First Name', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), onSaved: (value) { _patientSearchFormValues.FirstName = value; }, validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, ), SizedBox( height: 10, ), Text( 'Middle Name', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( decoration: InputDecoration( hintText: 'Middle Name', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, onSaved: (value) { _patientSearchFormValues.MiddleName = value; }, ), SizedBox( height: 10, ), Text( 'Last Name', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( decoration: InputDecoration( hintText: 'Last Name', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, onSaved: (value) { _patientSearchFormValues.LastName = value; }, ), SizedBox( height: 10, ), Text( 'Phone Number', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Phone Number', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, onSaved: (value) { _patientSearchFormValues.PatientMobileNumber = value; }, ), SizedBox( height: 10, ), // Container(child: GridView(gridDelegate: null,),) SizedBox( height: 10, ), Text( 'Patiant ID', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Patiant ID', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, onSaved: (value) { _patientSearchFormValues.PatientID = int.parse(value); }), SizedBox( height: 10, ), Text( 'Patiant File', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.number, decoration: InputDecoration( hintText: 'Patiant File', hintStyle: TextStyle( fontSize: isSmallScreen ? 14 : constraints.maxWidth * 0.024), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(20)), borderSide: BorderSide(color: Hexcolor('#CCCCCC')), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide( color: Theme.of(context).primaryColor), ) //BorderRadius.all(Radius.circular(20)); ), validator: (value) { if (value.isEmpty) { return 'Please enter some text'; } return null; }, onSaved: (value) { // _patientSearchFormValues. = value; }, ), (!(_selectedType=='3' ||_selectedType=='5'))? DynamicElements(_patientSearchFormValues): SizedBox( height: 0, ), SizedBox( height: 10, ), Text( 'Patiant', style: TextStyle(fontSize: 16), ), SizedBox( height: 10, ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10.0)), border: Border.all(color: Theme.of(context).primaryColor), ), width: double.infinity, child: DropdownButton( value: _selectedLocation, iconSize: 24, elevation: 16, selectedItemBuilder: (BuildContext context) { return LOCATIONS.map((item) { return Text(item['text']); }).toList(); }, onChanged: (String newValue) => { setState(() { _selectedLocation = newValue; }) }, items: LOCATIONS.map((item) { return DropdownMenuItem( child: Text('${item['text']}'), value: item['val'], ); }).toList(), ), ), SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ RaisedButton( onPressed: () { _saveForm(); }, textColor: Colors.white, elevation: 0.0, padding: const EdgeInsets.all(0.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), side: BorderSide( width: 0.5, color: Hexcolor('#CCCCCC'))), child: Container( padding: const EdgeInsets.all(10.0), height: 50, width: 200, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Text('Search', textAlign: TextAlign.center, style: TextStyle( fontSize: isSmallScreen ? 20 : constraints.maxWidth * 0.020)), Icon(Icons.search) ], ), ), ) ], ) ], ), ), ); }), )); } }