Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Upgrade to new ML, Add Feedback Button
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Mar 12, 2022
1 parent 7389eb9 commit 36ac95c
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 132 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The app is currently incomplete as it's only used to show our idea.

- Web ❓ Not directly target, but with magic of Flutter, it works

Testing detailed is noted in the Manual
Testing detail is noted in the Manual

## Download & Manual

Expand Down
Binary file added assets/fonts/Kanit-SemiBold.ttf
Binary file not shown.
Binary file removed assets/fonts/Sarabun-Bold.ttf
Binary file not shown.
Binary file removed assets/fonts/Sarabun-Light.ttf
Binary file not shown.
Binary file removed assets/fonts/Sarabun-Medium.ttf
Binary file not shown.
93 changes: 0 additions & 93 deletions assets/fonts/Sarabun-OFL.txt

This file was deleted.

1 change: 1 addition & 0 deletions lib/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ AppLocalizations useTranslation(BuildContext context) {
return AppLocalizations.of(context)!;
}

/// Alias for `AppLocalizations`
typedef Translation = AppLocalizations;
5 changes: 2 additions & 3 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
"swipe_hint": "Swipe Left or Right",
"learn_more": "Learn more",
"pollution_produced": "Pollution produced is {pollution} grams of CO2!",
"your_data": "YOUR DATA",
"chicken": "Chicken Rice",
"omelet": "Omelet Rice",
"your_data": "YOUR MEAL DATA",
"chart_desc": "Following Pie Chart represents calories in each nutrition category of meal",
"take_home_recommendation": "Take your leftover back home may be a good choice!",
"any_menu_suits_me": "Any menu suits me?",
"recommended": "Recommended",
Expand Down
5 changes: 2 additions & 3 deletions lib/l10n/app_th.arb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
"swipe_hint": "ปัดไปทางซ้ายหรือขวา",
"learn_more": "เรียนรู้เพิ่มเติม",
"pollution_produced": "มลพิษที่เกิดขึ้นคือคาร์บอนไดออกไซต์ {pollution} กรัม!",
"your_data": "ข้อมูลของคุณ",
"chicken": "ข้าวมันไก่",
"omelet": "ข้าวไข่เจียว",
"your_data": "ข้อมูลมื้ออาหารของคุณ",
"chart_desc": "แผนภูมิวงกลมด้านล่าง แสดงแคลอรี่ (cal) ของแต่ละหมู่ ในมื้ออาหารของคุณ",
"take_home_recommendation": "นำอาหารที่เหลืออยู่กลับบ้านก็อาจเป็นทางเลือกที่ดีนะ!",
"any_menu_suits_me": "มีเมนูที่เหมาะกับฉันไหม?",
"recommended": "แนะนำ",
Expand Down
5 changes: 2 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ void addFontLicense(String fontName) {
}

