Skip to content

Commit eff1a40

Browse files
committed
Merge branch 'master' into MacOS
2 parents ec47028 + a527bc0 commit eff1a40

20 files changed

+438
-110
lines changed

.build/Plugin.Badge.nuspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<releaseNotes>
1717
[1.3.0-beta]
1818
- #31 MacOS support
19+
[1.2.1]
20+
- #20 Support for more badge postions: TopCenter, BottomCenter, LeftCenter, RightCenter
21+
[1.2.0]
22+
- #8 #20 #36 Bindable badge position for Android and UWP
1923
[1.2.0-beta3]
2024
- UAP ensure missing *.xr.xml is also copied.
2125
- UAP XF dependency updated

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ Thumbs.db
4646

4747
**/Resource.designer.cs
4848
/.build/FAKE.4.61.3
49-
/Source/.vs/Plugin.Badge/v15/sqlite3
49+
/Source/.vs/Plugin.Badge/v15/sqlite3/storage.ide

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# <img src="icon_small.png" width="80" height="80"/> xamarin-forms-tab-badge [![Build Status](https://www.bitrise.io/app/6fbb08a710d8f2aa.svg?token=SlEUDTzwNV54nK7HHhUdOQ&branch=master)](https://www.bitrise.io/app/6fbb08a710d8f2aa)
2-
**Xamarin Forms** bindable tab badges for iOS and Android. The plugin creates a custom renderer (iOS & Android) and a custom attached property for adding tab bar badges which can be bound in XF shared code.
2+
**Xamarin Forms** bindable tab badges for iOS, Android and UWP. The plugin creates a custom renderer (iOS, Android & UWP) and a custom attached property for adding tab bar badges which can be bound in XF shared code.
33

44
## Sample
55
<img src="Screencasts/xamarin.forms.android.gif" height="600"/><img src="Screencasts/xamarin.forms.ios.gif" height="600"/>
@@ -12,6 +12,7 @@
1212
| Bindable Badge Color || ✓ (iOS >= 10.0) |||
1313
| Bindable Badge Text Color || ✓ (iOS >= 10.0) |||
1414
| Bindable Badge Font |\* |\*(iOS >= 10.0) |||
15+
| Bindable Badge Postion |||||
1516
| Dynamic tab add/removal || On overflow, 'More' / '...' menu don't have badges. |||
1617

1718
\***Caution**: For Xamarin.Forms Android make sure to use AppCompat. I.e.inherit from FormsAppCompatActivity
@@ -127,6 +128,14 @@ ToDo:
127128
- you can alo try to set font family, should work in theory
128129
- font size is not supported yet on android ......
129130

131+
### Badge Position
132+
133+
Very similar to `BadgeColor` just use [`TabBadge.BadgePosition` (XAML) or `TabBadge.BadgePositionPropery` (CSharp)].
134+
135+
| TopLeft | BottomLeft | BottomRight | Center | TopCenter | BottomCenter | LeftCenter | RightCenter |
136+
| ------------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
137+
| <img src="Screencasts/badge_topleft.PNG" height="50"/> | <img src="Screencasts/badge_bottomleft.PNG" height="50"/> | <img src="Screencasts/badge_bottomright.PNG" height="50"/> | <img src="Screencasts/badge_center.PNG" height="50"/> | | | | |
138+
130139
## Showning / Hiding the badge
131140
If the value of the `BadgeText` is set to null or empty string the badge is hidden. To show it again set a non null or empty value
132141

Screencasts/badge_bottomleft.PNG

8.03 KB
Loading

Screencasts/badge_bottomright.PNG

7.43 KB
Loading

Screencasts/badge_center.PNG

6.72 KB
Loading

Screencasts/badge_topleft.PNG

7.22 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace Plugin.Badge.Abstractions
2+
{
3+
public enum BadgePosition
4+
{
5+
PositionTopRight = 0,
6+
PositionTopLeft = 1,
7+
PositionBottomRight = 2,
8+
PositionBottomLeft = 3,
9+
PositionCenter = 4,
10+
PositionTopCenter = 5,
11+
PositionBottomCenter = 6,
12+
PositionLeftCenter = 7,
13+
PositionRightCenter = 8,
14+
}
15+
}

Source/Plugin.Badge.Abstractions/Plugin.Badge.Abstractions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
3232
<ItemGroup>
33+
<Compile Include="BadgePosition.cs" />
3334
<Compile Include="Properties\AssemblyInfo.cs" />
3435
<Compile Include="TabBadge.cs" />
3536
</ItemGroup>

Source/Plugin.Badge.Abstractions/TabBadge.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Xamarin.Forms;
33
namespace Plugin.Badge.Abstractions
44
{
5-
public class TabBadge //: TabbedPage
5+
public class TabBadge
66
{
77
public static BindableProperty BadgeTextProperty = BindableProperty.CreateAttached("BadgeText", typeof(string), typeof(TabBadge), default(string), BindingMode.OneWay);
88

@@ -16,7 +16,6 @@ public static void SetBadgeText(BindableObject view, string value)
1616
view.SetValue(BadgeTextProperty, value);
1717
}
1818

19-
2019
public static BindableProperty BadgeColorProperty = BindableProperty.CreateAttached("BadgeColor", typeof(Color), typeof(TabBadge), Color.Default, BindingMode.OneWay);
2120

2221
public static Color GetBadgeColor(BindableObject view)
@@ -52,5 +51,44 @@ public static void SetBadgeFont(BindableObject view, Font value)
5251
{
5352
view.SetValue(BadgeFontProperty, value);
5453
}
54+
55+
public static BindableProperty BadgePositionProperty = BindableProperty.CreateAttached("BadgePosition", typeof(BadgePosition), typeof(TabBadge), BadgePosition.PositionTopRight, BindingMode.OneWay);
56+
57+
public static BadgePosition GetBadgePosition(BindableObject view)
58+
{
59+
return (BadgePosition)view.GetValue(BadgePositionProperty);
60+
}
61+
62+
public static void SetBadgePosition(BindableObject view, BadgePosition value)
63+
{
64+
view.SetValue(BadgePositionProperty, value);
65+
}
66+
67+
public static BindableProperty BadgeMarginProperty = BindableProperty.CreateAttached("BadgeMargin", typeof(Thickness), typeof(TabBadge), GetDefaultMargins(), BindingMode.OneWay);
68+
69+
public static Thickness GetBadgeMargin(BindableObject view)
70+
{
71+
return (Thickness)view.GetValue(BadgeMarginProperty);
72+
}
73+
74+
public static void SetBadgeMargin(BindableObject view, Thickness value)
75+
{
76+
view.SetValue(BadgeMarginProperty, value);
77+
}
78+
79+
public static Thickness GetDefaultMargins()
80+
{
81+
switch (Device.RuntimePlatform)
82+
{
83+
case Device.Android:
84+
return new Thickness(-10, -5);
85+
case Device.Windows:
86+
return new Thickness(0);
87+
case Device.iOS:
88+
return new Thickness(0);
89+
}
90+
91+
return new Thickness(0);
92+
}
5593
}
5694
}

0 commit comments

Comments
 (0)