baby age in ovulation period

merge-update-with-lab-changes
hussam al-habibeh 5 years ago
parent d3868844de
commit 4b90f16ab9

@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:jiffy/jiffy.dart';
import 'ovulation_result_page.dart'; import 'ovulation_result_page.dart';
@ -22,6 +23,8 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
int lutealPhaseLength = 0; int lutealPhaseLength = 0;
String selectedDate; String selectedDate;
var dateFrom = DateTime.now(); var dateFrom = DateTime.now();
var babyAgeWeeks;
var babyAgeDays;
var dateTo = DateTime.now(); var dateTo = DateTime.now();
var conceivedDate = DateTime.now(); var conceivedDate = DateTime.now();
var deliveryDue = DateTime.now(); var deliveryDue = DateTime.now();
@ -78,10 +81,15 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
bloodSugarDate = date; bloodSugarDate = date;
dateFrom = date.add(Duration(days: 10)); dateFrom = date.add(Duration(days: 10));
updatedDt = DateFormat.yMMMEd().format(dateFrom); updatedDt = DateFormat.yMMMEd().format(dateFrom);
dateTo = date.add(Duration(days: 20)); dateTo = date.add(Duration(days: 20));
conceivedDate = date.add(Duration(days: 14)); conceivedDate = date.add(Duration(days: 14));
deliveryDue = date.add(Duration(days: 280)); deliveryDue = date.add(Duration(days: 280));
// babyAge = Jiffy([DateTime.now()]).diff(Jiffy([date]), Units.WEEK);
babyAgeWeeks = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day])
.diff(Jiffy([date.year, date.month, dateTo.day]), Units.WEEK);
babyAgeDays = Jiffy([DateTime.now().year, DateTime.now().month, DateTime.now().day])
.diff(Jiffy([date.year, date.month, dateTo.day]), Units.DAY);
}); });
}, },
currentTime: DateTime.now(), currentTime: DateTime.now(),
@ -91,9 +99,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: double.infinity, width: double.infinity,
height: 65, height: 65,
decoration: BoxDecoration( decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -124,8 +130,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
child: Row( child: Row(
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0),
vertical: 10.0, horizontal: 8.0),
child: Center( child: Center(
child: Container( child: Container(
width: 60.0, width: 60.0,
@ -146,10 +151,8 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
Container( Container(
height: 38.0, height: 38.0,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.center,
CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -166,8 +169,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
), ),
onTap: () { onTap: () {
setState(() { setState(() {
if (cycleLength < 45) if (cycleLength < 45) cycleLength++;
cycleLength++;
}); });
}, },
), ),
@ -179,8 +181,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
), ),
onTap: () { onTap: () {
setState(() { setState(() {
if (cycleLength > 0) if (cycleLength > 0) cycleLength--;
cycleLength--;
}); });
}, },
), ),
@ -229,8 +230,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
child: Row( child: Row(
children: [ children: [
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0),
vertical: 10.0, horizontal: 8.0),
child: Center( child: Center(
child: Container( child: Container(
width: 60.0, width: 60.0,
@ -245,17 +245,14 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Center( child: Center(
child: child: Text(lutealPhaseLength.toString()),
Text(lutealPhaseLength.toString()),
), ),
), ),
Container( Container(
height: 38.0, height: 38.0,
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.center,
CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -272,8 +269,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
), ),
onTap: () { onTap: () {
setState(() { setState(() {
if (lutealPhaseLength < 15) if (lutealPhaseLength < 15) lutealPhaseLength++;
lutealPhaseLength++;
}); });
}, },
), ),
@ -285,8 +281,7 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
), ),
onTap: () { onTap: () {
setState(() { setState(() {
if (lutealPhaseLength > 0) if (lutealPhaseLength > 0) lutealPhaseLength--;
lutealPhaseLength--;
}); });
}, },
), ),
@ -332,11 +327,13 @@ class _OvulationPeriodState extends State<OvulationPeriod> {
context, context,
FadePage( FadePage(
page: OvulationResult( page: OvulationResult(
conceivedDate: conceivedDate, conceivedDate: conceivedDate,
dateFrom: dateFrom, dateFrom: dateFrom,
dateTo: dateTo, dateTo: dateTo,
deliveryDue: deliveryDue, deliveryDue: deliveryDue,
)), babyAge: babyAgeWeeks,
babyAgeDays: babyAgeDays,
)),
); );
} }
}); });

@ -11,7 +11,17 @@ class OvulationResult extends StatelessWidget {
var dateTo; var dateTo;
var conceivedDate; var conceivedDate;
var deliveryDue; var deliveryDue;
OvulationResult({this.dateFrom, this.dateTo, this.deliveryDue, this.conceivedDate}); var babyAge;
var babyAgeDays;
OvulationResult({
this.dateFrom,
this.dateTo,
this.deliveryDue,
this.conceivedDate,
this.babyAge,
this.babyAgeDays,
});
//var newFormat = DateFormat("yy-MM-dd"); //var newFormat = DateFormat("yy-MM-dd");
@override @override
@ -68,7 +78,7 @@ class OvulationResult extends StatelessWidget {
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
), ),
Texts( Texts(
'5 Weeks, 2', babyAge.toString() + " Weeks," + "2",
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
fontSize: 21.0, fontSize: 21.0,
), ),

@ -148,6 +148,8 @@ dependencies:
#Handle Geolocation #Handle Geolocation
geolocator: ^6.1.10 geolocator: ^6.1.10
jiffy: ^3.0.0
screen: ^0.0.5 screen: ^0.0.5
#google maps places #google maps places
google_maps_place_picker: ^1.0.0 google_maps_place_picker: ^1.0.0

Loading…
Cancel
Save