Future<void> main() async {
// addFontLicense("Kanit");
addFontLicense("Sarabun");
addFontLicense("Kanit");

await Future.wait([
dotenv.load(),
Expand Down Expand Up @@ -102,7 +101,7 @@ class _MyAppState extends State<MyApp> {
primarySwatch: Colors.orange,
appBarTheme: const AppBarTheme(color: lightOrange),
scaffoldBackgroundColor: const Color(0xFFF4E3D8),
fontFamily: "Sarabun",
fontFamily: "Kanit",
),
home: state.username == null
? const LoginPage()
Expand Down
10 changes: 6 additions & 4 deletions lib/models/ml_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class FoodNutrition {
required this.carbohydrate,
required this.fat,
required this.protein,
required this.pollution,
});

final double carbohydrate;
final double fat;
final double protein;
final double pollution;

factory FoodNutrition.fromRawJson(String str) =>
FoodNutrition.fromJson(json.decode(str));
Expand All @@ -62,10 +64,10 @@ class FoodNutrition {
}

factory FoodNutrition.fromJson(Map<String, dynamic> json) => FoodNutrition(
carbohydrate: td(json["carbohydrate"]),
fat: td(json["fat"]),
protein: td(json["protein"]),
);
carbohydrate: td(json["carbohydrate"]),
fat: td(json["fat"]),
protein: td(json["protein"]),
pollution: td(json["pollution"]));

Map<String, double> toJson() => {
"carbohydrate": carbohydrate,
Expand Down
9 changes: 7 additions & 2 deletions lib/views/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "package:flutter/material.dart";
// 📦 Package imports:
import "package:niku/namespace.dart" as n;
import "package:package_info_plus/package_info_plus.dart";
import "package:url_launcher/url_launcher.dart";

// 🌎 Project imports:
import "package:food_busters/components/background.dart";
Expand All @@ -27,6 +28,8 @@ const webAppWarn =
"Our UI is designed for Portrait mode, please rotate or "
"change your window size.";

const feedbackUrl = "https://forms.gle/sKw883rMThW2tykB9";

class HomePage extends StatefulWidget {
const HomePage({Key? key, this.welcomeBack = false}) : super(key: key);

Expand All @@ -50,8 +53,10 @@ class _HomePageState extends State<HomePage> {
elevation: 0,
title: n.Text(t.home)..color = Colors.black,
actions: [
n.IconButton(Icons.gamepad)
..onPressed = () {}
n.IconButton(Icons.feedback)
..onPressed = () {
launch(feedbackUrl);
}
..freezed,
n.IconButton(Icons.settings)
..onPressed = () {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/record/other_busters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class _OtherBustersPageState extends State<OtherBustersPage> {
style: const TextStyle(
fontSize: 18.0,
color: Colors.black,
fontFamily: "Sarabun",
fontFamily: "Kanit",
),
children: [
const TextSpan(text: "- "),
Expand Down
12 changes: 11 additions & 1 deletion lib/views/scan/scanafter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _ScanAfterPageState extends State<ScanAfterPage> {
int percent = 0;
int pointRecieved = 0;
Map<String, double> foodData = {"undefined": 100};
double pollution = 0;
MLAPIResult? apiResult;
Quote? quote;
int successedPromise = 0;
Expand Down Expand Up @@ -84,7 +85,9 @@ class _ScanAfterPageState extends State<ScanAfterPage> {
}

apiResult = MLAPIResult.fromRawJson(mlResponse.body);
pollution = apiResult!.foodNutrition.pollution;
foodData = apiResult!.foodNutrition.toJson();
foodData.remove("pollution");
successedPromise++;
}

Expand Down Expand Up @@ -295,6 +298,11 @@ class _ScanAfterPageState extends State<ScanAfterPage> {
..fontSize = 28
..w500
..freezed,
n.Text(t.chart_desc)
..fontSize = 12
..center
..w400
..freezed,
Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0),
child: PieChart(
Expand All @@ -310,7 +318,9 @@ class _ScanAfterPageState extends State<ScanAfterPage> {
..center
..w500
..freezed,
Text(t.take_home_recommendation),
n.Text(t.take_home_recommendation)
..center
..freezed,
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ packages:
source: hosted
version: "1.3.0"
url_launcher:
dependency: transitive
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
Expand Down
33 changes: 13 additions & 20 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.401
version: 1.0.407

environment:
sdk: ">=2.16.0 <3.0.0"
Expand Down Expand Up @@ -50,6 +50,7 @@ dependencies:
pie_chart: ^5.1.0
share_plus: ^3.1.0
table_calendar: ^3.0.4
url_launcher: ^6.0.20

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -89,8 +90,7 @@ flutter:
- assets/images/foods/
- assets/images/icons/

# - assets/fonts/Kanit-OFL.txt
- assets/fonts/Sarabun-OFL.txt
- assets/fonts/Kanit-OFL.txt

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand All @@ -104,31 +104,24 @@ flutter:
# list giving the asset and other descriptors for the font. For
# example:
fonts:
# - family: Montserrat
# - family: loremipsum
# fonts:
# - asset: assets/fonts/Montserrat-Light.ttf
# - asset: assets/fonts/loremipsum-Light.ttf
# weight: 300
# - asset: assets/fonts/Montserrat-Medium.ttf
# - asset: assets/fonts/loremipsum-Medium.ttf
# weight: 500
# - asset: assets/fonts/Montserrat-Bold.ttf
# - asset: assets/fonts/loremipsum-Bold.ttf
# weight: 700

# - family: Kanit
# fonts:
# - asset: assets/fonts/Kanit-Light.ttf
# weight: 300
# - asset: assets/fonts/Kanit-Medium.ttf
# weight: 500
# - asset: assets/fonts/Kanit-Bold.ttf
# weight: 700

- family: Sarabun
- family: Kanit
fonts:
- asset: assets/fonts/Sarabun-Light.ttf
- asset: assets/fonts/Kanit-Light.ttf
weight: 300
- asset: assets/fonts/Sarabun-Medium.ttf
- asset: assets/fonts/Kanit-Medium.ttf
weight: 500
- asset: assets/fonts/Sarabun-Bold.ttf
- asset: assets/fonts/Kanit-SemiBold.ttf
weight: 600
- asset: assets/fonts/Kanit-Bold.ttf
weight: 700

# For details regarding fonts from package dependencies,
Expand Down

0 comments on commit 36ac95c

Please sign in to comment.