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.
diplomatic-quarter/lib/pages/Covid-DriveThru/covid-payment-alert.dart

337 lines
14 KiB
Dart

import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-payment-summary.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class CovidPaymentAlert extends StatefulWidget {
PatientShareResponse patientShareResponse;
CovidPaymentAlert({@required this.patientShareResponse});
@override
_CovidPaymentAlertState createState() => _CovidPaymentAlertState();
}
class _CovidPaymentAlertState extends State<CovidPaymentAlert> {
AppSharedPreferences sharedPref = AppSharedPreferences();
AuthenticatedUser authUser;
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: TranslationBase.of(context).covidTest,
isShowAppBar: true,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
height: 200.0,
color: new Color(0xFFc5272d),
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 50.0),
child: SvgPicture.asset(
'assets/images/new-design/alert_icon.svg',
width: 80.0,
height: 80.0),
),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 30.0, right: 20.0),
child: Text(TranslationBase.of(context).covidAlert,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 24.0)),
),
Container(
width: MediaQuery.of(context).size.width * 0.55,
margin: EdgeInsets.only(
left: 30.0, right: 20.0, top: 5.0),
child: Text(
TranslationBase.of(context).covidAlertHeader,
// "Pay With-in 15 mins to confirm the appointment",
overflow: TextOverflow.clip,
style: TextStyle(
color: Colors.white, fontSize: 20.0)),
),
],
),
),
],
),
),
Container(
margin: EdgeInsets.only(left: 20.0, right: 20.0, top: 30.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
alignment: Alignment.center,
child: Text(TranslationBase.of(context).covidAlertMins,
overflow: TextOverflow.clip,
style: TextStyle(
color: new Color(0xFFc5272d),
fontSize: 24.0,
fontWeight: FontWeight.bold)),
),
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(top: 15.0),
child: Text(
TranslationBase.of(context).covidAlertInfo,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey[700],
fontSize: 18.0,
letterSpacing: 0.8)),
),
Container(
margin: EdgeInsets.only(
top: 40.0, bottom: 10.0, left: 0.0, right: 20.0),
child: Text(TranslationBase.of(context).appoInfo,
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700],
fontWeight: FontWeight.bold)),
),
Container(
margin: EdgeInsets.only(left: 0.0, bottom: 20.0),
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.grey[200],
boxShadow: [
BoxShadow(color: Colors.grey, spreadRadius: 2),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(
top: 15.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Text(TranslationBase.of(context).covidTest,
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Row(
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 20.0, right: 20.0),
child: Icon(
Icons.local_hospital,
size: 24,
color: Colors.grey[700],
)),
Container(
child: Text(
widget.patientShareResponse.projectName !=
null
? widget
.patientShareResponse.projectName
: "NULL",
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700])),
),
],
),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Row(
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 20.0, right: 20.0),
child: Icon(
Icons.date_range,
size: 24,
color: Colors.grey[700],
)),
Container(
child: Text(
widget.patientShareResponse
.appointmentDate !=
null
? getDate(widget.patientShareResponse
.appointmentDate)
.split(" ")[0]
: "NULL",
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700])),
),
],
),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Row(
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 20.0, right: 20.0),
child: Icon(
Icons.access_time,
size: 24,
color: Colors.grey[700],
)),
Container(
child: Text(
widget.patientShareResponse
.appointmentDate !=
null
? getDate(widget.patientShareResponse
.appointmentDate)
.split(" ")[1]
: "NULL",
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700])),
),
],
),
),
Container(
margin: EdgeInsets.only(bottom: 10.0),
child: Row(
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 20.0, right: 20.0),
child: SvgPicture.asset(
"assets/images/new-design/track_icon.svg",
width: 20.0,
height: 20.0)),
Container(
child: Text(
widget.patientShareResponse.doctorNameObj !=
null
? widget
.patientShareResponse.doctorNameObj
: "NULL",
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[700])),
),
],
),
),
],
),
),
],
),
),
],
),
),
bottomSheet: Container(
margin: EdgeInsets.all(10.0),
child: Flex(
direction: Axis.horizontal,
children: <Widget>[
Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.fromLTRB(10.0, 0.0, 5.0, 0.0),
child: ButtonTheme(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
minWidth: MediaQuery.of(context).size.width * 0.7,
height: 45.0,
child: RaisedButton(
color: new Color(0xFF60686b),
textColor: Colors.white,
disabledTextColor: Colors.white,
disabledColor: Colors.grey[500],
onPressed: () {
startPaymentProcess();
},
child: Text(TranslationBase.of(context).next, style: TextStyle(fontSize: 18.0)),
),
),
),
),
],
),
),
);
}
startPaymentProcess() {
navigateToPaymentMethod(context, widget.patientShareResponse);
}
Future navigateToPaymentMethod(
context, PatientShareResponse patientShareResponse) async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
setState(() {
authUser = data;
});
}
Navigator.push(
context, FadePage(page: PaymentMethod()))
.then((value) {
print(value);
if (value != null) {
Navigator.push(
context,
FadePage(
page: CovidPaymentSummary(
patientShareResponse: widget.patientShareResponse,
selectedPaymentMethod: value.toString()),
),
);
}
});
}
String getDate(String appoDate) {
var appoDateFormatted = "";
var dateObj = DateUtil.convertStringToDate(appoDate);
setState(() {
appoDateFormatted = DateUtil.getWeekDay(dateObj.weekday) +
", " +
dateObj.day.toString() +
" " +
DateUtil.getMonth(dateObj.month) +
" " +
dateObj.year.toString() +
" " +
dateObj.hour.toString() +
":" +
dateObj.minute.toString() +
":00";
});
return appoDateFormatted;
}
}