Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
404 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:my_bmi_calculator/core/components/textwidget/text.dart'; | ||
import 'package:my_bmi_calculator/core/constants/app_constants.dart'; | ||
import 'package:rflutter_alert/rflutter_alert.dart'; | ||
|
||
class MyAlert { | ||
final String warning = "Warning"; | ||
final String ok = "Ok"; | ||
|
||
Future<bool?> getAlert(String text, BuildContext context) { | ||
return Alert( | ||
context: context, | ||
title: warning, | ||
desc: text, | ||
buttons: [ | ||
DialogButton( | ||
color: accentColor, | ||
child: MyText( | ||
text: ok, | ||
color: mainColor, | ||
fontSize: 25, | ||
fontWeight: FontWeight.w400, | ||
), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
], | ||
style: const AlertStyle( | ||
alertBorder: RoundedRectangleBorder( | ||
side: BorderSide.none, | ||
borderRadius: BorderRadius.all( | ||
Radius.circular(20), | ||
), | ||
), | ||
backgroundColor: mainColor, | ||
titleStyle: TextStyle( | ||
color: accentColor, | ||
fontSize: 30, | ||
fontWeight: FontWeight.w500, | ||
), | ||
descStyle: TextStyle( | ||
color: accentColor, | ||
fontSize: 25, | ||
fontWeight: FontWeight.w300, | ||
), | ||
), | ||
).show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_bmi_calculator/core/components/textwidget/text.dart'; | ||
import 'package:my_bmi_calculator/core/constants/app_constants.dart'; | ||
import 'package:my_bmi_calculator/home/viewmodel/home_view_model.dart'; | ||
|
||
class CalculateButton extends StatefulWidget { | ||
const CalculateButton({ | ||
Key? key, | ||
required this.heightController, | ||
required this.weightController, | ||
required this.callback, | ||
}) : super(key: key); | ||
|
||
final TextEditingController heightController; | ||
final TextEditingController weightController; | ||
final VoidCallback callback; | ||
final String buttonText = "Calculate"; | ||
|
||
@override | ||
_CalculateButtonState createState() => _CalculateButtonState(); | ||
} | ||
|
||
class _CalculateButtonState extends State<CalculateButton> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return ClipRRect( | ||
borderRadius: const BorderRadius.all( | ||
Radius.circular(75), | ||
), | ||
child: Container( | ||
width: MediaQuery.of(context).size.width * 0.5, | ||
height: MediaQuery.of(context).size.height * 0.1, | ||
color: accentColor, | ||
child: TextButton( | ||
onPressed: () { | ||
setState(() { | ||
FocusScope.of(context).unfocus(); | ||
bool isItChecked = HomeViewModel().nullTextControl( | ||
widget.heightController.text.isEmpty, | ||
widget.weightController.text.isEmpty, | ||
context, | ||
); | ||
if (isItChecked == false) { | ||
widget.callback(); | ||
} | ||
}); | ||
}, | ||
child: MyText( | ||
text: widget.buttonText, | ||
color: mainColor, | ||
fontSize: 25.0, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_bmi_calculator/core/constants/app_constants.dart'; | ||
|
||
class MyTextField extends StatelessWidget { | ||
const MyTextField({ | ||
Key? key, | ||
required this.controller, | ||
}) : super(key: key); | ||
|
||
final TextEditingController controller; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return TextField( | ||
controller: controller, | ||
textAlign: TextAlign.center, | ||
keyboardType: TextInputType.number, | ||
cursorColor: accentColor, | ||
decoration: const InputDecoration( | ||
border: InputBorder.none, | ||
hintText: '0', | ||
hintStyle: TextStyle( | ||
color: accentColor, | ||
fontSize: 42, | ||
), | ||
), | ||
style: const TextStyle( | ||
color: accentColor, | ||
fontSize: 42, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MyText extends StatelessWidget { | ||
const MyText({ | ||
Key? key, required this.text, required this.fontSize, required this.color, this.textAlign, this.fontWeight, | ||
}) : super(key: key); | ||
|
||
final String text; | ||
final double fontSize; | ||
final Color color; | ||
final TextAlign? textAlign; | ||
final FontWeight? fontWeight; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Text( | ||
text, | ||
style: TextStyle( | ||
color: color, | ||
fontSize: fontSize, | ||
fontWeight: fontWeight, | ||
), | ||
textAlign: textAlign, | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
lib/man_woman_buttons/gender_cont.dart → lib/home/model/gender_cont.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
// ignore_for_file: prefer_const_constructors | ||
import 'package:flutter/material.dart'; | ||
|
||
class GenderContanier extends StatelessWidget { | ||
const GenderContanier({Key? key, required this.gender, required this.contColor}) : super(key: key); | ||
const GenderContanier({ | ||
Key? key, | ||
required this.gender, | ||
required this.contColor, | ||
}) : super(key: key); | ||
|
||
final String gender; | ||
final Color contColor; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ClipRRect( | ||
borderRadius: BorderRadius.all( | ||
borderRadius: const BorderRadius.all( | ||
Radius.circular(20), | ||
), | ||
child: Center( | ||
child: Container( | ||
child: Image.asset( | ||
'assets/images/$gender.png', | ||
), | ||
width: MediaQuery.of(context).size.width / 2.5, | ||
height: MediaQuery.of(context).size.height / 9.5, | ||
width: MediaQuery.of(context).size.width * 0.4, | ||
height: MediaQuery.of(context).size.height * 0.12, | ||
color: contColor, | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_bmi_calculator/core/components/button/calculate_button.dart'; | ||
import 'package:my_bmi_calculator/core/components/textfield/textfield.dart'; | ||
import 'package:my_bmi_calculator/core/components/textwidget/text.dart'; | ||
import 'package:my_bmi_calculator/core/constants/app_constants.dart'; | ||
import 'package:my_bmi_calculator/home/viewmodel/home_view_model.dart'; | ||
|
||
class DataInput extends StatefulWidget { | ||
const DataInput({Key? key}) : super(key: key); | ||
|
||
@override | ||
_DataInputState createState() => _DataInputState(); | ||
} | ||
|
||
class _DataInputState extends State<DataInput> { | ||
final TextEditingController _heightController = TextEditingController(); | ||
final TextEditingController _weightController = TextEditingController(); | ||
double _bmiResult = 0.0; | ||
static const String heigthText = "Your Height in cm"; | ||
static const String weigthText = "Your Weight in kg"; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
const MyText( | ||
text: heigthText, | ||
fontSize: 25, | ||
color: accentColor, | ||
), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.01, | ||
), | ||
// HEIGHT INPUT | ||
MyTextField(controller: _heightController), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.01, | ||
), | ||
const MyText( | ||
text: weigthText, | ||
fontSize: 25, | ||
color: accentColor, | ||
), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.01, | ||
), | ||
// WEIGHT INPUT | ||
MyTextField( | ||
controller: _weightController, | ||
), | ||
CalculateButton( | ||
heightController: _heightController, | ||
weightController: _weightController, | ||
callback: () { | ||
setState(() { | ||
_bmiResult = HomeViewModel().result( | ||
_heightController.text, _weightController.text, context)!; | ||
}); | ||
}), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.03, | ||
), | ||
MyText( | ||
text: 'Your BMI : ${_bmiResult.toStringAsFixed(2)}', | ||
fontSize: 42, | ||
color: accentColor, | ||
fontWeight: FontWeight.w300, | ||
), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.01, | ||
), | ||
SizedBox( | ||
width: MediaQuery.of(context).size.width * 0.5, | ||
child: const Divider( | ||
color: accentColor, | ||
height: 1, | ||
), | ||
), | ||
SizedBox( | ||
height: MediaQuery.of(context).size.height * 0.01, | ||
), | ||
MyText( | ||
text: HomeViewModel().controlResult(_bmiResult), | ||
fontSize: 42, | ||
color: accentColor, | ||
textAlign: TextAlign.center, | ||
fontWeight: FontWeight.w300, | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.