fix: iOS tab icon issue

This commit is contained in:
Tsanie Lily 2020-05-23 18:41:46 +08:00
parent 08ee19400b
commit 5e03b835a0
37 changed files with 244 additions and 52 deletions

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "bookmark-solid.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "bookmark-solid@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "bookmark-solid@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "bookmark-regular.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "bookmark-regular@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "bookmark-regular@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "sort-size-up-alt-solid.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "sort-size-up-alt-solid@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "sort-size-up-alt-solid@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "sort-size-up-alt-regular.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "sort-size-up-alt-regular@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "sort-size-up-alt-regular@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "sparkles-solid.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "sparkles-solid@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "sparkles-solid@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "sparkles-regular.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "sparkles-regular@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "sparkles-regular@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "user-solid.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "user-solid@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "user-solid@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

View File

@ -0,0 +1,23 @@
{
"images": [
{
"filename": "user-regular.png",
"scale": "1x",
"idiom": "universal"
},
{
"filename": "user-regular@2x.png",
"scale": "2x",
"idiom": "universal"
},
{
"filename": "user-regular@3x.png",
"scale": "3x",
"idiom": "universal"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -136,6 +136,38 @@
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv.png" />
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv%402x.png" />
<ImageAsset Include="Assets.xcassets\LauncherLogo.imageset\pixiv%403x.png" />
<ImageAsset Include="Assets.xcassets\IconUserRegular.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconUser.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconSparklesRegular.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconSparkles.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconSortRegular.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconSort.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconBookmarkRegular.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconBookmark.imageset\Contents.json" />
<ImageAsset Include="Assets.xcassets\IconUserRegular.imageset\user-regular.png" />
<ImageAsset Include="Assets.xcassets\IconUserRegular.imageset\user-regular%402x.png" />
<ImageAsset Include="Assets.xcassets\IconUserRegular.imageset\user-regular%403x.png" />
<ImageAsset Include="Assets.xcassets\IconUser.imageset\user-solid.png" />
<ImageAsset Include="Assets.xcassets\IconUser.imageset\user-solid%402x.png" />
<ImageAsset Include="Assets.xcassets\IconUser.imageset\user-solid%403x.png" />
<ImageAsset Include="Assets.xcassets\IconSparkles.imageset\sparkles-solid.png" />
<ImageAsset Include="Assets.xcassets\IconSparkles.imageset\sparkles-solid%402x.png" />
<ImageAsset Include="Assets.xcassets\IconSparkles.imageset\sparkles-solid%403x.png" />
<ImageAsset Include="Assets.xcassets\IconSparklesRegular.imageset\sparkles-regular.png" />
<ImageAsset Include="Assets.xcassets\IconSparklesRegular.imageset\sparkles-regular%402x.png" />
<ImageAsset Include="Assets.xcassets\IconSparklesRegular.imageset\sparkles-regular%403x.png" />
<ImageAsset Include="Assets.xcassets\IconSort.imageset\sort-size-up-alt-solid.png" />
<ImageAsset Include="Assets.xcassets\IconSort.imageset\sort-size-up-alt-solid%402x.png" />
<ImageAsset Include="Assets.xcassets\IconSort.imageset\sort-size-up-alt-solid%403x.png" />
<ImageAsset Include="Assets.xcassets\IconSortRegular.imageset\sort-size-up-alt-regular.png" />
<ImageAsset Include="Assets.xcassets\IconSortRegular.imageset\sort-size-up-alt-regular%402x.png" />
<ImageAsset Include="Assets.xcassets\IconSortRegular.imageset\sort-size-up-alt-regular%403x.png" />
<ImageAsset Include="Assets.xcassets\IconBookmark.imageset\bookmark-solid.png" />
<ImageAsset Include="Assets.xcassets\IconBookmark.imageset\bookmark-solid%402x.png" />
<ImageAsset Include="Assets.xcassets\IconBookmark.imageset\bookmark-solid%403x.png" />
<ImageAsset Include="Assets.xcassets\IconBookmarkRegular.imageset\bookmark-regular.png" />
<ImageAsset Include="Assets.xcassets\IconBookmarkRegular.imageset\bookmark-regular%402x.png" />
<ImageAsset Include="Assets.xcassets\IconBookmarkRegular.imageset\bookmark-regular%403x.png" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@ -165,6 +197,14 @@
<Folder Include="Renderers\AppShellSection\" />
<Folder Include="Effects\" />
<Folder Include="Assets.xcassets\LauncherLogo.imageset\" />
<Folder Include="Assets.xcassets\IconUserRegular.imageset\" />
<Folder Include="Assets.xcassets\IconUser.imageset\" />
<Folder Include="Assets.xcassets\IconSparklesRegular.imageset\" />
<Folder Include="Assets.xcassets\IconSparkles.imageset\" />
<Folder Include="Assets.xcassets\IconSortRegular.imageset\" />
<Folder Include="Assets.xcassets\IconSort.imageset\" />
<Folder Include="Assets.xcassets\IconBookmarkRegular.imageset\" />
<Folder Include="Assets.xcassets\IconBookmark.imageset\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\fa-light-300.ttf" />

View File

@ -32,7 +32,7 @@ namespace Pixiview.iOS.Renderers
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
return new AppShellTabBarAppearanceTracker((AppShell)Element);
return new AppShellTabBarAppearanceTracker();
}
protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker()

View File

@ -1,4 +1,4 @@
using System.Linq;
using System.Diagnostics.CodeAnalysis;
using CoreGraphics;
using UIKit;
using Xamarin.Forms;
@ -100,14 +100,6 @@ namespace Pixiview.iOS.Renderers.AppShellSection
UIColor _defaultTint;
UIColor _defaultUnselectedTint;
private readonly AppShell appShell;
private bool initIcons;
public AppShellTabBarAppearanceTracker(AppShell shell)
{
appShell = shell;
}
public void ResetAppearance(UITabBarController controller)
{
if (_defaultTint == null)
@ -119,6 +111,7 @@ namespace Pixiview.iOS.Renderers.AppShellSection
tabBar.UnselectedItemTintColor = _defaultUnselectedTint;
}
[SuppressMessage("Code Notifications", "XI0001:Notifies you with advices on how to use Apple APIs", Justification = "<Pending>")]
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
IShellAppearanceElement appearanceElement = appearance;
@ -127,33 +120,20 @@ namespace Pixiview.iOS.Renderers.AppShellSection
var tintColor = appearanceElement.EffectiveTabBarForegroundColor; // appearanceElement.EffectiveTabBarTitleColor;
var tabBar = controller.TabBar;
if (tabBar.Items != null && !initIcons)
if (tabBar.Items != null && tabBar.Items.Length == 4)
{
initIcons = true;
var sources = appShell.CurrentItem.Items.Select(i => (FontImageSource)i.Icon).ToArray();
var images = new UIImage[sources.Length];
var handler = new FontImageSourceHandler();
for (var i = 0; i < images.Length; i++)
{
var font = sources[i];
if (font != null)
{
images[i] = handler.LoadImageAsync(new FontImageSource
{
FontFamily = "FontAwesome5Pro-Solid",
Glyph = font.Glyph,
Size = font.Size
}).Result;
}
}
for (var i = 0; i < tabBar.Items.Length; i++)
{
var image = images[i];
if (image != null)
{
tabBar.Items[i].SelectedImage = image;
}
}
var tabUser = tabBar.Items[0];
tabUser.Image = UIImage.FromBundle("IconUserRegular");
tabUser.SelectedImage = UIImage.FromBundle("IconUser");
var tabRecommend = tabBar.Items[1];
tabRecommend.Image = UIImage.FromBundle("IconSparklesRegular");
tabRecommend.SelectedImage = UIImage.FromBundle("IconSparkles");
var tabRank = tabBar.Items[2];
tabRank.Image = UIImage.FromBundle("IconSortRegular");
tabRank.SelectedImage = UIImage.FromBundle("IconSort");
var tabFavorite = tabBar.Items[3];
tabFavorite.Image = UIImage.FromBundle("IconBookmarkRegular");
tabFavorite.SelectedImage = UIImage.FromBundle("IconBookmark");
}
if (_defaultTint == null)

View File

@ -73,26 +73,22 @@
</Shell.ItemTemplate>
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems"
Route="{x:Static util:Routes.Illust}">
<Tab Icon="{DynamicResource FontIconUser}"
FlyoutIcon="{DynamicResource FontIconUserFlyout}"
<Tab FlyoutIcon="{DynamicResource FontIconUserFlyout}"
Title="{r:Text Follow}"
Route="{x:Static util:Routes.Follow}">
<ShellContent ContentTemplate="{DataTemplate i:MainPage}"/>
</Tab>
<Tab Icon="{DynamicResource FontIconSparkles}"
FlyoutIcon="{DynamicResource FontIconSparklesFlyout}"
<Tab FlyoutIcon="{DynamicResource FontIconSparklesFlyout}"
Title="{r:Text Recommends}"
Route="{x:Static util:Routes.Recommends}">
<ShellContent ContentTemplate="{DataTemplate i:RecommendsPage}"/>
</Tab>
<Tab Icon="{DynamicResource FontIconOrder}"
FlyoutIcon="{DynamicResource FontIconOrderFlyout}"
<Tab FlyoutIcon="{DynamicResource FontIconOrderFlyout}"
Title="{r:Text Ranking}"
Route="{x:Static util:Routes.Ranking}">
<ShellContent ContentTemplate="{DataTemplate i:RankingPage}"/>
</Tab>
<Tab Icon="{DynamicResource FontIconFavorite}"
FlyoutIcon="{DynamicResource FontIconFavoriteFlyout}"
<Tab FlyoutIcon="{DynamicResource FontIconFavoriteFlyout}"
Title="{r:Text Favorites}"
Route="{x:Static util:Routes.Favorites}">
<ShellContent ContentTemplate="{DataTemplate i:FavoritesPage}"/>

View File

@ -4,10 +4,6 @@ namespace Pixiview.UI.Theme
{
public abstract class ThemeBase : ResourceDictionary
{
public const string FontIconUser = nameof(FontIconUser);
public const string FontIconSparkles = nameof(FontIconSparkles);
public const string FontIconOrder = nameof(FontIconOrder);
public const string FontIconFavorite = nameof(FontIconFavorite);
public const string FontIconUserFlyout = nameof(FontIconUserFlyout);
public const string FontIconSparklesFlyout = nameof(FontIconSparklesFlyout);
public const string FontIconOrderFlyout = nameof(FontIconOrderFlyout);
@ -63,10 +59,6 @@ namespace Pixiview.UI.Theme
Add(FontIconOrderFlyout, GetSolidIcon(StyleDefinition.IconOrder, solidFontFamily));
Add(FontIconFavoriteFlyout, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily));
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily));
Add(FontIconUser, GetSolidIcon(StyleDefinition.IconUser, regularFontFamily));
Add(FontIconSparkles, GetSolidIcon(StyleDefinition.IconSparkles, regularFontFamily));
Add(FontIconOrder, GetSolidIcon(StyleDefinition.IconOrder, regularFontFamily));
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, regularFontFamily));
#elif __ANDROID__
Add(FontIconUserFlyout, ImageSource.FromFile("ic_user"));
Add(FontIconSparklesFlyout, ImageSource.FromFile("ic_sparkles"));