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

Commit

Permalink
UI Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Mar 7, 2022
1 parent 951210a commit 7f89c64
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 73 deletions.
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
docs/* linguist-documentation=false
android/**/* linguist-generated=true
ios/**/* linguist-generated=true
web/**/* linguist-generated=true
6 changes: 3 additions & 3 deletions android/app/src/main/res/drawable-v21/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<item>
<!-- <item>
<bitmap
android:gravity="fill"
android:gravity="center"
android:src="@mipmap/launch_image" />
</item>
</item> -->
</layer-list>
8 changes: 4 additions & 4 deletions android/app/src/main/res/drawable/launch_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<item>
<!-- <item>
<bitmap
android:gravity="fill"
android:gravity="center"
android:src="@mipmap/launch_image" />
</item>
</layer-list>
</item> -->
</layer-list>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
Expand All @@ -10,9 +10,9 @@
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
Expand Down
Binary file removed assets/launch_image.png
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/components/exchange_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AlertDialog exchangeSuccess(
Text(t.exchange_complete),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Image.asset("assets/images/dummy_QR.png"),
child: Image.asset("assets/images/dummy_QR.webp"),
),
Text(t.use_this_qr, style: const TextStyle(fontSize: 12)),
],
Expand Down
20 changes: 20 additions & 0 deletions lib/components/profile_picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import "package:flutter/material.dart";

Container profilePic(String img, double size, {Widget? child}) {
if (img.startsWith("assets/")) return profileAssets(img, size, child: child);
return profileNetwork(img, size, child: child);
}

Container profileNetwork(String img, double size, {Widget? child}) {
return Container(
height: size,
width: size,
Expand All @@ -15,3 +20,18 @@ Container profilePic(String img, double size, {Widget? child}) {
child: child,
);
}

Container profileAssets(String img, double size, {Widget? child}) {
return Container(
height: size,
width: size,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(img),
),
),
child: child,
);
}
39 changes: 39 additions & 0 deletions lib/constants/fun_facts.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 🎯 Dart imports:
import "dart:math";

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

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

const facts = {
"en": [
"Do you know that 3.3 billion tons of "
"carbon footprint are from food waste?",
"Cheese makes you fart and also cause a lot of pollution when made!",
"Mushroom tastes kinda like meat. Care to try?",
"Grains are 'in' right now. Try one to be super healthy.",
"Somwua is a cow! Not a buffalo!",
"Eat everything on your plate. It helps make cleaning up easier as well.",
"Food Busters will never give environment up, never gonna let ocean down. "
"Never gonna run around and desert the world."
],
"th": [
"สมวัว คือ 'วัว'นะ ไม่ใช่ควาย 🐮😭 อย่าบูลลี่น้อนนน",
"คุณรู้หรือไม่? ว่าคาร์บอนฟุตปริ้นท์กว่า 3.3 พันล้านตันมาจากเศษอาหาร"
]
};

String getRandomFact(BuildContext context) {
final facts = getFacts(context);

return facts[Random().nextInt(facts.length)];
}

List<String> getFacts(BuildContext context) {
final locale = MyApp.of(context).localeStrSimp;

if (locale == "th") return facts["th"]!;
return facts["en"]!;
}
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@
"guide_vegetable_header": "Left over VEGETABLE = METHANE",
"guide_vegetable_content": "Don't like vegetables? If you don't like it, tell chef to not put in becaus 30% of your food waste are vegetables!",
"cannot_share_loading": "You cannot share right now because it is loading or error occured",
"detected_by_sfc": "We automatically fill the menu for you from result of Smart Food Scanner 🌟✨ with confidence of"
"detected_by_sfc": "We automatically fill the menu for you from result of Smart Food Scanner 🌟✨ with confidence of",
"fun_fact": "Fun Fact"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_th.arb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,6 @@
"guide_vegetable_header": "ผักที่กินเหลือ = มีเทน!",
"guide_vegetable_content": "ไม่ชอบผักใช่ไหม? หากคุณไม่ชอบผัก ให้บอกเชฟว่าอย่าใส่ผักมา เพราะ 30% ของอาหารเหลือคือผัก!",
"cannot_share_loading": "คุณไม่สามารถแชร์ได้ตอนนี้ เนื่องจากกำลังโหลดอยู่หรือมีข้อผิดพลาดเกินขึ้น",
"detected_by_sfc": "เราได้เติมเมนูของคุณโดยอัตโนมัติจากผลสแกนของ Smart Food Scanner 🌟✨ ด้วยความมั่นใจที่"
"detected_by_sfc": "เราได้เติมเมนูของคุณโดยอัตโนมัติจากผลสแกนของ Smart Food Scanner 🌟✨ ด้วยความมั่นใจที่",
"fun_fact": "เกร็ดน่ารู้"
}
6 changes: 2 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import "package:food_busters/models/state/app_state.dart";
import "package:food_busters/styles/styles.dart";
import "package:food_busters/views/login.dart";

void main() => _main();

Future<void> _main() async {
await dotenv.load();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(const MyApp());
}
Expand Down
6 changes: 5 additions & 1 deletion lib/models/state/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ import "package:food_busters/models/state/god.dart";
import "package:food_busters/models/state/image.dart";
import "package:food_busters/models/state/point.dart";

