parent
c331f12bcc
commit
5d846d77eb
@ -0,0 +1,18 @@
|
||||
class DynamicCodeModel {
|
||||
String doctorId = '';
|
||||
String dynamicCode = '';
|
||||
String recordId = '';
|
||||
|
||||
DynamicCodeModel();
|
||||
|
||||
factory DynamicCodeModel.fromJson(Map<String, dynamic> json){
|
||||
DynamicCodeModel rtvm = new DynamicCodeModel();
|
||||
|
||||
rtvm.doctorId = json['doctorId'] ?? '';
|
||||
rtvm.dynamicCode= json['dynamicCode']??'';
|
||||
rtvm.recordId= json['recordId']??'';
|
||||
|
||||
return rtvm;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
class GetConnectedDoctorsModel {
|
||||
String doctor_name='';
|
||||
String doctor_id='';
|
||||
String specialization='';
|
||||
String qualification='';
|
||||
String practiceplace1='';
|
||||
String practiceplace2='';
|
||||
String practiceplace3='';
|
||||
String hospital_name='';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GetConnectedDoctorsModel();
|
||||
|
||||
factory GetConnectedDoctorsModel.fromJson(Map<String, dynamic> json){
|
||||
GetConnectedDoctorsModel rtvm = new GetConnectedDoctorsModel();
|
||||
rtvm.doctor_name = json['doctorName'] ?? '';
|
||||
rtvm.specialization = json['specialization'] ?? '';
|
||||
rtvm.qualification = json['qualification'] ?? '';
|
||||
rtvm.doctor_id = json['doctorId'] ?? '';
|
||||
rtvm.hospital_name = json['placeOfPractice'][0]['hospitalName'] ?? '';
|
||||
|
||||
return rtvm;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
|
||||
|
||||
class AddDoctor extends StatefulWidget {
|
||||
const AddDoctor({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddDoctor> createState() => _AddDoctorState();
|
||||
}
|
||||
|
||||
class _AddDoctorState extends State<AddDoctor> {
|
||||
bool isPwdObscureText=true;
|
||||
bool isFirstAddButtonShow=false;
|
||||
bool isSecondAddButtonShow=false;
|
||||
bool is2ndPlaceOfPracticeControllerVisible=false;
|
||||
bool is3rdPlaceOfPracticeControllerVisible=false;
|
||||
bool isConfirmPwdObscureText=true;
|
||||
TextEditingController doctorIdController = TextEditingController();
|
||||
String? gender;
|
||||
List placeOfPractices=[];
|
||||
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
|
||||
bool isQrScannerVisible=false;
|
||||
String doctorId='';
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<void> scanQR() async {
|
||||
String barcodeScanRes;
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
try {
|
||||
barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
|
||||
'#ff6666', 'Cancel', true, ScanMode.QR);
|
||||
print(barcodeScanRes);
|
||||
setState(() {
|
||||
doctorId=jsonDecode(barcodeScanRes)['doctorId'];
|
||||
doctorIdController.text=doctorId;
|
||||
});
|
||||
} on PlatformException {
|
||||
barcodeScanRes = 'Failed to get platform version.';
|
||||
}}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
appBar:AppSettings.appBar('Add Doctor'),
|
||||
body: Stack(children: <Widget>[
|
||||
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
FocusScope.of(context).requestFocus(new FocusNode());
|
||||
},
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height:MediaQuery.of(context).size.height * .02,
|
||||
),
|
||||
Container(
|
||||
|
||||
child: Column(
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: (){
|
||||
scanQR();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
Text('Scan Qr Code',style: TextStyle(fontSize: 12,color: secondaryColor),)
|
||||
],
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: doctorIdController,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(
|
||||
Icons.person,
|
||||
color: greyColor,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: greyColor)),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: greyColor),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: greyColor),
|
||||
),
|
||||
labelText: 'Doctor Id',
|
||||
labelStyle: TextStyle(
|
||||
color: greyColor, //<-- SEE HERE
|
||||
),
|
||||
),
|
||||
),
|
||||
),//name
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Container(
|
||||
width:double.infinity,
|
||||
height: MediaQuery.of(context).size.height * .06,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async{
|
||||
if(doctorIdController.text!=''){
|
||||
AppSettings.preLoaderDialog(context);
|
||||
var payload = new Map<String, dynamic>();
|
||||
|
||||
payload["doctorId"] =doctorIdController.text.toString();
|
||||
|
||||
bool status = await AppSettings.addDoctor(payload);
|
||||
if(status){
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longSuccessToast('Doctor added successfully');
|
||||
Navigator.pop(context);
|
||||
}
|
||||
else{
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longFailedToast('There is a problem for adding doctor');
|
||||
}
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please enter valid details');
|
||||
}
|
||||
|
||||
},
|
||||
child: Text('Add Doctor'),
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
)
|
||||
)),
|
||||
),
|
||||
]));
|
||||
}
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:healthcare_user/models/dynamic_code_model.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
|
||||
class DynamicCode extends StatefulWidget {
|
||||
const DynamicCode({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DynamicCode> createState() => _DynamicCodeState();
|
||||
}
|
||||
|
||||
class _DynamicCodeState extends State<DynamicCode> {
|
||||
|
||||
bool isDataLoading=false;
|
||||
bool isSereverIssue = false;
|
||||
List<DynamicCodeModel> originalList = [];
|
||||
List<String> items = ["1", "2", "3", "4", "5", "6", "7", "8"];
|
||||
RefreshController _refreshController =
|
||||
RefreshController(initialRefresh: true);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
getAllDynamicCodes();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> getAllDynamicCodes() async {
|
||||
isDataLoading=true;
|
||||
try {
|
||||
var response = await AppSettings.getDynamicCode();
|
||||
|
||||
setState(() {
|
||||
originalList = ((jsonDecode(response)) as List)
|
||||
.map((dynamic model) {
|
||||
return DynamicCodeModel.fromJson(model);
|
||||
}).toList();
|
||||
originalList=originalList.reversed.toList();
|
||||
isDataLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
isDataLoading = false;
|
||||
isSereverIssue = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _onRefresh() async{
|
||||
// monitor network fetch
|
||||
await Future.delayed(Duration(milliseconds: 1000));
|
||||
// if failed,use refreshFailed()
|
||||
/*items.remove((items.length-1).toString());
|
||||
if(mounted)
|
||||
setState(() {
|
||||
|
||||
});*/
|
||||
await getAllDynamicCodes();
|
||||
_refreshController.refreshCompleted(
|
||||
resetFooterState: true,
|
||||
);
|
||||
}
|
||||
|
||||
void _onLoading() async{
|
||||
// monitor network fetch
|
||||
await Future.delayed(Duration(milliseconds: 1000));
|
||||
// if failed,use loadFailed(),if no data return,use LoadNodata()
|
||||
items.add((items.length+1).toString());
|
||||
if(mounted)
|
||||
setState(() {
|
||||
|
||||
});
|
||||
_refreshController.loadComplete();
|
||||
}
|
||||
|
||||
Widget _renderUi(){
|
||||
if(originalList.length!=0){
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.all(0),
|
||||
itemCount: originalList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return GestureDetector(
|
||||
onTap: (){
|
||||
|
||||
},
|
||||
child: Card(
|
||||
|
||||
//color: prescriptionsList[index].cardColor,
|
||||
child: Padding(
|
||||
padding:EdgeInsets.all(8) ,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
Container(
|
||||
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Doctor Id',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
'Dynamic code',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
'Record Id',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(width:MediaQuery.of(context).size.width * .01,),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
':',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
':',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
':',
|
||||
style: labelTextStyle(),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
SizedBox(width:MediaQuery.of(context).size.width * .01,),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(originalList[index].doctorId.toString().toUpperCase(),style: valuesTextStyle()),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
originalList[index].dynamicCode,
|
||||
style: valuesTextStyle(),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .01,),
|
||||
Text(
|
||||
originalList[index].recordId,
|
||||
style: valuesTextStyle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
else{
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(height: MediaQuery.of(context).size.height * .25,),
|
||||
Text('No Dynamic Codes available'),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CircleAvatar(
|
||||
backgroundColor: primaryColor,
|
||||
radius: 40,
|
||||
child: IconButton(
|
||||
iconSize: 40,
|
||||
icon: const Icon(
|
||||
Icons.info,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () async {
|
||||
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Dynamic Code'),
|
||||
body: SmartRefresher(
|
||||
enablePullDown: true,
|
||||
enablePullUp: false,
|
||||
/* header: WaterDropHeader(
|
||||
waterDropColor: primaryColor,
|
||||
),*/
|
||||
header: CustomHeader(
|
||||
builder: (BuildContext context, RefreshStatus? mode) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
// Set the color of the circular progress indicator
|
||||
valueColor: AlwaysStoppedAnimation<Color>(primaryColor),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
footer: CustomFooter(
|
||||
builder: (BuildContext context,LoadStatus? mode){
|
||||
Widget body ;
|
||||
if(mode==LoadStatus.idle){
|
||||
body = Text("pull up load");
|
||||
}
|
||||
else if(mode==LoadStatus.loading){
|
||||
body = Container();
|
||||
}
|
||||
else if(mode == LoadStatus.failed){
|
||||
body = Text("Load Failed!Click retry!");
|
||||
}
|
||||
else if(mode == LoadStatus.canLoading){
|
||||
body = Text("release to load more");
|
||||
}
|
||||
else{
|
||||
body = Text("No more Data");
|
||||
}
|
||||
return Container(
|
||||
height: 55.0,
|
||||
child: Center(child:body),
|
||||
);
|
||||
},
|
||||
),
|
||||
controller: _refreshController,
|
||||
onRefresh: _onRefresh,
|
||||
onLoading: _onLoading,
|
||||
|
||||
child:_renderUi()
|
||||
|
||||
/*ListView.builder(
|
||||
itemBuilder: (c, i) => Card(child: Center(child: Text(items[i]))),
|
||||
itemExtent: 100.0,
|
||||
itemCount: items.length,
|
||||
),*/
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue