Skip to content

Commit

Permalink
1.0.0+2
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez committed Aug 17, 2020
1 parent 35524aa commit 6e666e7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<application
android:name="io.flutter.app.FlutterApplication"
android:label="bmicalculator"
android:label="BMI Calculator Lite"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
17 changes: 17 additions & 0 deletions lib/AppBody.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'Utils/RegExInputFormatter.dart';
import 'Utils/sizeconfig.dart';
import 'View/legendsTable.dart';

String bmiResult;

class AppBody extends StatefulWidget {
@override
_AppBodyState createState() => _AppBodyState();
Expand All @@ -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;
}

Expand Down Expand Up @@ -85,6 +100,7 @@ class _AppBodyState extends State<AppBody> {
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: Container(
Expand Down Expand Up @@ -158,6 +174,7 @@ class _AppBodyState extends State<AppBody> {
weight: weightController.text)
.toStringAsFixed(1);
calculatedBmi = answer;
bmiResult = answer;
});
}
},
Expand Down
46 changes: 43 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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',
),
Expand All @@ -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: <Widget>[
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',
)
Expand All @@ -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);
},
);
}
14 changes: 0 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ 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"

dependencies:
google_fonts: ^1.1.0
url_launcher: ^5.4.11
flutter_linkify: ^3.1.3
share: ^0.6.4+3

flutter:
Expand Down

0 comments on commit 6e666e7

Please sign in to comment.