@ -7,8 +7,10 @@ import 'package:flutter/cupertino.dart';
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/services.dart ' ;
import ' package:flutter/services.dart ' ;
const activeCardColor = Color ( 0xff70777A ) ;
const activeCardColor = Color ( 0xff515a5d ) ;
const inactiveCardColor = Color ( 0xffFAFAFd ) ;
const activeTextColor = Color ( 0xffFAFAFA ) ;
const inactiveCardColor = Color ( 0xffFAFAFA ) ;
const inactiveTextColor = Color ( 0xff60686B ) ;
class BloodSugar extends StatefulWidget {
class BloodSugar extends StatefulWidget {
@ override
@ override
@ -20,6 +22,8 @@ Color color;
class _BloodSugarState extends State < BloodSugar > {
class _BloodSugarState extends State < BloodSugar > {
Color cardMGColor = inactiveCardColor ;
Color cardMGColor = inactiveCardColor ;
Color cardMMOLColor = inactiveCardColor ;
Color cardMMOLColor = inactiveCardColor ;
Color textMGColor = inactiveTextColor ;
Color textMMOLColor = inactiveTextColor ;
void updateColor ( int type ) {
void updateColor ( int type ) {
/ / MG / DLT card
/ / MG / DLT card
@ -30,6 +34,8 @@ class _BloodSugarState extends State<BloodSugar> {
} else {
} else {
cardMGColor = inactiveCardColor ;
cardMGColor = inactiveCardColor ;
}
}
textMGColor = activeTextColor ;
textMMOLColor = inactiveTextColor ;
}
}
if ( type = = 2 ) {
if ( type = = 2 ) {
if ( cardMMOLColor = = inactiveCardColor ) {
if ( cardMMOLColor = = inactiveCardColor ) {
@ -38,6 +44,8 @@ class _BloodSugarState extends State<BloodSugar> {
} else {
} else {
cardMMOLColor = inactiveCardColor ;
cardMMOLColor = inactiveCardColor ;
}
}
textMGColor = inactiveTextColor ;
textMMOLColor = activeTextColor ;
}
}
}
}
@ -45,7 +53,7 @@ class _BloodSugarState extends State<BloodSugar> {
if ( textController . text . isEmpty ) return ;
if ( textController . text . isEmpty ) return ;
if ( cardMGColor = = activeCardColor ) {
if ( cardMGColor = = activeCardColor ) {
inputValue = double . parse ( textController . text ) ;
inputValue = double . parse ( textController . text ) ;
inputValue = inputValue / 1 5 ;
inputValue = inputValue / 1 8 ;
unit = ' mmol/l ' ;
unit = ' mmol/l ' ;
} else if ( cardMMOLColor = = activeCardColor ) {
} else if ( cardMMOLColor = = activeCardColor ) {
inputValue = double . parse ( textController . text ) ;
inputValue = double . parse ( textController . text ) ;
@ -74,16 +82,17 @@ class _BloodSugarState extends State<BloodSugar> {
isShowAppBar: true ,
isShowAppBar: true ,
isShowDecPage: false ,
isShowDecPage: false ,
appBarTitle: TranslationBase . of ( context ) . bloodSugarConversion ,
appBarTitle: TranslationBase . of ( context ) . bloodSugarConversion ,
body: Padding (
body: Container (
padding: const EdgeInsets . all ( 16.0 ) ,
padding: const EdgeInsets . all ( 16.0 ) ,
child: Column (
children: [
Expanded (
child: SingleChildScrollView (
child: SingleChildScrollView (
child: Container (
height: MediaQuery . of ( context ) . size . height * 0.7 ,
child: Column (
child: Column (
/ / crossAxisAlignment: CrossAxisAlignment . start ,
/ / crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
Container (
Container (
width: 350.0 ,
margin: EdgeInsets . symmetric ( horizontal: 8 ) ,
child: Text (
child: Text (
TranslationBase . of ( context ) . convertBloodSugarStatement ,
TranslationBase . of ( context ) . convertBloodSugarStatement ,
/ / textAlign: TextAlign . center ,
/ / textAlign: TextAlign . center ,
@ -91,18 +100,18 @@ class _BloodSugarState extends State<BloodSugar> {
) ,
) ,
) ,
) ,
SizedBox (
SizedBox (
height: 15 .0,
height: 12 .0,
) ,
) ,
Container (
Container (
color: Colors . white ,
color: Colors . white ,
height: 120.0 ,
child: Padding (
child: Padding (
padding: const EdgeInsets . all ( 8.0 ) ,
padding: const EdgeInsets . symmetric (
vertical: 16.0 , horizontal: 8 ) ,
child: Column (
child: Column (
/ / crossAxisAlignment: CrossAxisAlignment . end ,
children: [
children: [
Padding (
Padding (
padding: const EdgeInsets . symmetric ( horizontal: 15.0 ) ,
padding:
const EdgeInsets . symmetric ( horizontal: 16.0 ) ,
child: Row (
child: Row (
children: [
children: [
Texts (
Texts (
@ -112,81 +121,91 @@ class _BloodSugarState extends State<BloodSugar> {
) ,
) ,
) ,
) ,
SizedBox (
SizedBox (
height: 9 .0,
height: 8 .0,
) ,
) ,
Row (
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
children: [
GestureDetector (
SizedBox (
width: 16.0 ,
) ,
Expanded (
child: GestureDetector (
onTap: ( ) {
onTap: ( ) {
setState ( ( ) {
setState ( ( ) {
updateColor ( 1 ) ;
updateColor ( 1 ) ;
if ( textController . text . isNotEmpty ) {
calculateBloodSugar ( ) ;
inputValue =
double . parse ( textController . text ) ;
inputValue = inputValue / 15 ;
}
unit = ' mmol/l ' ;
} ) ;
} ) ;
} ,
} ,
child: Container (
child: Container (
height: 65.0 ,
height: 65.0 ,
width: 150.0 ,
decoration: BoxDecoration (
decoration: BoxDecoration (
boxShadow: [
boxShadow: [
BoxShadow (
BoxShadow (
color: Colors . grey . withOpacity ( 0.5 ) ,
color: Colors . grey . withOpacity ( 0.5 ) ,
spreadRadius: 3 ,
spreadRadius: 3 ,
blurRadius: 7 ,
blurRadius: 7 ,
offset: Offset (
offset: Offset ( 0 ,
0 , 3 ) , / / changes position of shadow
3 ) , / / changes position of shadow
) ,
) ,
] ,
] ,
color: cardMGColor ,
color: cardMGColor ,
borderRadius: BorderRadius . circular ( 3.0 ) ,
borderRadius:
BorderRadius . circular ( 3.0 ) ,
) ,
) ,
child: Padding (
child: Padding (
padding: const EdgeInsets . symmetric (
padding: const EdgeInsets . symmetric (
vertical: 0.0 , horizontal: 18.0 ) ,
vertical: 0.0 , horizontal: 18.0 ) ,
child: Texts ( ' MG/DLt TO \n MMOL/L ' ) ,
child: Texts (
' MG/DLt TO \n MMOL/L ' ,
color: textMGColor ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,
GestureDetector (
SizedBox (
width: 12.0 ,
) ,
Expanded (
child: GestureDetector (
onTap: ( ) {
onTap: ( ) {
setState ( ( ) {
setState ( ( ) {
updateColor ( 2 ) ;
updateColor ( 2 ) ;
if ( textController . text . isNotEmpty ) {
calculateBloodSugar ( ) ;
inputValue =
double . parse ( textController . text ) ;
inputValue = inputValue / 18 ;
}
unit = ' mg/dlt ' ;
} ) ;
} ) ;
} ,
} ,
child: Container (
child: Container (
height: 65.0 ,
height: 65.0 ,
width: 150.0 ,
decoration: BoxDecoration (
decoration: BoxDecoration (
color: cardMMOLColor ,
color: cardMMOLColor ,
borderRadius: BorderRadius . circular ( 3.0 ) ,
borderRadius:
BorderRadius . circular ( 3.0 ) ,
boxShadow: [
boxShadow: [
BoxShadow (
BoxShadow (
color: Colors . grey . withOpacity ( 0.5 ) ,
color: Colors . grey . withOpacity ( 0.5 ) ,
spreadRadius: 3 ,
spreadRadius: 3 ,
blurRadius: 7 ,
blurRadius: 7 ,
offset: Offset (
offset: Offset ( 0 ,
0 , 3 ) , / / changes position of shadow
3 ) , / / changes position of shadow
) ,
) ,
] ,
] ,
) ,
) ,
child: Padding (
child: Padding (
padding: const EdgeInsets . symmetric (
padding: const EdgeInsets . symmetric (
horizontal: 16.0 ) ,
horizontal: 16.0 ) ,
child: Texts ( ' \n MMOL/L TO MG/DLt ' ) ,
child: Texts (
' MMOL/L TO MG/DLt ' ,
color: textMMOLColor ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,
SizedBox (
width: 16.0 ,
) ,
] ,
] ,
) ,
) ,
] ,
] ,
@ -194,10 +213,11 @@ class _BloodSugarState extends State<BloodSugar> {
) ,
) ,
) ,
) ,
SizedBox (
SizedBox (
height: 25 .0,
height: 24 .0,
) ,
) ,
Container (
Container (
height: 65.0 ,
height: 65.0 ,
padding: EdgeInsets . symmetric ( horizontal: 8 ) ,
decoration: BoxDecoration (
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 6.0 ) ,
borderRadius: BorderRadius . circular ( 6.0 ) ,
color: Colors . white ,
color: Colors . white ,
@ -209,9 +229,19 @@ class _BloodSugarState extends State<BloodSugar> {
] ,
] ,
keyboardType: TextInputType . number ,
keyboardType: TextInputType . number ,
decoration: InputDecoration (
decoration: InputDecoration (
labelText: TranslationBase . of ( context ) . enterReadingValue ,
labelText:
border: OutlineInputBorder (
TranslationBase . of ( context ) . enterReadingValue ,
borderSide: BorderSide ( color: Colors . black45 ) ) ,
enabledBorder: UnderlineInputBorder (
borderSide: BorderSide ( color: Colors . white ) ,
) ,
disabledBorder: UnderlineInputBorder (
borderSide: BorderSide ( color: Colors . white ) ,
) ,
focusedBorder: UnderlineInputBorder (
borderSide: BorderSide ( color: Colors . white ) ,
) ,
border: UnderlineInputBorder (
borderSide: BorderSide ( color: Colors . white ) ) ,
labelStyle: TextStyle (
labelStyle: TextStyle (
color: Colors . black87 ,
color: Colors . black87 ,
) ,
) ,
@ -219,7 +249,7 @@ class _BloodSugarState extends State<BloodSugar> {
) ,
) ,
) ,
) ,
SizedBox (
SizedBox (
height: 25 .0,
height: 24 .0,
) ,
) ,
Visibility (
Visibility (
visible: _visible ,
visible: _visible ,
@ -241,11 +271,12 @@ class _BloodSugarState extends State<BloodSugar> {
Row (
Row (
children: [
children: [
Text (
Text (
inputValue . toStringAsFixed ( 3 ) ,
inputValue . toStringAsFixed ( 2 ) ,
style: TextStyle ( fontSize: 35.0 ) ,
style: TextStyle ( fontSize: 35.0 ) ,
) ,
) ,
Padding (
Padding (
padding: EdgeInsets . only ( left: 4.0 , top: 10.0 ) ,
padding:
EdgeInsets . only ( left: 4.0 , top: 10.0 ) ,
child: Text (
child: Text (
unit . toString ( ) ,
unit . toString ( ) ,
style: TextStyle (
style: TextStyle (
@ -262,15 +293,15 @@ class _BloodSugarState extends State<BloodSugar> {
) ,
) ,
) ,
) ,
) ,
) ,
SizedBox (
] ,
height: 30.0 ,
) ,
) ,
Flexible (
) ,
child: Container (
) ,
height: 50.0 ,
Container (
width: 150.0 ,
margin: EdgeInsets . symmetric ( horizontal: 16 ) ,
child: SecondaryButton (
child: SecondaryButton (
label: TranslationBase . of ( context ) . calculate ,
label: TranslationBase . of ( context ) . calculate ,
color: Color ( 0XFF515A5D ) ,
onTap: ( ) {
onTap: ( ) {
setState ( ( ) {
setState ( ( ) {
_visible = = false
_visible = = false
@ -281,12 +312,9 @@ class _BloodSugarState extends State<BloodSugar> {
} ,
} ,
) ,
) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
) ,
) ,
) ;
) ;
}
}
}
}