merge-update-with-lab-changes
mosazaid 5 years ago
parent b59ca8dedd
commit 3077624c58

@ -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 / 15; inputValue = inputValue / 18;
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,217 +82,237 @@ 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: SingleChildScrollView( child: Column(
child: Container( children: [
height: MediaQuery.of(context).size.height * 0.7, Expanded(
child: Column( child: SingleChildScrollView(
//crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ //crossAxisAlignment: CrossAxisAlignment.start,
Container( children: [
width: 350.0, Container(
child: Text( margin: EdgeInsets.symmetric(horizontal: 8),
TranslationBase.of(context).convertBloodSugarStatement, child: Text(
//textAlign: TextAlign.center, TranslationBase.of(context).convertBloodSugarStatement,
style: TextStyle(fontSize: 20.0), //textAlign: TextAlign.center,
), style: TextStyle(fontSize: 20.0),
), ),
SizedBox( ),
height: 15.0, SizedBox(
), height: 12.0,
Container( ),
color: Colors.white, Container(
height: 120.0, color: Colors.white,
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.symmetric(
child: Column( vertical: 16.0, horizontal: 8),
//crossAxisAlignment: CrossAxisAlignment.end, child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0),
child: Row(
children: [
Texts(
TranslationBase.of(context).convertFrom,
)
],
),
),
SizedBox(
height: 9.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
GestureDetector( Padding(
onTap: () { padding:
setState(() { const EdgeInsets.symmetric(horizontal: 16.0),
updateColor(1); child: Row(
if (textController.text.isNotEmpty) { children: [
inputValue = Texts(
double.parse(textController.text); TranslationBase.of(context).convertFrom,
inputValue = inputValue / 15; )
} ],
unit = 'mmol/l'; ),
}); ),
}, SizedBox(
child: Container( height: 8.0,
height: 65.0, ),
width: 150.0, Row(
decoration: BoxDecoration( mainAxisAlignment: MainAxisAlignment.spaceEvenly,
boxShadow: [ crossAxisAlignment: CrossAxisAlignment.center,
BoxShadow( children: [
color: Colors.grey.withOpacity(0.5), SizedBox(
spreadRadius: 3, width: 16.0,
blurRadius: 7, ),
offset: Offset( Expanded(
0, 3), // changes position of shadow child: GestureDetector(
onTap: () {
setState(() {
updateColor(1);
calculateBloodSugar();
});
},
child: Container(
height: 65.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(0,
3), // changes position of shadow
),
],
color: cardMGColor,
borderRadius:
BorderRadius.circular(3.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Texts(
'MG/DLt TO \nMMOL/L',
color: textMGColor,
),
),
), ),
], ),
color: cardMGColor,
borderRadius: BorderRadius.circular(3.0),
), ),
child: Padding( SizedBox(
padding: const EdgeInsets.symmetric( width: 12.0,
vertical: 0.0, horizontal: 18.0),
child: Texts('MG/DLt TO \nMMOL/L'),
), ),
), Expanded(
), child: GestureDetector(
GestureDetector( onTap: () {
onTap: () { setState(() {
setState(() { updateColor(2);
updateColor(2); calculateBloodSugar();
if (textController.text.isNotEmpty) { });
inputValue = },
double.parse(textController.text); child: Container(
inputValue = inputValue / 18; height: 65.0,
} decoration: BoxDecoration(
unit = 'mg/dlt'; color: cardMMOLColor,
}); borderRadius:
}, BorderRadius.circular(3.0),
child: Container( boxShadow: [
height: 65.0, BoxShadow(
width: 150.0, color: Colors.grey.withOpacity(0.5),
decoration: BoxDecoration( spreadRadius: 3,
color: cardMMOLColor, blurRadius: 7,
borderRadius: BorderRadius.circular(3.0), offset: Offset(0,
boxShadow: [ 3), // changes position of shadow
BoxShadow( ),
color: Colors.grey.withOpacity(0.5), ],
spreadRadius: 3, ),
blurRadius: 7, child: Padding(
offset: Offset( padding: const EdgeInsets.symmetric(
0, 3), // changes position of shadow horizontal: 16.0),
child: Texts(
'MMOL/L TO MG/DLt ',
color: textMMOLColor,
),
),
), ),
], ),
), ),
child: Padding( SizedBox(
padding: const EdgeInsets.symmetric( width: 16.0,
horizontal: 16.0),
child: Texts('\nMMOL/L TO MG/DLt '),
), ),
), ],
), ),
], ],
), ),
], ),
), ),
), SizedBox(
), height: 24.0,
SizedBox( ),
height: 25.0, Container(
), height: 65.0,
Container( padding: EdgeInsets.symmetric(horizontal: 8),
height: 65.0, decoration: BoxDecoration(
decoration: BoxDecoration( borderRadius: BorderRadius.circular(6.0),
borderRadius: BorderRadius.circular(6.0), color: Colors.white,
color: Colors.white, ),
), child: TextFormField(
child: TextFormField( controller: textController,
controller: textController, inputFormatters: <TextInputFormatter>[
inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.digitsOnly // FilteringTextInputFormatter.digitsOnly
], ],
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(
labelStyle: TextStyle( borderSide: BorderSide(color: Colors.white),
color: Colors.black87, ),
disabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
border: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
labelStyle: TextStyle(
color: Colors.black87,
),
),
), ),
), ),
), SizedBox(
), height: 24.0,
SizedBox(
height: 25.0,
),
Visibility(
visible: _visible,
child: Container(
height: 115.0,
width: 350.0,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(15.0),
), ),
child: Padding( Visibility(
padding: const EdgeInsets.all(8.0), visible: _visible,
child: Column( child: Container(
crossAxisAlignment: CrossAxisAlignment.start, height: 115.0,
mainAxisAlignment: MainAxisAlignment.center, width: 350.0,
children: [ decoration: BoxDecoration(
Texts(TranslationBase.of(context).result + ": "), color: Colors.white,
Row( border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Texts(TranslationBase.of(context).result + ": "),
inputValue.toStringAsFixed(3), Row(
style: TextStyle(fontSize: 35.0), children: [
), Text(
Padding( inputValue.toStringAsFixed(2),
padding: EdgeInsets.only(left: 4.0, top: 10.0), style: TextStyle(fontSize: 35.0),
child: Text(
unit.toString(),
style: TextStyle(
color: Color(0xffC5273A),
fontSize: 15.0,
fontWeight: FontWeight.w500,
), ),
), Padding(
padding:
EdgeInsets.only(left: 4.0, top: 10.0),
child: Text(
unit.toString(),
style: TextStyle(
color: Color(0xffC5273A),
fontSize: 15.0,
fontWeight: FontWeight.w500,
),
),
),
],
), ),
], ],
), ),
], ),
), ),
), ),
), ],
),
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,
onTap: () { color: Color(0XFF515A5D),
setState(() { onTap: () {
_visible == false setState(() {
? _visible = !_visible _visible == false
: _visible = _visible; ? _visible = !_visible
calculateBloodSugar(); : _visible = _visible;
}); calculateBloodSugar();
}, });
), },
), ),
),
],
), ),
), ],
), ),
), ),
); );

Loading…
Cancel
Save