diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f0151c3..333fdef 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -13,7 +13,6 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background"/> + diff --git a/android/app/src/main/java/co/appbrewery/bmicalculator/MainActivity.java b/android/app/src/main/java/co/appbrewery/bmicalculator/MainActivity.java index f6a4330..4f68f03 100644 --- a/android/app/src/main/java/co/appbrewery/bmicalculator/MainActivity.java +++ b/android/app/src/main/java/co/appbrewery/bmicalculator/MainActivity.java @@ -1,13 +1,7 @@ package co.appbrewery.bmicalculator; -import android.os.Bundle; -import io.flutter.app.FlutterActivity; -import io.flutter.plugins.GeneratedPluginRegistrant; +import io.flutter.embedding.android.FlutterActivity; public class MainActivity extends FlutterActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - GeneratedPluginRegistrant.registerWith(this); - } + } diff --git a/android/app/src/main/kotlin/co/appbrewery/bmicalculator/MainActivity.kt b/android/app/src/main/kotlin/co/appbrewery/bmicalculator/MainActivity.kt new file mode 100644 index 0000000..259b231 --- /dev/null +++ b/android/app/src/main/kotlin/co/appbrewery/bmicalculator/MainActivity.kt @@ -0,0 +1,6 @@ +package co.appbrewery.bmicalculator + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle index 6de3728..6c62fae 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,6 +24,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 92f82fb..1df82eb 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* 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, ); }; }; @@ -39,6 +40,7 @@ /* 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 = ""; }; @@ -71,6 +73,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEBA1CF902C7004384FC /* Flutter.framework */, @@ -187,6 +190,7 @@ 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; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings index 949b678..f9b0d7c 100644 --- a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -2,7 +2,7 @@ - BuildSystemType - Original + PreviewsEnabled + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/lib/calculator_brain.dart b/lib/calculator_brain.dart index 5783edd..1a01042 100644 --- a/lib/calculator_brain.dart +++ b/lib/calculator_brain.dart @@ -3,32 +3,42 @@ import 'dart:math'; class CalculatorBrain { CalculatorBrain({this.height, this.weight}); - final int height; - final int weight; + final int? height; + final int? weight; - double _bmi; + double _bmi = 0.0; String calculateBMI() { - _bmi = weight / pow(height / 100, 2); - return _bmi.toStringAsFixed(1); + if (height != null && weight != null) { + _bmi = weight! / pow(height! / 100, 2); + return _bmi.toStringAsFixed( + 1); // Returning the BMI as a string with 1 decimal place + } else { + return 'Invalid input'; // Return a message indicating invalid input if either height or weight is null + } } - String getResult() { - if (_bmi >= 25) { + + String getResult () { + if (_bmi > 25) { return 'Overweight'; - } else if (_bmi > 18.5) { + } + else if (_bmi > 18.5) { return 'Normal'; - } else { - return 'Underweight'; } + else { + return 'Underweight'; + } } String getInterpretation() { - if (_bmi >= 25) { - return 'You have a higher than normal body weight. Try to exercise more.'; - } else if (_bmi >= 18.5) { + if (_bmi > 25) { + 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 { + } + else { return 'You have a lower than normal body weight. You can eat a bit more.'; } } diff --git a/lib/components/bottom_button.dart b/lib/components/bottomButton.dart similarity index 68% rename from lib/components/bottom_button.dart rename to lib/components/bottomButton.dart index d2822f2..1057b97 100644 --- a/lib/components/bottom_button.dart +++ b/lib/components/bottomButton.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:bmi_calculator/constants.dart'; +import '../constants.dart'; class BottomButton extends StatelessWidget { - BottomButton({@required this.onTap, @required this.buttonTitle}); + BottomButton({required this.onTap, @required this.buttonTitle}); - final Function onTap; - final String buttonTitle; + final VoidCallback onTap; + final String? buttonTitle; @override Widget build(BuildContext context) { @@ -14,14 +14,14 @@ class BottomButton extends StatelessWidget { child: Container( child: Center( child: Text( - buttonTitle, + buttonTitle.toString(), style: kLargeButtonTextStyle, ), ), - color: kBottomContainerColour, + color: kBottomContainerClr, margin: EdgeInsets.only(top: 10.0), - padding: EdgeInsets.only(bottom: 20.0), width: double.infinity, + padding: EdgeInsets.only(bottom: 20.0), height: kBottomContainerHeight, ), ); diff --git a/lib/components/icon_content.dart b/lib/components/icon_content.dart index 474bda6..736a151 100644 --- a/lib/components/icon_content.dart +++ b/lib/components/icon_content.dart @@ -1,11 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:bmi_calculator/constants.dart'; + +import '../constants.dart'; + class IconContent extends StatelessWidget { - IconContent({this.icon, this.label}); - final IconData icon; - final String label; + IconContent({this.icn, this.label}); + + final IconData? icn; + final String? label; @override Widget build(BuildContext context) { @@ -13,16 +16,13 @@ class IconContent extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( - icon, + icn ?? Icons.error, size: 80.0, ), SizedBox( height: 15.0, ), - Text( - label, - style: kLabelTextStyle, - ) + Text(label ?? '', style: kLabelTextStyle,) ], ); } diff --git a/lib/components/reusable_card.dart b/lib/components/reusable_card.dart index c5d65de..5a805b3 100644 --- a/lib/components/reusable_card.dart +++ b/lib/components/reusable_card.dart @@ -1,11 +1,14 @@ import 'package:flutter/material.dart'; + class ReusableCard extends StatelessWidget { - ReusableCard({@required this.colour, this.cardChild, this.onPress}); - final Color colour; - final Widget cardChild; - final Function onPress; + ReusableCard({required this.clr, this.cardChild, this.onPress}); + + final Color clr; + + final Widget? cardChild; + final VoidCallback? onPress; @override Widget build(BuildContext context) { @@ -15,7 +18,7 @@ class ReusableCard extends StatelessWidget { child: cardChild, margin: EdgeInsets.all(15.0), decoration: BoxDecoration( - color: colour, + color: clr, borderRadius: BorderRadius.circular(10.0), ), ), diff --git a/lib/components/round_icon_button.dart b/lib/components/round_iconButton.dart similarity index 71% rename from lib/components/round_icon_button.dart rename to lib/components/round_iconButton.dart index 966bca5..25316c7 100644 --- a/lib/components/round_icon_button.dart +++ b/lib/components/round_iconButton.dart @@ -1,23 +1,26 @@ import 'package:flutter/material.dart'; +import '../constants.dart'; + + class RoundIconButton extends StatelessWidget { + RoundIconButton({@required this.icon, @required this.onPressed}); - final IconData icon; - final Function onPressed; + final IconData? icon; + final VoidCallback? onPressed; @override Widget build(BuildContext context) { - return RawMaterialButton( - elevation: 0.0, + return RawMaterialButton(onPressed: onPressed, + shape: CircleBorder(), child: Icon(icon), - onPressed: onPressed, + elevation: 4.0, + fillColor: Color(0xFF4C4F5E), constraints: BoxConstraints.tightFor( width: 56.0, height: 56.0, ), - shape: CircleBorder(), - fillColor: Color(0xFF4C4F5E), ); } } diff --git a/lib/constants.dart b/lib/constants.dart index 8ea4ec1..97dd904 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,30 +1,33 @@ import 'package:flutter/material.dart'; -const kBottomContainerHeight = 80.0; -const kActiveCardColour = Color(0xFF1D1E33); -const kInactiveCardColour = Color(0xFF111328); -const kBottomContainerColour = Color(0xFFEB1555); -const kLabelTextStyle = TextStyle( - fontSize: 18.0, - color: Color(0xFF8D8E98), -); + +const kBottomContainerHeight = 80.0; +const kActiveCardColor = Color(0xFF1D1E33); +const kBottomContainerClr = Color(0xFFEB1555); +// const activeCardColor = Color(0xFF1d1E33); +const kInactiveCardColor = Color(0xFF111328); const kNumberTextStyle = TextStyle( - fontSize: 50.0, - fontWeight: FontWeight.w900, +fontSize: 50.0, +fontWeight: FontWeight.w900, ); const kLargeButtonTextStyle = TextStyle( fontSize: 25.0, fontWeight: FontWeight.bold, ); +const kLabelTextStyle = TextStyle( + fontSize: 18.0, + color: Color(0xFF8D8E98), +); const kTitleTextStyle = TextStyle( fontSize: 50.0, fontWeight: FontWeight.bold, ); + const kResultTextStyle = TextStyle( color: Color(0xFF24D876), fontSize: 22.0, @@ -38,4 +41,4 @@ const kBMITextStyle = TextStyle( const kBodyTextStyle = TextStyle( fontSize: 22.0, -); +); \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 2d04eb6..0be8c94 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:bmi_calculator/screens/input_page.dart'; +import 'screens/input_page.dart'; void main() => runApp(BMICalculator()); @@ -7,11 +7,19 @@ class BMICalculator extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - theme: ThemeData.dark().copyWith( - primaryColor: Color(0xFF0A0E21), - scaffoldBackgroundColor: Color(0xFF0A0E21), + theme: ThemeData.dark( + + ).copyWith( + primaryColor: Color(0xFF0A0E21), + appBarTheme: AppBarTheme( + backgroundColor: Color(0xFF0A0E21), + ), + scaffoldBackgroundColor: Color(0xFF0A0E21), + // colorScheme: ColorScheme.fromSwatch() + // .copyWith(secondary: Colors.purple), ), home: InputPage(), ); } } + diff --git a/lib/screens/input_page.dart b/lib/screens/input_page.dart index d3da204..7c8b4a2 100644 --- a/lib/screens/input_page.dart +++ b/lib/screens/input_page.dart @@ -1,16 +1,16 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:bmi_calculator/components/icon_content.dart'; -import 'package:bmi_calculator/components/reusable_card.dart'; -import 'package:bmi_calculator/constants.dart'; -import 'package:bmi_calculator/screens/results_page.dart'; -import 'package:bmi_calculator/components/bottom_button.dart'; -import 'package:bmi_calculator/components/round_icon_button.dart'; -import 'package:bmi_calculator/calculator_brain.dart'; +import 'package:bmicalculator/components/reusable_card.dart'; +import '../components/icon_content.dart'; +import '../constants.dart'; +import 'package:bmicalculator/screens/results_page.dart'; +import '../components/bottomButton.dart'; +import '../components/round_iconButton.dart'; +import 'package:bmicalculator/calculator_brain.dart'; enum Gender { - male, - female, + Male, + Female, } class InputPage extends StatefulWidget { @@ -19,218 +19,190 @@ class InputPage extends StatefulWidget { } class _InputPageState extends State { - Gender selectedGender; + Gender? selectedGender; int height = 180; - int weight = 60; - int age = 20; + int weight = 55; + int age = 21; + @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text('BMI CALCULATOR'), - ), - body: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: Row( - children: [ - Expanded( - child: ReusableCard( - onPress: () { - setState(() { - selectedGender = Gender.male; - }); - }, - colour: selectedGender == Gender.male - ? kActiveCardColour - : kInactiveCardColour, - cardChild: IconContent( - icon: FontAwesomeIcons.mars, - label: 'MALE', + appBar: AppBar( + title: Text('BMI CALCULATOR'), + ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: ReusableCard( + onPress: () { + setState(() { + selectedGender = Gender.Male; + }); + }, + clr: selectedGender == Gender.Male + ? kActiveCardColor + : kInactiveCardColor, + cardChild: IconContent( + icn: FontAwesomeIcons.mars, + label: 'MALE', + ), ), ), - ), - Expanded( - child: ReusableCard( + Expanded( + child: ReusableCard( onPress: () { setState(() { - selectedGender = Gender.female; + selectedGender = Gender.Female; }); }, - colour: selectedGender == Gender.female - ? kActiveCardColour - : kInactiveCardColour, + clr: selectedGender == Gender.Female + ? kActiveCardColor + : kInactiveCardColor, cardChild: IconContent( - icon: FontAwesomeIcons.venus, + icn: FontAwesomeIcons.venus, label: 'FEMALE', ), - ), - ), - ], - )), - Expanded( - child: ReusableCard( - colour: kActiveCardColour, - cardChild: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'HEIGHT', - style: kLabelTextStyle, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.baseline, - textBaseline: TextBaseline.alphabetic, - children: [ - Text( - height.toString(), - style: kNumberTextStyle, - ), - Text( - 'cm', - style: kLabelTextStyle, - ) - ], - ), - SliderTheme( - data: SliderTheme.of(context).copyWith( - inactiveTrackColor: Color(0xFF8D8E98), - activeTrackColor: Colors.white, - thumbColor: Color(0xFFEB1555), - overlayColor: Color(0x29EB1555), - thumbShape: - RoundSliderThumbShape(enabledThumbRadius: 15.0), - overlayShape: - RoundSliderOverlayShape(overlayRadius: 30.0), - ), - child: Slider( - value: height.toDouble(), - min: 120.0, - max: 220.0, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - ), - ), - ], - ), - ), - ), - Expanded( - child: Row( - children: [ - Expanded( - child: ReusableCard( - colour: kActiveCardColour, - cardChild: Column( + )), + ], + )), + Expanded( + child: ReusableCard( + clr: kActiveCardColor, + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + + children: [ + Text('Height', style: kLabelTextStyle), + Row( mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, children: [ Text( - 'WEIGHT', - style: kLabelTextStyle, - ), - Text( - weight.toString(), + height.toString(), style: kNumberTextStyle, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RoundIconButton( - icon: FontAwesomeIcons.minus, - onPressed: () { - setState(() { - weight--; - }); - }), - SizedBox( - width: 10.0, - ), - RoundIconButton( - icon: FontAwesomeIcons.plus, - onPressed: () { - setState(() { - weight++; - }); - }, - ), - ], - ), + Text( + 'cm', style: kLabelTextStyle, + ) ], ), - ), + SliderTheme( + data: SliderTheme.of(context).copyWith( + thumbShape: RoundSliderThumbShape(enabledThumbRadius: 15.0), + overlayShape: RoundSliderOverlayShape(overlayRadius: 30.0), + thumbColor: Color(0xFFEB1555), + activeTrackColor: Colors.white, + overlayColor: Color(0x1fEB1555), + inactiveTrackColor: Color(0xFF8D8E98), + ), + child: Slider( + value: height.toDouble(), + min: 120.0, + max: 220.0, + onChanged: (double newValue){ + setState(() { + height = newValue.round(); + }); + }, + ), + ) + ], ), - Expanded( - child: ReusableCard( - colour: kActiveCardColour, - cardChild: Column( + ), + ), + Expanded( + child: Row( + children: [ + Expanded(child: ReusableCard(clr: kActiveCardColor, + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('Weight', style: kLabelTextStyle), + Text( + weight.toString(), + style: kNumberTextStyle, + ), + Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'AGE', - style: kLabelTextStyle, - ), - Text( - age.toString(), - style: kNumberTextStyle, + children: [ + RoundIconButton(icon: FontAwesomeIcons.minus, + onPressed: (){ + setState(() { + weight--; + }); + },), + SizedBox( + width: 10.0, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - RoundIconButton( - icon: FontAwesomeIcons.minus, - onPressed: () { - setState( - () { - age--; - }, - ); - }, - ), - SizedBox( - width: 10.0, - ), - RoundIconButton( - icon: FontAwesomeIcons.plus, - onPressed: () { - setState(() { - age++; - }); - }) - ], - ) + RoundIconButton(icon: FontAwesomeIcons.plus, + onPressed: (){ + setState(() { + weight++; + }); + },), ], + ) + ], + + ), + )), + Expanded(child: ReusableCard(clr: kActiveCardColor, + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'AGE', + style: kLabelTextStyle, ), - ), + Text( + age.toString(), + style: kNumberTextStyle, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RoundIconButton(icon: FontAwesomeIcons.minus, onPressed: (){ + setState(() { + age--; + }); + }), + SizedBox( + width: 10.0, + ), + RoundIconButton(icon: FontAwesomeIcons.plus, onPressed: (){ + setState(() { + age++; + }); + }) + ], + ) + + ], ), + )), ], - ), - ), - BottomButton( - buttonTitle: 'CALCULATE', - onTap: () { - CalculatorBrain calc = - CalculatorBrain(height: height, weight: weight); + )), + BottomButton(buttonTitle: 'CALCULATE', onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ResultsPage( - bmiResult: calc.calculateBMI(), - resultText: calc.getResult(), - interpretation: calc.getInterpretation(), - ), - ), - ); - }, - ), - ], - ), - ); + CalculatorBrain calc = CalculatorBrain(height: height, weight: weight); + + + + Navigator.push(context, MaterialPageRoute(builder: (context) => ResultsPage( + bmiResult: calc.calculateBMI(), + resultText: calc.getResult(), + interpretation: calc.getInterpretation(), + ))); + },), + ], + )); } } + + diff --git a/lib/screens/results_page.dart b/lib/screens/results_page.dart index 5fe5239..a243d50 100644 --- a/lib/screens/results_page.dart +++ b/lib/screens/results_page.dart @@ -1,17 +1,16 @@ +import 'package:bmicalculator/constants.dart'; import 'package:flutter/material.dart'; -import 'package:bmi_calculator/constants.dart'; -import 'package:bmi_calculator/components/reusable_card.dart'; -import 'package:bmi_calculator/components/bottom_button.dart'; +import 'package:bmicalculator/components/reusable_card.dart'; +import 'package:bmicalculator/components/bottomButton.dart'; class ResultsPage extends StatelessWidget { - ResultsPage( - {@required this.interpretation, - @required this.bmiResult, - @required this.resultText}); - final String bmiResult; - final String resultText; - final String interpretation; + ResultsPage({required this.bmiResult, required this.resultText, required this.interpretation}); + + final String bmiResult; + final String resultText; + final String interpretation; + @override Widget build(BuildContext context) { @@ -22,48 +21,37 @@ class ResultsPage extends StatelessWidget { body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: Container( - padding: EdgeInsets.all(15.0), - alignment: Alignment.bottomLeft, - child: Text( - 'Your Result', - style: kTitleTextStyle, - ), - ), - ), - Expanded( - flex: 5, - child: ReusableCard( - colour: kActiveCardColour, - cardChild: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - resultText.toUpperCase(), - style: kResultTextStyle, - ), - Text( - bmiResult, - style: kBMITextStyle, - ), - Text( - interpretation, - textAlign: TextAlign.center, - style: kBodyTextStyle, - ), - ], + children: [ + Expanded(child: Container( + padding: EdgeInsets.all(15.0), + alignment: Alignment.bottomLeft, + child: Text('Your Result', style: kTitleTextStyle,), + )), + Expanded(flex: 5, + child: ReusableCard(clr: kActiveCardColor, + cardChild: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text(resultText.toUpperCase(), style: kResultTextStyle,), + Text( + bmiResult.toUpperCase(), + style: kBMITextStyle, ), - ), + Padding( + padding: const EdgeInsets.only(left: 2.0, right: 2.0), + child: Text( + interpretation.toUpperCase(), + style: kBodyTextStyle, + textAlign: TextAlign.center, + ), + ) + ], + ),), ), - BottomButton( - buttonTitle: 'RE-CALCULATE', - onTap: () { - Navigator.pop(context); - }, - ) + BottomButton(onTap: (){ + Navigator.pop(context); + }, buttonTitle: 'RE-CALCULATE') ], ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 6dded66..3ae557f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,21 +1,22 @@ -name: bmi_calculator +name: bmicalculator description: A new Flutter application. version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.6" dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.2 - font_awesome_flutter: ^8.4.0 + cupertino_icons: ^1.0.5 dev_dependencies: + font_awesome_flutter: ^10.5.0 flutter_test: sdk: flutter + flutter_lints: ^1.0.0 flutter: uses-material-design: true