-
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 #97 from TetsuOtter/9-impl-hako-tab
- Loading branch information
Showing
21 changed files
with
1,225 additions
and
44 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,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); | ||
} | ||
} |
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
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> |
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 |
---|---|---|
@@ -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}"; | ||
} | ||
} |
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,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; | ||
} | ||
} | ||
} |
Oops, something went wrong.