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/ChildVaccines/vaccinationtable_page.dart

201 lines
8.9 KiB
Dart

import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/vaccination_table_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:provider/provider.dart';
import 'dialogs/SelectGenderDialog.dart';
class VaccinationTablePage extends StatelessWidget {
final List_BabyInformationModel babyInfo;
VaccinationTablePage(this.babyInfo);
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
final double height = (size.height - kToolbarHeight - 60);
ProjectViewModel projectViewModel = Provider.of(context);
var checkedValue;
return BaseView<VaccinationTableViewModel>(
onModelReady: (model) => model.getCreateVaccinationTable(babyInfo, false),
builder: (_, model, w) => AppScaffold(
isShowAppBar: true,
baseViewModel: model,
appBarTitle: TranslationBase.of(context).vaccination,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGrey2Color,
body: Container(
height: double.infinity,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Container(
margin: EdgeInsets.only(left: 16, right: 16, top: 16),
child: Column(
children: [
Container(
decoration: containerRadius(Colors.white, 12),
padding: EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
babyInfo.babyName,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: -0.64,
),
),
mHeight(8),
Row(
children: [
Text(
TranslationBase.of(context).gender + " :",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
letterSpacing: -0.4,
color: CustomColors.textColor,
),
),
Text(
babyInfo.gender == 1 ? TranslationBase.of(context).female : TranslationBase.of(context).male,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.4,
color: CustomColors.black,
),
),
],
),
Row(
children: [
Text(
TranslationBase.of(context).dateOfBirth + " :",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w600,
letterSpacing: -0.4,
color: CustomColors.textColor,
),
),
Text(
DateUtil.getFormattedDate(babyInfo.dOB, "MMM dd,yyyy"),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.4,
color: CustomColors.black,
),
),
],
),
],
),
),
mHeight(12),
Container(
decoration: containerRadius(Colors.white, 12),
padding: EdgeInsets.all(12),
child: Table(
columnWidths: {
0: FlexColumnWidth(1.8),
1: FlexColumnWidth(1.8),
2: FlexColumnWidth(1.8),
},
children: fullData(context, model, projectViewModel),
),
),
],
),
),
),
),
Container(
width: double.infinity,
padding: EdgeInsets.all(12),
color: Colors.white,
child: SecondaryButton(
textColor: Colors.white,
color: CustomColors.accentColor,
label: TranslationBase.of(context).sendEmail,
//
onTap: () {
//SelectGenderDialog();
//===============
showDialog(
context: context,
builder: (cxt) => SelectGenderDialog(
okFunction: () async {
await model.getCreateVaccinationTable(babyInfo, true);
if (model.state == ViewState.Idle) {
AppToast.showSuccessToast(message: TranslationBase.of(context).emailSentSuccessfully);
} else {
AppToast.showErrorToast(message: TranslationBase.of(context).EmailSentError);
}
},
),
);
//=========
},
),
),
],
),
),
),
);
}
List<TableRow> fullData(BuildContext context, VaccinationTableViewModel model, ProjectViewModel projectViewModel) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).visit),
Utils.tableColumnTitle(TranslationBase.of(context).description),
Utils.tableColumnTitle(TranslationBase.of(context).dueDate),
],
),
);
model.creteVaccinationTableModelList.forEach(
(diabtec) {
tableRow.add(
TableRow(
children: [
Utils.tableColumnValue(diabtec.visit, isCapitable: false, mProjectViewModel: projectViewModel),
// Utils.tableColumnValue(diabtec.vaccinesDescription, isCapitable: false, mProjectViewModel: projectViewModel),
Html(
// data:"<html><head><style type='text/css'>.Test {list-style-image:url('http://10.50.100.198:4444/Images/Bullet_List_Small.png');}</style></head><body><table><tr align='left'><td align='left'>BCG</td></tr><tr align='left'><td align='left'>HEPATITIS B</td></tr></table></body></html>"//model.creteVaccinationTableModelList[index].vaccinesDescription
data: diabtec.vaccinesDescription,
),
Utils.tableColumnValue(diabtec.givenAt, isCapitable: false, mProjectViewModel: projectViewModel),
],
),
);
},
);
return tableRow;
}
}