Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

「ハコ」タブを簡易実装 #97

Merged
merged 29 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
442dde1
add `ForegroundBlackWhite`
TetsuOtter Nov 5, 2023
70e1397
Create SimpleRow.cs
TetsuOtter Nov 5, 2023
04089ea
Create SimpleView.cs
TetsuOtter Nov 5, 2023
57d4252
列番2段表示用に高さを調整
TetsuOtter Nov 6, 2023
9399a6b
列番2段表示のサンプル追加
TetsuOtter Nov 6, 2023
838358b
スタイルを修正
TetsuOtter Nov 6, 2023
7433ba3
初期状態で「ハコ」タブを表示するようにした
TetsuOtter Nov 6, 2023
34b867b
単一選択機能を実装
TetsuOtter Nov 7, 2023
90d1a41
AppViewModelとの連動を実装
TetsuOtter Nov 7, 2023
b3897da
HakoをContentViewからGridに変更
TetsuOtter Nov 7, 2023
de7f1df
WindowサイズをAppViewModelに格納するようにした
TetsuOtter Nov 9, 2023
a962492
行路施行日のラベル生成をDTACElementStylesに移行
TetsuOtter Nov 9, 2023
8063039
TabButtonのサイズ自動調整を実装
TetsuOtter Nov 9, 2023
18e023f
AppViewModelのPropChanged Handlerにて、propごとに関数分離
TetsuOtter Nov 9, 2023
8043342
AffectDateの生成をViewHostに移動
TetsuOtter Nov 9, 2023
da19d67
一部定数のpublic化
TetsuOtter Nov 9, 2023
c1bf02e
add `InsertBetweenChars` function
TetsuOtter Nov 9, 2023
df267e4
Create HeaderView.cs
TetsuOtter Nov 9, 2023
6a6d937
とりあえず行路一覧を表示できるようにした
TetsuOtter Nov 9, 2023
b73f2fd
Merge branch 'main' into 9-impl-hako-tab
TetsuOtter Nov 9, 2023
be63a11
WorkのRemarksにサンプル文字列をセット
TetsuOtter Nov 9, 2023
22d2bfa
HakoでRemarksを表示できるようにした
TetsuOtter Nov 9, 2023
04e8fea
タブ切り替えを行った際に、自動でRemarksを閉じるようにした
TetsuOtter Nov 9, 2023
fb0f692
不要な実装を削除
TetsuOtter Nov 10, 2023
bfa4f63
Create Utils.cs
TetsuOtter Nov 10, 2023
8ead2d6
recordからclassに変更
TetsuOtter Nov 10, 2023
682a8e8
初期状態で選択されている列車がきちんとUIにも反映されるようにした
TetsuOtter Nov 10, 2023
c952389
列車非選択状態では、時刻表に何も表示しないようにした
TetsuOtter Nov 10, 2023
b2bf6e7
スタイルを調整
TetsuOtter Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading