Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 2b1c7a1

Browse files
RonnyRosRonny R
andauthored
Tabindicator should be correct width and correct position. #980 #947 (#1223)
Co-authored-by: Ronny R <ronny@source.no>
1 parent f866708 commit 2b1c7a1

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

samples/XCT.Sample/Pages/Views/TabView/TabWidthPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
TabStripBackgroundColor="Blue"
1919
TabStripHeight="60"
2020
TabIndicatorColor="Yellow"
21+
TabIndicatorWidth="10"
2122
TabContentBackgroundColor="Yellow">
2223
<xct:TabViewItem
2324
Icon="triangle.png"

src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/TabView.shared.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ void UpdateTabIndicatorWidth(double tabIndicatorWidth)
976976
{
977977
if (tabStripIndicator != null)
978978
{
979-
tabStripIndicator.WidthRequest = tabIndicatorWidth;
979+
tabStripIndicator.WidthRequest = TabIndicatorWidth > 0 ? TabIndicatorWidth : tabIndicatorWidth;
980980
}
981981
}
982982

@@ -1076,16 +1076,14 @@ void UpdateTabIndicatorPosition(ItemsViewScrolledEventArgs args)
10761076
{
10771077
var progress = (offset - contentWidthCollection[previousIndex]) / (contentWidthCollection[nextIndex] - contentWidthCollection[previousIndex]);
10781078
var position = toRight ? currentTabViewItem.X + (currentTabViewItemWidth * progress) : currentTabViewItem.X - (currentTabViewItemWidth * progress);
1079-
1080-
tabStripIndicator.TranslateTo(position, 0, tabIndicatorAnimationDuration, Easing.Linear);
10811079
}
10821080
}
10831081
}
10841082

10851083
void UpdateTabIndicatorPosition(View currentTabViewItem)
10861084
{
10871085
var width = TabIndicatorWidth > 0 ? (currentTabViewItem.Width - tabStripIndicator.Width) : 0;
1088-
var position = currentTabViewItem.X + (width / 2);
1086+
var position = currentTabViewItem.X + (width / 2) - 1;
10891087
tabStripIndicator.TranslateTo(position, 0, tabIndicatorAnimationDuration, Easing.Linear);
10901088
}
10911089

0 commit comments

Comments
 (0)