diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 0b639038..59cf2638 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -3,13 +3,13 @@ name: Eatvio App Android Test on: [ pull_request ] env: - flutter_version: "3.24.4" + flutter_version: "3.24.5" java_version: "21.x" flutter_channel: "stable" jobs: build: - runs-on: ubuntu-latest + runs-on: [ dev-office ] steps: - uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: with: distribution: "zulu" java-version: ${{ env.java_version }} - cache: "gradle" + id: setup-jdk - name: Install Android SDK run: | @@ -31,28 +31,17 @@ jobs: mv cmdline-tools/* $HOME/Android/Sdk/cmdline-tools/latest/ export ANDROID_SDK_ROOT=$HOME/Android/Sdk export PATH=$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin - yes | sdkmanager --licenses 2>/dev/null || true + yes | sdkmanager --licenses 2>/dev/null || true - name: Set up Android environment variables run: | echo "ANDROID_SDK_ROOT=$HOME/Android/Sdk" >> $GITHUB_ENV echo "PATH=$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin:$HOME/Android/Sdk/platform-tools:$HOME/Android/Sdk/build-tools/30.0.3" >> $GITHUB_ENV - echo "ANDROID_HOME=$HOME/Android/Sdk" >> $GITHUB_ENV - - - name: Debug Environment Variables - run: | - echo "ANDROID_SDK_ROOT: $ANDROID_SDK_ROOT" - echo "ANDROID_HOME: $ANDROID_HOME" - echo "PATH: $PATH" - - - uses: actions/cache@v2 - with: - path: ${{ runner.tool_cache }}/flutter - key: flutter-${{ env.flutter_version }}-${{ env.flutter_channel }} + echo "ANDROID_HOME=$HOME/Android/Sdk" >> $GITHUB_ENV - name: Install jq run: | - apt-get install -y jq + apt-get install -y jq - id: flutter-action uses: actions/flutter-action@v2 @@ -61,22 +50,11 @@ jobs: flutter-version: ${{ env.flutter_version }} cache: true - - name: Show cache keys - run: | - echo CACHE-PATH=${{ steps.flutter-action.outputs.CACHE-PATH }} - echo CACHE-KEY=${{ steps.flutter-action.outputs.CACHE-KEY }} - echo CHANNEL=${{ steps.flutter-action.outputs.CHANNEL }} - echo VERSION=${{ steps.flutter-action.outputs.VERSION }} - echo ARCHITECTURE=${{ steps.flutter-action.outputs.ARCHITECTURE }} - echo PUB-CACHE-PATH=${{ steps.flutter-action.outputs.PUB-CACHE-PATH }} - echo PUB-CACHE-KEY=${{ steps.flutter-action.outputs.PUB-CACHE-KEY }} - shell: bash - - name: Fix dir permissions run: | git config --global --add safe.directory /opt/hostedtoolcache/flutter/${{ env.flutter_channel }}-${{ env.flutter_version }}-${{ steps.flutter-action.outputs.ARCHITECTURE }} flutter config --android-sdk="$ANDROID_HOME" - flutter doctor -v + flutter doctor -v - name: Get dependencies run: flutter pub get @@ -84,16 +62,13 @@ jobs: - name: Native Analyze run: flutter analyze - #- name: Run Code Metrics - # run: flutter pub run dart_code_metrics:metrics lib --disable-sunset-warning --fatal-warnings --fatal-performance - - name: Test run: | - flutter test + flutter test - name: Build apk run: | - flutter build apk + flutter build apk - name: Rename and move apk run: | @@ -101,7 +76,7 @@ jobs: APK_NAME="eatvio_app_${TIMESTAMP}.apk" mv build/app/outputs/flutter-apk/app-release.apk $APK_NAME echo "APK build finished $APK_NAME" - echo "APK_NAME=$APK_NAME" >> $GITHUB_ENV + echo "APK_NAME=$APK_NAME" >> $GITHUB_ENV - name: Upload APK artifact uses: actions/upload-artifact@v3 diff --git a/lib/features/diary/presentation/bloc/diary_cubit.dart b/lib/features/diary/presentation/bloc/diary_cubit.dart index 74df5385..0c243ac4 100644 --- a/lib/features/diary/presentation/bloc/diary_cubit.dart +++ b/lib/features/diary/presentation/bloc/diary_cubit.dart @@ -25,7 +25,7 @@ class DiaryCubit extends Cubit { emit( DiaryState.loaded( diary: await diaryRepository.getDiaryByDate(date), - nutrition: await getNutrition(await diaryRepository.getDiaryIndexByDate(date)), + nutrition: await getNutrition((await diaryRepository.getDiaryByDate(date)).id), currentSelectedSatietyRating: currentSelectedSatietyRating, ), ); diff --git a/lib/features/diary/repositories/diary_repository.dart b/lib/features/diary/repositories/diary_repository.dart index 42f352f1..3db06d6f 100644 --- a/lib/features/diary/repositories/diary_repository.dart +++ b/lib/features/diary/repositories/diary_repository.dart @@ -11,14 +11,11 @@ class DiaryRepository { }); Future getDiaryByDate(String date) async { - return (await diaryService.getDiaryDay( - index: await getDiaryIndexByDate(date), - )) - .diary; + return (await getDiaryIndexByDate(date)).last; } - Future getDiaryIndexByDate(String date) async { - return (await diaryService.getDiaryIndexByDate(date: date)).id; + Future> getDiaryIndexByDate(String date) async { + return (await diaryService.getDiaryIndexByDate(date: date)); } Future getNutritionData(int index) async { diff --git a/lib/features/diary/services/diary_service.dart b/lib/features/diary/services/diary_service.dart index 833f9604..d4edd406 100644 --- a/lib/features/diary/services/diary_service.dart +++ b/lib/features/diary/services/diary_service.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:eatvio_app/features/diary/models/diary_day_model.dart'; -import 'package:eatvio_app/features/diary/models/diary_index_model.dart'; import 'package:eatvio_app/features/diary/models/nutrition_model.dart'; import 'package:retrofit/retrofit.dart'; @@ -12,7 +11,7 @@ abstract class DiaryService { factory DiaryService(Dio dio, {String baseUrl}) = _DiaryService; @GET('/api/diary/index/{date}') - Future getDiaryIndexByDate({ + Future> getDiaryIndexByDate({ @Path('date') required String date, // yyyy-mm-dd }); diff --git a/lib/features/diary/services/diary_service.g.dart b/lib/features/diary/services/diary_service.g.dart index 03fa20ed..816c7fb5 100644 --- a/lib/features/diary/services/diary_service.g.dart +++ b/lib/features/diary/services/diary_service.g.dart @@ -22,12 +22,13 @@ class _DiaryService implements DiaryService { final ParseErrorLogger? errorLogger; @override - Future getDiaryIndexByDate({required String date}) async { + Future> getDiaryIndexByDate( + {required String date}) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _options = _setStreamType(Options( + final _options = _setStreamType>(Options( method: 'GET', headers: _headers, extra: _extra, @@ -43,10 +44,12 @@ class _DiaryService implements DiaryService { _dio.options.baseUrl, baseUrl, ))); - final _result = await _dio.fetch>(_options); - late DiaryIndexModel _value; + final _result = await _dio.fetch>(_options); + late List _value; try { - _value = DiaryIndexModel.fromJson(_result.data!); + _value = _result.data! + .map((dynamic i) => DiaryDayModel.fromJson(i as Map)) + .toList(); } on Object catch (e, s) { errorLogger?.logError(e, s, _options); rethrow; diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart index 380d37c4..48ace714 100644 --- a/lib/features/profile/presentation/pages/profile_screen.dart +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -124,7 +124,7 @@ class _ProfileScreenState extends State { if (widget.author == null) const SizedBox(height: 16), _activePlans(state), if (widget.author == null) const SizedBox(height: 16), - _newBlogPostButton(), + if (widget.author == null) _newBlogPostButton(), _blogPosts(state), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 652f6273..5b2c8596 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: eatvio_app description: A new Flutter project. -version: 0.0.0+1 +version: 1.0.2+17 publish_to: "none" environment: