diff --git a/.github/workflows/cd-action.yml b/.github/workflows/cd-action.yml index 8fe969ea..6c1a7a43 100644 --- a/.github/workflows/cd-action.yml +++ b/.github/workflows/cd-action.yml @@ -19,12 +19,12 @@ env: CSPROJ_PATH: ./TRViS/TRViS.csproj THIRD_PARTY_LICENSE_INFO_DIR: ./TRViS/Resources/Raw/licenses THIRD_PARTY_LICENSE_LIST_NAME: license_list - TARGET_FRAMEWORK: net8.0-ios + TARGET_FRAMEWORK: net9.0-ios TARGET_RUNTIME: ios-arm64 - TARGET_FRAMEWORK_MAC: net8.0-maccatalyst + TARGET_FRAMEWORK_MAC: net9.0-maccatalyst TARGET_RUNTIME_MAC: osx - TARGET_FRAMEWORK_ANDROID: net8.0-android - TARGET_FRAMEWORK_WIN: net8.0-windows10.0.19041.0 + TARGET_FRAMEWORK_ANDROID: net9.0-android + TARGET_FRAMEWORK_WIN: net9.0-windows10.0.19041.0 TARGET_RUNTIME_WINX64: win10-x64 TARGET_RUNTIME_WINX86: win10-x86 OUTPUT_DIR: ./out @@ -36,9 +36,9 @@ env: ASSET_NAME_WIN_X86: TRViS-win-x86 ASSET_NAME_WIN_X64_SELF_CONTAINED: TRViS-win-x64-self-contained ASSET_NAME_WIN_X86_SELF_CONTAINED: TRViS-win-x86-self-contained - SDK_VERSION: '8.0.401' + SDK_VERSION: '9.0.100' APP_CENTER_SECRETS_FILE_NAME: ./TRViS/AppCenterSecrets.cs - IOS_DSYM_PATH: ./TRViS/bin/Release/net8.0-ios/ios-arm64 + IOS_DSYM_PATH: ./TRViS/bin/Release/net9.0-ios/ios-arm64 IOS_DSYM_FILENAME: TRViS.app.dSYM jobs: diff --git a/TRViS.IO/Loaders/LoaderJson.cs b/TRViS.IO/Loaders/LoaderJson.cs index a03527a8..d99577cb 100644 --- a/TRViS.IO/Loaders/LoaderJson.cs +++ b/TRViS.IO/Loaders/LoaderJson.cs @@ -158,7 +158,7 @@ private LoaderJson(WorkGroupData[] workGroups) // TODO: JSONでのNextTrainIdのサポート NextTrainId = trainIndex != trainList.Length - 1 ? trainIdList[trainIdIndex] : null }, - trainData.TimetableRows.Select((v, i) => new TimetableRow( + trainData.TimetableRows.Select(static (v, i) => new TimetableRow( Id: v.Id ?? i.ToString(), Location: new(v.Location_m, v.Longitude_deg, v.Latitude_deg, v.OnStationDetectRadius_m), DriveTimeMM: v.DriveTime_MM, @@ -257,7 +257,7 @@ public IReadOnlyList GetWorkList(string workGroupId) => WorkData.Values.Where(v => v.WorkGroupId == workGroupId).ToArray(); public IReadOnlyList GetTrainDataList(string workId) - => TrainData.Values.Where((v) => WorkIdByTrainId[v.Item1.Id] == workId).Select(v => v.Item1).ToArray(); + => TrainData.Values.Where((v) => WorkIdByTrainId[v.Item1.Id] == workId).Select(static v => v.Item1).ToArray(); public IReadOnlyList GetTrainDataGroupList() { diff --git a/TRViS.IO/Loaders/LoaderSQL.cs b/TRViS.IO/Loaders/LoaderSQL.cs index dcdc8d73..f1f4e205 100644 --- a/TRViS.IO/Loaders/LoaderSQL.cs +++ b/TRViS.IO/Loaders/LoaderSQL.cs @@ -32,7 +32,7 @@ on n.Id equals t.WorkId TrainNumber = t.TrainNumber }; - foreach (var group in res.GroupBy(v => v.GroupId)) + foreach (var group in res.GroupBy(static v => v.GroupId)) { List fileInfo = new(); foreach (var work in group) diff --git a/TRViS.LocationService.Tests/TRViS.LocationService.Tests.csproj b/TRViS.LocationService.Tests/TRViS.LocationService.Tests.csproj index e66ce188..9af04c1d 100644 --- a/TRViS.LocationService.Tests/TRViS.LocationService.Tests.csproj +++ b/TRViS.LocationService.Tests/TRViS.LocationService.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable diff --git a/TRViS.LocationService/LonLatLocationService.cs b/TRViS.LocationService/LonLatLocationService.cs index 4165897e..16e2b94d 100644 --- a/TRViS.LocationService/LonLatLocationService.cs +++ b/TRViS.LocationService/LonLatLocationService.cs @@ -37,7 +37,7 @@ public StaLocationInfo[]? StaLocationInfo return; _staLocationInfo = value; - CanUseService = _staLocationInfo?.Any(v => v.HasLonLatLocation) ?? false; + CanUseService = _staLocationInfo?.Any(static v => v.HasLonLatLocation) ?? false; ResetLocationInfo(); } } diff --git a/TRViS.NetworkSyncService/TRViS.NetworkSyncService.csproj b/TRViS.NetworkSyncService/TRViS.NetworkSyncService.csproj index 4aa8f0e2..c2a9bba7 100644 --- a/TRViS.NetworkSyncService/TRViS.NetworkSyncService.csproj +++ b/TRViS.NetworkSyncService/TRViS.NetworkSyncService.csproj @@ -11,7 +11,7 @@ - + diff --git a/TRViS/App.xaml.cs b/TRViS/App.xaml.cs index 1b300ac1..dbb6185b 100644 --- a/TRViS/App.xaml.cs +++ b/TRViS/App.xaml.cs @@ -12,16 +12,24 @@ public App() { logger.Trace("App Creating (URL: {0})", AppLinkUri?.ToString() ?? "(null))"); + try + { InitializeComponent(); - - MainPage = new AppShell(); + } + catch (Exception ex) + { + logger.Error(ex, "App Initialize Failed"); + NLog.LogManager.Flush(); + NLog.LogManager.Shutdown(); + System.Environment.Exit(1); + } logger.Trace("App Created"); } protected override Window CreateWindow(IActivationState? activationState) { - Window window = base.CreateWindow(activationState); + Window window = new(new AppShell()); logger.Info("Window Created"); @@ -59,9 +67,9 @@ public static void SetAppLinkUri(string uri) return; } - if (app.MainPage is null) + if (app.Windows.Count == 0) { - logger.Warn("App.Current.MainPage is null"); + logger.Warn("app.Windows is Empty"); AppLinkUri = uri; return; } diff --git a/TRViS/AppShell.xaml b/TRViS/AppShell.xaml index 04a38b02..94e6ae9b 100644 --- a/TRViS/AppShell.xaml +++ b/TRViS/AppShell.xaml @@ -18,15 +18,15 @@ - diff --git a/TRViS/AppShell.xaml.cs b/TRViS/AppShell.xaml.cs index e04a17bd..3b8156df 100644 --- a/TRViS/AppShell.xaml.cs +++ b/TRViS/AppShell.xaml.cs @@ -45,10 +45,12 @@ public AppShell() AppCenterSettingViewModel.IsEnabledChanged += ApplyFlyoutBhavior; ApplyFlyoutBhavior(this, false, AppCenterSettingViewModel.IsEnabled); - SetBinding(Shell.BackgroundColorProperty, new Binding() { Source = easterEggPageViewModel, Path = nameof(EasterEggPageViewModel.ShellBackgroundColor) }); - SetBinding(Shell.TitleColorProperty, new Binding() { Source = easterEggPageViewModel, Path = nameof(EasterEggPageViewModel.ShellTitleTextColor) }); + this.BindingContext = easterEggPageViewModel; + this.SetBinding(BackgroundColorProperty, static (EasterEggPageViewModel vm) => vm.ShellBackgroundColor); + this.SetBinding(TitleColorProperty, static (EasterEggPageViewModel vm) => vm.ShellTitleTextColor); - FlyoutIconImage.SetBinding(FontImageSource.ColorProperty, new Binding() { Source = easterEggPageViewModel, Path = nameof(EasterEggPageViewModel.ShellTitleTextColor) }); + FlyoutIconImage.BindingContext = easterEggPageViewModel; + FlyoutIconImage.SetBinding(FontImageSource.ColorProperty, static (EasterEggPageViewModel vm) => vm.ShellTitleTextColor); InstanceManager.AppViewModel.WindowWidth = DeviceDisplay.Current.MainDisplayInfo.Width; InstanceManager.AppViewModel.WindowHeight = DeviceDisplay.Current.MainDisplayInfo.Height; @@ -90,12 +92,12 @@ protected override void OnPropertyChanged([CallerMemberName] string? propertyNam } } - protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint) + protected override Size MeasureOverride(double widthConstraint, double heightConstraint) { InstanceManager.AppViewModel.WindowWidth = widthConstraint; InstanceManager.AppViewModel.WindowHeight = heightConstraint; - logger.Trace("OnMeasure: {0}x{1}", widthConstraint, heightConstraint); - return base.OnMeasure(widthConstraint, heightConstraint); + logger.Trace("MeasureOverride: {0}x{1}", widthConstraint, heightConstraint); + return base.MeasureOverride(widthConstraint, heightConstraint); } public event ValueChangedEventHandler? SafeAreaMarginChanged; diff --git a/TRViS/DTAC/DTACElementStyles.cs b/TRViS/DTAC/DTACElementStyles.cs index 0b4adf2d..58dc7fb3 100644 --- a/TRViS/DTAC/DTACElementStyles.cs +++ b/TRViS/DTAC/DTACElementStyles.cs @@ -53,8 +53,8 @@ public static readonly AppThemeGenericsBindingExtension MarkerMarkButtonB public static readonly AppThemeColorBindingExtension ForegroundBlackWhite = genColor(0x00, 0xFF); public static readonly AppThemeGenericsBindingExtension ForegroundBlackWhiteBrush = ForegroundBlackWhite.ToBrushTheme(); - public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideFrameColor = genColor(0xFF, 0xAA); - public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideDisabledFrameColor = genColor(0xDD, 0x99); + public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideBorderColor = genColor(0xFF, 0xAA); + public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideDisabledBorderColor = genColor(0xDD, 0x99); public static readonly AppThemeColorBindingExtension LocationServiceSelectedSideTextColor = genColor(0xFF, 0xDD); public static readonly AppThemeColorBindingExtension LocationServiceNotSelectedSideTextColor = genColor(0x00, 0x00); public static readonly AppThemeColorBindingExtension LocationServiceNotSelectedSideBaseColor = genColor(0xFF, 0xDD); @@ -100,7 +100,7 @@ public static readonly AppThemeGenericsBindingExtension MarkerMarkButtonB new(new(64)) ); - public static readonly AppThemeGenericsValueTypeBindingExtension AppIconOpacity = new(0.1, 0.05); + public static readonly AppThemeGenericsValueTypeBindingExtension AppIconOpacity = new(0.05, 0.025); public static readonly AppThemeColorBindingExtension AppIconBgColor = new( new(0xCC, 0xFF, 0xCC), new(0xA3, 0xCC, 0xA3) @@ -415,7 +415,7 @@ public static double GetTimetableTrackLabelFontSize(string trackName, double cur trackName = HtmlTagRegex().Replace(trackName, ""); trackName = XmlEscapedStrRegex().Replace(trackName, ""); } - int maxLineLength = trackName.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Select(v => v.Length).Max(); + int maxLineLength = trackName.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Select(static v => v.Length).Max(); if (maxLineLength <= 2) return currentFontSize; else diff --git a/TRViS/DTAC/HakoParts/SimpleRow.cs b/TRViS/DTAC/HakoParts/SimpleRow.cs index 655a88c8..7e05d4aa 100644 --- a/TRViS/DTAC/HakoParts/SimpleRow.cs +++ b/TRViS/DTAC/HakoParts/SimpleRow.cs @@ -51,40 +51,50 @@ static Label GenTimeLabel(int rowIndex, int colIndex, TimeData? time) return v; } - readonly Frame SelectTrainButtonFrame; - static readonly Color SelectTrainButtonFrameBorderColor = new(0.6f); - static readonly Shadow SelectTrainButtonFrameShadow = new() + readonly Border SelectTrainButtonBorder; + static readonly Color SelectTrainButtonBorderStrokeColor = new(0.6f); + static readonly Shadow SelectTrainButtonShadow = new() { Brush = Colors.Black, Offset = new(0, 0), Radius = 4, Opacity = 0.4f, }; - static Frame GenSelectTrainButtonFrame(Label TrainNumberLabel) + static readonly Shadow SelectTrainButtonEmptyShadow = new() { - Frame v = new() + Brush = Colors.Transparent, + Offset = new(0, 0), + Radius = 4, + Opacity = 0, + }; + static Border GenSelectTrainButtonBorder(Label TrainNumberLabel) + { + Border v = new() { Margin = StaNameTrainNumButtonMargin, Padding = TrainNumButtonPadding, VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Center, MinimumWidthRequest = 120, - HasShadow = true, - Shadow = SelectTrainButtonFrameShadow, - BorderColor = SelectTrainButtonFrameBorderColor, + Shadow = SelectTrainButtonEmptyShadow, + Stroke = SelectTrainButtonBorderStrokeColor, + StrokeShape = new RoundRectangle() + { + CornerRadius = 8, + }, }; - DTACElementStyles.DefaultBGColor.Apply(v, Frame.BackgroundColorProperty); + DTACElementStyles.DefaultBGColor.Apply(v, Border.BackgroundColorProperty); v.Content = TrainNumberLabel; return v; } readonly ToggleButton SelectTrainButton; - static ToggleButton GenSelectTrainButton(Frame SelectTrainButtonFrame, EventHandler> IsSelectedChanged, int rowIndex) + static ToggleButton GenSelectTrainButton(Border SelectTrainButtonBorder, EventHandler> IsSelectedChanged, int rowIndex) { ToggleButton v = new() { - Content = SelectTrainButtonFrame, + Content = SelectTrainButtonBorder, IsRadio = true, }; @@ -142,16 +152,16 @@ public SimpleRow(Grid parentGrid, int dataIndex, TrainData TrainData) if (TrainData.Rows is not null) { - FirstRow = TrainData.Rows.FirstOrDefault(v => !v.IsInfoRow); - LastRow = TrainData.Rows.LastOrDefault(v => !v.IsInfoRow); + FirstRow = TrainData.Rows.FirstOrDefault(static v => !v.IsInfoRow); + LastRow = TrainData.Rows.LastOrDefault(static v => !v.IsInfoRow); } int rowIndex_StaName_SelectBtn = dataIndex * 2; int rowIndex_time = rowIndex_StaName_SelectBtn + 1; TrainNumberLabel = GenTrainNumberLabel(TrainData); - SelectTrainButtonFrame = GenSelectTrainButtonFrame(TrainNumberLabel); - SelectTrainButton = GenSelectTrainButton(SelectTrainButtonFrame, (sender, e) => + SelectTrainButtonBorder = GenSelectTrainButtonBorder(TrainNumberLabel); + SelectTrainButton = GenSelectTrainButton(SelectTrainButtonBorder, (sender, e) => { IsSelectedChanged?.Invoke(this, e.OldValue, e.NewValue); SetTrainNumberButtonState(); @@ -183,13 +193,13 @@ void SetTrainNumberButtonState() { if (SelectTrainButton.IsEnabled && SelectTrainButton.IsChecked) { - DTACElementStyles.DefaultGreen.Apply(SelectTrainButtonFrame, Frame.BorderColorProperty); - SelectTrainButtonFrame.HasShadow = false; + DTACElementStyles.DefaultGreen.Apply(SelectTrainButtonBorder, Border.StrokeProperty); + SelectTrainButtonBorder.Shadow = SelectTrainButtonEmptyShadow; } else { - SelectTrainButtonFrame.BorderColor = SelectTrainButtonFrameBorderColor; - SelectTrainButtonFrame.HasShadow = true; + SelectTrainButtonBorder.Stroke = SelectTrainButtonBorderStrokeColor; + SelectTrainButtonBorder.Shadow = SelectTrainButtonShadow; } } diff --git a/TRViS/DTAC/OpenCloseButton.cs b/TRViS/DTAC/OpenCloseButton.cs index b7b10591..5391fcca 100644 --- a/TRViS/DTAC/OpenCloseButton.cs +++ b/TRViS/DTAC/OpenCloseButton.cs @@ -15,34 +15,7 @@ public OpenCloseButton() { logger.Trace("Creating..."); - this.SetBinding(TextProperty, new Binding() - { - Source = this, - Path = nameof(TextWhenClosed) - }); - - DataTrigger dataTrigger = new(typeof(OpenCloseButton)) - { - Binding = new Binding() - { - Source = this, - Path = nameof(IsOpen) - }, - Value = true, - }; - - dataTrigger.Setters.Add(new() - { - Property = TextProperty, - Value = new Binding() - { - Source = this, - Path = nameof(TextWhenOpen) - } - }); - - Triggers.Add(dataTrigger); - + Text = IsOpen ? TextWhenOpen : TextWhenClosed; CornerRadius = 4; Padding = 0; BorderWidth = 0; @@ -71,6 +44,7 @@ partial void OnIsOpenChanged(bool oldValue, bool newValue) try { IsOpenChanged?.Invoke(this, new(oldValue, newValue)); + Text = newValue ? TextWhenOpen : TextWhenClosed; } catch (Exception ex) { @@ -79,4 +53,19 @@ partial void OnIsOpenChanged(bool oldValue, bool newValue) Utils.ExitWithAlert(ex); } } + + partial void OnTextWhenOpenChanged(string? newValue) + { + if (IsOpen) + { + Text = newValue; + } + } + partial void OnTextWhenClosedChanged(string? newValue) + { + if (!IsOpen) + { + Text = newValue; + } + } } diff --git a/TRViS/DTAC/PageParts/Hako.xaml b/TRViS/DTAC/PageParts/Hako.xaml index fba2478b..7a2b5534 100644 --- a/TRViS/DTAC/PageParts/Hako.xaml +++ b/TRViS/DTAC/PageParts/Hako.xaml @@ -4,6 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:TRViS.DTAC" xmlns:root="clr-namespace:TRViS" + xmlns:vm="clr-namespace:TRViS.ViewModels" xmlns:HakoParts="clr-namespace:TRViS.DTAC.HakoParts" BackgroundColor="{x:Static local:DTACElementStyles.DefaultBGColor}" x:Class="TRViS.DTAC.Hako"> @@ -15,6 +16,7 @@ diff --git a/TRViS/DTAC/PageParts/Hako.xaml.cs b/TRViS/DTAC/PageParts/Hako.xaml.cs index 109a420c..819a4c2a 100644 --- a/TRViS/DTAC/PageParts/Hako.xaml.cs +++ b/TRViS/DTAC/PageParts/Hako.xaml.cs @@ -52,12 +52,7 @@ public Hako() SimpleView.SetBinding( WidthRequestProperty, - new Binding() - { - Source = SimpleViewScrollView, - Path = nameof(headerView.Width), - Mode = BindingMode.OneWay, - } + BindingBase.Create(static (ScrollView x) => x.Width, BindingMode.OneWay, source: headerView) ); logger.Trace("Created"); diff --git a/TRViS/DTAC/PageParts/TabButton.xaml.cs b/TRViS/DTAC/PageParts/TabButton.xaml.cs index 98b6f9fa..bf728c8d 100644 --- a/TRViS/DTAC/PageParts/TabButton.xaml.cs +++ b/TRViS/DTAC/PageParts/TabButton.xaml.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Runtime.CompilerServices; using DependencyPropertyGenerator; using Microsoft.AppCenter.Crashes; using TRViS.ViewModels; @@ -28,6 +29,8 @@ public TabButton() InstanceManager.AppViewModel.PropertyChanged += AppViewModel_PropertyChanged; OnWindowWidthChanged(InstanceManager.AppViewModel.WindowWidth); + OnIsEnabledChanged(IsEnabled); + logger.Trace("Created"); } @@ -40,11 +43,21 @@ private void AppViewModel_PropertyChanged(object? sender, PropertyChangedEventAr break; } } + protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null) + { + base.OnPropertyChanged(propertyName); + switch (propertyName) + { + case nameof(IsEnabled): + OnIsEnabledChanged(IsEnabled); + break; + } + } void OnWindowWidthChanged(double newValue) { - if (newValue == 0) - { - return; + if (newValue == 0) + { + return; } try { @@ -106,6 +119,22 @@ partial void OnIsSelectedChanged(bool newValue) } } + private void OnIsEnabledChanged(bool newValue) + { + if (newValue) + { + ButtonLabel.Opacity = 1; + } + else + { + ButtonLabel.Opacity = 0.5; + if (IsSelected) + { + InstanceManager.DTACViewHostViewModel.TabMode = DTACViewHostViewModel.Mode.Hako; + } + } + } + void BaseBox_Tapped(object sender, EventArgs e) { try diff --git a/TRViS/DTAC/TimetableParts/LocationServiceButton.cs b/TRViS/DTAC/TimetableParts/LocationServiceButton.cs index 5a1bfad5..6827180c 100644 --- a/TRViS/DTAC/TimetableParts/LocationServiceButton.cs +++ b/TRViS/DTAC/TimetableParts/LocationServiceButton.cs @@ -1,5 +1,6 @@ using System.Runtime.CompilerServices; using Microsoft.AppCenter.Crashes; +using Microsoft.Maui.Controls.Shapes; using TRViS.Controls; namespace TRViS.DTAC; @@ -16,23 +17,28 @@ public class LocationServiceButton : ToggleButton readonly Label Label_ON = DTACElementStyles.LabelStyle - + @@ -32,6 +33,7 @@ Style="{x:Static dtac:DTACElementStyles.TimetableDefaultNumberLabelStyleResource}" Grid.Column="1" HorizontalOptions="Start" + x:DataType="dtac:TimeCell" TextColor="{Binding TextColor, Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type dtac:TimeCell}}}" Text="{Binding TimeData.Second, StringFormat='{0:D02}', Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type dtac:TimeCell}}}"/> @@ -42,11 +44,13 @@ VerticalOptions="Center" Padding="2" Grid.ColumnSpan="2" + x:DataType="dtac:TimeCell" TextColor="{Binding TextColor, Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type dtac:TimeCell}}}" Text="{Binding TimeData.Text, Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type dtac:TimeCell}}}" FontAttributes="Bold"/> - + + +