Skip to content

Commit

Permalink
Merge pull request #97 from TetsuOtter/9-impl-hako-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
TetsuOtter authored Nov 10, 2023
2 parents aef4892 + b2bf6e7 commit 7ee4b17
Show file tree
Hide file tree
Showing 21 changed files with 1,225 additions and 44 deletions.
485 changes: 473 additions & 12 deletions TRViS.IO/Models/DBStructure.cs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions TRViS.IO/Utils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace TRViS.IO;

internal static class Utils
{
public static bool IsArrayEquals<T>(T[]? arr1, T[]? arr2, IEqualityComparer<T>? comparer = null)
{
if (arr1 == arr2)
return true;
else if (arr1 is null || arr2 is null)
return false;
else if (arr1.Length != arr2.Length)
return false;

return arr1.AsSpan().SequenceEqual(arr2.AsSpan(), comparer);
}
}
18 changes: 18 additions & 0 deletions TRViS/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.Versioning;
#endif

using System.Runtime.CompilerServices;
using TRViS.RootPages;
using TRViS.ViewModels;

Expand Down Expand Up @@ -67,6 +68,23 @@ void ApplyFlyoutBhavior(object? sender, bool oldValue, bool newValue)
}
}

protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
base.OnPropertyChanged(propertyName);

switch (propertyName)
{
case nameof(Width):
logger.Trace("Width: {0}", Width);
InstanceManager.AppViewModel.WindowWidth = Width;
break;
case nameof(Height):
logger.Trace("Height: {0}", Height);
InstanceManager.AppViewModel.WindowHeight = Height;
break;
}
}

public event ValueChangedEventHandler<Thickness>? SafeAreaMarginChanged;
Thickness _SafeAreaMargin;
public Thickness SafeAreaMargin
Expand Down
32 changes: 31 additions & 1 deletion TRViS/DTAC/DTACElementStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
new(0x00, 0x33, 0x00)
);

public static readonly AppThemeColorBindingExtension ForegroundBlackWhite = genColor(0x00, 0xFF);

public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideFrameColor = genColor(0xFF, 0xAA);
public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideTextColor = genColor(0xFF, 0xDD);
public static readonly AppThemeColorBindingExtension LocationServiceNotSelectedSideBaseColor = genColor(0xFF, 0xDD);
Expand All @@ -60,6 +62,8 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
public const string MaterialIconFontFamily = "MaterialIconsRegular";
public const string TimetableNumFontFamily = "Helvetica";

public const string AffectDateLabelTextPrefix = "行路施行日\n";

public static readonly Shadow DefaultShadow = new()
{
Brush = Colors.Black,
Expand Down Expand Up @@ -92,7 +96,7 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
v.Margin = new(4);
v.LineBreakMode = LineBreakMode.CharacterWrap;

v.LineHeight = DeviceInfo.Platform == DevicePlatform.Android ? 0.9 : 1;
v.LineHeight = DeviceInfo.Platform == DevicePlatform.Android ? 0.9 : 1.1;

return v;
}
Expand All @@ -106,6 +110,32 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
return v;
}

public static T AffectDateLabelStyle<T>() where T : Label, new()
{
T v = LabelStyle<T>();

v.Margin = new(18, 0);
v.LineHeight = 1.4;
v.FontSize = 16;
v.HorizontalOptions = LayoutOptions.Start;
v.Text = AffectDateLabelTextPrefix;

return v;
}

public static T HakoTabWorkInfoLabelStyle<T>() where T : Label, new()
{
T v = AffectDateLabelStyle<T>();

v.FontAttributes = FontAttributes.Bold;
v.FontSize = DefaultTextSize;
v.Text = null;
v.HorizontalOptions = LayoutOptions.End;
v.HorizontalTextAlignment = TextAlignment.End;

return v;
}

