Skip to content

Commit

Permalink
Move to .NET 8 and minor fixes (#9)
Browse files Browse the repository at this point in the history
* 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 dotnet/android-libraries#717
xamarin/GooglePlayServicesComponents#694
  • Loading branch information
BerserkerDotNet authored May 20, 2023
1 parent b5e956a commit 8b86007
Show file tree
Hide file tree
Showing 23 changed files with 169 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-wt-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/workout-tracker-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
Expand Down
4 changes: 2 additions & 2 deletions src/WorkoutTracker.MAUI/Controls/ExerciseSetView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:ctrl="clr-namespace:WorkoutTracker.MAUI.Controls"
xmlns:ctrl="clr-namespace:WorkoutTracker.Services.Models;assembly=WorkoutTracker.Services"
x:Class="WorkoutTracker.MAUI.Controls.ExerciseSetView">
<Grid Margin="0,0,8,0" x:DataType="ctrl:SetWrapper">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<dxe:Chip Text="{Binding Number}" BackgroundColor="{Binding Color}" Grid.Column="0" HeightRequest="40" WidthRequest="40" Tap="OnTap" />
<dxe:Chip Text="{Binding Number}" BackgroundColor="{Binding Color}" Grid.Column="0" HeightRequest="50" WidthRequest="50" Tap="OnTap" />
<dxe:NumericEdit Value="{Binding Set.Weight, Mode=TwoWay}" Prefix="Weight:" Suffix="LB" Grid.Column="1" BoxMode="Filled" BackgroundColor="Transparent" MinValue="0" SelectValueOnFocus="True" />
<dxe:NumericEdit Value="{Binding Set.Repetitions}" Prefix="Reps:" Grid.Column="2" BoxMode="Filled" BackgroundColor="Transparent" MinValue="0" SelectValueOnFocus="True" />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
x:Name="setsStatus"
Margin="10,2"
HeightRequest="40"
WidthRequest="50" />
WidthRequest="60" />
</StackLayout>
<dxe:Chip x:Name="contextMenuBtn"
Grid.Column="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using WorkoutTracker.Models.Contracts;
using WorkoutTracker.Models.Entities;
using WorkoutTracker.Models.Presentation;
using WorkoutTracker.Services.Models;

namespace WorkoutTracker.MAUI.Controls;

Expand Down Expand Up @@ -205,9 +206,4 @@ private void OnReduceSetsClicked(object sender, System.EventArgs e)
ReduceSetsCommand.Execute(_viewModel);
}
}
}

public record SetWrapper(int Number, IExerciseSet Set, LogEntryViewModel Model)
{
public Color Color => Set.GetColor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors"
xmlns:ctrl="clr-namespace:WorkoutTracker.MAUI.Controls"
xmlns:ctrl="clr-namespace:WorkoutTracker.Services.Models;assembly=WorkoutTracker.Services"
x:Class="WorkoutTracker.MAUI.Controls.WorkoutDefinitionEditor">
<Grid Margin="0,0,8,0" x:DataType="ctrl:SetWrapper">
<Grid.ColumnDefinitions>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -33,31 +29,4 @@ public static MauiAppBuilder AddViews(this MauiAppBuilder builder)
builder.Services.AddSingleton<EditWorkoutDefinition>();
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
};
}
}
}
1 change: 1 addition & 0 deletions src/WorkoutTracker.MAUI/Services/ApiRepositoryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using WorkoutTracker.Models.Contracts;
using WorkoutTracker.Models.Entities;
using WorkoutTracker.Models.Presentation;
using WorkoutTracker.Services;

namespace WorkoutTracker.MAUI.Services;

Expand Down
1 change: 1 addition & 0 deletions src/WorkoutTracker.MAUI/Services/Data/DataSyncWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using WorkoutTracker.MAUI.Services;
using WorkoutTracker.MAUI.Services.Data;
using WorkoutTracker.Models.Presentation;
using WorkoutTracker.Services;

namespace WorkoutTracker.MAUI.ViewModels;

