From 8b86007ca75b2a1062fca40656a722021a445128 Mon Sep 17 00:00:00 2001 From: Andrii Snihyr Date: Sat, 20 May 2023 10:50:46 -0700 Subject: [PATCH] Move to .NET 8 and minor fixes (#9) * fix width of the set indicator fix persistance of the model when sets are updated migrate to .NET 8 * fix width of the set indicator fix persistance of the model when sets are updated migrate to .NET 8 * run on windows * package updates and using a flag * no framework flag * downgrade package due to https://github.com/xamarin/AndroidX/issues/717 https://github.com/xamarin/GooglePlayServicesComponents/issues/694 --- .github/workflows/publish-wt-service.yml | 4 +- .github/workflows/workout-tracker-api.yml | 6 +- build/build.csproj | 2 +- .../Controls/ExerciseSetView.xaml | 4 +- .../Controls/ExerciseSetsCollection.xaml | 2 +- .../Controls/ExerciseSetsCollection.xaml.cs | 6 +- .../Controls/WorkoutDefinitionEditor.xaml | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 33 +-------- .../Services/ApiRepositoryClient.cs | 1 + .../Services/Data/DataSyncWorker.cs | 1 + .../ViewModels/EditExercisePageViewModel.cs | 1 + src/WorkoutTracker.MAUI/Views/Workout.xaml | 5 +- src/WorkoutTracker.MAUI/Views/Workout.xaml.cs | 2 +- .../WorkoutTracker.MAUI.csproj | 25 +++---- .../WorkoutTracker.Models.csproj | 2 +- .../ApplicationContext.cs | 2 +- .../Extensions/IExerciseSetExtensions.cs | 34 +++++++++ .../Interfaces/IWorkoutDataProvider.cs | 2 + .../Models/SetWrapper.cs | 10 +++ .../ViewModels/WorkoutViewModel.cs | 29 ++++---- .../WorkoutTracker.Services.csproj | 2 +- .../ViewModels/WorkoutViewModelTests.cs | 74 +++++++++++++++++++ .../WorkoutTracker.UnitTests.csproj | 2 +- 23 files changed, 169 insertions(+), 82 deletions(-) rename src/{WorkoutTracker.MAUI/Services => WorkoutTracker.Services}/ApplicationContext.cs (96%) create mode 100644 src/WorkoutTracker.Services/Extensions/IExerciseSetExtensions.cs create mode 100644 src/WorkoutTracker.Services/Models/SetWrapper.cs rename src/{WorkoutTracker.MAUI => WorkoutTracker.Services}/ViewModels/WorkoutViewModel.cs (92%) create mode 100644 tests/WorkoutTracker.UnitTests/ViewModels/WorkoutViewModelTests.cs diff --git a/.github/workflows/publish-wt-service.yml b/.github/workflows/publish-wt-service.yml index f3985df..43fc51d 100644 --- a/.github/workflows/publish-wt-service.yml +++ b/.github/workflows/publish-wt-service.yml @@ -10,7 +10,7 @@ env: PROJECT_NAME_FOR_DOCKER: workouttracker-api jobs: publish: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Checkout to the branch uses: actions/checkout@v2 @@ -34,7 +34,7 @@ jobs: name: binlog path: msbuild.binlog deploy: - runs-on: ubuntu-latest + runs-on: windows-latest needs: publish steps: - name: Azure Login diff --git a/.github/workflows/workout-tracker-api.yml b/.github/workflows/workout-tracker-api.yml index ba138c6..20fa7da 100644 --- a/.github/workflows/workout-tracker-api.yml +++ b/.github/workflows/workout-tracker-api.yml @@ -10,11 +10,11 @@ env: CONTAINER_APP_NAME: workout-tracker-api CONTAINER_APP_RESOURCE_GROUP_NAME: workout-tracker CONTAINER_REGISTRY_LOGIN_SERVER: berserkerdotnetcregistry.azurecr.io - DOTNET_CORE_VERSION: 7.0.x + DOTNET_CORE_VERSION: 8.0.x PROJECT_NAME_FOR_DOCKER: workouttracker-api jobs: build: - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Checkout to the branch uses: actions/checkout@v2 @@ -30,7 +30,7 @@ jobs: - name: Install dependencies run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore -bl + run: dotnet build --configuration Release --no-restore -bl -p:AndroidEnableMarshalMethods=false - name: Test run: dotnet test --no-restore --verbosity normal - name: Upload binlog for investigation diff --git a/build/build.csproj b/build/build.csproj index ae21513..3cddce0 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 CS0649;CS0169 .. diff --git a/src/WorkoutTracker.MAUI/Controls/ExerciseSetView.xaml b/src/WorkoutTracker.MAUI/Controls/ExerciseSetView.xaml index a9f00fe..2017e18 100644 --- a/src/WorkoutTracker.MAUI/Controls/ExerciseSetView.xaml +++ b/src/WorkoutTracker.MAUI/Controls/ExerciseSetView.xaml @@ -2,7 +2,7 @@ @@ -10,7 +10,7 @@ - + diff --git a/src/WorkoutTracker.MAUI/Controls/ExerciseSetsCollection.xaml b/src/WorkoutTracker.MAUI/Controls/ExerciseSetsCollection.xaml index 95b0d7d..d1def39 100644 --- a/src/WorkoutTracker.MAUI/Controls/ExerciseSetsCollection.xaml +++ b/src/WorkoutTracker.MAUI/Controls/ExerciseSetsCollection.xaml @@ -62,7 +62,7 @@ x:Name="setsStatus" Margin="10,2" HeightRequest="40" - WidthRequest="50" /> + WidthRequest="60" /> Set.GetColor(); } \ No newline at end of file diff --git a/src/WorkoutTracker.MAUI/Controls/WorkoutDefinitionEditor.xaml b/src/WorkoutTracker.MAUI/Controls/WorkoutDefinitionEditor.xaml index 04bad17..ee923e1 100644 --- a/src/WorkoutTracker.MAUI/Controls/WorkoutDefinitionEditor.xaml +++ b/src/WorkoutTracker.MAUI/Controls/WorkoutDefinitionEditor.xaml @@ -2,7 +2,7 @@ diff --git a/src/WorkoutTracker.MAUI/Extensions/ServiceCollectionExtensions.cs b/src/WorkoutTracker.MAUI/Extensions/ServiceCollectionExtensions.cs index 73f882a..3db393c 100644 --- a/src/WorkoutTracker.MAUI/Extensions/ServiceCollectionExtensions.cs +++ b/src/WorkoutTracker.MAUI/Extensions/ServiceCollectionExtensions.cs @@ -1,11 +1,7 @@ using Microsoft.Extensions.DependencyInjection; -using Microsoft.Maui.Graphics; using Microsoft.Maui.Hosting; using WorkoutTracker.MAUI.ViewModels; using WorkoutTracker.MAUI.Views; -using WorkoutTracker.Models.Contracts; -using WorkoutTracker.Models.Entities; -using WorkoutTracker.Models.Presentation; using WorkoutTracker.Services.ViewModels; namespace WorkoutTracker.MAUI.Extensions; @@ -33,31 +29,4 @@ public static MauiAppBuilder AddViews(this MauiAppBuilder builder) builder.Services.AddSingleton(); return builder; } -} - -public static class IExerciseSetExtensions -{ - public static Color GetColor(this IExerciseSet set) - { - return set switch - { - LegacySet => Colors.LightGreen, - CompletedSet => Colors.LightGreen, - InProgressSet => Colors.LightPink, - ProposedSet => Colors.LightSkyBlue, - _ => Colors.Gray - }; - } - - public static SetStatus GetStatus(this IExerciseSet set) - { - return set switch - { - LegacySet => SetStatus.Completed, - CompletedSet => SetStatus.Completed, - InProgressSet => SetStatus.InProgress, - ProposedSet => SetStatus.NotStarted, - _ => SetStatus.NotStarted - }; - } -} +} \ No newline at end of file diff --git a/src/WorkoutTracker.MAUI/Services/ApiRepositoryClient.cs b/src/WorkoutTracker.MAUI/Services/ApiRepositoryClient.cs index fea11ab..5961a97 100644 --- a/src/WorkoutTracker.MAUI/Services/ApiRepositoryClient.cs +++ b/src/WorkoutTracker.MAUI/Services/ApiRepositoryClient.cs @@ -14,6 +14,7 @@ using WorkoutTracker.Models.Contracts; using WorkoutTracker.Models.Entities; using WorkoutTracker.Models.Presentation; +using WorkoutTracker.Services; namespace WorkoutTracker.MAUI.Services; diff --git a/src/WorkoutTracker.MAUI/Services/Data/DataSyncWorker.cs b/src/WorkoutTracker.MAUI/Services/Data/DataSyncWorker.cs index 4a8c51d..03d06d3 100644 --- a/src/WorkoutTracker.MAUI/Services/Data/DataSyncWorker.cs +++ b/src/WorkoutTracker.MAUI/Services/Data/DataSyncWorker.cs @@ -16,6 +16,7 @@ using WorkoutTracker.MAUI.Services.Data.Entities; using WorkoutTracker.Models.Entities; using WorkoutTracker.Models.Presentation; +using WorkoutTracker.Services; using Xamarin.Android.Net; namespace WorkoutTracker.MAUI.Services.Data; diff --git a/src/WorkoutTracker.MAUI/ViewModels/EditExercisePageViewModel.cs b/src/WorkoutTracker.MAUI/ViewModels/EditExercisePageViewModel.cs index 33d7386..d272c69 100644 --- a/src/WorkoutTracker.MAUI/ViewModels/EditExercisePageViewModel.cs +++ b/src/WorkoutTracker.MAUI/ViewModels/EditExercisePageViewModel.cs @@ -4,6 +4,7 @@ using WorkoutTracker.MAUI.Services; using WorkoutTracker.MAUI.Services.Data; using WorkoutTracker.Models.Presentation; +using WorkoutTracker.Services; namespace WorkoutTracker.MAUI.ViewModels; diff --git a/src/WorkoutTracker.MAUI/Views/Workout.xaml b/src/WorkoutTracker.MAUI/Views/Workout.xaml index 404d910..c39d896 100644 --- a/src/WorkoutTracker.MAUI/Views/Workout.xaml +++ b/src/WorkoutTracker.MAUI/Views/Workout.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:conv="clr-namespace:WorkoutTracker.MAUI.Converters" xmlns:ctrl="clr-namespace:WorkoutTracker.MAUI.Controls" - xmlns:vm="clr-namespace:WorkoutTracker.MAUI.ViewModels" + xmlns:vm="clr-namespace:WorkoutTracker.Services.ViewModels;assembly=WorkoutTracker.Services" xmlns:model="clr-namespace:WorkoutTracker.Models.Presentation;assembly=WorkoutTracker.Models" xmlns:entities="clr-namespace:WorkoutTracker.Models.Entities;assembly=WorkoutTracker.Models" xmlns:dxcv="clr-namespace:DevExpress.Maui.CollectionView;assembly=DevExpress.Maui.CollectionView" @@ -50,7 +50,8 @@ Icon="timer" IconVisible="True" IconColor="White" /> -