Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong app UI colors. #182

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
Expand Down Expand Up @@ -53,7 +50,7 @@ android {
applicationId "de.mensa_ka.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 19
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down Expand Up @@ -81,7 +78,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions app/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion app/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
31 changes: 23 additions & 8 deletions app/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
include ':app'

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
}

include ":app"
10 changes: 4 additions & 6 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ class MensaApp extends StatelessWidget {
onSecondary: Color(0xFFFFFFFF),
error: Color(0xFFD32F2F),
onError: Color(0xFFFFFFFF),
background: Color(0xFFFFFFFF),
onBackground: Color(0xFF000000),
surface: Color(0xFFF6F6F6),
surface: Color(0xFFFFFFFF),
surfaceDim: Color(0xFFF6F6F6),
surfaceTint: Color(0xFFD2D2D2),
onSurface: Color(0xFF000000)),
),
Expand All @@ -159,9 +158,8 @@ class MensaApp extends StatelessWidget {
onSecondary: Color(0xFFFFFFFF),
error: Color(0xFFD32F2F),
onError: Color(0xFFFFFFFF),
background: Color(0xFF1E1E1E),
onBackground: Color(0xFFFFFFFF),
surface: Color(0xFF333333),
surface: Color(0xFF1E1E1E),
surfaceDim: Color(0xFF333333),
surfaceTint: Color(0xFF202020),
onSurface: Color(0xFFFFFFFF)),
),
Expand Down
69 changes: 35 additions & 34 deletions app/lib/model/database/SQLiteDatabaseAccess.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ class SQLiteDatabaseAccess implements IDatabaseAccess {

@override
Future<void> updateAll(List<MealPlan> mealPlans) async {
for (MealPlan mealPlan in mealPlans) {
await _insertCanteen(mealPlan.line.canteen);
await _insertLine(mealPlan.line);
await _insertMealPlan(mealPlan);
}
// todo: this function is very slow and slows down updating considerably.
await Future.wait(mealPlans.expand((mealPlan) => [
_insertCanteen(mealPlan.line.canteen),
_insertLine(mealPlan.line),
// todo: especially _insertMealPlan
_insertMealPlan(mealPlan)
]));
}

@override
Expand Down Expand Up @@ -440,12 +442,14 @@ class SQLiteDatabaseAccess implements IDatabaseAccess {
Future<int> _insertMealPlanMeal(Meal meal, DBMealPlan mealPlan) async {
var db = await database;

await db.delete(DBMealAllergen.tableName,
where: '${DBMealAllergen.columnMealID} = ?', whereArgs: [meal.id]);
await db.delete(DBMealAdditive.tableName,
where: '${DBMealAdditive.columnMealID} = ?', whereArgs: [meal.id]);
await db.delete(DBImage.tableName,
where: '${DBImage.columnMealID} = ?', whereArgs: [meal.id]);
await Future.wait([
db.delete(DBMealAllergen.tableName,
where: '${DBMealAllergen.columnMealID} = ?', whereArgs: [meal.id]),
db.delete(DBMealAdditive.tableName,
where: '${DBMealAdditive.columnMealID} = ?', whereArgs: [meal.id]),
db.delete(DBImage.tableName,
where: '${DBImage.columnMealID} = ?', whereArgs: [meal.id])
]);

DBMeal dbMeal = DBMeal(meal.id, meal.name, meal.foodType,
meal.individualRating, meal.numberOfRatings, meal.averageRating);
Expand All @@ -460,17 +464,16 @@ class SQLiteDatabaseAccess implements IDatabaseAccess {
_dateFormat.format(meal.nextServed ?? DateTime.now()),
meal.numberOfOccurance,
meal.relativeFrequency ?? Frequency.normal);
await Future.wait(
meal.allergens?.map((e) => _insertMealAllergen(e, dbMeal)).toList() ??
[]);
await Future.wait(
meal.additives?.map((e) => _insertMealAdditive(e, dbMeal)).toList() ??
[]);
await Future.wait(meal.sides!
.map((e) => _insertMealPlanSide(e, dbMeal, mealPlan))
.toList());
await Future.wait(
meal.images?.map((e) => _insertImage(e, dbMeal)).toList() ?? []);
await Future.wait([
...(meal.allergens?.map((e) => _insertMealAllergen(e, dbMeal)).toList() ??
[]),
...(meal.additives?.map((e) => _insertMealAdditive(e, dbMeal)).toList() ??
[]),
...(meal.sides!
.map((e) => _insertMealPlanSide(e, dbMeal, mealPlan))
.toList()),
...(meal.images?.map((e) => _insertImage(e, dbMeal)).toList() ?? [])
]);
if (meal.nutritionData != null) {
await _insertMealNutritionData(meal.nutritionData!, dbMeal);
}
Expand Down Expand Up @@ -553,16 +556,15 @@ class SQLiteDatabaseAccess implements IDatabaseAccess {
EnvironmentInfo environmentInfo, DBMeal meal) async {
var db = await database;
var dbMealEnvironmentInfo = DBMealEnvironmentInfo(
meal.mealID,
environmentInfo.averageRating,
environmentInfo.co2Rating,
environmentInfo.co2Value,
environmentInfo.waterRating,
environmentInfo.waterValue,
environmentInfo.animalWelfareRating,
environmentInfo.rainforestRating,
environmentInfo.maxRating
);
meal.mealID,
environmentInfo.averageRating,
environmentInfo.co2Rating,
environmentInfo.co2Value,
environmentInfo.waterRating,
environmentInfo.waterValue,
environmentInfo.animalWelfareRating,
environmentInfo.rainforestRating,
environmentInfo.maxRating);
return await db.insert(
DBMealEnvironmentInfo.tableName, dbMealEnvironmentInfo.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace);
Expand Down Expand Up @@ -612,8 +614,7 @@ class SQLiteDatabaseAccess implements IDatabaseAccess {
environmentInfo.waterValue,
environmentInfo.animalWelfareRating,
environmentInfo.rainforestRating,
environmentInfo.maxRating
);
environmentInfo.maxRating);
return await db.insert(
DBSideEnvironmentInfo.tableName, dbSideEnvironmentInfo.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/MainPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _MainPageState extends State<MainPage> {
@override
Widget build(BuildContext context) {
return Container(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
child: SafeArea(
child: Scaffold(
body: IndexedStack(
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/buttons/MensaButton.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MensaButton extends StatelessWidget {
label: _semanticLabel,
child: MaterialButton(
textColor: Theme.of(context).colorScheme.onSurface,
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0),
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/buttons/MensaLink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MensaLink extends StatelessWidget {
),
elevation: 0,
side: BorderSide(
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
width: 1,
),
),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/dialogs/MensaDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MensaDialog extends StatelessWidget {
return Center(
child: SingleChildScrollView(
child: Dialog(
backgroundColor: Theme.of(context).colorScheme.background,
backgroundColor: Theme.of(context).colorScheme.surface,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)),
child: Column(children: [
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/dialogs/MensaFullscreenDialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MensaFullscreenDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Dialog.fullscreen(
backgroundColor: Theme.of(context).colorScheme.background,
backgroundColor: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: _appBar,
body: _content ?? Container(),
Expand Down
8 changes: 4 additions & 4 deletions app/lib/view/core/information_display/MealPreviewImage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ class MealPreviewImage extends StatelessWidget {
children: [
Icon(Icons.favorite,
size: 28,
color: Theme.of(context).colorScheme.onBackground),
color: Theme.of(context).colorScheme.onSurface),
Icon(Icons.favorite_border,
size: 28,
color:
Theme.of(context).colorScheme.background),
Theme.of(context).colorScheme.surface),
],
),
)),
Expand Down Expand Up @@ -125,7 +125,7 @@ class MealPreviewImage extends StatelessWidget {
size: 28,
color: Theme.of(context)
.colorScheme
.surface),
.surfaceDim),
],
),
))
Expand Down Expand Up @@ -157,7 +157,7 @@ class MealPreviewImage extends StatelessWidget {
size: 28,
color: Theme.of(context)
.colorScheme
.surface),
.surfaceDim),
],
),
)),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/view/core/input_components/MensaTextField.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MensaTextField extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
borderRadius: BorderRadius.circular(8),
),
padding: const EdgeInsets.symmetric(horizontal: 8),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/view/core/meal_view_format/MealGridEntry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class MealGridEntry extends StatelessWidget {
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
border: Border.all(
color: _meal.isFavorite
? Theme.of(context).colorScheme.secondary
: Theme.of(context).colorScheme.surface,
: Theme.of(context).colorScheme.surfaceDim,
width: _meal.isFavorite ? 2.5 : 0),
),
child: Column(children: [
Expand Down
4 changes: 2 additions & 2 deletions app/lib/view/core/meal_view_format/MealListEntry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class MealListEntry extends StatelessWidget {
bottomLeft: Radius.circular(10.5),
topRight: Radius.circular(8),
bottomRight: Radius.circular(8)),
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
border: _enableFavoriteHighlight ? Border.all(
color: _meal.isFavorite
? Theme.of(context).colorScheme.secondary
: Theme.of(context).colorScheme.surface,
: Theme.of(context).colorScheme.surfaceDim,
width: _meal.isFavorite ? 2.5 : 0) : Border.all(width: 0),
),
child: IntrinsicHeight(
Expand Down
10 changes: 5 additions & 5 deletions app/lib/view/core/selection_components/MensaCheckbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class MensaCheckbox extends StatelessWidget {
width: 18,
height: 18,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
borderRadius: BorderRadius.circular(4.0),
border: Border.all(
color: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surfaceDim,
width: 1,
),
),
Expand All @@ -37,11 +37,11 @@ class MensaCheckbox extends StatelessWidget {
borderRadius: BorderRadius.circular(4.0),
),
// Set the border color of the checkbox to the primary color when it is selected and to the surface color when it is not selected, this makes the border invisible
fillColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.selected)) {
fillColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) {
return Theme.of(context).colorScheme.primary;
} else {
return Theme.of(context).colorScheme.surface;
return Theme.of(context).colorScheme.surfaceDim;
}
}),
checkColor: Theme.of(context).colorScheme.onPrimary,
Expand Down
4 changes: 2 additions & 2 deletions app/lib/view/core/selection_components/MensaDropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class MensaDropdown<T> extends StatelessWidget {
// Container is used to give the dropdown a background color.
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
color: _backgroundColor ?? Theme.of(context).colorScheme.surface,
color: _backgroundColor ?? Theme.of(context).colorScheme.surfaceDim,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: DropdownButtonHideUnderline(
// DropdownButtonHideUnderline is used to hide the underline of the dropdown.
child: DropdownButton<T>(
dropdownColor: Theme.of(context).colorScheme.surface,
dropdownColor: Theme.of(context).colorScheme.surfaceDim,
elevation: 0,
borderRadius: BorderRadius.circular(4.0),
value: _value,
Expand Down
Loading
Loading