Expand Down
5 changes: 3 additions & 2 deletions src/WorkoutTracker.MAUI/Views/Workout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,7 +50,8 @@
Icon="timer"
IconVisible="True"
IconColor="White" />
<Label Text="No exercises for today." HorizontalOptions="CenterAndExpand" HorizontalTextAlignment="Center" Margin="8,0,0,0" IsVisible="{Binding TodaySets, Converter={StaticResource CollectionToVisibilityConverter}}" Grid.Row="1" />
<Label Text="No exercises for today." HorizontalOptions="CenterAndExpand" HorizontalTextAlignment="Center" Margin="8,0,0,0"
IsVisible="{Binding TodaySets, Converter={StaticResource CollectionToVisibilityConverter}}" Grid.Row="1" />
<dxcv:DXCollectionView
x:Name="setsList"
Grid.Row="1"
Expand Down
2 changes: 1 addition & 1 deletion src/WorkoutTracker.MAUI/Views/Workout.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AndroidX.Work;
using System;
using WorkoutTracker.MAUI.Services.Data;
using WorkoutTracker.MAUI.ViewModels;
using WorkoutTracker.Services.ViewModels;

namespace WorkoutTracker.MAUI.Views;

Expand Down
25 changes: 12 additions & 13 deletions src/WorkoutTracker.MAUI/WorkoutTracker.MAUI.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-android</TargetFramework>
<TargetFramework>net8.0-android</TargetFramework>
<OutputType>Exe</OutputType>
<SingleProject>true</SingleProject>
<UseMaui>true</UseMaui>
Expand All @@ -18,9 +18,9 @@
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>2.0</ApplicationDisplayVersion>

<UseInterpreter Condition="'$(TargetFramework)' == 'net7.0-android'">False</UseInterpreter>
<UseInterpreter Condition="'$(TargetFramework)' == 'net8.0-android'">False</UseInterpreter>
<LangVersion>preview</LangVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net7.0-android'">28.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-android'">28.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -64,23 +64,22 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Plugin.LocalNotification" Version="10.0.3" />
<PackageReference Include="CommunityToolkit.Maui" Version="3.1.0" />
<PackageReference Include="Plugin.LocalNotification" Version="10.1.4" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.1.0" />
<PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.7.1.5" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.5.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.47.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.25.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0-rc.2.*" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.0-preview.3.23177.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0-preview.3.23174.8" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.54.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.30.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0-preview.3.23174.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0-preview.3.23174.8" />
<PackageReference Include="DevExpress.Maui.Charts" Version="22.2.3" />
<PackageReference Include="DevExpress.Maui.CollectionView" Version="22.2.3" />
<PackageReference Include="DevExpress.Maui.Core" Version="22.2.3" />
<PackageReference Include="DevExpress.Maui.DataGrid" Version="22.2.3" />
<PackageReference Include="DevExpress.Maui.Editors" Version="22.2.3" />
<PackageReference Include="DevExpress.Maui.Scheduler" Version="22.2.3" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageReference Include="UnitsNet" Version="4.149.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.2" />
Expand Down
2 changes: 1 addition & 1 deletion src/WorkoutTracker.Models/WorkoutTracker.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using WorkoutTracker.MAUI.Interfaces;

namespace WorkoutTracker.MAUI.Services;
namespace WorkoutTracker.Services;

public class ApplicationContext : ILogger, INotificationService
{
Expand Down
34 changes: 34 additions & 0 deletions src/WorkoutTracker.Services/Extensions/IExerciseSetExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.Maui.Graphics;
using WorkoutTracker.Models.Contracts;
using WorkoutTracker.Models.Entities;
using WorkoutTracker.Models.Presentation;

namespace WorkoutTracker.Services.Extensions
{
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
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public interface IWorkoutDataProvider
Profile GetProfile();

IEnumerable<WorkoutProgram> GetPrograms();

IEnumerable<LogEntryViewModel> GetTodaysSchedule();
}
10 changes: 10 additions & 0 deletions src/WorkoutTracker.Services/Models/SetWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using WorkoutTracker.Models.Contracts;
using WorkoutTracker.Models.Presentation;
using WorkoutTracker.Services.Extensions;

namespace WorkoutTracker.Services.Models;

public record SetWrapper(int Number, IExerciseSet Set, LogEntryViewModel Model)
{
public Color Color => Set.GetColor();
}
Loading

0 comments on commit 8b86007

Please sign in to comment.