Merge branch 'fix-bugs' into 'development'

Fix bugs

See merge request Cloud_Solution/diplomatic-quarter!355
merge-requests/356/merge
Sultan khan 3 years ago
commit 6a0acd8afb

@ -7,8 +7,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
const activeCardColor = Color(0xff70777A);
const inactiveCardColor = Color(0xffFAFAFd);
const activeCardColor = Color(0xff515a5d);
const activeTextColor = Color(0xffFAFAFA);
const inactiveCardColor = Color(0xffFAFAFA);
const inactiveTextColor = Color(0xff60686B);
class BloodSugar extends StatefulWidget {
@override
@ -20,6 +22,8 @@ Color color;
class _BloodSugarState extends State<BloodSugar> {
Color cardMGColor = inactiveCardColor;
Color cardMMOLColor = inactiveCardColor;
Color textMGColor = inactiveTextColor;
Color textMMOLColor = inactiveTextColor;
void updateColor(int type) {
//MG/DLT card
@ -30,6 +34,8 @@ class _BloodSugarState extends State<BloodSugar> {
} else {
cardMGColor = inactiveCardColor;
}
textMGColor = activeTextColor;
textMMOLColor = inactiveTextColor;
}
if (type == 2) {
if (cardMMOLColor == inactiveCardColor) {
@ -38,6 +44,8 @@ class _BloodSugarState extends State<BloodSugar> {
} else {
cardMMOLColor = inactiveCardColor;
}
textMGColor = inactiveTextColor;
textMMOLColor = activeTextColor;
}
}
@ -45,7 +53,7 @@ class _BloodSugarState extends State<BloodSugar> {
if (textController.text.isEmpty) return;
if (cardMGColor == activeCardColor) {
inputValue = double.parse(textController.text);
inputValue = inputValue / 15;
inputValue = inputValue / 18;
unit = 'mmol/l';
} else if (cardMMOLColor == activeCardColor) {
inputValue = double.parse(textController.text);
@ -74,217 +82,237 @@ class _BloodSugarState extends State<BloodSugar> {
isShowAppBar: true,
isShowDecPage: false,
appBarTitle: TranslationBase.of(context).bloodSugarConversion,
body: Padding(
body: Container(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * 0.7,
child: Column(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 350.0,
child: Text(
TranslationBase.of(context).convertBloodSugarStatement,
//textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
),
SizedBox(
height: 15.0,
),
Container(
color: Colors.white,
height: 120.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
//crossAxisAlignment: CrossAxisAlignment.end,
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,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
//crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 8),
child: Text(
TranslationBase.of(context).convertBloodSugarStatement,
//textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
),
SizedBox(
height: 12.0,
),
Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16.0, horizontal: 8),
child: Column(
children: [
GestureDetector(
onTap: () {
setState(() {
updateColor(1);
if (textController.text.isNotEmpty) {
inputValue =
double.parse(textController.text);
inputValue = inputValue / 15;
}
unit = 'mmol/l';
});
},
child: Container(
height: 65.0,
width: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
children: [
Texts(
TranslationBase.of(context).convertFrom,
)
],
),
),
SizedBox(
height: 8.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 16.0,
),
Expanded(
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(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 18.0),
child: Texts('MG/DLt TO \nMMOL/L'),
SizedBox(
width: 12.0,
),
),
),
GestureDetector(
onTap: () {
setState(() {
updateColor(2);
if (textController.text.isNotEmpty) {
inputValue =
double.parse(textController.text);
inputValue = inputValue / 18;
}
unit = 'mg/dlt';
});
},
child: Container(
height: 65.0,
width: 150.0,
decoration: BoxDecoration(
color: cardMMOLColor,
borderRadius: BorderRadius.circular(3.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(
0, 3), // changes position of shadow
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
updateColor(2);
calculateBloodSugar();
});
},
child: Container(
height: 65.0,
decoration: BoxDecoration(
color: cardMMOLColor,
borderRadius:
BorderRadius.circular(3.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 3,
blurRadius: 7,
offset: Offset(0,
3), // changes position of shadow
),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0),
child: Texts(
'MMOL/L TO MG/DLt ',
color: textMMOLColor,
),
),
),
],
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0),
child: Texts('\nMMOL/L TO MG/DLt '),
SizedBox(
width: 16.0,
),
),
],
),
],
),
],
),
),
),
),
SizedBox(
height: 25.0,
),
Container(
height: 65.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
color: Colors.white,
),
child: TextFormField(
controller: textController,
inputFormatters: <TextInputFormatter>[
SizedBox(
height: 24.0,
),
Container(
height: 65.0,
padding: EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.0),
color: Colors.white,
),
child: TextFormField(
controller: textController,
inputFormatters: <TextInputFormatter>[
// FilteringTextInputFormatter.digitsOnly
],
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: TranslationBase.of(context).enterReadingValue,
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.black45)),
labelStyle: TextStyle(
color: Colors.black87,
],
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText:
TranslationBase.of(context).enterReadingValue,
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(
color: Colors.black87,
),
),
),
),
),
),
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),
SizedBox(
height: 24.0,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Texts(TranslationBase.of(context).result + ": "),
Row(
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(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
inputValue.toStringAsFixed(3),
style: TextStyle(fontSize: 35.0),
),
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,
Texts(TranslationBase.of(context).result + ": "),
Row(
children: [
Text(
inputValue.toStringAsFixed(2),
style: TextStyle(fontSize: 35.0),
),
),
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,
width: 150.0,
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
onTap: () {
setState(() {
_visible == false
? _visible = !_visible
: _visible = _visible;
calculateBloodSugar();
});
},
),
),
),
],
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 16),
child: SecondaryButton(
label: TranslationBase.of(context).calculate,
color: Color(0XFF515A5D),
onTap: () {
setState(() {
_visible == false
? _visible = !_visible
: _visible = _visible;
calculateBloodSugar();
});
},
),
),
),
],
),
),
);

Loading…
Cancel
Save