Skip to content

Commit

Permalink
Merge pull request #162 from TetsuOtter/force-show-icon-bg-when-light…
Browse files Browse the repository at this point in the history
…-mode

ライトモード時はアイコン背景を常に表示 ほか
  • Loading branch information
TetsuOtter authored Nov 23, 2024
2 parents 0672b47 + 363600a commit aa31470
Show file tree
Hide file tree
Showing 48 changed files with 419 additions and 285 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/cd-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions TRViS.IO/Loaders/LoaderJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -257,7 +257,7 @@ public IReadOnlyList<Work> GetWorkList(string workGroupId)
=> WorkData.Values.Where(v => v.WorkGroupId == workGroupId).ToArray();

public IReadOnlyList<Models.DB.TrainData> 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<TrainDataGroup> GetTrainDataGroupList()
{
Expand Down
2 changes: 1 addition & 1 deletion TRViS.IO/Loaders/LoaderSQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TrainDataFileInfo> fileInfo = new();
foreach (var work in group)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
2 changes: 1 addition & 1 deletion TRViS.LocationService/LonLatLocationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion TRViS.NetworkSyncService/TRViS.NetworkSyncService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

</Project>
18 changes: 13 additions & 5 deletions TRViS/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions TRViS/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
<Shell.FlyoutFooter>
<VerticalStackLayout
Margin="4">
<Frame
<Border
BackgroundColor="{AppThemeBinding Default=White, Dark=Black}"
BorderColor="{AppThemeBinding Default=#333, Dark=#CCC}"
Stroke="{AppThemeBinding Default=#333, Dark=#CCC}"
HorizontalOptions="Center"
Margin="8"
Padding="8">
<Label
Text="{x:Static local:AppShell.AppVersionString}"/>
</Frame>
</Border>
</VerticalStackLayout>
</Shell.FlyoutFooter>

Expand Down
14 changes: 8 additions & 6 deletions TRViS/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Thickness>? SafeAreaMarginChanged;
Expand Down
8 changes: 4 additions & 4 deletions TRViS/DTAC/DTACElementStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
public static readonly AppThemeColorBindingExtension ForegroundBlackWhite = genColor(0x00, 0xFF);
public static readonly AppThemeGenericsBindingExtension<Brush> 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);
Expand Down Expand Up @@ -100,7 +100,7 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
new(new(64))
);

public static readonly AppThemeGenericsValueTypeBindingExtension<double> AppIconOpacity = new(0.1, 0.05);
public static readonly AppThemeGenericsValueTypeBindingExtension<double> AppIconOpacity = new(0.05, 0.025);
public static readonly AppThemeColorBindingExtension AppIconBgColor = new(
new(0xCC, 0xFF, 0xCC),
new(0xA3, 0xCC, 0xA3)
Expand Down Expand Up @@ -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
Expand Down
48 changes: 29 additions & 19 deletions TRViS/DTAC/HakoParts/SimpleRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueChangedEventArgs<bool>> IsSelectedChanged, int rowIndex)
static ToggleButton GenSelectTrainButton(Border SelectTrainButtonBorder, EventHandler<ValueChangedEventArgs<bool>> IsSelectedChanged, int rowIndex)
{
ToggleButton v = new()
{
Content = SelectTrainButtonFrame,
Content = SelectTrainButtonBorder,
IsRadio = true,
};

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

Expand Down
45 changes: 17 additions & 28 deletions TRViS/DTAC/OpenCloseButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}
}
}
2 changes: 2 additions & 0 deletions TRViS/DTAC/PageParts/Hako.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -15,6 +16,7 @@

<Image
Style="{x:Static local:DTACElementStyles.AppIconStyleResource}"
x:DataType="vm:AppViewModel"
IsVisible="{Binding IsBgAppIconVisible, Source={x:Static root:InstanceManager.AppViewModel}}"
Opacity="{x:Static local:DTACElementStyles.AppIconOpacity}"
Grid.Row="2"/>
Expand Down
7 changes: 1 addition & 6 deletions TRViS/DTAC/PageParts/Hako.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading

0 comments on commit aa31470

Please sign in to comment.