Skip to content

Commit

Permalink
New controls for mobile devices with labels inset
Browse files Browse the repository at this point in the history
  • Loading branch information
grantcolley committed Oct 10, 2022
1 parent 1dc33c2 commit 5dbced9
Show file tree
Hide file tree
Showing 32 changed files with 1,271 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Headway.Core.Helpers;
using Headway.Core.Model;
using Headway.Core.Notifications;
using Headway.Blazor.Controls.Base;
using Headway.RequestApi.Requests;
using MediatR;
using Microsoft.AspNetCore.Components;
Expand All @@ -13,7 +12,7 @@
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Headway.Blazor.Controls.Components
namespace Headway.Blazor.Controls.Base
{
[DynamicComponent]
public abstract class OptionBase : DynamicComponentBase
Expand Down Expand Up @@ -59,7 +58,7 @@ protected override async Task OnInitializedAsync()

var arg = ComponentArgHelper.GetArg(ComponentArgs, Options.OPTIONS_CODE);

if(arg == null)
if (arg == null)
{
options = ComponentArgs
.Select(a => new OptionItem { Id = a.Name, Display = a.Value.ToString() })
Expand All @@ -84,7 +83,7 @@ protected override async Task OnParametersSetAsync()
options = new List<OptionItem>(optionItems);
}

await OnInitializedAsync().ConfigureAwait(false);
await OnInitializedAsync().ConfigureAwait(false);
}
}
}
25 changes: 25 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Checkbox.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits CheckboxBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudCheckBox T="bool" @bind-Checked="PropertyValue" Label="@Field.Label" />
}
else
{
<MudTooltip Text="@Field.Tooltip" Placement="Placement.Top">
<MudCheckBox T="bool" @bind-Checked="PropertyValue" Label="@Field.Label" />
</MudTooltip>
}
</div>
<div class="col-sm-8"></div>
</div>
</div>
21 changes: 21 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Checkbox.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Headway.Core.Attributes;
using Headway.Blazor.Controls.Base;

