Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
27 changes: 16 additions & 11 deletions .github/workflows/default_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand All @@ -31,9 +30,6 @@ jobs:
flutter-version: '3.27.1'
channel: 'stable'
cache: true

- name: Setup Just
uses: taiki-e/install-action@just

- name: Cache Flutter packages
uses: actions/cache@v4
Expand All @@ -43,10 +39,19 @@ jobs:
restore-keys: |
${{ runner.os }}-pub-cache-

# - name: Run CI
# run: just ci
# env:
# FDC_API_KEY: ${{ secrets.FDC_API_KEY }}
# SENTRY_DNS: ${{ secrets.SENTRY_DNS }}
# SUPABASE_PROJECT_ANON_KEY: ${{ secrets.SUPABASE_PROJECT_ANON_KEY }}
# SUPABASE_PROJECT_URL: ${{ secrets.SUPABASE_PROJECT_URL }}
- name: Install Pub Dependencies
run: flutter pub get

- name: Build with secrets
run: flutter pub run build_runner build --delete-conflicting-outputs
env:
FDC_API_KEY: ${{ secrets.FDC_API_KEY }}
SENTRY_DNS: ${{ secrets.SENTRY_DNS }}
SUPABASE_PROJECT_ANON_KEY: ${{ secrets.SUPABASE_PROJECT_ANON_KEY }}
SUPABASE_PROJECT_URL: ${{ secrets.SUPABASE_PROJECT_URL }}

- name: Analyze Code
run: flutter analyze

- name: Run Tests
run: flutter test
19 changes: 11 additions & 8 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: "35c388afb57ef061d06a39b537336c87e0e3d1b1"
channel: "stable"
revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
- platform: web
create_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
base_revision: 35c388afb57ef061d06a39b537336c87e0e3d1b1
create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- platform: android
create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
- platform: ios
create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1
base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1

# User provided section

Expand Down
65 changes: 30 additions & 35 deletions GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
# Getting started
## Android development with Windows 11
This IDE setup is tested on Windows 11.

# Getting Started
For setup first you need the following things:
- Android SDK and Android Emulator
- Flutter
- Flutter Version 3.27.1
- IDE like Android Studio or VS Code with Flutter Plugin installed.

Use paths for SDKs without spaces and special characters.

### Setup Android SDK and Emulator
1. Download Android Studio from https://developer.android.com/studio and install. Keep "Android Virtual Device" checked. Start Android Studio after installation.

2. Install the Android SDK when asked.

3. After finishing the SDK installation you should the "Welcome to Android Studio" Screen. Click on "More Actions" -> "SDK Manager", switch to "SDK Tools" tab and check "Android SDK Command-line Tools (latest)", click "OK" and install the tools.

4. Check under "More Actions" -> "Virtual Device Manager" if a virtual phone was set up, if not create one, e.g. a Medium Phone with Default Settings.

5. Close Android Studio.
## Steps to run App
1.⁠ ⁠Clone the repository with Git

### Setup Flutter SDK
1. Download Flutter 3.27.1 from https://docs.flutter.dev/install/archive and extract.
```git clone https://github.com/simonoppowa/OpenNutriTracker.git```

2. Add the bin folder in the folder where you extracted Flutter to the Path variable in "Advanced System Settings" -> "Environment Variables..." -> "System variables" -> "Path"
2.⁠ ⁠Get Dependencies

### Setup the Workspace in Visual Studio Code (VSC)
1. Create a new folder, open the folder in VSC.
```flutter pub get```

2. Configure the Android SDK path for Flutter:
3.⁠ ⁠Run Build Runner to generate Files

```flutter config --android-sdk "e:\path\to\androidSDK"```
```flutter pub run build_runner build```

3.⁠ ⁠Clone the repository with git in a VSC terminal (make sure the active folder in the terminal is your created folder from step 1):
4.⁠ ⁠Run App

```git clone https://github.com/simonoppowa/OpenNutriTracker.git .```
```flutter run lib/main.dart```

4.⁠ ⁠Get Dependencies.
## Running the Application

```flutter pub get```
The application can be run on multiple platforms. Here are the commands for each:

5.⁠ ⁠Run Build Runner to generate Files.

```flutter pub run build_runner build```
### Web (Chrome)
```bash
flutter run -d chrome
```

At the best revert all the visible generated files now, only env.g.dart is needed, it is not checked in because it is in .gitignore.
### iOS
```bash
open -a Simulator
flutter run
```

6.⁠ ⁠Restart VSC, VSC detects now that this is a flutter project. On the Bottom Right "No Device" ist displayed, click on it, then select "Start Medium Phone" on the command Palette on the top. Wait for the phone to boot up.
### macOS
```bash
flutter run -d macos
```

7. Press F5 to start a debug session (may take a while on the first time). Keep the virtual phone running all the time, just start and stop Debugging.
### Android
```bash
flutter run -d android
```
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,10 @@ See [Data Protection](https://www.iubenda.com/privacy-policy/53501884)
## Contribution
Contributions to OpenNutriTracker are welcome! If you find any issues or have suggestions for new features, please open an issue or submit a pull request. Make sure to follow the project's code style and guidelines.

Thanks to all the contributors:
<a href="https://github.com/simonoppowa/OpenNutriTracker/graphs/contributors">
<img src="https://contrib.rocks/image?repo=simonoppowa/OpenNutriTracker" />
</a>

### Getting Started With Development
## Getting Started
See the [Getting Started](GettingStarted.md) file for more information.


## Disclaimer
OpenNutriTracker is not a medical application. All data provided is not validated and should be used with caution. Please maintain a healthy lifestyle and consult a professional if you have any problems. Use during illness, pregnancy or lactation is not recommended.

Expand All @@ -82,4 +78,4 @@ For questions, suggestions, or collaborations, feel free to contact the project
Simon Oppowa

- GitHub: [@simonoppowa](https://github.com/simonoppowa)
- Email: [opennutritracker-dev@pm.me](mailto:opennutritracker-dev@pm.me)
- Email: [opennutritracker-dev@pm.me](mailto:opennutritracker-dev@pm.me)
6 changes: 0 additions & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

analyzer:
# generated files throw `unnecessary_string_escapes` lint so we ignore warnings.
# TODO: inject `ignore_for_file` as described below.
exclude:
- lib/generated/intl/*.dart

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
Expand Down
29 changes: 0 additions & 29 deletions justfile

This file was deleted.

9 changes: 3 additions & 6 deletions lib/core/data/data_source/config_data_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ class ConfigDataSource {

Future<void> setConfigDisclaimer(bool hasAcceptedDisclaimer) async {
_log.fine(
'Updating config hasAcceptedDisclaimer to $hasAcceptedDisclaimer',
);
'Updating config hasAcceptedDisclaimer to $hasAcceptedDisclaimer');
final config = _configBox.get(_configKey);
config?.hasAcceptedDisclaimer = hasAcceptedDisclaimer;
config?.save();
}

Future<void> setConfigAcceptedAnonymousData(
bool hasAcceptedAnonymousData,
) async {
bool hasAcceptedAnonymousData) async {
_log.fine(
'Updating config hasAcceptedAnonymousData to $hasAcceptedAnonymousData',
);
'Updating config hasAcceptedAnonymousData to $hasAcceptedAnonymousData');
final config = _configBox.get(_configKey);
config?.hasAcceptedSendAnonymousData = hasAcceptedAnonymousData;
config?.save();
Expand Down
46 changes: 18 additions & 28 deletions lib/core/data/data_source/intake_data_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,19 @@ class IntakeDataSource {

Future<void> deleteIntakeFromId(String intakeId) async {
log.fine('Deleting intake item from db');
_intakeBox.values.where((dbo) => dbo.id == intakeId).toList().forEach((
element,
) {
_intakeBox.values
.where((dbo) => dbo.id == intakeId)
.toList()
.forEach((element) {
element.delete();
});
}

Future<IntakeDBO?> updateIntake(
String intakeId,
Map<String, dynamic> fields,
) async {
log.fine(
'Updating intake $intakeId with fields ${fields.toString()} in db',
);
Future<IntakeDBO?> updateIntake(String intakeId, Map<String, dynamic> fields) async {
log.fine('Updating intake $intakeId with fields ${fields.toString()} in db');
var intakeObject = _intakeBox.values.indexed
.where((indexedDbo) => indexedDbo.$2.id == intakeId)
.firstOrNull;
if (intakeObject == null) {
.where((indexedDbo) => indexedDbo.$2.id == intakeId).firstOrNull;
if(intakeObject == null) {
log.fine('Cannot update intake $intakeId as it is non existent');
return null;
}
Expand All @@ -51,7 +46,7 @@ class IntakeDataSource {

Future<IntakeDBO?> getIntakeById(String intakeId) async {
return _intakeBox.values.firstWhereOrNull(
(intake) => intake.id == intakeId,
(intake) => intake.id == intakeId
);
}

Expand All @@ -60,30 +55,25 @@ class IntakeDataSource {
}

Future<List<IntakeDBO>> getAllIntakesByDate(
IntakeTypeDBO intakeType,
DateTime dateTime,
) async {
IntakeTypeDBO intakeType, DateTime dateTime) async {
return _intakeBox.values
.where(
(intake) =>
DateUtils.isSameDay(dateTime, intake.dateTime) &&
intake.type == intakeType,
)
.where((intake) =>
DateUtils.isSameDay(dateTime, intake.dateTime) &&
intake.type == intakeType)
.toList();
}

Future<List<IntakeDBO>> getRecentlyAddedIntake({int number = 100000}) async {
Future<List<IntakeDBO>> getRecentlyAddedIntake({int number = 100}) async {
final intakeList = _intakeBox.values.toList();

// sort list by date (newest first) and filter unique intake
intakeList.sort((a, b) => (-1) * a.dateTime.compareTo(b.dateTime));
intakeList
.sort((a, b) => (-1) * a.dateTime.compareTo(b.dateTime));

final filterCodes = <String>{};
final uniqueIntake = intakeList
.where(
(intake) =>
filterCodes.add(intake.meal.code ?? intake.meal.name ?? ""),
)
.where((intake) =>
filterCodes.add(intake.meal.code ?? intake.meal.name ?? ""))
.toList();

return uniqueIntake.take(number).toList();
Expand Down
Loading
Loading