Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 64 additions & 39 deletions Xam.Plugin.TabView/Xam.Plugin.TabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public TabViewControl()
{
//Parameterless constructor required for xaml instantiation.
}

public TabViewControl(IList<TabItem> tabItems, int selectedTabIndex = 0)
{
Initialize(tabItems, selectedTabIndex);
Expand Down Expand Up @@ -165,20 +165,20 @@ private void Init()
Content = _mainContainerSL;
}

protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
if (BindingContext != null)
{
foreach (var tab in ItemSource)
{
if (tab is TabItem view)
{
view.Content.BindingContext = BindingContext;
}
}
}
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
if (BindingContext != null)
{
foreach (var tab in ItemSource)
{
if (tab is TabItem view)
{
view.Content.BindingContext = BindingContext;
}
}
}
}

private void _carouselView_PositionSelected(object sender, PositionSelectedEventArgs e)
{
Expand All @@ -199,10 +199,20 @@ private void InitTabs()

var tab = ItemSource[i];
tab.IsCurrent = i == _position;
var headerIcon = new Image
{
Margin = new Thickness(0, 20, 0, 0),
BindingContext = tab,
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.Center,
WidthRequest = 16,
HeightRequest = 16
};
headerIcon.SetBinding(Image.SourceProperty, "HeaderIcon");

var headerLabel = new Label
{
Margin = new Thickness(5, 10, 5, 0),
Margin = new Thickness(5, 0, 5, 0),
BindingContext = tab,
VerticalTextAlignment = TextAlignment.Start,
HorizontalTextAlignment = TextAlignment.Center,
Expand Down Expand Up @@ -240,7 +250,7 @@ private void InitTabs()
{
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.FillAndExpand,
Children = { headerLabel, selectionBarBoxView }
Children = { headerIcon, headerLabel, selectionBarBoxView }
};

var tapRecognizer = new TapGestureRecognizer();
Expand Down Expand Up @@ -398,8 +408,9 @@ public static void HeaderTabTextFontAttributesChanged(BindableObject bindable, o
public readonly BindableProperty HeaderTabTextFontAttributesProperty = BindableProperty.Create(nameof(HeaderTabTextFontAttributes), typeof(FontAttributes), typeof(TabViewControl), FontAttributes.None, BindingMode.Default, null, HeaderTabTextFontAttributesChanged);
#endregion

#region TabItems
public static BindableProperty TabItemsProperty = BindableProperty.Create(nameof(TabItems), typeof(IList<TabItem>), typeof(TabViewControl), null, propertyChanged:OnTabItemsChanged);

#region TabItems
public static BindableProperty TabItemsProperty = BindableProperty.Create(nameof(TabItems), typeof(IList<TabItem>), typeof(TabViewControl), null, propertyChanged: OnTabItemsChanged);
private static void OnTabItemsChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is TabViewControl tabControl)
Expand All @@ -415,26 +426,26 @@ public IList<TabItem> TabItems
#endregion

#region TabSizeOption
public static BindableProperty TabSizeOptionProperty = BindableProperty.Create(nameof(TabSizeOption), typeof(GridLength), typeof(TabViewControl), default(GridLength), propertyChanged: OnTabSizeOptionChanged);
private static void OnTabSizeOptionChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is TabViewControl tabViewControl)
{
if (tabViewControl._headerContainerGrid != null && tabViewControl.ItemSource != null)
{
foreach (var tabContainer in tabViewControl._headerContainerGrid.ColumnDefinitions)
{
tabContainer.Width = (GridLength)newValue;
}
}
}
}
public GridLength TabSizeOption
{
get => (GridLength)GetValue(TabSizeOptionProperty);
set { SetValue(TabSizeOptionProperty, value); }
}
#endregion
public static BindableProperty TabSizeOptionProperty = BindableProperty.Create(nameof(TabSizeOption), typeof(GridLength), typeof(TabViewControl), default(GridLength), propertyChanged: OnTabSizeOptionChanged);
private static void OnTabSizeOptionChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is TabViewControl tabViewControl)
{
if (tabViewControl._headerContainerGrid != null && tabViewControl.ItemSource != null)
{
foreach (var tabContainer in tabViewControl._headerContainerGrid.ColumnDefinitions)
{
tabContainer.Width = (GridLength)newValue;
}
}
}
}
public GridLength TabSizeOption
{
get => (GridLength)GetValue(TabSizeOptionProperty);
set { SetValue(TabSizeOptionProperty, value); }
}
#endregion

public void SetPosition(int position)
{
Expand Down Expand Up @@ -528,6 +539,13 @@ public TabItem(string headerText, View content)
_content = content;
}

public TabItem(string headerText, View content, ImageSource headerIcon)
{
_headerText = headerText;
_content = content;
_headerIcon = headerIcon;
}

private string _headerText;
public string HeaderText
{
Expand Down Expand Up @@ -597,6 +615,13 @@ public FontAttributes HeaderTabTextFontAttributes
get { return _headerTabTextFontAttributes; }
set { SetProperty(ref _headerTabTextFontAttributes, value); }
}

private ImageSource _headerIcon;
public ImageSource HeaderIcon
{
get { return _headerIcon; }
set { SetProperty(ref _headerIcon, value); }
}
}

public class ObservableBase : INotifyPropertyChanged
Expand Down
16 changes: 11 additions & 5 deletions Xam.Plugin.TabView/Xam.Plugin.TabView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,17 +43,17 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="CarouselView.FormsPlugin.Abstractions, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CarouselView.FormsPlugin.5.0.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+Xamarin.iOS10\CarouselView.FormsPlugin.Abstractions.dll</HintPath>
<Reference Include="CarouselView.FormsPlugin.Abstractions, Version=1.0.6591.24917, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\CarouselView.FormsPlugin.5.2.0\lib\portable-net45+netcore45+wpa81+wp8+MonoAndroid10+Xamarin.iOS10\CarouselView.FormsPlugin.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
<HintPath>..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Core.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath>
<HintPath>..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Platform.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath>
<HintPath>..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\lib\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -62,7 +66,9 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Xamarin.Forms.2.3.4.247\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.3.4.247\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets'))" />
<Error Condition="!Exists('..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets'))" />
</Target>
<Import Project="..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets" Condition="Exists('..\..\..\..\..\..\Software Development\MMA IOS\Source\MMA\packages\Xamarin.Forms.2.5.1.527436\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 2 additions & 2 deletions Xam.Plugin.TabView/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CarouselView.FormsPlugin" version="5.0.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xamarin.Forms" version="2.3.4.247" targetFramework="portable45-net45+win8+wpa81" />
<package id="CarouselView.FormsPlugin" version="5.2.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xamarin.Forms" version="2.5.1.527436" targetFramework="portable45-net45+win8+wpa81" />
</packages>