diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 228de48..2770a98 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ _AppBodyState(); @@ -28,6 +30,19 @@ double calculateBMI({String weight, String height}) { var result = (_weight / pow(_height, 2)); print('result is $result'); + + if (result < 7.5) { + Fluttertoast.showToast( + msg: 'Your BMI is too low. Make sure your entered data is correct', + backgroundColor: Colors.yellow[900], + toastLength: Toast.LENGTH_LONG); + } else if (result > 41) { + Fluttertoast.showToast( + msg: 'Your BMI is too high. Make sure your entered data is correct', + backgroundColor: Colors.yellow[900], + ); + } + return result; } @@ -85,6 +100,7 @@ class _AppBodyState extends State { ), Row( crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Container( @@ -158,6 +174,7 @@ class _AppBodyState extends State { weight: weightController.text) .toStringAsFixed(1); calculatedBmi = answer; + bmiResult = answer; }); } }, diff --git a/lib/main.dart b/lib/main.dart index a1bd311..b82009b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:share/share.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'AppBody.dart'; @@ -38,7 +40,13 @@ class MyHomePage extends StatelessWidget { icon: Icon(Icons.share), onPressed: () { print('Pressed'); - Share.share('Not implemented yet :")'); + if (bmiResult != null) { + Share.share('My BMI is $bmiResult'); + } else { + Fluttertoast.showToast( + msg: 'Calculate your BMI first', + backgroundColor: Colors.red); + } }, tooltip: 'Share your current BMI', ), @@ -49,12 +57,27 @@ class MyHomePage extends StatelessWidget { showAboutDialog( context: context, applicationName: 'BMI Calculator Lite', - applicationVersion: '1.0.0-pre+1', + applicationVersion: '1.0.0+2', applicationIcon: Image.network( 'https://firebasestorage.googleapis.com/v0/b/bmi-flutter-2e776.appspot.com/o/logounnamed%20(Custom).png?alt=media&token=b22b53f7-bfc6-4a9b-89f3-92e681d1fe6c', width: 50, ), - applicationLegalese: '© maplerr aka fareez'); + applicationLegalese: '©maplerr 2020', + children: [ + SizedBox( + height: 10.0, + ), + aboutLinkButton( + title: "View on GitHub", + url: + 'https://github.com/fareezMaple/bmi_calculator-Flutter'), + aboutLinkButton( + title: 'Follow me on Twitter', + url: 'https://twitter.com/iqfareez2'), + aboutLinkButton( + title: 'Open on web', + url: 'https://bmi-flutter-2e776.web.app/'), + ]); }, tooltip: 'View some info', ) @@ -65,3 +88,20 @@ class MyHomePage extends StatelessWidget { ); } } + +_launchURL(String url) async { + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } +} + +Widget aboutLinkButton({String title, String url}) { + return OutlineButton( + child: Text(title), + onPressed: () { + _launchURL(url); + }, + ); +} diff --git a/pubspec.lock b/pubspec.lock index 152444b..9eb641d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -83,13 +83,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_linkify: - dependency: "direct main" - description: - name: flutter_linkify - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.3" flutter_test: dependency: "direct dev" description: flutter @@ -135,13 +128,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" - linkify: - dependency: transitive - description: - name: linkify - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2ae5cca..0a3d78c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0-pre+1 +version: 1.0.0+2 environment: sdk: ">=2.7.0 <3.0.0" @@ -23,7 +23,6 @@ environment: dependencies: google_fonts: ^1.1.0 url_launcher: ^5.4.11 - flutter_linkify: ^3.1.3 share: ^0.6.4+3 flutter: