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

Commit

Permalink
Code format, description misc small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Mar 8, 2022
1 parent 4fc3db5 commit 154a8e7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 64 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Food Busters

Mobile App to encourage reducing food wastes for environment and develop healthy diet.
Mobile App to encourage reducing pollution from food waste and develop healthy diet.

- [More About Food Busters](https://github.com/Food-Busters)

Expand Down
14 changes: 8 additions & 6 deletions lib/components/background.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// 🐦 Flutter imports:
import "package:flutter/material.dart";

Image bgImage(String name) => Image.asset(
"assets/images/" + name,
fit: BoxFit.cover,
width: double.infinity,
alignment: Alignment.center,
);
Image bgImage(String name) {
return Image.asset(
"assets/images/" + name,
fit: BoxFit.cover,
width: double.infinity,
alignment: Alignment.center,
);
}
2 changes: 1 addition & 1 deletion lib/data/delay.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// * Simulate Server Request
/// Simulate Server Request, Delay for 1 second
Future<void> serverRequest() async {
await Future.delayed(const Duration(milliseconds: 1000));
}
44 changes: 39 additions & 5 deletions lib/models/label10n.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
class Label10n {
String en;
String? th;
// * https://app.quicktype.io/

// 🎯 Dart imports:
import "dart:convert";

// 🐦 Flutter imports:
import "package:flutter/material.dart";

// 🌎 Project imports:
import "package:food_busters/main.dart";

class Label10n {
Label10n({
required this.en,
this.th,
});

String toStr(String loc) {
return (loc == "th") ? (th ?? en) : en;
final String en;
final String? th;

String get(BuildContext context) {
if (th == null) return en;

final lang = MyApp.of(context).localeStrSimp;

if (lang == "th") {
return th!;
} else {
return en;
}
}

factory Label10n.fromRawJson(String str) =>
Label10n.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory Label10n.fromJson(Map<String, dynamic> json) => Label10n(
en: json["en"],
th: json["th"],
);

Map<String, dynamic> toJson() => {
"en": en,
"th": th,
};
}
46 changes: 3 additions & 43 deletions lib/models/ml_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
// 🎯 Dart imports:
import "dart:convert";

// 🐦 Flutter imports:
import "package:flutter/material.dart";

// 🌎 Project imports:
import "package:food_busters/main.dart";
import "package:food_busters/models/label10n.dart";

class MLAPIResult {
MLAPIResult({
Expand All @@ -17,7 +14,7 @@ class MLAPIResult {
required this.version,
});

final FoodName foodName;
final Label10n foodName;
final FoodNutrition foodNutrition;
final double confidence;
final String version;
Expand All @@ -28,7 +25,7 @@ class MLAPIResult {
String toRawJson() => json.encode(toJson());

factory MLAPIResult.fromJson(Map<String, dynamic> json) => MLAPIResult(
foodName: FoodName.fromJson(json["foodName"]),
foodName: Label10n.fromJson(json["foodName"]),
foodNutrition: FoodNutrition.fromJson(json["foodNutrition"]),
confidence: json["confidence"].toDouble(),
version: json["version"],
Expand All @@ -42,43 +39,6 @@ class MLAPIResult {
};
}

class FoodName {
FoodName({
required this.en,
this.th,
});

final String en;
final String? th;

String get(BuildContext context) {
if (th == null) return en;

final lang = MyApp.of(context).localeStrSimp;

if (lang == "th") {
return th!;
} else {
return en;
}
}

factory FoodName.fromRawJson(String str) =>
FoodName.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory FoodName.fromJson(Map<String, dynamic> json) => FoodName(
en: json["en"],
th: json["th"],
);

Map<String, dynamic> toJson() => {
"en": en,
"th": th,
};
}

class FoodNutrition {
FoodNutrition({
required this.carbohydrate,
Expand Down
4 changes: 1 addition & 3 deletions lib/views/mission/mission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "package:niku/namespace.dart" as n;
import "package:food_busters/components/background.dart";
import "package:food_busters/data/dummy_current_missions.dart";
import "package:food_busters/hooks.dart";
import "package:food_busters/main.dart";
import "package:food_busters/models/mission.dart";
import "package:food_busters/styles/styles.dart";
import "package:food_busters/views/mission/new_mission.dart";
Expand Down Expand Up @@ -74,7 +73,6 @@ class _MyMissionPageState extends State<MyMissionPage> {
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
final data = snapshot.data!;
final loc = MyApp.of(context).localeStrSimp;
return ListView.separated(
padding: EdgeInsets.zero,
scrollDirection: Axis.vertical,
Expand All @@ -84,7 +82,7 @@ class _MyMissionPageState extends State<MyMissionPage> {
final ms = data[index];
return ListTile(
title: n.Column([
Text(ms.obj.toStr(loc)),
Text(ms.obj.get(context)),
Text(
"${ms.award.toString()} ${t.points}",
style: const TextStyle(
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: food_busters
description: Mobile App to encourage reducing Food Wastes
description: Mobile App to encourage reducing pollution from food waste and develop healthy diet.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
Expand All @@ -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.382
version: 1.0.384

environment:
sdk: ">=2.16.0 <3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="food_busters" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="apple-mobile-web-app-title" content="Food Busters" />
<link rel="apple-touch-icon" href="icons/somwua192.png" />

<!-- Favicon -->
Expand Down
2 changes: 1 addition & 1 deletion web/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display": "standalone",
"background_color": "#BCDFCB",
"theme_color": "#FFC068",
"description": "App to encourage reducing Food Wastes",
"description": "Mobile App to encourage reducing pollution from food waste and develop healthy diet.",
"orientation": "portrait-primary",
"prefer_related_applications": false,
"icons": [
Expand Down

0 comments on commit 154a8e7

Please sign in to comment.