namespace Headway.Blazor.Controls.Components.Mobile
{
[DynamicComponent]
public abstract class CheckboxBase : DynamicComponentBase
{
public bool PropertyValue
{
get
{
return (bool)Field.PropertyInfo.GetValue(Field.Model);
}
set
{
Field.PropertyInfo.SetValue(Field.Model, value);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits CheckboxNullableBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudCheckBox T="bool?" @bind-Checked="PropertyValue" Label="@Field.Label" />
}
else
{
<MudTooltip Text="@Field.Tooltip" Placement="Placement.Top">
<MudCheckBox T="bool?" @bind-Checked="PropertyValue" Label="@Field.Label" />
</MudTooltip>
}
</div>
<div class="col-sm-8"></div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Headway.Core.Attributes;
using Headway.Blazor.Controls.Base;

namespace Headway.Blazor.Controls.Components.Mobile
{
[DynamicComponent]
public abstract class CheckboxNullableBase : DynamicComponentBase
{
public bool? PropertyValue
{
get
{
return (bool?)Field.PropertyInfo.GetValue(Field.Model);
}
set
{
Field.PropertyInfo.SetValue(Field.Model, value);
}
}
}
}
27 changes: 27 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Date.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits DateBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudTextField T="DateTime" @bind-Value="@PropertyValue" For="FieldExpression" Format="yyyy-MM-dd"
Variant="Variant.Outlined" InputType="InputType.Date" Label="@Field.Label" />
}
else
{
<MudTooltip Text="@Field.Tooltip" Placement="Placement.Top">
<MudTextField T="DateTime" @bind-Value="@PropertyValue" For="FieldExpression" Format="yyyy-MM-dd"
Variant="Variant.Outlined" InputType="InputType.Date" Label="@Field.Label" />
</MudTooltip>
}
</div>
<div class="col-sm-8" />
</div>
</div>
32 changes: 32 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Date.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Headway.Core.Attributes;
using Headway.Blazor.Controls.Base;
using Microsoft.AspNetCore.Components;
using System;
using System.Linq.Expressions;

namespace Headway.Blazor.Controls.Components.Mobile
{
[DynamicComponent]
public abstract class DateBase : DynamicComponentBase
{
public Expression<Func<DateTime>> FieldExpression
{
get
{
return Expression.Lambda<Func<DateTime>>(Field.MemberExpression);
}
}

public DateTime PropertyValue
{
get
{
return (DateTime)Field.PropertyInfo.GetValue(Field.Model);
}
set
{
Field.PropertyInfo.SetValue(Field.Model, value);
}
}
}
}
27 changes: 27 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/DateNullable.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits DateNullableBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudTextField T="DateTime?" @bind-Value="@PropertyValue" For="FieldExpression" Format="yyyy-MM-dd"
Variant="Variant.Outlined" InputType="InputType.Date" Label="@Field.Label" />
}
else
{
<MudTooltip Text="@Field.Tooltip" Placement="Placement.Top">
<MudTextField T="DateTime?" @bind-Value="@PropertyValue" For="FieldExpression" Format="yyyy-MM-dd"
Variant="Variant.Outlined" InputType="InputType.Date" Label="@Field.Label" />
</MudTooltip>
}
</div>
<div class="col-sm-8" />
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Headway.Core.Attributes;
using Headway.Blazor.Controls.Base;
using Microsoft.AspNetCore.Components;
using System;
using System.Linq.Expressions;

namespace Headway.Blazor.Controls.Components.Mobile
{
[DynamicComponent]
public abstract class DateNullableBase : DynamicComponentBase
{
public Expression<Func<DateTime?>> FieldExpression
{
get
{
return Expression.Lambda<Func<DateTime?>>(Field.MemberExpression);
}
}

public DateTime? PropertyValue
{
get
{
return (DateTime?)Field.PropertyInfo.GetValue(Field.Model);
}
set
{
Field.PropertyInfo.SetValue(Field.Model, value);
}
}
}
}
27 changes: 27 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Decimal.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits DecimalBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudNumericField @bind-Value="@PropertyValue" MaxLength="@MaxLength" Min="@Min" Max="@Max"
For="FieldExpression" Variant="Variant.Outlined" Label="@Field.Label" />
}
else
{
<ComponentTip Text="@Field.Tooltip">
<MudNumericField @bind-Value="@PropertyValue" MaxLength="@MaxLength" Min="@Min" Max="@Max"
For="FieldExpression" Variant="Variant.Outlined" Label="@Field.Label" />
</ComponentTip>
}
</div>
<div class="col-sm-8" />
</div>
</div>
77 changes: 77 additions & 0 deletions src/Headway.Blazor.Controls/Components/Mobile/Decimal.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Headway.Core.Attributes;
using Headway.Core.Constants;
using Headway.Core.Helpers;
using Headway.Blazor.Controls.Base;
using Microsoft.AspNetCore.Components;
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Headway.Blazor.Controls.Components.Mobile
{
[DynamicComponent]
public abstract class DecimalBase : DynamicComponentBase
{
protected string format = string.Empty;
protected int? maxLength = null;
protected decimal? min = null;
protected decimal? max = null;

protected override Task OnInitializedAsync()
{
var formatArg = ComponentArgHelper.GetArg(ComponentArgs, Args.FORMAT);

if (formatArg != null)
{
format = formatArg.Value;
}

var maxLengthArg = ComponentArgHelper.GetArg(ComponentArgs, Args.MAX_LENGTH);

if (maxLengthArg != null)
{
maxLength = int.Parse(maxLengthArg.Value);
}

var minArg = ComponentArgHelper.GetArg(ComponentArgs, Args.MIN);

if (minArg != null)
{
min = decimal.Parse(minArg.Value);
}

var maxArg = ComponentArgHelper.GetArg(ComponentArgs, Args.MAX);

if (maxArg != null)
{
max = decimal.Parse(maxArg.Value);
}

return base.OnInitializedAsync();
}

public int MaxLength { get { return maxLength.HasValue ? maxLength.Value : int.MaxValue; } }
public decimal Max { get { return max ?? decimal.MaxValue; } }
public decimal Min { get { return min ?? decimal.MinValue; } }

public Expression<Func<decimal>> FieldExpression
{
get
{
return Expression.Lambda<Func<decimal>>(Field.MemberExpression);
}
}

public decimal PropertyValue
{
get
{
return (decimal)Field.PropertyInfo.GetValue(Field.Model);
}
set
{
Field.PropertyInfo.SetValue(Field.Model, value);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@using Headway.Core.Dynamic
@using Headway.Core.Model
@using Microsoft.AspNetCore.Components.Forms
@using System.Reflection
@using System.Linq.Expressions

@inherits DecimalNullableBase

<div class="mb-1">
<div class="row">
<div class="col-sm-4">
@if(string.IsNullOrWhiteSpace(Field.Tooltip))
{
<MudNumericField @bind-Value="@PropertyValue" Format="@format" MaxLength="@MaxLength" Min="@Min" Max="@Max"
For="FieldExpression" Variant="Variant.Outlined" Label="@Field.Label" />
}
else
{
<ComponentTip Text="@Field.Tooltip">
<MudNumericField @bind-Value="@PropertyValue" Format="@format" MaxLength="@MaxLength" Min="@Min" Max="@Max"
For="FieldExpression" Variant="Variant.Outlined" Label="@Field.Label" />
</ComponentTip>
}
</div>
<div class="col-sm-8" />
</div>
</div>
Loading

0 comments on commit 5dbced9

Please sign in to comment.