Skip to content

Commit

Permalink
Merge pull request #161 from TetsuOtter/160-app-icon-on-bg
Browse files Browse the repository at this point in the history
  • Loading branch information
TetsuOtter authored Oct 28, 2024
2 parents 69c9382 + 2ddf787 commit 0672b47
Show file tree
Hide file tree
Showing 23 changed files with 1,057 additions and 21 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/cd-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
|| github.event.pull_request.draft == false
)
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
needs:
- get-version
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
- name: Setup Xcode version
uses: maxim-lobanov/[email protected]
with:
xcode-version: 15
xcode-version: 16

- uses: actions/setup-dotnet@v4
with:
Expand Down Expand Up @@ -358,7 +358,7 @@ jobs:
|| github.event.pull_request.draft == false
)
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
needs:
- get-version
Expand Down Expand Up @@ -402,7 +402,7 @@ jobs:
- name: Setup Xcode version
uses: maxim-lobanov/[email protected]
with:
xcode-version: 15
xcode-version: 16

- uses: actions/setup-dotnet@v4
with:
Expand Down Expand Up @@ -628,7 +628,7 @@ jobs:
|| github.event.pull_request.draft == false
)
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 10
needs:
- build-ios
Expand Down Expand Up @@ -698,7 +698,7 @@ jobs:
|| github.event.pull_request.draft == false
)
runs-on: macos-14
runs-on: macos-15
timeout-minutes: 30
needs:
- build-mac
Expand Down
2 changes: 1 addition & 1 deletion TRViS.IO/TRViS.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.10" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="TRViS.JsonModels" Version="1.0.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>
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.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions TRViS/DTAC/DTACElementStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
new(new(64))
);

public static readonly AppThemeGenericsValueTypeBindingExtension<double> AppIconOpacity = new(0.1, 0.05);
public static readonly AppThemeColorBindingExtension AppIconBgColor = new(
new(0xCC, 0xFF, 0xCC),
new(0xA3, 0xCC, 0xA3)
);
public static readonly string AppIconSource = "appiconfg.png";
static Style? _appIconStyleResource = null;
public static Style AppIconStyleResource
{
get
{
if (_appIconStyleResource is not null)
return _appIconStyleResource;

_appIconStyleResource = new Style(typeof(Image))
{
Setters =
{
new Setter { Property = Image.SourceProperty, Value = AppIconSource },
new Setter { Property = Image.AspectProperty, Value = Aspect.AspectFit },
new Setter { Property = Image.MarginProperty, Value = new Thickness(8) },
// なぜかここでAppThemeBindingでOpacityを設定しても反映されない
}
};

return _appIconStyleResource;
}
}

static Style? _labelStyleResource = null;
public static Style LabelStyleResource
{
Expand Down
7 changes: 7 additions & 0 deletions TRViS/DTAC/PageParts/Hako.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TRViS.DTAC"
xmlns:root="clr-namespace:TRViS"
xmlns:HakoParts="clr-namespace:TRViS.DTAC.HakoParts"
BackgroundColor="{x:Static local:DTACElementStyles.DefaultBGColor}"
x:Class="TRViS.DTAC.Hako">
Expand All @@ -12,6 +13,12 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Image
Style="{x:Static local:DTACElementStyles.AppIconStyleResource}"
IsVisible="{Binding IsBgAppIconVisible, Source={x:Static root:InstanceManager.AppViewModel}}"
Opacity="{x:Static local:DTACElementStyles.AppIconOpacity}"
Grid.Row="2"/>

<ScrollView
x:Name="SimpleViewScrollView"
Grid.Row="2"
Expand Down
7 changes: 7 additions & 0 deletions TRViS/DTAC/VerticalStylePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ContentView
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:root="clr-namespace:TRViS"
xmlns:dtac="clr-namespace:TRViS.DTAC"
xmlns:models="clr-namespace:TRViS.IO.Models;assembly=TRViS.IO"
xmlns:ctrls="clr-namespace:TRViS.Controls"
Expand Down Expand Up @@ -201,6 +202,12 @@
FontSize_Large="28"
Grid.Row="5"/>

<Image
Style="{x:Static dtac:DTACElementStyles.AppIconStyleResource}"
IsVisible="{Binding IsBgAppIconVisible, Source={x:Static root:InstanceManager.AppViewModel}}"
Opacity="{x:Static dtac:DTACElementStyles.AppIconOpacity}"
Grid.Row="6"/>

<ScrollView
x:Name="TimetableAreaScrollView"
Grid.Row="6"/>
Expand Down
14 changes: 12 additions & 2 deletions TRViS/DTAC/ViewHost.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,24 @@
HorizontalOptions="End"
VerticalOptions="End"
Spacing="8">
<ImageButton
Aspect="AspectFill"
Margin="0,8"
HeightRequest="30"
WidthRequest="30"
Padding="0"
CornerRadius="7"
Source="{x:Static local:DTACElementStyles.AppIconSource}"
BackgroundColor="{x:Static local:DTACElementStyles.AppIconBgColor}"
Clicked="OnToggleBgAppIconButtonClicked" />
<Button
x:Name="ChangeThemeButton"
Margin="0"
Margin="0,6"
Padding="0"
FontFamily="MaterialIconsRegular"
FontSize="28"
HorizontalOptions="Center"
VerticalOptions="Center"
VerticalOptions="End"
BackgroundColor="Transparent"
Clicked="OnChangeThemeButtonClicked" />
<Label
Expand Down
18 changes: 18 additions & 0 deletions TRViS/DTAC/ViewHost.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ private void MenuButton_Clicked(object? sender, EventArgs e)
logger.Debug("FlyoutIsPresented is changed to {0}", Shell.Current.FlyoutIsPresented);
}

private void OnToggleBgAppIconButtonClicked(object? sender, EventArgs e)
{
bool newState = !InstanceManager.AppViewModel.IsBgAppIconVisible;
InstanceManager.AppViewModel.IsBgAppIconVisible = newState;
logger.Debug("IsBgAppIconVisible is changed to {0}", newState);
if (sender is VisualElement button)
{
if (newState)
{
DTACElementStyles.AppIconBgColor.Apply(button, BackgroundColorProperty);
}
else
{
button.BackgroundColor = Colors.Transparent;
}
}
}

private void Eevm_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (sender is not EasterEggPageViewModel vm)
Expand Down
6 changes: 6 additions & 0 deletions TRViS/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public static MauiApp CreateMauiApp()
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
#if IOS
.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler<Shell, HideShellTabRenderer>();
})
#endif
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"images" : [
{
"filename" : "appicon.any.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "appicon.dark.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"filename" : "appicon.tint.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions TRViS/Platforms/iOS/CustomAssets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
23 changes: 23 additions & 0 deletions TRViS/Platforms/iOS/HideShellTabRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform.Compatibility;
using UIKit;

namespace TRViS;

// ref: https://github.com/dotnet/maui/issues/23380#issuecomment-2386743442
public sealed class HideShellTabRenderer : ShellRenderer
{
private sealed class MyShellTabBarAppearanceTracker : ShellTabBarAppearanceTracker
{
public override void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
base.SetAppearance(controller, appearance);

if (OperatingSystem.IsIOSVersionAtLeast(18))
{
controller.TabBarHidden = true;
}
}
}
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker() => new MyShellTabBarAppearanceTracker();
}
2 changes: 1 addition & 1 deletion TRViS/Platforms/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<string>CustomAssets.xcassets/AppIcon.appiconset</string>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
Expand Down
Loading

0 comments on commit 0672b47

Please sign in to comment.