Normalized line endings
This commit is contained in:
Родитель
c9e6e1189d
Коммит
6bc918794a
|
@ -1,46 +1,46 @@
|
|||
# Autosave files
|
||||
*~
|
||||
|
||||
# build
|
||||
[Oo]bj/
|
||||
[Bb]in/
|
||||
packages/
|
||||
TestResults/
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.DS_Store
|
||||
*.sln.cache
|
||||
*.suo
|
||||
*.cache
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.log
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.user
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
Thumbs.db
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# resharper
|
||||
*_Resharper.*
|
||||
*.Resharper
|
||||
|
||||
# dotCover
|
||||
*.dotCover
|
||||
/.build/.fake
|
||||
/.build/FAKE.4.10.5
|
||||
/.build/out/lib
|
||||
/.build/out/nuget
|
||||
|
||||
# Autosave files
|
||||
*~
|
||||
|
||||
# build
|
||||
[Oo]bj/
|
||||
[Bb]in/
|
||||
packages/
|
||||
TestResults/
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.DS_Store
|
||||
*.sln.cache
|
||||
*.suo
|
||||
*.cache
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.log
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.user
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
Thumbs.db
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# resharper
|
||||
*_Resharper.*
|
||||
*.Resharper
|
||||
|
||||
# dotCover
|
||||
*.dotCover
|
||||
/.build/.fake
|
||||
/.build/FAKE.4.10.5
|
||||
/.build/out/lib
|
||||
/.build/out/nuget
|
||||
|
||||
Resource.designer.cs
|
|
@ -1,100 +1,100 @@
|
|||
using Plugin.Badge.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plugin.Badge.iOS
|
||||
{
|
||||
[Preserve]
|
||||
public class BadgedTabbedPageRenderer : TabbedRenderer
|
||||
{
|
||||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
base.ViewWillAppear(animated);
|
||||
|
||||
for (var i = 0; i < TabBar.Items.Length; i++)
|
||||
{
|
||||
AddTabBadge(i);
|
||||
}
|
||||
|
||||
Element.ChildAdded += OnTabAdded;
|
||||
Element.ChildRemoved += OnTabRemoved;
|
||||
}
|
||||
|
||||
private void AddTabBadge(int tabIndex)
|
||||
{
|
||||
var element = Tabbed.Children[tabIndex];
|
||||
element.PropertyChanged += OnTabbedPagePropertyChanged;
|
||||
|
||||
if (TabBar.Items.Length > tabIndex)
|
||||
{
|
||||
var tabBarItem = TabBar.Items[tabIndex];
|
||||
tabBarItem.BadgeValue = TabBadge.GetBadgeText(element);
|
||||
|
||||
var tabColor = TabBadge.GetBadgeColor(element);
|
||||
if (tabColor != Color.Default)
|
||||
{
|
||||
tabBarItem.BadgeColor = tabColor.ToUIColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTabbedPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
var page = sender as Page;
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
if (e.PropertyName == TabBadge.BadgeTextProperty.PropertyName)
|
||||
{
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
if(tabIndex < TabBar.Items.Length)
|
||||
TabBar.Items[tabIndex].BadgeValue = TabBadge.GetBadgeText(page);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == TabBadge.BadgeColorProperty.PropertyName)
|
||||
{
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
if (tabIndex < TabBar.Items.Length)
|
||||
TabBar.Items[tabIndex].BadgeColor = TabBadge.GetBadgeColor(page).ToUIColor();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnTabAdded(object sender, ElementEventArgs e)
|
||||
{
|
||||
//workaround for XF, tabbar is not updated at this point and we have no way to know when its updated.
|
||||
await Task.Delay(10);
|
||||
var page = e.Element as Page;
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
AddTabBadge(tabIndex);
|
||||
}
|
||||
|
||||
private void OnTabRemoved(object sender, ElementEventArgs e)
|
||||
{
|
||||
e.Element.PropertyChanged -= OnTabbedPagePropertyChanged;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (Tabbed != null)
|
||||
{
|
||||
foreach (var tab in Tabbed.Children)
|
||||
{
|
||||
tab.PropertyChanged -= OnTabbedPagePropertyChanged;
|
||||
}
|
||||
|
||||
Tabbed.ChildAdded -= OnTabAdded;
|
||||
Tabbed.ChildRemoved -= OnTabRemoved;
|
||||
}
|
||||
|
||||
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Plugin.Badge.Abstractions;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plugin.Badge.iOS
|
||||
{
|
||||
[Preserve]
|
||||
public class BadgedTabbedPageRenderer : TabbedRenderer
|
||||
{
|
||||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
base.ViewWillAppear(animated);
|
||||
|
||||
for (var i = 0; i < TabBar.Items.Length; i++)
|
||||
{
|
||||
AddTabBadge(i);
|
||||
}
|
||||
|
||||
Element.ChildAdded += OnTabAdded;
|
||||
Element.ChildRemoved += OnTabRemoved;
|
||||
}
|
||||
|
||||
private void AddTabBadge(int tabIndex)
|
||||
{
|
||||
var element = Tabbed.Children[tabIndex];
|
||||
element.PropertyChanged += OnTabbedPagePropertyChanged;
|
||||
|
||||
if (TabBar.Items.Length > tabIndex)
|
||||
{
|
||||
var tabBarItem = TabBar.Items[tabIndex];
|
||||
tabBarItem.BadgeValue = TabBadge.GetBadgeText(element);
|
||||
|
||||
var tabColor = TabBadge.GetBadgeColor(element);
|
||||
if (tabColor != Color.Default)
|
||||
{
|
||||
tabBarItem.BadgeColor = tabColor.ToUIColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTabbedPagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
var page = sender as Page;
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
if (e.PropertyName == TabBadge.BadgeTextProperty.PropertyName)
|
||||
{
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
if(tabIndex < TabBar.Items.Length)
|
||||
TabBar.Items[tabIndex].BadgeValue = TabBadge.GetBadgeText(page);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.PropertyName == TabBadge.BadgeColorProperty.PropertyName)
|
||||
{
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
if (tabIndex < TabBar.Items.Length)
|
||||
TabBar.Items[tabIndex].BadgeColor = TabBadge.GetBadgeColor(page).ToUIColor();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnTabAdded(object sender, ElementEventArgs e)
|
||||
{
|
||||
//workaround for XF, tabbar is not updated at this point and we have no way to know when its updated.
|
||||
await Task.Delay(10);
|
||||
var page = e.Element as Page;
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
var tabIndex = Tabbed.Children.IndexOf(page);
|
||||
AddTabBadge(tabIndex);
|
||||
}
|
||||
|
||||
private void OnTabRemoved(object sender, ElementEventArgs e)
|
||||
{
|
||||
e.Element.PropertyChanged -= OnTabbedPagePropertyChanged;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (Tabbed != null)
|
||||
{
|
||||
foreach (var tab in Tabbed.Children)
|
||||
{
|
||||
tab.PropertyChanged -= OnTabbedPagePropertyChanged;
|
||||
}
|
||||
|
||||
Tabbed.ChildAdded -= OnTabAdded;
|
||||
Tabbed.ChildRemoved -= OnTabRemoved;
|
||||
}
|
||||
|
||||
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
namespace Plugin.Badge.Sample.ViewModels
|
||||
{
|
||||
public class Tab1ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private static readonly List<Color> Colors = new List<Color>()
|
||||
{
|
||||
Color.Accent,
|
||||
Color.Aqua,
|
||||
Color.Black,
|
||||
Color.Blue,
|
||||
Color.Fuchsia,
|
||||
Color.Fuchsia,
|
||||
Color.Gray,
|
||||
Color.Green,
|
||||
Color.Lime,
|
||||
Color.Maroon,
|
||||
Color.Navy,
|
||||
Color.Pink,
|
||||
Color.Purple,
|
||||
Color.Red,
|
||||
Color.Silver,
|
||||
Color.Teal,
|
||||
Color.Transparent
|
||||
};
|
||||
|
||||
public Color BadgeColor { get; private set; }
|
||||
|
||||
public ICommand ChangeColorCommand => new Command((obj) =>
|
||||
{
|
||||
_color++;
|
||||
if (_color >= Colors.Count)
|
||||
_color = 0;
|
||||
|
||||
BadgeColor = Colors[_color];
|
||||
RaisePropertyChanged(nameof(BadgeColor));
|
||||
});
|
||||
|
||||
public ICommand IncrementCommand => new Command((obj) =>
|
||||
{
|
||||
_count++;
|
||||
RaisePropertyChanged(nameof(Count));
|
||||
});
|
||||
|
||||
public ICommand DecrementCommand => new Command((obj) =>
|
||||
{
|
||||
_count--;
|
||||
if (_count < 0)
|
||||
_count = 0;
|
||||
RaisePropertyChanged(nameof(Count));
|
||||
});
|
||||
|
||||
private int _count = 0;
|
||||
private int _color = 0;
|
||||
public string Count => _count <= 0 ? null : _count.ToString();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void RaisePropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms;
|
||||
namespace Plugin.Badge.Sample.ViewModels
|
||||
{
|
||||
public class Tab1ViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private static readonly List<Color> Colors = new List<Color>()
|
||||
{
|
||||
Color.Accent,
|
||||
Color.Aqua,
|
||||
Color.Black,
|
||||
Color.Blue,
|
||||
Color.Fuchsia,
|
||||
Color.Fuchsia,
|
||||
Color.Gray,
|
||||
Color.Green,
|
||||
Color.Lime,
|
||||
Color.Maroon,
|
||||
Color.Navy,
|
||||
Color.Pink,
|
||||
Color.Purple,
|
||||
Color.Red,
|
||||
Color.Silver,
|
||||
Color.Teal,
|
||||
Color.Transparent
|
||||
};
|
||||
|
||||
public Color BadgeColor { get; private set; }
|
||||
|
||||
public ICommand ChangeColorCommand => new Command((obj) =>
|
||||
{
|
||||
_color++;
|
||||
if (_color >= Colors.Count)
|
||||
_color = 0;
|
||||
|
||||
BadgeColor = Colors[_color];
|
||||
RaisePropertyChanged(nameof(BadgeColor));
|
||||
});
|
||||
|
||||
public ICommand IncrementCommand => new Command((obj) =>
|
||||
{
|
||||
_count++;
|
||||
RaisePropertyChanged(nameof(Count));
|
||||
});
|
||||
|
||||
public ICommand DecrementCommand => new Command((obj) =>
|
||||
{
|
||||
_count--;
|
||||
if (_count < 0)
|
||||
_count = 0;
|
||||
RaisePropertyChanged(nameof(Count));
|
||||
});
|
||||
|
||||
private int _count = 0;
|
||||
private int _color = 0;
|
||||
public string Count => _count <= 0 ? null : _count.ToString();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void RaisePropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче