Merge branch 'elham' into 'master'

move dropdwon list to cupertino picker

See merge request Cloud_Solution/doctor_app_flutter!5
merge-requests/6/merge
Elham 6 years ago
commit 7b3405eef4

@ -0,0 +1,59 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/*
*@author: Elham Rababah
*@Date:12/4/2020
*@param:
*@return:
*@desc: This class will contian some Function will help developer
*/
class Helpers {
/*
*@author: Elham Rababah
*@Date:12/4/2020
*@param: context, items, decKey, onSelectFun
*@return: Container Widget
*@desc: showCupertinoPicker its a general function to show cupertino picker
*/
showCupertinoPicker(context, items, decKey, onSelectFun) {
showModalBottomSheet(
context: context,
builder: (BuildContext builder) {
return Container(
height: SizeConfig.realScreenHeight * .3,
child: buildPickerItems(context, items, decKey, onSelectFun));
});
}
/*
*@author: Elham Rababah
*@Date:12/4/2020
*@param: context, List items, decKey, onSelectFun
*@return: Container widget
*@desc: buildPickerIterm this function will build the items of the cupertino
*/
buildPickerItems(context, List items, decKey, onSelectFun) {
return Container(
child: CupertinoPicker(
magnification: 1.5,
// backgroundColor: Colors.black87,
children: items.map((item) {
return Text(
'${item["$decKey"]}',
style:
TextStyle(color: Theme.of(context).primaryColor, fontSize: 20),
);
}).toList(),
itemExtent: 25, //height of each item
looping: true,
onSelectedItemChanged: (int index) {
// selectitem =index;
onSelectFun(index);
},
),
);
}
}

@ -1,3 +1,5 @@
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -15,7 +17,7 @@ import '../../util/dr_app_toast_msg.dart';
DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
DrAppToastMsg toastMsg = DrAppToastMsg(); DrAppToastMsg toastMsg = DrAppToastMsg();
Helpers helpers = Helpers();
class LoginForm extends StatefulWidget with DrAppToastMsg { class LoginForm extends StatefulWidget with DrAppToastMsg {
LoginForm({ LoginForm({
Key key, Key key,
@ -27,6 +29,7 @@ class LoginForm extends StatefulWidget with DrAppToastMsg {
class _LoginFormState extends State<LoginForm> { class _LoginFormState extends State<LoginForm> {
final loginFormKey = GlobalKey<FormState>(); final loginFormKey = GlobalKey<FormState>();
var projectIdController = TextEditingController();
String _platformImei = 'Unknown'; String _platformImei = 'Unknown';
String uniqueId = "Unknown"; String uniqueId = "Unknown";
var projectsList = []; var projectsList = [];
@ -119,14 +122,17 @@ class _LoginFormState extends State<LoginForm> {
userInfo.Password = value; userInfo.Password = value;
}), }),
buildSizedBox(), buildSizedBox(),
DropdownButtonFormField( TextFormField(
value: userInfo.ProjectID, controller: projectIdController,
isExpanded: false, onTap: () {
helpers.showCupertinoPicker(
context,projectsList, 'Desciption', onSelectProject);
},
showCursor: false,
readOnly: true,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.all(10), prefixIcon: Image.asset('assets/images/password_icon.png'),
isDense: true, hintText: 'Select your porject',
prefixIcon: Image.asset('assets/images/hospital_icon.png'),
// hintText: 'Enter Password',
hintStyle: hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier), TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
@ -141,25 +147,13 @@ class _LoginFormState extends State<LoginForm> {
//BorderRadius.all(Radius.circular(20)); //BorderRadius.all(Radius.circular(20));
), ),
validator: (value) { validator: (value) {
print(value); if (value.isEmpty) {
if (value == null) { return 'Please enter your porject';
return 'Please select your project';
} }
return null; return null;
}, },
items: projectsList.map((item) { onSaved: (value) {
return DropdownMenuItem( userInfo.Password = value;
child: Text(
'${item['Desciption']}',
),
value: item['ID'],
);
}).toList(),
onChanged: (value) {
print(value);
setState(() {
userInfo.ProjectID = value;
});
}), }),
buildSizedBox(), buildSizedBox(),
Row( Row(
@ -266,7 +260,6 @@ class _LoginFormState extends State<LoginForm> {
// save imei on shared preferance // save imei on shared preferance
} else { } else {
// handel error // handel error
print('Heeeeeeeeeeeer');
showLoginError(res['ErrorEndUserMessage']); showLoginError(res['ErrorEndUserMessage']);
} }
}).catchError((err) { }).catchError((err) {
@ -335,4 +328,12 @@ class _LoginFormState extends State<LoginForm> {
saveObjToString(String key, value) async { saveObjToString(String key, value) async {
sharedPref.setObj(key, value); sharedPref.setObj(key, value);
} }
onSelectProject(index) {
setState(() {
userInfo.ProjectID = projectsList[index]["ID"];
projectIdController.text = projectsList[index]['Desciption'];
});
}
} }

Loading…
Cancel
Save