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

Commit

Permalink
God Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Nov 4, 2021
1 parent afd7e91 commit fe432fc
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"learn_more": "Learn more",
"pollution_produced": "Pollution produced is {pollution} grams of CO2!",
"your_data": "YOUR DATA",
"chicken": "Chicken Rice",
"omelet": "Omelet Rice",
"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
2 changes: 2 additions & 0 deletions lib/l10n/app_th.arb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"learn_more": "เรียนรู้เพิ่มเติม",
"pollution_produced": "มลพิษที่เกิดขึ้นคือคาร์บอนไดออกไซต์ {pollution} กรัม!",
"your_data": "ข้อมูลของคุณ",
"chicken": "ข้าวมันไก่",
"omelet": "ข้าวไข่เจียว",
"take_home_recommendation": "นำอาหารที่เหลืออยู่กลับบ้านก็อาจเป็นทางเลือกที่ดีนะ!",
"any_menu_suits_me": "มีเมนูที่เหมาะกับฉันไหม?",
"recommended": "แนะนำ",
Expand Down
5 changes: 5 additions & 0 deletions lib/models/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ class AppState {
void assignPremium() {
_premium = true;
}

// * God Mode
String menu = "Chicken";
int get menuIndex => menu == "Chicken" ? 0 : 1;
int percent = 50;
}
5 changes: 4 additions & 1 deletion lib/views/scan/scanafter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _ScanAfterPageState extends State<ScanAfterPage> {

int percent = 0;
int pointRecieved = 0;
String food = "";

Map<String, double> foodData = {};

Expand All @@ -39,7 +40,9 @@ class _ScanAfterPageState extends State<ScanAfterPage> {

// * SIMULATE IMAGE PROCESSING
await Future.delayed(const Duration(milliseconds: 500));
percent = Random().nextInt(100) + 1;
percent = appState.percent;
food = appState.menu;

pointRecieved = (percent * percent / 100).floor();
appState.addPoints(pointRecieved);

Expand Down
54 changes: 54 additions & 0 deletions lib/views/settings.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import "dart:math";
import "package:flutter/material.dart";
import "package:flutter_gen/gen_l10n/app_localizations.dart";
import "package:flutter_toggle_tab/flutter_toggle_tab.dart";
import "package:food_busters/main.dart";
import "package:food_busters/styles/styles.dart";
import "package:food_busters/views/login.dart";
Expand All @@ -18,6 +20,7 @@ class _SettingsPageState extends State<SettingsPage> {
@override
Widget build(BuildContext context) {
final text = AppLocalizations.of(context)!;
final appState = MyApp.of(context).state;

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -74,6 +77,57 @@ class _SettingsPageState extends State<SettingsPage> {
);
},
),
const ListTile(
title: Text(
"GOD MODE",
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w500),
),
),
FlutterToggleTab(
labels: const ["Chicken", "Omelet"],
selectedLabelIndex: (index) {
setState(() {
appState.menu = index == 0 ? "Chicken" : "Omelet";
});
},
selectedIndex: appState.menuIndex,
selectedTextStyle: const TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.w700,
),
unSelectedTextStyle: const TextStyle(
color: Colors.black87,
fontSize: 14,
fontWeight: FontWeight.w500,
),
selectedBackgroundColors: const [lightGreen],
),
ListTile(
title: Text(
"Percent: ${appState.percent}",
textAlign: TextAlign.center,
),
leading: ElevatedButton(
onPressed: () {
setState(() {
appState.percent = max(0, appState.percent - 5);
});
},
child: const Icon(Icons.remove),
style: ElevatedButton.styleFrom(primary: lightGreen),
),
trailing: ElevatedButton(
onPressed: () {
setState(() {
appState.percent = min(100, appState.percent + 5);
});
},
child: const Icon(Icons.add),
style: ElevatedButton.styleFrom(primary: lightGreen),
),
),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion 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.190+1900000
version: 1.0.220+2200000

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit fe432fc

Please sign in to comment.