public static T LargeLabelStyle<T>() where T : Label, new()
{
T v = LabelStyle<T>();
Expand Down
19 changes: 17 additions & 2 deletions TRViS/DTAC/Hako.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
<Grid
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TRViS.DTAC"
xmlns:HakoParts="clr-namespace:TRViS.DTAC.HakoParts"
BackgroundColor="{x:Static local:DTACElementStyles.DefaultBGColor}"
x:Class="TRViS.DTAC.Hako">
</ContentView>
<Grid.RowDefinitions>
<RowDefinition Height="{x:Static local:VerticalStylePage.DATE_AND_START_BUTTON_ROW_HEIGHT}" />
<RowDefinition Height="80" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<ScrollView
x:Name="SimpleViewScrollView"
Grid.Row="2"
>
<HakoParts:SimpleView
x:Name="SimpleView"
/>
</ScrollView>
</Grid>
75 changes: 74 additions & 1 deletion TRViS/DTAC/Hako.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,87 @@
using DependencyPropertyGenerator;

using TRViS.DTAC.HakoParts;

namespace TRViS.DTAC;

public partial class Hako : ContentView
[DependencyProperty<string>("AffectDate")]
[DependencyProperty<string>("WorkName")]
[DependencyProperty<string>("WorkSpaceName")]
public partial class Hako : Grid
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

readonly HeaderView headerView = new();

readonly Label AffectDateLabel;
readonly Label WorkInfoLabel;
static Label GenAffectDateLabel()
{
Label v = DTACElementStyles.AffectDateLabelStyle<Label>();

SetRow(v, 0);

return v;
}
static Label GenWorkInfoLabel()
{
Label v = DTACElementStyles.HakoTabWorkInfoLabelStyle<Label>();

SetRow(v, 0);

return v;
}

public Hako()
{
logger.Trace("Creating...");

InitializeComponent();

Grid.SetRow(headerView, 1);
headerView.EdgeWidth = SimpleView.STA_NAME_TIME_COLUMN_WIDTH;
headerView.LeftEdgeText = Utils.InsertBetweenChars("乗務開始".AsSpan(), '\n');
headerView.RightEdgeText = Utils.InsertBetweenChars("乗務終了".AsSpan(), '\n');
Children.Add(headerView);

AffectDateLabel = GenAffectDateLabel();
Children.Add(AffectDateLabel);

WorkInfoLabel = GenWorkInfoLabel();
Children.Add(WorkInfoLabel);

SimpleView.SetBinding(
WidthRequestProperty,
new Binding()
{
Source = SimpleViewScrollView,
Path = nameof(headerView.Width),
Mode = BindingMode.OneWay,
}
);

logger.Trace("Created");
}

partial void OnAffectDateChanged(string? newValue)
{
logger.Info("AffectDate: {0}", newValue);
AffectDateLabel.Text = DTACElementStyles.AffectDateLabelTextPrefix + newValue;
}

partial void OnWorkNameChanged(string? newValue)
{
logger.Info("WorkName: {0}", newValue);
UpdateWorkInfoLabel(newValue, WorkSpaceName);
}
partial void OnWorkSpaceNameChanged(string? newValue)
{
logger.Info("WorkSpaceName: {0}", newValue);
UpdateWorkInfoLabel(WorkName, newValue);
}

void UpdateWorkInfoLabel(string? workName, string? workSpaceName)
{
WorkInfoLabel.Text = $"{workName}\n{workSpaceName}";
}
}
70 changes: 70 additions & 0 deletions TRViS/DTAC/HakoParts/HeaderView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace TRViS.DTAC.HakoParts;

public class HeaderView : Grid
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

readonly ColumnDefinition EdgeColumnDefinition = new(0);

readonly BoxView backgroundBoxView = new();

readonly Label leftEdgeLabel = DTACElementStyles.HeaderLabelStyle<Label>();
readonly Label rightEdgeLabel = DTACElementStyles.HeaderLabelStyle<Label>();

public HeaderView()
{
logger.Debug("Creating...");

ColumnDefinitions.Add(EdgeColumnDefinition);
ColumnDefinitions.Add(new(new(1, GridUnitType.Star)));
ColumnDefinitions.Add(EdgeColumnDefinition);

DTACElementStyles.HeaderBackgroundColor.Apply(backgroundBoxView, BoxView.ColorProperty);
Grid.SetColumnSpan(backgroundBoxView, 3);
backgroundBoxView.Shadow = new()
{
Brush = Colors.Black,
Offset = new(0, 1),
Radius = 1,
Opacity = 0.4f,
};
Children.Add(backgroundBoxView);

Grid.SetColumn(leftEdgeLabel, 0);
Children.Add(leftEdgeLabel);
Grid.SetColumn(rightEdgeLabel, 2);
Children.Add(rightEdgeLabel);

logger.Debug("Created");
}

public double EdgeWidth
{
get => EdgeColumnDefinition.Width.Value;
set
{
logger.Debug("value: {0} -> {0}", EdgeColumnDefinition.Width.Value, value);
EdgeColumnDefinition.Width = new(value, GridUnitType.Absolute);
}
}

public string? LeftEdgeText
{
get => leftEdgeLabel.Text;
set
{
logger.Debug("value: {0} -> {0}", leftEdgeLabel.Text, value);
leftEdgeLabel.Text = value;
}
}

public string? RightEdgeText
{
get => rightEdgeLabel.Text;
set
{
logger.Debug("value: {0} -> {0}", rightEdgeLabel.Text, value);
rightEdgeLabel.Text = value;
}
}
}
Loading

0 comments on commit 7ee4b17

Please sign in to comment.