done QR reader
parent
b07ff8154c
commit
7d3856f2b2
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@ -1,11 +1,184 @@
|
||||
import 'package:barcode_scan/platform_wrapper.dart';
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart';
|
||||
import 'package:doctor_app_flutter/providers/patients_provider.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_button.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
class QrReaderScreen extends StatelessWidget {
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../routes.dart';
|
||||
|
||||
class QrReaderScreen extends StatefulWidget {
|
||||
@override
|
||||
_QrReaderScreenState createState() => _QrReaderScreenState();
|
||||
}
|
||||
|
||||
class _QrReaderScreenState extends State<QrReaderScreen> {
|
||||
bool isLoading = false;
|
||||
PatientModel patient = PatientModel(
|
||||
ProjectID: 15,
|
||||
ClinicID: 0,
|
||||
DoctorID: 4709,
|
||||
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: "@dm!n",
|
||||
SessionID: "5G0yXn0Jnq",
|
||||
IsLoginForDoctorApp: true,
|
||||
PatientOutSA: false);
|
||||
List<PatiantInformtion> patientList = [];
|
||||
String error = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
appBarTitle: "QR Reader",
|
||||
body: Container(),
|
||||
body: Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: SizeConfig.realScreenHeight / 7),
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: 0.9,
|
||||
child: ListView(
|
||||
children: [
|
||||
AppText(
|
||||
'Start Scanning',
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
SizedBox(
|
||||
height: 7,
|
||||
),
|
||||
AppText(
|
||||
'scan Qr code to retrieve patient profile',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
textAlign: TextAlign.center
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
height: 150,
|
||||
child: Image.asset('assets/images/qr_code.png'),
|
||||
),
|
||||
SizedBox(
|
||||
height: 35,
|
||||
),
|
||||
Button(
|
||||
onTap: () {
|
||||
_scanQrAndGetPatient(context);
|
||||
},
|
||||
title: 'Scan Qr',
|
||||
loading: isLoading,
|
||||
icon: Image.asset('assets/images/qr_code_white.png'),
|
||||
),
|
||||
error!=''?Container(
|
||||
margin: EdgeInsets.only(top: 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(6.0),
|
||||
color: Theme.of(context).errorColor.withOpacity(0.06),
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(child: AppText(error ?? "Something went wrong.", color: Theme.of(context).errorColor)),
|
||||
],
|
||||
),
|
||||
):Container(),
|
||||
Column(
|
||||
children: patientList.map((item) {
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: {
|
||||
"patient": item,
|
||||
});
|
||||
},
|
||||
child: CardWithBgWidget(
|
||||
widget: Container(
|
||||
child: AppText(
|
||||
'${item.firstName} ${item.lastName}',
|
||||
fontSize: 2.5 * SizeConfig.textMultiplier,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList()
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_scanQrAndGetPatient(BuildContext context) async {
|
||||
/// When give qr we will change this method to get data
|
||||
/// var result = await BarcodeScanner.scan();
|
||||
/// int patientID = get from qr result
|
||||
String patientType = "1";
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
patientList = [];
|
||||
});
|
||||
patient.PatientID = 3120144;
|
||||
Provider.of<PatientsProvider>(context, listen: false)
|
||||
.getPatientList(patient, "1")
|
||||
.then((response) {
|
||||
if (response['MessageStatus'] == 1) {
|
||||
switch (patientType) {
|
||||
case "0":
|
||||
if (response['List_MyOutPatient'] != null) {
|
||||
setState(() {
|
||||
patientList = ModelResponse.fromJson(response['List_MyOutPatient']).list;
|
||||
isLoading = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
error = 'No patient';
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "1":
|
||||
if (response['List_MyInPatient'] != null) {
|
||||
setState(() {
|
||||
patientList = ModelResponse.fromJson(response['List_MyInPatient']).list;
|
||||
isLoading = false;
|
||||
error="";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
error = 'No patient';
|
||||
isLoading = false;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
error = response['ErrorMessage'] ?? response['ErrorEndUserMessage'];
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,146 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
|
||||
class Button extends StatefulWidget {
|
||||
Button({
|
||||
Key key,
|
||||
this.title: "",
|
||||
this.icon,
|
||||
this.onTap,
|
||||
this.loading: false,
|
||||
}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
final Widget icon;
|
||||
final VoidCallback onTap;
|
||||
final bool loading;
|
||||
|
||||
@override
|
||||
_ButtonState createState() => _ButtonState();
|
||||
}
|
||||
|
||||
class _ButtonState extends State<Button> with TickerProviderStateMixin {
|
||||
double _buttonSize = 1.0;
|
||||
AnimationController _animationController;
|
||||
Animation _animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_animationController = AnimationController(
|
||||
vsync: this,
|
||||
lowerBound: 0.7,
|
||||
upperBound: 1.0,
|
||||
duration: Duration(milliseconds: 120));
|
||||
_animation = CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Curves.easeOutQuad,
|
||||
reverseCurve: Curves.easeOutQuad);
|
||||
_animation.addListener(() {
|
||||
setState(() {
|
||||
_buttonSize = _animation.value;
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _buildIcon() {
|
||||
if (widget.icon != null && (widget.title != null && widget.title != "")) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(right: 12.0),
|
||||
height: 24.0,
|
||||
child: widget.icon);
|
||||
} else if (widget.icon != null) {
|
||||
return Container(
|
||||
height: 18.0,
|
||||
width: 18.0,
|
||||
child: widget.icon,
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IgnorePointer(
|
||||
ignoring: widget.loading,
|
||||
child: GestureDetector(
|
||||
onTapDown: (TapDownDetails tap) {
|
||||
_animationController.reverse(from: 1.0);
|
||||
},
|
||||
onTapUp: (TapUpDetails tap) {
|
||||
_animationController.forward();
|
||||
},
|
||||
onTapCancel: () {
|
||||
_animationController.forward();
|
||||
},
|
||||
onTap: Feedback.wrapForTap(widget.onTap, context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Transform.scale(
|
||||
scale: _buttonSize,
|
||||
child: AnimatedContainer(
|
||||
duration: Duration(milliseconds: 150),
|
||||
margin:
|
||||
EdgeInsets.only(bottom: widget.title.isNotEmpty ? 14.0 : 0.0),
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: widget.title != null && widget.title.isNotEmpty
|
||||
? 12.0
|
||||
: 15.0,
|
||||
horizontal: widget.title != null && widget.title.isNotEmpty
|
||||
? 22.0
|
||||
: 19),
|
||||
decoration: BoxDecoration(
|
||||
color: Hexcolor('#58434F'),
|
||||
borderRadius: BorderRadius.all(Radius.circular(100.0)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color.fromRGBO(70, 70, 70, 0.28),
|
||||
spreadRadius:
|
||||
_buttonSize < 1.0 ? -(1 - _buttonSize) * 50 : 0.0,
|
||||
offset: Offset(0, 7.0),
|
||||
blurRadius: 24.0)
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
_buildIcon(),
|
||||
widget.loading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(2.7),
|
||||
child: SizedBox(
|
||||
height: 19.0,
|
||||
width: 19.0,
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: Colors.white,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Hexcolor('#FFDDD9'),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.only(bottom: 3.0),
|
||||
child: Text(widget.title,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 17.0,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontFamily: "WorkSans")),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue