You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.0 KiB
Dart
113 lines
3.0 KiB
Dart
4 years ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
import '../SearchResults.dart';
|
||
|
|
||
|
class SearchByDoctor extends StatefulWidget {
|
||
|
@override
|
||
|
_SearchByDoctorState createState() => _SearchByDoctorState();
|
||
|
}
|
||
|
|
||
|
class _SearchByDoctorState extends State<SearchByDoctor> {
|
||
|
TextEditingController doctorNameController = new TextEditingController();
|
||
|
bool _isButtonDisabled;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
_isButtonDisabled = true;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.all(20.0),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
mainAxisSize: MainAxisSize.max,
|
||
|
children: <Widget>[
|
||
|
Container(
|
||
|
margin: EdgeInsets.only(top: 10.0, bottom: 15.0),
|
||
|
child: Text("Type the name of the doctor to help you find him",
|
||
|
style: TextStyle(fontSize: 16.0, letterSpacing: 0.9)),
|
||
|
),
|
||
|
Container(
|
||
|
decoration: BoxDecoration(color: Colors.white),
|
||
|
child: TextField(
|
||
|
controller: doctorNameController,
|
||
|
onChanged: (content) {
|
||
|
_onDocTextChanged(content);
|
||
|
},
|
||
|
decoration: InputDecoration(
|
||
|
labelText: "Type Doctor Name",
|
||
|
fillColor: Colors.white,
|
||
|
prefixIcon: Icon(Icons.search),
|
||
|
border: OutlineInputBorder())),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: Align(
|
||
|
alignment: FractionalOffset.bottomCenter,
|
||
|
child: _buildCounterButton(),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildCounterButton() {
|
||
|
return new ButtonTheme(
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(10.0),
|
||
|
),
|
||
|
minWidth: MediaQuery.of(context).size.width,
|
||
|
height: 45.0,
|
||
|
child: RaisedButton(
|
||
|
color: new Color(0xFF60686b),
|
||
|
textColor: Colors.white,
|
||
|
disabledTextColor: Colors.white,
|
||
|
disabledColor: new Color(0xFFbcc2c4),
|
||
|
onPressed: _isButtonDisabled ? null : _searchDoctor,
|
||
|
child: Text('Search', style: TextStyle(fontSize: 18.0)),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
_onDocTextChanged(content) {
|
||
|
print(content);
|
||
|
if (content.length >= 4) {
|
||
|
setState(() {
|
||
|
_isButtonDisabled = false;
|
||
|
});
|
||
|
} else {
|
||
|
setState(() {
|
||
|
_isButtonDisabled = true;
|
||
|
});
|
||
|
}
|
||
|
print(_isButtonDisabled);
|
||
|
}
|
||
|
|
||
|
void _searchDoctor() {
|
||
|
// if (doctorNameController.text != "")
|
||
|
// print(doctorNameController.text);
|
||
|
navigateToSearchResults(context);
|
||
|
// else
|
||
|
// print("Empty");
|
||
|
}
|
||
|
|
||
|
Future navigateToSearchResults(context) async {
|
||
|
Navigator.push(
|
||
|
context, MaterialPageRoute(builder: (context) => SearchResults()));
|
||
|
}
|
||
|
|
||
|
_isDoctorNameValid() {
|
||
|
if (doctorNameController.text != null || doctorNameController.text != "") {
|
||
|
if (doctorNameController.text.length >= 4) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|