diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 9367d483..9625e105 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 00000000..6030d359 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/sachet/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/sachet/AndroidStudioProjects/bmi-calculator-flutter" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=/Users/sachet/AndroidStudioProjects/bmi-calculator-flutter/lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=/Users/sachet/AndroidStudioProjects/bmi-calculator-flutter/.dart_tool/package_config.json" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 1df82eba..f9a4f465 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,17 +3,12 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; @@ -29,8 +24,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -40,15 +33,12 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -62,8 +52,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -73,10 +61,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -155,7 +140,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -190,7 +175,6 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -200,6 +184,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -210,10 +195,11 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -263,7 +249,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -301,7 +286,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -335,7 +320,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -379,7 +363,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -389,7 +373,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -427,7 +410,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16..919434a6 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 786d6aad..f1560181 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/lib/bmi_brain.dart b/lib/bmi_brain.dart new file mode 100644 index 00000000..46a6d9a5 --- /dev/null +++ b/lib/bmi_brain.dart @@ -0,0 +1,33 @@ +import 'dart:math'; + +class CalculatorBrain { + CalculatorBrain({this.weight, this.height}); + final int height; + final int weight; + + double _bmi; + String calculateBMI() { + _bmi = weight / pow(height / 100, 2); + return _bmi.toStringAsFixed(1); + } + + String getResult() { + if (_bmi >= 25.0) { + return 'Overweight'; + } else if (_bmi > 18.5) { + return 'Normal'; + } else { + return 'Underweight'; + } + } + + String getInterpretation() { + if (_bmi >= 25.0) { + return 'You have a higher than normal body weight. Try to exercise more.'; + } else if (_bmi >= 18.5) { + return 'You have a normal body weight. Good job!'; + } else { + return 'You have a lower than normal body weight. You can eat a bit more.'; + } + } +} diff --git a/lib/components/Reusable_Card.dart b/lib/components/Reusable_Card.dart new file mode 100644 index 00000000..d0321467 --- /dev/null +++ b/lib/components/Reusable_Card.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; + +class ReusableCard extends StatelessWidget { + ReusableCard({@required this.colour, this.cardChild, this.onPress}); + final Widget cardChild; + final Color colour; + final Function onPress; + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onPress, + child: Container( + child: cardChild, + margin: EdgeInsets.all(15.0), + decoration: BoxDecoration( + color: colour, + borderRadius: BorderRadius.circular(10.0), + ), + ), + ); + } +} diff --git a/lib/components/bottomButton.dart b/lib/components/bottomButton.dart new file mode 100644 index 00000000..f1701578 --- /dev/null +++ b/lib/components/bottomButton.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:bmi_calculator/constants.dart'; + +class BottomButton extends StatelessWidget { + BottomButton({@required this.onTap, @required this.buttonTitle}); + final Function onTap; + final String buttonTitle; + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + color: kBottomContainerColor, + margin: EdgeInsets.only(top: 10.0), + height: 85.0, + width: double.infinity, + padding: EdgeInsets.only(bottom: 10), + child: Center( + child: Text( + buttonTitle, + style: TextStyle( + fontSize: 30.0, + fontWeight: FontWeight.w800, + ), + ), + ), + ), + ); + } +} diff --git a/lib/components/card_details.dart b/lib/components/card_details.dart new file mode 100644 index 00000000..bcba7b23 --- /dev/null +++ b/lib/components/card_details.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import '../constants.dart'; + +class cardDetails extends StatelessWidget { + cardDetails({this.cardIcon, this.cardText}); + + final IconData cardIcon; + final String cardText; + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + cardIcon, + size: 100, + ), + SizedBox( + height: 20, + ), + Text( + cardText, + style: kLabelStyle, + ), + ], + ); + } +} diff --git a/lib/components/roundIconButton.dart b/lib/components/roundIconButton.dart new file mode 100644 index 00000000..0b5d93e4 --- /dev/null +++ b/lib/components/roundIconButton.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:bmi_calculator/constants.dart'; + +class RoundIconButton extends StatelessWidget { + RoundIconButton({this.icon, this.onPressed}); + final IconData icon; + final Function onPressed; + @override + Widget build(BuildContext context) { + return RawMaterialButton( + onPressed: onPressed, + elevation: 5.0, + child: Icon(icon), + constraints: BoxConstraints.tightFor(width: 56, height: 56), + shape: CircleBorder(), + fillColor: Color(0xFF4C4F5E), + ); + } +} diff --git a/lib/constants.dart b/lib/constants.dart new file mode 100644 index 00000000..99b2e8a0 --- /dev/null +++ b/lib/constants.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +const kCardColour = Color(0xFF1D1E33); +const kTapCardColour = Color(0xFF111328); +const kBottomContainerColor = Color(0xFFEB1555); +const kNumberStyle = TextStyle( + fontSize: 50.0, + fontWeight: FontWeight.w900, +); +const kLabelStyle = TextStyle( + color: Color(0xCCCCCCFF), + fontSize: 20, + fontWeight: FontWeight.bold, +); +const kTitleTextStyle = TextStyle( + fontWeight: FontWeight.bold, + fontSize: 50.0, +); +const kResultTextStyle = TextStyle( + fontSize: 22.0, + color: Color(0xFF24D875), + fontWeight: FontWeight.bold, +); +const kBMIstyle = TextStyle( + fontWeight: FontWeight.bold, + fontSize: 100, +); +const kBodyStyle = TextStyle( + fontSize: 22, +); diff --git a/lib/main.dart b/lib/main.dart index 78f51b11..fd1e08e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'screens/input_page.dart'; void main() => runApp(BMICalculator()); @@ -6,29 +7,10 @@ class BMICalculator extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - home: InputPage(), - ); - } -} - -class InputPage extends StatefulWidget { - @override - _InputPageState createState() => _InputPageState(); -} - -class _InputPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('BMI CALCULATOR'), - ), - body: Center( - child: Text('Body Text'), - ), - floatingActionButton: FloatingActionButton( - child: Icon(Icons.add), + theme: ThemeData.dark().copyWith( + scaffoldBackgroundColor: Color(0xFF0A0E21), ), + home: InputPage(), ); } } diff --git a/lib/screens/input_page.dart b/lib/screens/input_page.dart new file mode 100644 index 00000000..9868c36e --- /dev/null +++ b/lib/screens/input_page.dart @@ -0,0 +1,236 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import '../components/Reusable_Card.dart'; +import '../components/card_details.dart'; +import '../constants.dart'; +import 'result_page.dart'; +import 'package:bmi_calculator/bmi_brain.dart'; +import 'package:bmi_calculator/components/bottomButton.dart'; +import 'package:bmi_calculator/components/roundIconButton.dart'; + +enum Gender { + male, + female, +} + +class InputPage extends StatefulWidget { + @override + _InputPageState createState() => _InputPageState(); +} + +class _InputPageState extends State { + Gender selectedGender; + int height = 180; + int weight = 60; + int age = 20; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('BMI CALCULATOR'), + backgroundColor: Color(0xFF0A0E21), + ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: ReusableCard( + onPress: () { + setState(() { + selectedGender = Gender.male; + }); + }, + colour: selectedGender == Gender.male + ? kTapCardColour + : kCardColour, + cardChild: cardDetails( + cardIcon: FontAwesomeIcons.mars, + cardText: 'MALE', + ), + ), + ), + Expanded( + child: ReusableCard( + onPress: () { + setState(() { + selectedGender = Gender.female; + }); + }, + colour: selectedGender == Gender.female + ? kTapCardColour + : kCardColour, + cardChild: cardDetails( + cardIcon: FontAwesomeIcons.venus, + cardText: 'FEMALE', + ), + ), + ) + ], + ), + ), + Expanded( + child: ReusableCard( + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Height', + style: kLabelStyle, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + Text( + height.toString(), + style: kNumberStyle, + ), + Text( + 'cm', + style: kLabelStyle, + ) + ], + ), + SliderTheme( + data: SliderTheme.of(context).copyWith( + activeTrackColor: Colors.white, + inactiveTrackColor: Color(0xFF8D8E98), + thumbColor: Color(0xFFEB1555), + overlayColor: Color(0x29EB1555), + thumbShape: + RoundSliderThumbShape(enabledThumbRadius: 15.0), + overlayShape: + RoundSliderOverlayShape(overlayRadius: 30.0), + ), + child: Slider( + value: height.toDouble(), + max: 220, + min: 120, + onChanged: (double newHeight) { + setState(() { + height = newHeight.round(); + }); + }), + ) + ], + ), + colour: kCardColour, + ), + ), + Expanded( + child: Row( + children: [ + Expanded( + child: ReusableCard( + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'WEIGHT', + style: kLabelStyle, + ), + Text( + weight.toString(), + style: kNumberStyle, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RoundIconButton( + icon: FontAwesomeIcons.minus, + onPressed: () { + setState(() { + weight--; + }); + }, + ), + SizedBox( + width: 15.0, + ), + RoundIconButton( + icon: FontAwesomeIcons.plus, + onPressed: () { + setState(() { + weight++; + }); + }, + ), + ], + ) + ], + ), + colour: kCardColour, + ), + ), + Expanded( + child: ReusableCard( + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'AGE', + style: kLabelStyle, + ), + Text( + age.toString(), + style: kNumberStyle, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RoundIconButton( + icon: FontAwesomeIcons.minus, + onPressed: () { + setState(() { + age--; + }); + }, + ), + SizedBox( + width: 15.0, + ), + RoundIconButton( + icon: FontAwesomeIcons.plus, + onPressed: () { + setState(() { + age++; + }); + }, + ), + ], + ) + ], + ), + colour: kCardColour, + ), + ) + ], + ), + ), + BottomButton( + onTap: () { + CalculatorBrain calc = + CalculatorBrain(height: height, weight: weight); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ResultsPage( + bmiResult: calc.calculateBMI(), + interpretation: calc.getInterpretation(), + resultText: calc.getResult(), + ), + ), + ); + }, + buttonTitle: 'CALCULATE', + ), + ], + ), + ); + } +} diff --git a/lib/screens/result_page.dart b/lib/screens/result_page.dart new file mode 100644 index 00000000..13fe65b9 --- /dev/null +++ b/lib/screens/result_page.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:bmi_calculator/constants.dart'; +import 'package:bmi_calculator/components/Reusable_Card.dart'; +import 'package:bmi_calculator/components/bottomButton.dart'; + +class ResultsPage extends StatelessWidget { + ResultsPage( + {@required this.bmiResult, + @required this.interpretation, + @required this.resultText}); + final String bmiResult; + final String resultText; + final String interpretation; + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('BMI CALCULATOR'), + backgroundColor: kTapCardColour, + ), + body: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Container( + padding: EdgeInsets.all(15), + alignment: Alignment.bottomLeft, + child: Text( + 'Your Result', + style: kTitleTextStyle, + ), + ), + ), + Expanded( + flex: 5, + child: ReusableCard( + colour: kCardColour, + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + resultText.toUpperCase(), + style: kResultTextStyle, + ), + Text( + bmiResult, + style: kBMIstyle, + ), + Text( + interpretation, + style: kBodyStyle, + textAlign: TextAlign.center, + ) + ], + ), + ), + ), + Expanded( + child: Column( + children: [ + SizedBox( + height: 20, + ), + Expanded( + child: BottomButton( + onTap: () { + Navigator.pop(context); + }, + buttonTitle: 'Re-Calculate', + ), + ), + ], + ), + ) + ], + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 6dc027c6..201d4d89 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: sdk: flutter cupertino_icons: ^0.1.2 + font_awesome_flutter: ^10.4.0 dev_dependencies: flutter_test: