From 35c0e888ad8d2717f2d6949f002f265a6c2abdb8 Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Wed, 5 Apr 2023 23:49:59 +0530 Subject: [PATCH 1/7] App Updated --- ios/Flutter/AppFrameworkInfo.plist | 2 +- ios/Runner.xcodeproj/project.pbxproj | 33 ++--- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- ios/Runner/Info.plist | 4 + lib/Reusable_Card.dart | 18 +++ lib/card_details.dart | 33 +++++ lib/input_page.dart | 120 ++++++++++++++++++ lib/main.dart | 26 +--- pubspec.yaml | 1 + 10 files changed, 191 insertions(+), 50 deletions(-) create mode 100644 lib/Reusable_Card.dart create mode 100644 lib/card_details.dart create mode 100644 lib/input_page.dart 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/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/Reusable_Card.dart b/lib/Reusable_Card.dart new file mode 100644 index 00000000..ff6f7d4f --- /dev/null +++ b/lib/Reusable_Card.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class ReusableCard extends StatelessWidget { + ReusableCard({@required this.colour, this.cardChild}); + final Widget cardChild; + final Color colour; + @override + Widget build(BuildContext context) { + return Container( + child: cardChild, + margin: EdgeInsets.all(15.0), + decoration: BoxDecoration( + color: colour, + borderRadius: BorderRadius.circular(10.0), + ), + ); + } +} diff --git a/lib/card_details.dart b/lib/card_details.dart new file mode 100644 index 00000000..67b6f681 --- /dev/null +++ b/lib/card_details.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; + +const labelStyle = TextStyle( + color: Color(0xCCCCCCFF), + fontSize: 17, + fontWeight: FontWeight.bold, +); + +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: labelStyle, + ), + ], + ); + } +} diff --git a/lib/input_page.dart b/lib/input_page.dart new file mode 100644 index 00000000..79bd61d8 --- /dev/null +++ b/lib/input_page.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'Reusable_Card.dart'; +import 'card_details.dart'; + +const cardColour = Color(0xFF1D1E33); +const tapCardColour = Color(0xFF111328); +const bottomContainerColor = Color(0xFFEB1555); + +enum Gender { + male, + female, +} + +class InputPage extends StatefulWidget { + @override + _InputPageState createState() => _InputPageState(); +} + +class _InputPageState extends State { + Color maleCardColor = cardColour; + Color femaleCardColor = cardColour; + + void updateColor(Gender gender) { + if (gender == Gender.male) { + if (maleCardColor == cardColour) { + maleCardColor = tapCardColour; + femaleCardColor = cardColour; + } else { + maleCardColor = cardColour; + } + } else if (gender == Gender.female) { + if (femaleCardColor == cardColour) { + maleCardColor = cardColour; + femaleCardColor = tapCardColour; + } else { + femaleCardColor = cardColour; + } + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('BMI CALCULATOR'), + backgroundColor: Color(0xFF0A0E21), + ), + body: Column( + children: [ + Expanded( + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(Gender.male); + }); + }, + child: ReusableCard( + colour: maleCardColor, + cardChild: cardDetails( + cardIcon: FontAwesomeIcons.mars, + cardText: 'MALE', + ), + ), + ), + ), + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(Gender.female); + }); + }, + child: ReusableCard( + colour: femaleCardColor, + cardChild: cardDetails( + cardIcon: FontAwesomeIcons.venus, + cardText: 'FEMALE', + ), + ), + ), + ) + ], + ), + ), + Expanded( + child: ReusableCard( + colour: cardColour, + ), + ), + Expanded( + child: Row( + children: [ + Expanded( + child: ReusableCard( + colour: cardColour, + ), + ), + Expanded( + child: ReusableCard( + colour: cardColour, + ), + ) + ], + ), + ), + Container( + color: bottomContainerColor, + margin: EdgeInsets.only(top: 10.0), + height: 80.0, + width: double.infinity, + ), + ], + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 78f51b11..df25554f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import '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/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: From 38b0f00c561426d99306d1ff5e7ae568503f0750 Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Thu, 6 Apr 2023 10:17:56 +0530 Subject: [PATCH 2/7] App Updated --- lib/input_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/input_page.dart b/lib/input_page.dart index 79bd61d8..bcfa1c0a 100644 --- a/lib/input_page.dart +++ b/lib/input_page.dart @@ -110,7 +110,7 @@ class _InputPageState extends State { Container( color: bottomContainerColor, margin: EdgeInsets.only(top: 10.0), - height: 80.0, + height: 85.0, width: double.infinity, ), ], From b69581e22ce6466373e23e34619ac59ffa524db6 Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Mon, 17 Apr 2023 23:31:16 +0530 Subject: [PATCH 3/7] Input Page Completed --- lib/Reusable_Card.dart | 18 ---- lib/bmi_brain.dart | 0 lib/components/Reusable_Card.dart | 22 ++++ lib/{ => components}/card_details.dart | 10 +- lib/constants.dart | 14 +++ lib/input_page.dart | 120 ---------------------- lib/main.dart | 2 +- lib/screens/input_page.dart | 135 +++++++++++++++++++++++++ 8 files changed, 175 insertions(+), 146 deletions(-) delete mode 100644 lib/Reusable_Card.dart create mode 100644 lib/bmi_brain.dart create mode 100644 lib/components/Reusable_Card.dart rename lib/{ => components}/card_details.dart (78%) create mode 100644 lib/constants.dart delete mode 100644 lib/input_page.dart create mode 100644 lib/screens/input_page.dart diff --git a/lib/Reusable_Card.dart b/lib/Reusable_Card.dart deleted file mode 100644 index ff6f7d4f..00000000 --- a/lib/Reusable_Card.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; - -class ReusableCard extends StatelessWidget { - ReusableCard({@required this.colour, this.cardChild}); - final Widget cardChild; - final Color colour; - @override - Widget build(BuildContext context) { - return Container( - child: cardChild, - margin: EdgeInsets.all(15.0), - decoration: BoxDecoration( - color: colour, - borderRadius: BorderRadius.circular(10.0), - ), - ); - } -} diff --git a/lib/bmi_brain.dart b/lib/bmi_brain.dart new file mode 100644 index 00000000..e69de29b 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/card_details.dart b/lib/components/card_details.dart similarity index 78% rename from lib/card_details.dart rename to lib/components/card_details.dart index 67b6f681..bcba7b23 100644 --- a/lib/card_details.dart +++ b/lib/components/card_details.dart @@ -1,13 +1,9 @@ import 'package:flutter/material.dart'; - -const labelStyle = TextStyle( - color: Color(0xCCCCCCFF), - fontSize: 17, - fontWeight: FontWeight.bold, -); +import '../constants.dart'; class cardDetails extends StatelessWidget { cardDetails({this.cardIcon, this.cardText}); + final IconData cardIcon; final String cardText; @@ -25,7 +21,7 @@ class cardDetails extends StatelessWidget { ), Text( cardText, - style: labelStyle, + style: kLabelStyle, ), ], ); diff --git a/lib/constants.dart b/lib/constants.dart new file mode 100644 index 00000000..035f6730 --- /dev/null +++ b/lib/constants.dart @@ -0,0 +1,14 @@ +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, +); diff --git a/lib/input_page.dart b/lib/input_page.dart deleted file mode 100644 index bcfa1c0a..00000000 --- a/lib/input_page.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'Reusable_Card.dart'; -import 'card_details.dart'; - -const cardColour = Color(0xFF1D1E33); -const tapCardColour = Color(0xFF111328); -const bottomContainerColor = Color(0xFFEB1555); - -enum Gender { - male, - female, -} - -class InputPage extends StatefulWidget { - @override - _InputPageState createState() => _InputPageState(); -} - -class _InputPageState extends State { - Color maleCardColor = cardColour; - Color femaleCardColor = cardColour; - - void updateColor(Gender gender) { - if (gender == Gender.male) { - if (maleCardColor == cardColour) { - maleCardColor = tapCardColour; - femaleCardColor = cardColour; - } else { - maleCardColor = cardColour; - } - } else if (gender == Gender.female) { - if (femaleCardColor == cardColour) { - maleCardColor = cardColour; - femaleCardColor = tapCardColour; - } else { - femaleCardColor = cardColour; - } - } - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('BMI CALCULATOR'), - backgroundColor: Color(0xFF0A0E21), - ), - body: Column( - children: [ - Expanded( - child: Row( - children: [ - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColor(Gender.male); - }); - }, - child: ReusableCard( - colour: maleCardColor, - cardChild: cardDetails( - cardIcon: FontAwesomeIcons.mars, - cardText: 'MALE', - ), - ), - ), - ), - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColor(Gender.female); - }); - }, - child: ReusableCard( - colour: femaleCardColor, - cardChild: cardDetails( - cardIcon: FontAwesomeIcons.venus, - cardText: 'FEMALE', - ), - ), - ), - ) - ], - ), - ), - Expanded( - child: ReusableCard( - colour: cardColour, - ), - ), - Expanded( - child: Row( - children: [ - Expanded( - child: ReusableCard( - colour: cardColour, - ), - ), - Expanded( - child: ReusableCard( - colour: cardColour, - ), - ) - ], - ), - ), - Container( - color: bottomContainerColor, - margin: EdgeInsets.only(top: 10.0), - height: 85.0, - width: double.infinity, - ), - ], - ), - ); - } -} diff --git a/lib/main.dart b/lib/main.dart index df25554f..fd1e08e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'input_page.dart'; +import 'screens/input_page.dart'; void main() => runApp(BMICalculator()); diff --git a/lib/screens/input_page.dart b/lib/screens/input_page.dart new file mode 100644 index 00000000..cf6a0310 --- /dev/null +++ b/lib/screens/input_page.dart @@ -0,0 +1,135 @@ +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'; + +enum Gender { + male, + female, +} + +class InputPage extends StatefulWidget { + @override + _InputPageState createState() => _InputPageState(); +} + +class _InputPageState extends State { + Gender selectedGender; + int height = 180; + + @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, + ) + ], + ), + Slider( + value: height.toDouble(), + max: 220, + min: 120, + activeColor: Color(0xFFEB1555), + inactiveColor: Color(0xFF8D8E98), + onChanged: (double newHeight) { + setState(() { + height = newHeight.round(); + }); + }) + ], + ), + colour: kCardColour, + ), + ), + Expanded( + child: Row( + children: [ + Expanded( + child: ReusableCard( + colour: kCardColour, + ), + ), + Expanded( + child: ReusableCard( + colour: kCardColour, + ), + ) + ], + ), + ), + Container( + color: kBottomContainerColor, + margin: EdgeInsets.only(top: 10.0), + height: 85.0, + width: double.infinity, + ), + ], + ), + ); + } +} From 27a42a3d851d98cba013a4aba04eeb83e551f1ab Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:47:48 +0530 Subject: [PATCH 4/7] Result page added --- lib/screens/input_page.dart | 151 +++++++++++++++++++++++++++++++---- lib/screens/result_page.dart | 13 +++ 2 files changed, 148 insertions(+), 16 deletions(-) create mode 100644 lib/screens/result_page.dart diff --git a/lib/screens/input_page.dart b/lib/screens/input_page.dart index cf6a0310..d943a9c7 100644 --- a/lib/screens/input_page.dart +++ b/lib/screens/input_page.dart @@ -3,6 +3,7 @@ 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'; enum Gender { male, @@ -17,6 +18,8 @@ class InputPage extends StatefulWidget { class _InputPageState extends State { Gender selectedGender; int height = 180; + int weight = 60; + int age = 20; @override Widget build(BuildContext context) { @@ -90,17 +93,27 @@ class _InputPageState extends State { ) ], ), - Slider( - value: height.toDouble(), - max: 220, - min: 120, - activeColor: Color(0xFFEB1555), - inactiveColor: Color(0xFF8D8E98), - onChanged: (double newHeight) { - setState(() { - height = newHeight.round(); - }); - }) + 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, @@ -111,25 +124,131 @@ class _InputPageState extends State { 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, ), ) ], ), ), - Container( - color: kBottomContainerColor, - margin: EdgeInsets.only(top: 10.0), - height: 85.0, - width: double.infinity, + GestureDetector( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => ResultsPage())); + }, + child: Container( + color: kBottomContainerColor, + margin: EdgeInsets.only(top: 10.0), + height: 85.0, + width: double.infinity, + child: Center( + child: Text( + 'CALCULATE', + style: TextStyle( + fontSize: 30.0, + fontWeight: FontWeight.w800, + ), + ), + ), + ), ), ], ), ); } } + +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/screens/result_page.dart b/lib/screens/result_page.dart new file mode 100644 index 00000000..84c7de04 --- /dev/null +++ b/lib/screens/result_page.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; + +class ResultsPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('BMI CALCULATOR'), + ), + body: Text('HELLO'), + ); + } +} From 86de6a6ade75c09dd9a49a375d5de4f90986a3b9 Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Mon, 24 Apr 2023 23:57:17 +0530 Subject: [PATCH 5/7] Result page added --- lib/screens/result_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screens/result_page.dart b/lib/screens/result_page.dart index 84c7de04..c16f95c9 100644 --- a/lib/screens/result_page.dart +++ b/lib/screens/result_page.dart @@ -7,7 +7,7 @@ class ResultsPage extends StatelessWidget { appBar: AppBar( title: Text('BMI CALCULATOR'), ), - body: Text('HELLO'), + body: Text('Hi'), ); } } From 0ede7341537d13de2ec2335b8710a0a7aed5a8ed Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Tue, 25 Apr 2023 23:05:59 +0530 Subject: [PATCH 6/7] Result page --- ios/Flutter/flutter_export_environment.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 ios/Flutter/flutter_export_environment.sh 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" From a1001096087fdb3dc6877a5e702b2c2cdaa927ca Mon Sep 17 00:00:00 2001 From: SachetVijay <81145614+SachetVijay@users.noreply.github.com> Date: Tue, 23 May 2023 11:43:48 +0530 Subject: [PATCH 7/7] Final App Completed --- lib/bmi_brain.dart | 33 ++++++++++++++ lib/components/bottomButton.dart | 30 +++++++++++++ lib/components/roundIconButton.dart | 19 ++++++++ lib/constants.dart | 16 +++++++ lib/screens/input_page.dart | 50 +++++++-------------- lib/screens/result_page.dart | 70 ++++++++++++++++++++++++++++- 6 files changed, 183 insertions(+), 35 deletions(-) create mode 100644 lib/components/bottomButton.dart create mode 100644 lib/components/roundIconButton.dart diff --git a/lib/bmi_brain.dart b/lib/bmi_brain.dart index e69de29b..46a6d9a5 100644 --- a/lib/bmi_brain.dart +++ 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/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/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 index 035f6730..99b2e8a0 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -12,3 +12,19 @@ const kLabelStyle = TextStyle( 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/screens/input_page.dart b/lib/screens/input_page.dart index d943a9c7..9868c36e 100644 --- a/lib/screens/input_page.dart +++ b/lib/screens/input_page.dart @@ -4,6 +4,9 @@ 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, @@ -209,46 +212,25 @@ class _InputPageState extends State { ], ), ), - GestureDetector( + BottomButton( onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => ResultsPage())); - }, - child: Container( - color: kBottomContainerColor, - margin: EdgeInsets.only(top: 10.0), - height: 85.0, - width: double.infinity, - child: Center( - child: Text( - 'CALCULATE', - style: TextStyle( - fontSize: 30.0, - fontWeight: FontWeight.w800, + 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', ), ], ), ); } } - -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/screens/result_page.dart b/lib/screens/result_page.dart index c16f95c9..13fe65b9 100644 --- a/lib/screens/result_page.dart +++ b/lib/screens/result_page.dart @@ -1,13 +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', + ), + ), + ], + ), + ) + ], ), - body: Text('Hi'), ); } }