Added favorites tab with new selected icon capabilities in TabbedPage

This commit is contained in:
Kyle Spearrin 2016-06-13 22:04:25 -04:00
parent 0007cac17b
commit e4926c4425
11 changed files with 77 additions and 0 deletions

View File

@ -13,9 +13,13 @@ namespace Bit.App.Pages
TintColor = Color.FromHex("ffffff");
var settingsNavigation = new ExtendedNavigationPage(new SettingsPage());
var favoritesNavigation = new ExtendedNavigationPage(new VaultListSitesPage());
var vaultNavigation = new ExtendedNavigationPage(new VaultListSitesPage());
var syncNavigation = new ExtendedNavigationPage(new SyncPage());
favoritesNavigation.Title = AppResources.Favorites;
favoritesNavigation.Icon = "star";
vaultNavigation.Title = AppResources.MyVault;
vaultNavigation.Icon = "fa-lock";
@ -25,6 +29,7 @@ namespace Bit.App.Pages
settingsNavigation.Title = AppResources.Settings;
settingsNavigation.Icon = "fa-cogs";
Children.Add(favoritesNavigation);
Children.Add(vaultNavigation);
Children.Add(syncNavigation);
Children.Add(settingsNavigation);

View File

@ -178,6 +178,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Favorites.
/// </summary>
internal static string Favorites {
get {
return ResourceManager.GetString("Favorites", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Folder.
/// </summary>

View File

@ -168,6 +168,10 @@
<value>Email Address</value>
<comment>Full label for a email address.</comment>
</data>
<data name="Favorites" xml:space="preserve">
<value>Favorites</value>
<comment>Title for your favorite items in the vault.</comment>
</data>
<data name="Folder" xml:space="preserve">
<value>Folder</value>
<comment>Label for a folder.</comment>

View File

@ -1,6 +1,7 @@
using System;
using Bit.App.Controls;
using Bit.iOS.Controls;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
@ -19,5 +20,45 @@ namespace Bit.iOS.Controls
TabBar.BarTintColor = page.BarTintColor.ToUIColor();
TabBar.BackgroundColor = page.BackgroundColor.ToUIColor();
}
public override void ViewWillAppear(bool animated)
{
if(TabBar?.Items == null)
{
return;
}
var tabs = Element as TabbedPage;
if(tabs != null)
{
for(int i = 0; i < TabBar.Items.Length; i++)
{
UpdateItem(TabBar.Items[i], tabs.Children[i].Icon);
}
}
base.ViewWillAppear(animated);
}
private void UpdateItem(UITabBarItem item, string icon)
{
if(item == null)
{
return;
}
try
{
icon = string.Concat(icon, "_selected");
if(item?.SelectedImage?.AccessibilityIdentifier == icon)
{
return;
}
item.SelectedImage = UIImage.FromBundle(icon);
item.SelectedImage.AccessibilityIdentifier = icon;
}
catch { }
}
}
}

BIN
src/iOS/Resources/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

View File

@ -375,6 +375,24 @@
<ItemGroup>
<BundleResource Include="Resources\bg%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star_selected.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star_selected%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\star_selected%403x.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>