-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from LiamMorrow/serialization-improvements
- Loading branch information
Showing
28 changed files
with
693 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
LiftLog.Ui/Models/CurrentSessionStateDao/CurrentSessionStateDaoV2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace LiftLog.Ui.Models.CurrentSessionStateDao; | ||
|
||
using LiftLog.Ui.Models.SessionHistoryDao; | ||
using LiftLog.Ui.Store.CurrentSession; | ||
|
||
internal partial class CurrentSessionStateDaoV2 | ||
{ | ||
public CurrentSessionStateDaoV2( | ||
SessionDaoV2? workoutSession, | ||
SessionDaoV2? historySession, | ||
UUIDDao? latestSetTimerNotificationId | ||
) | ||
{ | ||
WorkoutSession = workoutSession; | ||
HistorySession = historySession; | ||
LatestSetTimerNotificationId = latestSetTimerNotificationId; | ||
} | ||
|
||
public static CurrentSessionStateDaoV2 FromModel(CurrentSessionState model) => | ||
new( | ||
model.WorkoutSession is null ? null : SessionDaoV2.FromModel(model.WorkoutSession), | ||
model.HistorySession is null ? null : SessionDaoV2.FromModel(model.HistorySession), | ||
model.LatestSetTimerNotificationId | ||
); | ||
|
||
public CurrentSessionState ToModel() => | ||
new(WorkoutSession?.ToModel(), HistorySession?.ToModel(), LatestSetTimerNotificationId); | ||
} |
11 changes: 11 additions & 0 deletions
11
LiftLog.Ui/Models/CurrentSessionStateDao/CurrentSessionStateDaoV2.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
package LiftLog.Ui.Models.CurrentSessionStateDao; | ||
|
||
import "Models/Utils.proto"; | ||
import "Models/SessionHistoryDao/SessionHistoryDaoV2.proto"; | ||
|
||
message CurrentSessionStateDaoV2 { | ||
optional LiftLog.Ui.Models.SessionHistoryDao.SessionDaoV2 workout_session = 1; | ||
optional LiftLog.Ui.Models.SessionHistoryDao.SessionDaoV2 history_session = 2; | ||
optional LiftLog.Ui.Models.UUIDDao latest_set_timer_notification_id = 3; | ||
} |
102 changes: 102 additions & 0 deletions
102
LiftLog.Ui/Models/SessionBlueprintDao/SessionBlueprintDaoV2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System.Collections.Immutable; | ||
using Google.Protobuf.WellKnownTypes; | ||
using LiftLog.Lib; | ||
|
||
namespace LiftLog.Ui.Models.SessionBlueprintDao; | ||
|
||
internal partial class SessionBlueprintContainerDaoV2 | ||
{ | ||
public SessionBlueprintContainerDaoV2(IEnumerable<SessionBlueprintDaoV2> sessions) | ||
{ | ||
SessionBlueprints.AddRange(sessions); | ||
} | ||
|
||
public static SessionBlueprintContainerDaoV2 FromModel( | ||
ImmutableList<Lib.Models.SessionBlueprint> model | ||
) => new(model.Select(SessionBlueprintDaoV2.FromModel)); | ||
|
||
public ImmutableListValue<Lib.Models.SessionBlueprint> ToModel() => | ||
SessionBlueprints.Select(x => x.ToModel()).ToImmutableList(); | ||
} | ||
|
||
internal partial class SessionBlueprintDaoV2 | ||
{ | ||
public SessionBlueprintDaoV2( | ||
string name, | ||
IEnumerable<ExerciseBlueprintDaoV2> exerciseBlueprints | ||
) | ||
{ | ||
Name = name; | ||
ExerciseBlueprints.AddRange(exerciseBlueprints); | ||
} | ||
|
||
public static SessionBlueprintDaoV2 FromModel(Lib.Models.SessionBlueprint model) => | ||
new(model.Name, model.Exercises.Select(ExerciseBlueprintDaoV2.FromModel).ToImmutableList()); | ||
|
||
public Lib.Models.SessionBlueprint ToModel() => | ||
new(Name, ExerciseBlueprints.Select(x => x.ToModel()).ToImmutableList()); | ||
} | ||
|
||
internal partial class ExerciseBlueprintDaoV2 | ||
{ | ||
public ExerciseBlueprintDaoV2( | ||
string name, | ||
int sets, | ||
int repsPerSet, | ||
DecimalValue initialWeight, | ||
DecimalValue weightIncreaseOnSuccess, | ||
RestDaoV2 restBetweenSets, | ||
bool supersetWithNext | ||
) | ||
{ | ||
Name = name; | ||
Sets = sets; | ||
RepsPerSet = repsPerSet; | ||
InitialWeight = initialWeight; | ||
WeightIncreaseOnSuccess = weightIncreaseOnSuccess; | ||
RestBetweenSets = restBetweenSets; | ||
SupersetWithNext = supersetWithNext; | ||
} | ||
|
||
public static ExerciseBlueprintDaoV2 FromModel(Lib.Models.ExerciseBlueprint model) => | ||
new( | ||
model.Name, | ||
model.Sets, | ||
model.RepsPerSet, | ||
model.InitialWeight, | ||
model.WeightIncreaseOnSuccess, | ||
RestDaoV2.FromModel(model.RestBetweenSets), | ||
model.SupersetWithNext | ||
); | ||
|
||
public Lib.Models.ExerciseBlueprint ToModel() => | ||
new( | ||
Name, | ||
Sets, | ||
RepsPerSet, | ||
InitialWeight, | ||
WeightIncreaseOnSuccess, | ||
RestBetweenSets.ToModel(), | ||
SupersetWithNext | ||
); | ||
} | ||
|
||
internal partial class RestDaoV2 | ||
{ | ||
public RestDaoV2(Duration minRest, Duration maxRest, Duration failureRest) | ||
{ | ||
MinRest = minRest; | ||
MaxRest = maxRest; | ||
FailureRest = failureRest; | ||
} | ||
|
||
public static RestDaoV2 FromModel(Lib.Models.Rest model) => | ||
new( | ||
Duration.FromTimeSpan(model.MinRest), | ||
Duration.FromTimeSpan(model.MaxRest), | ||
Duration.FromTimeSpan(model.FailureRest) | ||
); | ||
|
||
public Lib.Models.Rest ToModel() => | ||
new(MinRest.ToTimeSpan(), MaxRest.ToTimeSpan(), FailureRest.ToTimeSpan()); | ||
} |
31 changes: 31 additions & 0 deletions
31
LiftLog.Ui/Models/SessionBlueprintDao/SessionBlueprintDaoV2.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
syntax = "proto3"; | ||
package LiftLog.Ui.Models.SessionBlueprintDao; | ||
|
||
import "Models/Utils.proto"; | ||
import "google/protobuf/duration.proto"; | ||
|
||
message SessionBlueprintContainerDaoV2 { | ||
repeated SessionBlueprintDaoV2 session_blueprints = 1; | ||
} | ||
|
||
message SessionBlueprintDaoV2 { | ||
string name = 1; | ||
repeated ExerciseBlueprintDaoV2 exercise_blueprints = 2; | ||
} | ||
|
||
|
||
message ExerciseBlueprintDaoV2 { | ||
string name = 1; | ||
int32 sets = 2; | ||
int32 reps_per_set = 3; | ||
LiftLog.Ui.Models.DecimalValue initial_weight = 4; | ||
LiftLog.Ui.Models.DecimalValue weight_increase_on_success = 5; | ||
RestDaoV2 rest_between_sets = 6; | ||
bool superset_with_next = 7; | ||
} | ||
|
||
message RestDaoV2 { | ||
google.protobuf.Duration min_rest = 1; | ||
google.protobuf.Duration max_rest = 2; | ||
google.protobuf.Duration failure_rest = 3; | ||
} |
Oops, something went wrong.