class AppState with AccountState, GodModeState, ImageState, PointState {}
class AppState with AccountState, GodModeState, ImageState, PointState {
void reset() {
// todo implement database and this method
}
}
3 changes: 0 additions & 3 deletions lib/styles/styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const tan = Color(0xFFF4E4D8);
const brown = Color(0xFF533F2C);
const rose = Color(0xFFF1D0C5);

const discordPfp =
"https://external-preview.redd.it/4PE-nlL_PdMD5PrFNLnjurHQ1QKPnCvg368LTDnfM-M.png?auto=webp&s=ff4c3fbc1cce1a1856cff36b5d2a40a6d02cc1c3";

const bold = TextStyle(fontWeight: FontWeight.w500);

// * 肉 Hooks
Expand Down
2 changes: 1 addition & 1 deletion lib/views/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class _HomePageState extends State<HomePage> {
])
..crossStart
..p = 16,
profilePic(discordPfp, 100),
profilePic("assets/images/somwua_icon.webp", 100),
]),
navButtons()..p = 8,
])
Expand Down
24 changes: 13 additions & 11 deletions lib/views/mission/new_mission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import "package:flutter/material.dart";

// 📦 Package imports:
import "package:flutter_gen/gen_l10n/app_localizations.dart";
import "package:food_busters/hooks.dart";
import "package:niku/namespace.dart" as n;

// 🌎 Project imports:
Expand Down Expand Up @@ -37,13 +37,13 @@ class _NewMissionPageState extends State<NewMissionPage> {

@override
Widget build(BuildContext context) {
final text = AppLocalizations.of(context)!;
final t = useTranslation(context);

return Scaffold(
backgroundColor: tan,
extendBodyBehindAppBar: true,
appBar: AppBar(
title: Text("${text.mission} ($pageLabel)"),
title: Text("${t.mission} ($pageLabel)"),
backgroundColor: Colors.transparent,
elevation: 0,
),
Expand All @@ -52,8 +52,8 @@ class _NewMissionPageState extends State<NewMissionPage> {
Center(
child: SingleChildScrollView(
child: n.Column([
missionBlock(text, text.eat_less, lightOrange),
missionBlock(text, text.eat_more, lightGreen),
missionBlock(t.eat_less, lightOrange),
missionBlock(t.eat_more, lightGreen),
])
..mainCenter,
),
Expand All @@ -62,7 +62,9 @@ class _NewMissionPageState extends State<NewMissionPage> {
);
}

Widget missionBlock(AppLocalizations text, String title, Color color) {
Widget missionBlock(String title, Color color) {
final t = useTranslation(context);

return Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
Expand All @@ -89,7 +91,7 @@ class _NewMissionPageState extends State<NewMissionPage> {
borderRadius: BorderRadius.circular(6.0),
),
child: n.Row([
Text(text.within),
Text(t.within),
Container(
width: 60,
height: 40,
Expand All @@ -104,7 +106,7 @@ class _NewMissionPageState extends State<NewMissionPage> {
),
),
),
Text(text.days),
Text(t.days),
])
..mainEvenly
..p = 8,
Expand All @@ -117,22 +119,22 @@ class _NewMissionPageState extends State<NewMissionPage> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(text.challenge_accepted),
title: Text(t.challenge_accepted),
backgroundColor: lightGreen,
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: n.Text(text.window_close)
child: n.Text(t.window_close)
..color = Colors.black
..freezed,
)
],
),
);
},
child: Text(text.i_can_do_this),
child: Text(t.i_can_do_this),
style: tanBtn,
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/views/record/leaderboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
borderRadius: BorderRadius.circular(16.0),
),
child: n.Column([
profilePic(discordPfp, 100),
profilePic("assets/images/somwua_icon.webp", 100),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: bigNeonLeaves(4),
Expand Down
19 changes: 18 additions & 1 deletion lib/views/scan/scanafter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "package:share_plus/share_plus.dart";
// 🌎 Project imports:
import "package:food_busters/components/background.dart";
import "package:food_busters/components/buttons.dart";
import "package:food_busters/constants/fun_facts.dart";
import "package:food_busters/hooks.dart";
import "package:food_busters/main.dart";
import "package:food_busters/models/ml_error.dart";
Expand Down Expand Up @@ -183,7 +184,23 @@ class _ScanAfterPageState extends State<ScanAfterPage> {
),
);
}
return const CircularProgressIndicator();
return n.Column([
const CircularProgressIndicator(color: lightOrange),
n.Column([
n.Text(t.fun_fact)
..w500
..fontSize = 26,
n.Text(getRandomFact(context))
..center
..freezed,
])
..center
..px = 6
..freezed,
])
..center
..gap = 48
..freezed;
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/views/scan/scanbefore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _ScanBeforePageState extends State<ScanBeforePage> {
..freezed,
backHomeBtn(context),
])
..mainCenter
..center
..freezed,
]),
);
Expand Down
Loading

0 comments on commit 7f89c64

Please sign in to comment.