This commit is contained in:
Depechie 2017-02-22 00:08:06 +01:00
Родитель 4526dd8354
Коммит 1c52f87ec9
60 изменённых файлов: 6328 добавлений и 6333 удалений

Просмотреть файл

@ -96,19 +96,19 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Effects.cs" />
<Compile Include="Effects\ChangeColorSwitchEffect.cs" />
<Compile Include="Effects\ClearEntryEffect.cs" />
<Compile Include="Effects\MultiLineLabelEffect.cs" />
<Compile Include="Effects\RemoveEntryLineEffect.cs" />
<Compile Include="Effects\Switch\SwitchChangeColor.cs" />
<Compile Include="Effects\Entry\EntryClear.cs" />
<Compile Include="Effects\Label\LabelMultiLine.cs" />
<Compile Include="Effects\Entry\EntryRemoveLine.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Effects\CapitalizeKeyboardEffect.cs" />
<Compile Include="Effects\RemoveBorderEffect.cs" />
<Compile Include="Effects\DisableAutoCorrectEffect.cs" />
<Compile Include="Effects\SizeFontToFitEffect.cs" />
<Compile Include="Effects\CustomFontEffect.cs" />
<Compile Include="Effects\SelectAllTextEntryEffect.cs" />
<Compile Include="Effects\ChangeColorPickerEffect.cs" />
<Compile Include="Effects\Entry\EntryCapitalizeKeyboard.cs" />
<Compile Include="Effects\Entry\EntryRemoveBorder.cs" />
<Compile Include="Effects\Entry\EntryDisableAutoCorrect.cs" />
<Compile Include="Effects\Label\LabelSizeFontToFit.cs" />
<Compile Include="Effects\Label\LabelCustomFont.cs" />
<Compile Include="Effects\Entry\EntrySelectAllText.cs" />
<Compile Include="Effects\Picker\PickerChangeColor.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

Просмотреть файл

@ -6,15 +6,15 @@ using FormsCommunityToolkit.Effects.Droid;
using Android.Runtime;
using System.Linq;
[assembly: ExportEffect(typeof(CapitalizeKeyboardEffect), nameof(CapitalizeKeyboardEffect))]
[assembly: ExportEffect(typeof(EntryCapitalizeKeyboard), nameof(EntryCapitalizeKeyboard))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve(AllMembers = true)]
public class CapitalizeKeyboardEffect : PlatformEffect
public class EntryCapitalizeKeyboard : PlatformEffect
{
InputTypes old;
IInputFilter[] oldFilters;
private InputTypes _old;
private IInputFilter[] _oldFilters;
protected override void OnAttached()
{
@ -22,12 +22,12 @@ namespace FormsCommunityToolkit.Effects.Droid
if (editText == null)
return;
old = editText.InputType;
oldFilters = editText.GetFilters().ToArray();
_old = editText.InputType;
_oldFilters = editText.GetFilters().ToArray();
editText.SetRawInputType(InputTypes.ClassText | InputTypes.TextFlagCapCharacters);
var newFilters = oldFilters.ToList();
var newFilters = _oldFilters.ToList();
newFilters.Add(new InputFilterAllCaps());
editText.SetFilters(newFilters.ToArray());
}
@ -38,8 +38,8 @@ namespace FormsCommunityToolkit.Effects.Droid
if (editText == null)
return;
editText.SetRawInputType(old);
editText.SetFilters(oldFilters);
editText.SetRawInputType(_old);
editText.SetFilters(_oldFilters);
}
}
}

Просмотреть файл

@ -5,11 +5,11 @@ using FormsCommunityToolkit.Effects.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(ClearEntryEffect), nameof(ClearEntryEffect))]
[assembly: ExportEffect(typeof(EntryClear), nameof(EntryClear))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve(AllMembers = true)]
public class ClearEntryEffect : PlatformEffect
public class EntryClear : PlatformEffect
{
protected override void OnAttached()
{

Просмотреть файл

@ -1,17 +1,17 @@
using System;
using Android.Text;
using Android.Widget;
using FormsCommunityToolkit.Effects.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(DisableAutoCorrectEffect), nameof(DisableAutoCorrectEffect))]
[assembly: ExportEffect(typeof(EntryDisableAutoCorrect), nameof(EntryDisableAutoCorrect))]
namespace FormsCommunityToolkit.Effects.Droid
{
public class DisableAutoCorrectEffect : PlatformEffect
public class EntryDisableAutoCorrect : PlatformEffect
{
Android.Text.InputTypes old;
private InputTypes _old;
protected override void OnAttached()
{
@ -19,7 +19,7 @@ namespace FormsCommunityToolkit.Effects.Droid
if (editText == null)
return;
old = editText.InputType;
_old = editText.InputType;
editText.InputType = editText.InputType | Android.Text.InputTypes.TextFlagNoSuggestions;
}
@ -29,7 +29,7 @@ namespace FormsCommunityToolkit.Effects.Droid
if (editText == null)
return;
editText.InputType = old;
editText.InputType = _old;
}
}
}

Просмотреть файл

@ -3,12 +3,11 @@ using Xamarin.Forms.Platform.Android;
using FormsCommunityToolkit.Effects.Droid;
using Android.Runtime;
[assembly: ExportEffect(typeof(RemoveBorderEffect), nameof(RemoveBorderEffect))]
[assembly: ExportEffect(typeof(EntryRemoveBorder), nameof(EntryRemoveBorder))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve(AllMembers = true)]
public class RemoveBorderEffect : PlatformEffect
public class EntryRemoveBorder : PlatformEffect
{
protected override void OnAttached()
{

Просмотреть файл

@ -6,11 +6,11 @@ using FormsCommunityToolkit.Effects.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(RemoveEntryLineEffect), nameof(RemoveEntryLineEffect))]
[assembly: ExportEffect(typeof(EntryRemoveLine), nameof(EntryRemoveLine))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve(AllMembers = true)]
public class RemoveEntryLineEffect : PlatformEffect
public class EntryRemoveLine : PlatformEffect
{
protected override void OnAttached()
{

Просмотреть файл

@ -1,17 +1,15 @@
using Android.Text;
using Android.Widget;
using Android.Widget;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using FormsCommunityToolkit.Effects.Droid;
using Android.Runtime;
using System.Linq;
[assembly: ExportEffect(typeof(SelectAllTextEntryEffect), nameof(SelectAllTextEntryEffect))]
[assembly: ExportEffect(typeof(EntrySelectAllText), nameof(EntrySelectAllText))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve(AllMembers = true)]
public class SelectAllTextEntryEffect : PlatformEffect
public class EntrySelectAllText : PlatformEffect
{
protected override void OnAttached()

Просмотреть файл

@ -5,10 +5,10 @@ using FormsCommunityToolkit.Effects.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(CustomFontEffect), nameof(CustomFontEffect))]
[assembly: ExportEffect(typeof(LabelCustomFont), nameof(LabelCustomFont))]
namespace FormsCommunityToolkit.Effects.Droid
{
public class CustomFontEffect : PlatformEffect
public class LabelCustomFont : PlatformEffect
{
protected override void OnAttached()
{
@ -18,7 +18,7 @@ namespace FormsCommunityToolkit.Effects.Droid
return;
else
{
var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.CustomFontEffect);
var effect = (FormsCommunityToolkit.Effects.LabelCustomFont)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.LabelCustomFont);
if (effect != null && !string.IsNullOrWhiteSpace(effect.FontPath))
{
var font = Typeface.CreateFromAsset(Forms.Context.Assets, effect.FontPath);

Просмотреть файл

@ -4,10 +4,10 @@ using FormsCommunityToolkit.Effects.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportEffect(typeof(MultiLineLabelEffect), nameof(MultiLineLabelEffect))]
[assembly: ExportEffect(typeof(LabelMultiLine), nameof(LabelMultiLine))]
namespace FormsCommunityToolkit.Effects.Droid
{
public class MultiLineLabelEffect : PlatformEffect
public class LabelMultiLine : PlatformEffect
{
protected override void OnAttached()
{
@ -16,7 +16,7 @@ namespace FormsCommunityToolkit.Effects.Droid
if (control == null)
return;
var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect);
var effect = (FormsCommunityToolkit.Effects.LabelMultiLine)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.LabelMultiLine);
if (effect != null && effect.Lines > 0)
{
control.SetSingleLine(false);

Просмотреть файл

@ -7,7 +7,7 @@ using Android.Graphics;
using Android.Util;
using Android.Content;
[assembly: ExportEffect(typeof(SizeFontToFitEffect), nameof(SizeFontToFitEffect))]
[assembly: ExportEffect(typeof(LabelSizeFontToFit), nameof(LabelSizeFontToFit))]
namespace FormsCommunityToolkit.Effects.Droid
{
@ -16,21 +16,21 @@ namespace FormsCommunityToolkit.Effects.Droid
const string TextMeasure = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const float Threshold = 0.5f; // How close we have to be
readonly TextView textView;
private readonly TextView _textView;
public ShrinkTextOnLayoutChangeListener(TextView textView) : base()
{
this.textView = textView;
_textView = textView;
}
public void OnLayoutChange(Android.Views.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)
{
if (textView.Width <= 0 || textView.Height <= 0) return;
if (_textView.Width <= 0 || _textView.Height <= 0) return;
var hi = ConvertSpToPixels(textView.TextSize, textView.Context);
var hi = ConvertSpToPixels(_textView.TextSize, _textView.Context);
var lo = 1f;
var paint = new Paint(textView.Paint);
var paint = new Paint(_textView.Paint);
var bounds = new Rect();
while ((hi - lo) > Threshold)
@ -39,13 +39,13 @@ namespace FormsCommunityToolkit.Effects.Droid
paint.TextSize = size;
paint.GetTextBounds(TextMeasure, 0, TextMeasure.Length, bounds);
if (paint.MeasureText(textView.Text) >= textView.Width || bounds.Height() >= textView.Height)
if (paint.MeasureText(_textView.Text) >= _textView.Width || bounds.Height() >= _textView.Height)
hi = size; // too big
else
lo = size; // too small
}
textView.SetTextSize(ComplexUnitType.Px, lo);
_textView.SetTextSize(ComplexUnitType.Px, lo);
}
static float ConvertSpToPixels(float sp, Context context) => TypedValue.ApplyDimension(ComplexUnitType.Px, sp, context.Resources.DisplayMetrics);
@ -53,9 +53,9 @@ namespace FormsCommunityToolkit.Effects.Droid
[Preserve(AllMembers = true)]
public class SizeFontToFitEffect : PlatformEffect
public class LabelSizeFontToFit : PlatformEffect
{
ShrinkTextOnLayoutChangeListener _listener;
private ShrinkTextOnLayoutChangeListener _listener;
protected override void OnAttached()
{

Просмотреть файл

@ -1,25 +1,24 @@
using Android.Runtime;
using FormsCommunityToolkit.Effects.Droid;
using FormsCommunityToolkit.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Color = Xamarin.Forms.Color;
using Picker = Android.Widget.EditText;
using PickerChangeColor = FormsCommunityToolkit.Effects.Droid.PickerChangeColor;
[assembly: ExportEffect(typeof(ChangeColorPickerEffect), nameof(ChangeColorPickerEffect))]
[assembly: ExportEffect(typeof(PickerChangeColor), nameof(PickerChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.Droid
{
[Preserve (AllMembers = true)]
public class ChangeColorPickerEffect : PlatformEffect
public class PickerChangeColor : PlatformEffect
{
private Color _color;
protected override void OnAttached ()
{
_color = (Color)Element.GetValue(ChangePickerColorEffect.ColorProperty);
_color = (Color)Element.GetValue(FormsCommunityToolkit.Effects.PickerChangeColor.ColorProperty);
((Picker)Control).SetHintTextColor(_color.ToAndroid());
}
protected override void OnDetached ()

Просмотреть файл

@ -6,35 +6,36 @@ using Android.Graphics.Drawables;
using Android.Runtime;
using Android.Support.V7.Widget;
using Android.Widget;
using FormsCommunityToolkit.Effects.Droid;
using FormsCommunityToolkit.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Color = Xamarin.Forms.Color;
using Switch = Android.Widget.Switch;
using SwitchChangeColor = FormsCommunityToolkit.Effects.Droid.SwitchChangeColor;
[assembly: ExportEffect(typeof(ChangeColorSwitchEffect), nameof(ChangeColorSwitchEffect))]
[assembly: ExportEffect(typeof(SwitchChangeColor), nameof(SwitchChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.Droid
{
/// <summary>
/// http://stackoverflow.com/questions/11253512/change-on-color-of-a-switch
/// </summary>
[Preserve(AllMembers = true)]
public class ChangeColorSwitchEffect : PlatformEffect
public class SwitchChangeColor : PlatformEffect
{
Color trueColor;
Color falseColor;
private Color _trueColor;
private Color _falseColor;
protected override void OnAttached()
{
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean)
{
trueColor = (Color)Element.GetValue(ChangeColorEffect.TrueColorProperty);
falseColor = (Color)Element.GetValue(ChangeColorEffect.FalseColorProperty);
_trueColor = (Color)Element.GetValue(FormsCommunityToolkit.Effects.SwitchChangeColor.TrueColorProperty);
_falseColor = (Color)Element.GetValue(FormsCommunityToolkit.Effects.SwitchChangeColor.FalseColorProperty);
((SwitchCompat)Control).CheckedChange += OnCheckedChange;
//Supported formats for Parse are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(falseColor.ToAndroid(), PorterDuff.Mode.Multiply);
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_falseColor.ToAndroid(), PorterDuff.Mode.Multiply);
}
//TODO: Glenn - From lollipop mr1 you can also use the TintList instead of working with events... not sure what the best approach is
@ -62,12 +63,12 @@ namespace FormsCommunityToolkit.Effects.Droid
{
if (checkedChangeEventArgs.IsChecked)
{
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(trueColor.ToAndroid(), PorterDuff.Mode.Multiply);
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_trueColor.ToAndroid(), PorterDuff.Mode.Multiply);
//((SwitchCompat) Control).TrackDrawable.SetColorFilter(Android.Graphics.Color.Green, PorterDuff.Mode.Multiply);
}
else
{
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(falseColor.ToAndroid(), PorterDuff.Mode.Multiply);
((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_falseColor.ToAndroid(), PorterDuff.Mode.Multiply);
//((SwitchCompat)Control).TrackDrawable.SetColorFilter(Android.Graphics.Color.Green, PorterDuff.Mode.Multiply);
}
}

11788
src/Effects/Effects.Android/Resources/Resource.Designer.cs сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -108,14 +108,14 @@
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="Effects\ChangeColorPickerEffect.cs" />
<Compile Include="Effects\SelectAllTextEntryEffect.cs" />
<Compile Include="Effects\ChangeColorSwitchEffect.cs" />
<Compile Include="Effects\CapitalizeKeyboardEffect.cs" />
<Compile Include="Effects\MultiLineLabelEffect.cs" />
<Compile Include="Effects\RemoveBorderEffect.cs" />
<Compile Include="Effects\UWPSearchBarSuggestionEffect.cs" />
<Compile Include="Effects\ViewBlurEffect.cs" />
<Compile Include="Effects\Picker\PickerChangeColor.cs" />
<Compile Include="Effects\Entry\EntrySelectAllText.cs" />
<Compile Include="Effects\Switch\SwitchChangeColor.cs" />
<Compile Include="Effects\Entry\EntryCapitalizeKeyboard.cs" />
<Compile Include="Effects\Label\LabelMultiLine.cs" />
<Compile Include="Effects\Entry\EntryRemoveBorder.cs" />
<Compile Include="Effects\SearchBar\SearchBarSuggestion.cs" />
<Compile Include="Effects\View\ViewBlur.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VisualTreeExtensions.cs" />
<EmbeddedResource Include="Properties\Effects.UWP.rd.xml" />
@ -123,10 +123,9 @@
<ItemGroup>
<ProjectReference Include="..\Effects\Effects.csproj">
<Project>{67f9d3a8-f71e-4428-913f-c37ae82cdb24}</Project>
<Name>FormsCommunityToolkit.Effects</Name>
<Name>Effects</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>

Просмотреть файл

@ -4,12 +4,11 @@ using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.UWP;
[assembly: ExportEffect(typeof(CapitalizeKeyboardEffect), nameof(CapitalizeKeyboardEffect))]
[assembly: ExportEffect(typeof(EntryCapitalizeKeyboard), nameof(EntryCapitalizeKeyboard))]
namespace FormsCommunityToolkit.Effects.UWP
{
[Preserve]
public class CapitalizeKeyboardEffect : PlatformEffect
public class EntryCapitalizeKeyboard : PlatformEffect
{
protected override void OnAttached()
{

Просмотреть файл

@ -2,33 +2,31 @@
using FormsCommunityToolkit.Effects.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
using Thickness = Windows.UI.Xaml.Thickness;
[assembly: ExportEffect(typeof(RemoveBorderEffect), nameof(RemoveBorderEffect))]
[assembly: ExportEffect(typeof(EntryRemoveBorder), nameof(EntryRemoveBorder))]
namespace FormsCommunityToolkit.Effects.UWP
{
public class RemoveBorderEffect : PlatformEffect
public class EntryRemoveBorder : PlatformEffect
{
Thickness old;
private Windows.UI.Xaml.Thickness _old;
protected override void OnAttached()
{
var textBox = Control as TextBox;
if (textBox == null)
return;
old = textBox.BorderThickness;
textBox.BorderThickness = new Thickness(0);
_old = textBox.BorderThickness;
textBox.BorderThickness = new Windows.UI.Xaml.Thickness(0);
}
protected override void OnDetached()
{
var textBox = Control as TextBox;
if (textBox == null)
return;
textBox.BorderThickness = old;
textBox.BorderThickness = _old;
}
}
}
}

Просмотреть файл

@ -5,12 +5,11 @@ using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml;
[assembly: ExportEffect(typeof(SelectAllTextEntryEffect), nameof(SelectAllTextEntryEffect))]
[assembly: ExportEffect(typeof(EntrySelectAllText), nameof(EntrySelectAllText))]
namespace FormsCommunityToolkit.Effects.UWP
{
[Preserve]
public class SelectAllTextEntryEffect : PlatformEffect
public class EntrySelectAllText : PlatformEffect
{
protected override void OnAttached()
{
@ -20,7 +19,6 @@ namespace FormsCommunityToolkit.Effects.UWP
textBox.GotFocus -= TextboxOnGotFocus;
textBox.GotFocus += TextboxOnGotFocus;
}
private void TextboxOnGotFocus(object sender, RoutedEventArgs e)
@ -37,4 +35,4 @@ namespace FormsCommunityToolkit.Effects.UWP
textbox.GotFocus -= TextboxOnGotFocus;
}
}
}
}

Просмотреть файл

@ -5,13 +5,13 @@ using FormsCommunityToolkit.Effects.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
[assembly: ExportEffect(typeof(MultiLineLabelEffect), nameof(MultiLineLabelEffect))]
[assembly: ExportEffect(typeof(LabelMultiLine), nameof(LabelMultiLine))]
namespace FormsCommunityToolkit.Effects.UWP
{
public class MultiLineLabelEffect : PlatformEffect
public class LabelMultiLine : PlatformEffect
{
int initialeLines;
TextWrapping initialTextWrapping;
private int _initialeLines;
private TextWrapping _initialTextWrapping;
protected override void OnAttached()
{
@ -21,10 +21,10 @@ namespace FormsCommunityToolkit.Effects.UWP
return;
else
{
initialeLines = control.MaxLines;
initialTextWrapping = control.TextWrapping;
_initialeLines = control.MaxLines;
_initialTextWrapping = control.TextWrapping;
var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect);
var effect = (FormsCommunityToolkit.Effects.LabelMultiLine)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.LabelMultiLine);
if (effect != null && effect.Lines > 0)
{
control.MaxLines = effect.Lines;
@ -41,8 +41,8 @@ namespace FormsCommunityToolkit.Effects.UWP
return;
else
{
control.MaxLines = initialeLines;
control.TextWrapping = initialTextWrapping;
control.MaxLines = _initialeLines;
control.TextWrapping = _initialTextWrapping;
}
}
}

Просмотреть файл

@ -1,22 +1,22 @@
using Windows.UI.Xaml.Controls;
using FormsCommunityToolkit.Effects.UWP.Effects;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml.Media;
using FormsCommunityToolkit.Effects;
using PickerChangeColor = FormsCommunityToolkit.Effects.UWP.Effects.PickerChangeColor;
[assembly: ExportEffect(typeof(ChangeColorPickerEffect), nameof(ChangeColorPickerEffect))]
[assembly: ExportEffect(typeof(PickerChangeColor), nameof(PickerChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.UWP.Effects
{
[Preserve]
public class ChangeColorPickerEffect : PlatformEffect
public class PickerChangeColor : PlatformEffect
{
private Windows.UI.Color _color;
protected override void OnAttached()
{
var color = (Color)Element.GetValue(ChangePickerColorEffect.ColorProperty);
var color = (Color)Element.GetValue(FormsCommunityToolkit.Effects.PickerChangeColor.ColorProperty);
_color = ConvertColor(color);
(Control as ComboBox).Foreground = new SolidColorBrush( _color);
}
@ -30,4 +30,4 @@ namespace FormsCommunityToolkit.Effects.UWP.Effects
return Windows.UI.Color.FromArgb((byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255));
}
}
}
}

Просмотреть файл

@ -1,15 +1,16 @@
using FormsCommunityToolkit.Effects.UWP.Effects;
using System;
using System;
using System.Collections.ObjectModel;
using Windows.UI.Xaml.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
using System.ComponentModel;
using FormsCommunityToolkit.Effects;
using SearchBarSuggestion = FormsCommunityToolkit.Effects.UWP.Effects.SearchBarSuggestion;
[assembly: ExportEffect(typeof(UWPSearchBarSuggestionEffect), nameof(UWPSearchBarSuggestionEffect))]
[assembly: ExportEffect(typeof(SearchBarSuggestion), nameof(SearchBarSuggestionEffect))]
namespace FormsCommunityToolkit.Effects.UWP.Effects
{
public class UWPSearchBarSuggestionEffect : PlatformEffect
public class SearchBarSuggestion : PlatformEffect
{
protected override void OnAttached()
{
@ -19,7 +20,7 @@ namespace FormsCommunityToolkit.Effects.UWP.Effects
autoSuggestBox.SuggestionChosen += OnSuggestionChosen;
autoSuggestBox.TextChanged += OnTextChangedEffect;
autoSuggestBox.AutoMaximizeSuggestionArea = true;
autoSuggestBox.ItemsSource = SearchBarSuggestionEffect.GetSuggestions(Element);
autoSuggestBox.ItemsSource = FormsCommunityToolkit.Effects.SearchBarSuggestion.GetSuggestions(Element);
}
}
@ -37,20 +38,20 @@ namespace FormsCommunityToolkit.Effects.UWP.Effects
private void OnTextChangedEffect(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs e)
{
Action platformSpecificAction = (Action)Element.GetValue(SearchBarSuggestionEffect.TextChangedActionProperty);
Action platformSpecificAction = (Action)Element.GetValue(FormsCommunityToolkit.Effects.SearchBarSuggestion.TextChangedActionProperty);
platformSpecificAction?.Invoke();
}
protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
{
base.OnElementPropertyChanged(args);
if (args.PropertyName == SearchBarSuggestionEffect.SuggestionsProperty.PropertyName)
if (args.PropertyName == FormsCommunityToolkit.Effects.SearchBarSuggestion.SuggestionsProperty.PropertyName)
UpdateItemsSource();
}
private void UpdateItemsSource()
{
((AutoSuggestBox)Control).ItemsSource = SearchBarSuggestionEffect.GetSuggestions(Element);
((AutoSuggestBox)Control).ItemsSource = FormsCommunityToolkit.Effects.SearchBarSuggestion.GetSuggestions(Element);
}
}
}
}

Просмотреть файл

@ -1,5 +1,4 @@
using Windows.UI.Xaml.Controls;
using FormsCommunityToolkit.Effects.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.UWP;
@ -8,25 +7,26 @@ using System;
using Windows.UI.Xaml;
using System.Linq;
using Windows.UI.Xaml.Media.Animation;
using FormsCommunityToolkit.Effects;
using SwitchChangeColor = FormsCommunityToolkit.Effects.UWP.SwitchChangeColor;
[assembly: ExportEffect(typeof(ChangeColorSwitchEffect), nameof(ChangeColorSwitchEffect))]
[assembly: ExportEffect(typeof(SwitchChangeColor), nameof(SwitchChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.UWP
{
[Preserve]
public class ChangeColorSwitchEffect : PlatformEffect
public class SwitchChangeColor : PlatformEffect
{
Windows.UI.Color trueColor;
Windows.UI.Color falseColor;
private Windows.UI.Color _trueColor;
private Windows.UI.Color _falseColor;
protected override void OnAttached()
{
var color = (Color)Element.GetValue(ChangeColorEffect.TrueColorProperty);
trueColor = ConvertColor(color);
var color = (Color)Element.GetValue(FormsCommunityToolkit.Effects.SwitchChangeColor.TrueColorProperty);
_trueColor = ConvertColor(color);
// currently not supported
color = (Color)Element.GetValue(ChangeColorEffect.FalseColorProperty);
falseColor = ConvertColor(color);
color = (Color)Element.GetValue(FormsCommunityToolkit.Effects.SwitchChangeColor.FalseColorProperty);
_falseColor = ConvertColor(color);
var toggleSwitch = Control as ToggleSwitch;
if (toggleSwitch == null)
@ -69,7 +69,7 @@ namespace FormsCommunityToolkit.Effects.UWP
if ((target == "SwitchKnobBounds") && (property == "Fill"))
{
var frame = timeline.KeyFrames.First();
frame.Value = new SolidColorBrush(trueColor) { Opacity = .7 };
frame.Value = new SolidColorBrush(_trueColor) { Opacity = .7 };
break;
}
}
@ -78,7 +78,7 @@ namespace FormsCommunityToolkit.Effects.UWP
var rect = toggleSwitch.GetChildByName("SwitchKnobBounds") as Windows.UI.Xaml.Shapes.Rectangle;
if (rect != null)
rect.Fill = new SolidColorBrush(trueColor);
rect.Fill = new SolidColorBrush(_trueColor);
toggleSwitch.Loaded -= OnSwitchLoaded;
}

Просмотреть файл

@ -3,44 +3,45 @@ using System.Numerics;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Hosting;
using FormsCommunityToolkit.Effects;
using Microsoft.Graphics.Canvas.Effects;
using FormsCommunityToolkit.Effects.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
using ViewBlur = FormsCommunityToolkit.Effects.UWP.ViewBlur;
[assembly: ExportEffect(typeof(ViewBlurEffect), nameof(ViewBlurEffect))]
[assembly: ExportEffect(typeof(ViewBlur), nameof(ViewBlurEffect))]
namespace FormsCommunityToolkit.Effects.UWP
{
public class ViewBlurEffect : PlatformEffect
public class ViewBlur : PlatformEffect
{
SpriteVisual blurVisual;
CompositionBrush blurBrush;
Visual rootVisual;
private SpriteVisual _blurVisual;
private CompositionBrush _blurBrush;
private Visual _rootVisual;
Compositor Compositor { get; set; }
protected override void OnAttached()
{
var blurAmount = (double)Element.GetValue(BlurEffect.BlurAmountProperty);
var blurAmount = (double)Element.GetValue(FormsCommunityToolkit.Effects.ViewBlur.BlurAmountProperty);
rootVisual = ElementCompositionPreview.GetElementVisual(Container);
_rootVisual = ElementCompositionPreview.GetElementVisual(Container);
Compositor = rootVisual.Compositor;
Compositor = _rootVisual.Compositor;
blurVisual = Compositor.CreateSpriteVisual();
_blurVisual = Compositor.CreateSpriteVisual();
var brush = BuildBlurBrush();
brush.SetSourceParameter("source", Compositor.CreateBackdropBrush());
blurBrush = brush;
blurVisual.Brush = blurBrush;
_blurBrush = brush;
_blurVisual.Brush = _blurBrush;
ElementCompositionPreview.SetElementChildVisual(Container, blurVisual);
ElementCompositionPreview.SetElementChildVisual(Container, _blurVisual);
Container.Loading += OnLoading;
Container.Unloaded += OnUnloaded;
blurBrush.Properties.InsertScalar("Blur.BlurAmount", (float)blurAmount);
rootVisual.Properties.InsertScalar("BlurAmount", (float)blurAmount);
_blurBrush.Properties.InsertScalar("Blur.BlurAmount", (float)blurAmount);
_rootVisual.Properties.InsertScalar("BlurAmount", (float)blurAmount);
SetUpPropertySetExpressions();
}
@ -51,8 +52,8 @@ namespace FormsCommunityToolkit.Effects.UWP
if (args.PropertyName == "BlurAmount")
{
var blurAmount = (double)Element.GetValue(BlurEffect.BlurAmountProperty);
rootVisual.Properties.InsertScalar("BlurAmount", (float)blurAmount);
var blurAmount = (double)Element.GetValue(FormsCommunityToolkit.Effects.ViewBlur.BlurAmountProperty);
_rootVisual.Properties.InsertScalar("BlurAmount", (float)blurAmount);
}
}
@ -60,9 +61,9 @@ namespace FormsCommunityToolkit.Effects.UWP
{
var exprAnimation = Compositor.CreateExpressionAnimation();
exprAnimation.Expression = "sourceProperties.BlurAmount";
exprAnimation.SetReferenceParameter("sourceProperties", rootVisual.Properties);
exprAnimation.SetReferenceParameter("sourceProperties", _rootVisual.Properties);
blurBrush.Properties.StartAnimation("Blur.BlurAmount", exprAnimation);
_blurBrush.Properties.StartAnimation("Blur.BlurAmount", exprAnimation);
}
protected override void OnDetached()
@ -86,10 +87,10 @@ namespace FormsCommunityToolkit.Effects.UWP
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
if (blurVisual == null)
if (_blurVisual == null)
return;
else
blurVisual.Size = new Vector2((float)Container.ActualWidth, (float)Container.ActualHeight);
_blurVisual.Size = new Vector2((float)Container.ActualWidth, (float)Container.ActualHeight);
}
private CompositionEffectBrush BuildBlurBrush()
@ -112,4 +113,4 @@ namespace FormsCommunityToolkit.Effects.UWP
return brush;
}
}
}
}

Просмотреть файл

@ -55,20 +55,20 @@
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Effects\ClearEntryEffect.cs" />
<Compile Include="Effects\MultiLineLabelEffect.cs" />
<Compile Include="Effects\Entry\EntryClear.cs" />
<Compile Include="Effects\Label\LabelMultiLine.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Effects\CapitalizeKeyboardEffect.cs" />
<Compile Include="Effects\RemoveBorderEffect.cs" />
<Compile Include="Effects\Entry\EntryCapitalizeKeyboard.cs" />
<Compile Include="Effects\Entry\EntryRemoveBorder.cs" />
<Compile Include="Effects.cs" />
<Compile Include="Effects\DisableAutoCorrectEffect.cs" />
<Compile Include="Effects\ViewBlurEffect.cs" />
<Compile Include="Effects\SizeFontToFitEffect.cs" />
<Compile Include="Effects\ChangeColorSwitchEffect.cs" />
<Compile Include="Effects\CustomFontEffect.cs" />
<Compile Include="Effects\ItalicPlaceholderEffect.cs" />
<Compile Include="Effects\SelectAllTextEntryEffect.cs" />
<Compile Include="Effects\ChangeColorPickerEffect.cs" />
<Compile Include="Effects\Entry\EntryDisableAutoCorrect.cs" />
<Compile Include="Effects\View\ViewBlur.cs" />
<Compile Include="Effects\Label\LabelSizeFontToFit.cs" />
<Compile Include="Effects\Switch\SwitchChangeColor.cs" />
<Compile Include="Effects\Label\LabelCustomFont.cs" />
<Compile Include="Effects\Entry\EntryItalicPlaceholder.cs" />
<Compile Include="Effects\Entry\EntrySelectAllText.cs" />
<Compile Include="Effects\Picker\PickerChangeColor.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

Просмотреть файл

@ -1,38 +0,0 @@
using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect (typeof (ChangeColorSwitchEffect), nameof (ChangeColorSwitchEffect))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class ChangeColorSwitchEffect : PlatformEffect
{
Color trueColor;
Color falseColor;
public ChangeColorSwitchEffect ()
{
}
protected override void OnAttached ()
{
trueColor = (Color)Element.GetValue (ChangeColorEffect.TrueColorProperty);
falseColor = (Color)Element.GetValue (ChangeColorEffect.FalseColorProperty);
if (falseColor != Color.Transparent)
{
(Control as UISwitch).TintColor = falseColor.ToUIColor ();
(Control as UISwitch).Layer.CornerRadius = 16;
(Control as UISwitch).BackgroundColor = falseColor.ToUIColor ();
}
if (trueColor != Color.Transparent)
(Control as UISwitch).OnTintColor = trueColor.ToUIColor ();
}
protected override void OnDetached ()
{
}
}
}

Просмотреть файл

@ -1,28 +0,0 @@
using Foundation;
using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect(typeof(ClearEntryEffect), nameof(ClearEntryEffect))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class ClearEntryEffect : PlatformEffect
{
protected override void OnAttached()
{
ConfigureControl();
}
protected override void OnDetached()
{
}
private void ConfigureControl()
{
((UITextField)Control).ClearButtonMode = UITextFieldViewMode.WhileEditing;
}
}
}

Просмотреть файл

@ -4,14 +4,13 @@ using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Foundation;
[assembly: ExportEffect(typeof(CapitalizeKeyboardEffect), nameof(CapitalizeKeyboardEffect))]
[assembly: ExportEffect(typeof(EntryCapitalizeKeyboard), nameof(EntryCapitalizeKeyboard))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class CapitalizeKeyboardEffect : PlatformEffect
public class EntryCapitalizeKeyboard : PlatformEffect
{
UITextAutocapitalizationType old;
private UITextAutocapitalizationType _old;
protected override void OnAttached()
{
@ -19,7 +18,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (editText == null)
return;
old = editText.AutocapitalizationType;
_old = editText.AutocapitalizationType;
editText.AutocapitalizationType = UITextAutocapitalizationType.AllCharacters;
}
@ -29,7 +28,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (editText == null)
return;
editText.AutocapitalizationType = old;
editText.AutocapitalizationType = _old;
}
}
}

Просмотреть файл

@ -0,0 +1,39 @@
using Foundation;
using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect(typeof(EntryClear), nameof(EntryClear))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class EntryClear : PlatformEffect
{
private UITextFieldViewMode _old;
protected override void OnAttached()
{
ConfigureControl();
}
protected override void OnDetached()
{
var editText = Control as UITextField;
if (editText == null)
return;
editText.ClearButtonMode = _old;
}
private void ConfigureControl()
{
var editText = Control as UITextField;
if (editText == null)
return;
_old = editText.ClearButtonMode;
editText.ClearButtonMode = UITextFieldViewMode.WhileEditing;
}
}
}

Просмотреть файл

@ -5,16 +5,15 @@ using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect(typeof(DisableAutoCorrectEffect), nameof(DisableAutoCorrectEffect))]
[assembly: ExportEffect(typeof(EntryDisableAutoCorrect), nameof(EntryDisableAutoCorrect))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve]
public class DisableAutoCorrectEffect : PlatformEffect
public class EntryDisableAutoCorrect : PlatformEffect
{
UITextSpellCheckingType spellCheckingType;
UITextAutocorrectionType autocorrectionType;
UITextAutocapitalizationType autocapitalizationType;
private UITextSpellCheckingType _spellCheckingType;
private UITextAutocorrectionType _autocorrectionType;
private UITextAutocapitalizationType _autocapitalizationType;
protected override void OnAttached()
@ -23,9 +22,9 @@ namespace FormsCommunityToolkit.Effects.iOS
if (editText == null) return;
spellCheckingType = editText.SpellCheckingType;
autocorrectionType = editText.AutocorrectionType;
autocapitalizationType = editText.AutocapitalizationType;
_spellCheckingType = editText.SpellCheckingType;
_autocorrectionType = editText.AutocorrectionType;
_autocapitalizationType = editText.AutocapitalizationType;
editText.SpellCheckingType = UITextSpellCheckingType.No; // No Spellchecking
editText.AutocorrectionType = UITextAutocorrectionType.No; // No Autocorrection
@ -37,9 +36,9 @@ namespace FormsCommunityToolkit.Effects.iOS
var editText = Control as UITextField;
if (editText == null) return;
editText.SpellCheckingType = spellCheckingType;
editText.AutocorrectionType = autocorrectionType;
editText.AutocapitalizationType = autocapitalizationType;
editText.SpellCheckingType = _spellCheckingType;
editText.AutocorrectionType = _autocorrectionType;
editText.AutocapitalizationType = _autocapitalizationType;
}
}
}

Просмотреть файл

@ -5,13 +5,13 @@ using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect(typeof(ItalicPlaceholderEffect), nameof(ItalicPlaceholderEffect))]
[assembly: ExportEffect(typeof(EntryItalicPlaceholder), nameof(EntryItalicPlaceholder))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class ItalicPlaceholderEffect : PlatformEffect
public class EntryItalicPlaceholder : PlatformEffect
{
NSAttributedString old;
private NSAttributedString _old;
protected override void OnAttached()
{
@ -19,7 +19,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (entry == null || string.IsNullOrWhiteSpace(entry.Placeholder))
return;
old = entry.AttributedPlaceholder;
_old = entry.AttributedPlaceholder;
var entryFontSize = entry.Font.PointSize;
entry.AttributedPlaceholder = new NSAttributedString(entry.Placeholder, font: UIFont.ItalicSystemFontOfSize(entryFontSize));
}
@ -30,7 +30,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (entry == null)
return;
entry.AttributedPlaceholder = old;
entry.AttributedPlaceholder = _old;
}
}
}

Просмотреть файл

@ -4,14 +4,13 @@ using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Foundation;
[assembly: ExportEffect(typeof(RemoveBorderEffect), nameof(RemoveBorderEffect))]
[assembly: ExportEffect(typeof(EntryRemoveBorder), nameof(EntryRemoveBorder))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class RemoveBorderEffect : PlatformEffect
public class EntryRemoveBorder : PlatformEffect
{
UITextBorderStyle old;
private UITextBorderStyle _old;
protected override void OnAttached()
{
@ -19,7 +18,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (editText == null)
return;
old = editText.BorderStyle;
_old = editText.BorderStyle;
editText.BorderStyle = UITextBorderStyle.None;
}
@ -29,7 +28,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (editText == null)
return;
editText.BorderStyle = old;
editText.BorderStyle = _old;
}
}
}

Просмотреть файл

@ -5,14 +5,12 @@ using UIKit;
using Foundation;
using ObjCRuntime;
[assembly: ExportEffect(typeof(SelectAllTextEntryEffect), nameof(SelectAllTextEntryEffect))]
[assembly: ExportEffect(typeof(EntrySelectAllText), nameof(EntrySelectAllText))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class SelectAllTextEntryEffect : PlatformEffect
public class EntrySelectAllText : PlatformEffect
{
protected override void OnAttached()
{
var editText = Control as UITextField;

Просмотреть файл

@ -4,10 +4,10 @@ using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using System.Linq;
[assembly: ExportEffect (typeof (CustomFontEffect), nameof (CustomFontEffect))]
[assembly: ExportEffect (typeof (LabelCustomFont), nameof (LabelCustomFont))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class CustomFontEffect : PlatformEffect
public class LabelCustomFont : PlatformEffect
{
protected override void OnAttached ()
{
@ -16,7 +16,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (control == null)
return;
var effect = (FormsCommunityToolkit.Effects.CustomFontEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.CustomFontEffect);
var effect = (FormsCommunityToolkit.Effects.LabelCustomFont)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.LabelCustomFont);
if (effect != null && !string.IsNullOrWhiteSpace(effect.FontPath))
control.Font = UIFont.FromName(effect.FontFamilyName, control.Font.PointSize);
}

Просмотреть файл

@ -5,12 +5,12 @@ using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportEffect(typeof(MultiLineLabelEffect), nameof(MultiLineLabelEffect))]
[assembly: ExportEffect(typeof(LabelMultiLine), nameof(LabelMultiLine))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class MultiLineLabelEffect : PlatformEffect
public class LabelMultiLine : PlatformEffect
{
nint initialeLines;
private nint _initialeLines;
protected override void OnAttached()
{
@ -19,9 +19,9 @@ namespace FormsCommunityToolkit.Effects.iOS
if (control == null)
return;
initialeLines = control.Lines;
_initialeLines = control.Lines;
var effect = (FormsCommunityToolkit.Effects.MultiLineLabelEffect)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.MultiLineLabelEffect);
var effect = (FormsCommunityToolkit.Effects.LabelMultiLine)Element.Effects.FirstOrDefault(item => item is FormsCommunityToolkit.Effects.LabelMultiLine);
if (effect != null && effect.Lines > 0)
control.Lines = effect.Lines;
}
@ -33,7 +33,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (control == null)
return;
control.Lines = initialeLines;
control.Lines = _initialeLines;
}
}
}

Просмотреть файл

@ -4,12 +4,12 @@ using FormsCommunityToolkit.Effects.iOS;
using UIKit;
using Foundation;
[assembly: ExportEffect(typeof(SizeFontToFitEffect), nameof(SizeFontToFitEffect))]
[assembly: ExportEffect(typeof(LabelSizeFontToFit), nameof(LabelSizeFontToFit))]
namespace FormsCommunityToolkit.Effects.iOS
{
[Preserve(AllMembers = true)]
public class SizeFontToFitEffect : PlatformEffect
public class LabelSizeFontToFit : PlatformEffect
{
protected override void OnAttached()
{

Просмотреть файл

@ -1,14 +1,14 @@
using FormsCommunityToolkit.Effects.iOS;
using FormsCommunityToolkit.Effects;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using Color = Xamarin.Forms.Color;
using PickerChangeColor = FormsCommunityToolkit.Effects.iOS.PickerChangeColor;
[assembly: ExportEffect(typeof(ChangeColorPickerEffect), nameof(ChangeColorPickerEffect))]
[assembly: ExportEffect(typeof(PickerChangeColor), nameof(PickerChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class ChangeColorPickerEffect : PlatformEffect
public class PickerChangeColor : PlatformEffect
{
private Color _color;
@ -17,7 +17,7 @@ namespace FormsCommunityToolkit.Effects.iOS
/*
* Text Color change when I select a value
*/
_color = (Color)Element.GetValue(ChangePickerColorEffect.ColorProperty);
_color = (Color)Element.GetValue(FormsCommunityToolkit.Effects.PickerChangeColor.ColorProperty);
(Control as UITextField).AttributedPlaceholder = new Foundation.NSAttributedString((Control as UITextField).AttributedPlaceholder.Value, foregroundColor: _color.ToUIColor());
}

Просмотреть файл

@ -0,0 +1,39 @@
using FormsCommunityToolkit.Effects;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using SwitchChangeColor = FormsCommunityToolkit.Effects.iOS.SwitchChangeColor;
[assembly: ExportEffect (typeof (SwitchChangeColor), nameof (SwitchChangeColorEffect))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class SwitchChangeColor : PlatformEffect
{
private Color _trueColor;
private Color _falseColor;
public SwitchChangeColor ()
{
}
protected override void OnAttached ()
{
_trueColor = (Color)Element.GetValue (FormsCommunityToolkit.Effects.SwitchChangeColor.TrueColorProperty);
_falseColor = (Color)Element.GetValue (FormsCommunityToolkit.Effects.SwitchChangeColor.FalseColorProperty);
if (_falseColor != Color.Transparent)
{
(Control as UISwitch).TintColor = _falseColor.ToUIColor ();
(Control as UISwitch).Layer.CornerRadius = 16;
(Control as UISwitch).BackgroundColor = _falseColor.ToUIColor ();
}
if (_trueColor != Color.Transparent)
(Control as UISwitch).OnTintColor = _trueColor.ToUIColor ();
}
protected override void OnDetached ()
{
}
}
}

Просмотреть файл

@ -1,21 +1,17 @@
using System;
using System.ComponentModel;
using System.Drawing;
using FormsCommunityToolkit.Effects.iOS;
using FormsCommunityToolkit.Effects;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using ViewBlur = FormsCommunityToolkit.Effects.iOS.ViewBlur;
[assembly: ExportEffect(typeof(ViewBlurEffect), nameof(ViewBlurEffect))]
[assembly: ExportEffect(typeof(ViewBlur), nameof(ViewBlurEffect))]
namespace FormsCommunityToolkit.Effects.iOS
{
public class ViewBlurEffect : PlatformEffect
public class ViewBlur : PlatformEffect
{
public ViewBlurEffect()
{
}
protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
{
base.OnElementPropertyChanged(args);
@ -27,7 +23,7 @@ namespace FormsCommunityToolkit.Effects.iOS
if (args.PropertyName == nameof(visualElement.Width) || args.PropertyName == nameof(visualElement.Height))
{
var blurAmount = (double)Element.GetValue(BlurEffect.BlurAmountProperty);
var blurAmount = (double)Element.GetValue(FormsCommunityToolkit.Effects.ViewBlur.BlurAmountProperty);
var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class CapitalizeKeyboardEffect : RoutingEffect
{
public CapitalizeKeyboardEffect() : base(EffectIds.CapitalizeKeyboardEffect)
{
}
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class ClearEntryEffect : RoutingEffect
{
public ClearEntryEffect() : base(EffectIds.ClearEntryEffect)
{
}
}
}

Просмотреть файл

@ -8,73 +8,73 @@
public class EffectIds
{
/// <summary>
/// Id for <see cref="ViewBlurEffect"/>
/// Id for <see cref="ViewBlur"/>
/// </summary>
public static string ViewBlurEffect => typeof(ViewBlurEffect).FullName;
public static string ViewBlur => typeof(ViewBlurEffect).FullName;
/// <summary>
/// Id for <see cref="CapitalizeKeyboardEffect"/>
/// Id for <see cref="EntryCapitalizeKeyboard"/>
/// </summary>
public static string CapitalizeKeyboardEffect => typeof(CapitalizeKeyboardEffect).FullName;
public static string EntryCapitalizeKeyboard => typeof(EntryCapitalizeKeyboard).FullName;
/// <summary>
/// Id for <see cref="ChangeColorSwitchEffect"/>
/// Id for <see cref="SwitchChangeColor"/>
/// </summary>
public static string ChangeColorSwitchEffect => typeof(ChangeColorSwitchEffect).FullName;
public static string SwitchChangeColor => typeof(SwitchChangeColorEffect).FullName;
/// <summary>
/// Id for <see cref="ChangeColorPickerEffect"/>
/// Id for <see cref="PickerChangeColor"/>
/// </summary>
public static string ChangeColorPickerEffect => typeof(ChangeColorPickerEffect).FullName;
public static string PickerChangeColor => typeof(PickerChangeColorEffect).FullName;
/// <summary>
/// Id for <see cref="ClearEntryEffect"/>
/// Id for <see cref="EntryClear"/>
/// </summary>
public static string ClearEntryEffect => typeof(ClearEntryEffect).FullName;
public static string EntryClear => typeof(EntryClear).FullName;
/// <summary>
/// Id for <see cref="CustomFontEffect"/>
/// Id for <see cref="LabelCustomFont"/>
/// </summary>
public static string CustomFontEffect => typeof(CustomFontEffect).FullName;
public static string LabelCustomFont => typeof(LabelCustomFont).FullName;
/// <summary>
/// Id for <see cref="DisableAutoCorrectEffect"/>
/// Id for <see cref="EntryDisableAutoCorrect"/>
/// </summary>
public static string DisableAutoCorrectEffect => typeof(DisableAutoCorrectEffect).FullName;
public static string EntryDisableAutoCorrect => typeof(EntryDisableAutoCorrect).FullName;
/// <summary>
/// Id for <see cref="ItalicPlaceholderEffect"/>
/// Id for <see cref="EntryItalicPlaceholder"/>
/// </summary>
public static string ItalicPlaceholderEffect => typeof(ItalicPlaceholderEffect).FullName;
public static string EntryItalicPlaceholder => typeof(EntryItalicPlaceholder).FullName;
/// <summary>
/// Id for <see cref="MultiLineLabelEffect"/>
/// Id for <see cref="LabelMultiLine"/>
/// </summary>
public static string MultiLineLabelEffect => typeof(MultiLineLabelEffect).FullName;
public static string LabelMultiLine => typeof(LabelMultiLine).FullName;
/// <summary>
/// Id for <see cref="RemoveBorderEffect"/>
/// Id for <see cref="EntryRemoveBorder"/>
/// </summary>
public static string RemoveBorderEffect => typeof(RemoveBorderEffect).FullName;
public static string EntryRemoveBorder => typeof(EntryRemoveBorder).FullName;
/// <summary>
/// Id for <see cref="RemoveEntryLineEffect"/>
/// Id for <see cref="EntryRemoveLine"/>
/// </summary>
public static string RemoveEntryLineEffect => typeof(RemoveEntryLineEffect).FullName;
public static string EntryRemoveLine => typeof(EntryRemoveLine).FullName;
/// <summary>
/// Id for <see cref="UWPSearchBarSuggestionEffect"/>
/// Id for <see cref="SearchBarSuggestion"/>
/// </summary>
public static string UWPSearchBarSuggestionEffect => typeof(UWPSearchBarSuggestionEffect).FullName;
public static string SearchBarSuggestion => typeof(SearchBarSuggestionEffect).FullName;
/// <summary>
/// Id for <see cref="SelectAllTextEntryEffect"/>
/// Id for <see cref="EntrySelectAllText"/>
/// </summary>
public static string SelectAllTextEntryEffect => typeof(SelectAllTextEntryEffect).FullName;
public static string EntrySelectAllText => typeof(EntrySelectAllText).FullName;
/// <summary>
/// Id for <see cref="SizeFontToFitEffect"/>
/// Id for <see cref="LabelSizeFontToFit"/>
/// </summary>
public static string SizeFontToFitEffect => typeof(SizeFontToFitEffect).FullName;
public static string LabelSizeFontToFit => typeof(LabelSizeFontToFit).FullName;
}
}

Просмотреть файл

@ -36,22 +36,22 @@
<DocumentationFile>bin\Release\FormsCommunityToolkit.Effects.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="BlurEffect.cs" />
<Compile Include="ChangeColorEffect.cs" />
<Compile Include="ClearEntryEffect.cs" />
<Compile Include="View\ViewBlur.cs" />
<Compile Include="Switch\SwitchChangeColor.cs" />
<Compile Include="Entry\EntryClear.cs" />
<Compile Include="EffectIds.cs" />
<Compile Include="MultiLineLabelEffect.cs" />
<Compile Include="Label\LabelMultiLine.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoveEntryLineEffect.cs" />
<Compile Include="CapitializeKeyboardEffect.cs" />
<Compile Include="RemoveBorderEffect.cs" />
<Compile Include="DisableAutoCorrectEffect.cs" />
<Compile Include="SearchBarSuggestionEffect.cs" />
<Compile Include="SizeFontToFitEffect.cs" />
<Compile Include="CustomFontEffect.cs" />
<Compile Include="ItalicPlaceholderEffect.cs" />
<Compile Include="SelectAllTextEntryEffect.cs" />
<Compile Include="ChangePickerColorEffect.cs" />
<Compile Include="Entry\EntryRemoveLine.cs" />
<Compile Include="Entry\EntryCapitializeKeyboard.cs" />
<Compile Include="Entry\EntryRemoveBorder.cs" />
<Compile Include="Entry\EntryDisableAutoCorrect.cs" />
<Compile Include="SearchBar\SearchBarSuggestion.cs" />
<Compile Include="Label\LabelSizeFontToFit.cs" />
<Compile Include="Label\LabelCustomFont.cs" />
<Compile Include="Entry\EntryItalicPlaceholder.cs" />
<Compile Include="Entry\EntrySelectAllText.cs" />
<Compile Include="Picker\PickerChangeColor.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntryCapitalizeKeyboard : RoutingEffect
{
public EntryCapitalizeKeyboard() : base(EffectIds.EntryCapitalizeKeyboard)
{
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntryClear : RoutingEffect
{
public EntryClear() : base(EffectIds.EntryClear)
{
}
}
}

Просмотреть файл

@ -5,9 +5,9 @@ namespace FormsCommunityToolkit.Effects
/// <summary>
/// When attached to a Xamarin.Forms.Entry control, disables auto-suggestion, auto-capitilisation and auto-correction for entered text.
/// </summary>
public class DisableAutoCorrectEffect : RoutingEffect
public class EntryDisableAutoCorrect : RoutingEffect
{
public DisableAutoCorrectEffect() : base(EffectIds.DisableAutoCorrectEffect)
public EntryDisableAutoCorrect() : base(EffectIds.EntryDisableAutoCorrect)
{
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntryItalicPlaceholder : RoutingEffect
{
public EntryItalicPlaceholder() : base(EffectIds.EntryItalicPlaceholder)
{
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntryRemoveBorder : RoutingEffect
{
public EntryRemoveBorder() : base(EffectIds.EntryRemoveBorder)
{
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntryRemoveLine : RoutingEffect
{
public EntryRemoveLine() : base(EffectIds.EntryRemoveLine)
{
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class EntrySelectAllText : RoutingEffect
{
public EntrySelectAllText() : base(EffectIds.EntrySelectAllText)
{
}
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class ItalicPlaceholderEffect : RoutingEffect
{
public ItalicPlaceholderEffect() : base(EffectIds.ItalicPlaceholderEffect)
{
}
}
}

Просмотреть файл

@ -3,7 +3,7 @@
namespace FormsCommunityToolkit.Effects
{
public class CustomFontEffect : RoutingEffect
public class LabelCustomFont : RoutingEffect
{
/// <summary>
/// Only needed on Android, FontFamilyName can be disregarded
@ -17,7 +17,7 @@ namespace FormsCommunityToolkit.Effects
/// <value>The name of the font family.</value>
public string FontFamilyName { get; set; }
public CustomFontEffect () : base (EffectIds.CustomFontEffect)
public LabelCustomFont () : base (EffectIds.LabelCustomFont)
{
}
}

Просмотреть файл

@ -2,11 +2,11 @@
namespace FormsCommunityToolkit.Effects
{
public class MultiLineLabelEffect : RoutingEffect
public class LabelMultiLine : RoutingEffect
{
public int Lines { get; set; }
public MultiLineLabelEffect() : base(EffectIds.MultiLineLabelEffect)
public LabelMultiLine() : base(EffectIds.LabelMultiLine)
{
}
}

Просмотреть файл

@ -0,0 +1,11 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class LabelSizeFontToFit : RoutingEffect
{
public LabelSizeFontToFit() : base(EffectIds.LabelSizeFontToFit)
{
}
}
}

Просмотреть файл

@ -3,10 +3,9 @@ using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public static class ChangePickerColorEffect
public static class PickerChangeColor
{
public static readonly BindableProperty ColorProperty = BindableProperty.CreateAttached ("Color", typeof (Color?), typeof (ChangePickerColorEffect), Color.Transparent, propertyChanged: OnColorChanged);
// public static readonly BindableProperty TrueColorProperty = BindableProperty.CreateAttached ("TrueColor", typeof (Color?), typeof (ChangeColorEffect), Color.Transparent, propertyChanged: OnColorChanged);
public static readonly BindableProperty ColorProperty = BindableProperty.CreateAttached ("Color", typeof (Color?), typeof (PickerChangeColor), Color.Transparent, propertyChanged: OnColorChanged);
private static void OnColorChanged (BindableObject bindable, object oldValue, object newValue)
{
@ -16,9 +15,9 @@ namespace FormsCommunityToolkit.Effects
var color = (Color)newValue;
var attachedEffect = control.Effects.FirstOrDefault (e => e is ChangeColorPickerEffect);
var attachedEffect = control.Effects.FirstOrDefault (e => e is PickerChangeColorEffect);
if (color != Color.Transparent && attachedEffect == null) {
control.Effects.Add (new ChangeColorPickerEffect ());
control.Effects.Add (new PickerChangeColorEffect ());
} else if (color == Color.Transparent && attachedEffect != null) {
control.Effects.Remove (attachedEffect);
}
@ -36,9 +35,9 @@ namespace FormsCommunityToolkit.Effects
}
public class ChangeColorPickerEffect : RoutingEffect
public class PickerChangeColorEffect : RoutingEffect
{
public ChangeColorPickerEffect() : base(EffectIds.ChangeColorPickerEffect)
public PickerChangeColorEffect() : base(EffectIds.PickerChangeColor)
{
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class RemoveBorderEffect : RoutingEffect
{
public RemoveBorderEffect() : base(EffectIds.RemoveBorderEffect)
{
}
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class RemoveEntryLineEffect : RoutingEffect
{
public RemoveEntryLineEffect() : base(EffectIds.RemoveEntryLineEffect)
{
}
}
}

Просмотреть файл

@ -4,10 +4,10 @@ using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public static class SearchBarSuggestionEffect
public static class SearchBarSuggestion
{
public static readonly BindableProperty SuggestionsProperty = BindableProperty.CreateAttached("Suggestions", typeof(ObservableCollection<string>), typeof(SearchBarSuggestionEffect), new ObservableCollection<string>(), propertyChanged: OnSuggestionsChanged);
public static readonly BindableProperty TextChangedActionProperty = BindableProperty.CreateAttached("TextChangedAction", typeof(Action), typeof(SearchBarSuggestionEffect), null, propertyChanged: OnTextChangedActionChanged);
public static readonly BindableProperty SuggestionsProperty = BindableProperty.CreateAttached("Suggestions", typeof(ObservableCollection<string>), typeof(SearchBarSuggestion), new ObservableCollection<string>(), propertyChanged: OnSuggestionsChanged);
public static readonly BindableProperty TextChangedActionProperty = BindableProperty.CreateAttached("TextChangedAction", typeof(Action), typeof(SearchBarSuggestion), null, propertyChanged: OnTextChangedActionChanged);
public static ObservableCollection<string> GetSuggestions(BindableObject view)
{
@ -47,9 +47,9 @@ namespace FormsCommunityToolkit.Effects
}
}
public class UWPSearchBarSuggestionEffect : RoutingEffect
public class SearchBarSuggestionEffect : RoutingEffect
{
public UWPSearchBarSuggestionEffect() : base(EffectIds.UWPSearchBarSuggestionEffect)
public SearchBarSuggestionEffect() : base(EffectIds.SearchBarSuggestion)
{
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class SelectAllTextEntryEffect : RoutingEffect
{
public SelectAllTextEntryEffect() : base(EffectIds.SelectAllTextEntryEffect)
{
}
}
}

Просмотреть файл

@ -1,11 +0,0 @@
using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public class SizeFontToFitEffect : RoutingEffect
{
public SizeFontToFitEffect() : base(EffectIds.SizeFontToFitEffect)
{
}
}
}

Просмотреть файл

@ -3,10 +3,10 @@ using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public static class ChangeColorEffect
public static class SwitchChangeColor
{
public static readonly BindableProperty FalseColorProperty = BindableProperty.CreateAttached ("FalseColor", typeof (Color?), typeof (ChangeColorEffect), Color.Transparent, propertyChanged: OnColorChanged);
public static readonly BindableProperty TrueColorProperty = BindableProperty.CreateAttached ("TrueColor", typeof (Color?), typeof (ChangeColorEffect), Color.Transparent, propertyChanged: OnColorChanged);
public static readonly BindableProperty FalseColorProperty = BindableProperty.CreateAttached ("FalseColor", typeof (Color?), typeof (SwitchChangeColor), Color.Transparent, propertyChanged: OnColorChanged);
public static readonly BindableProperty TrueColorProperty = BindableProperty.CreateAttached ("TrueColor", typeof (Color?), typeof (SwitchChangeColor), Color.Transparent, propertyChanged: OnColorChanged);
private static void OnColorChanged (BindableObject bindable, object oldValue, object newValue)
{
@ -16,9 +16,9 @@ namespace FormsCommunityToolkit.Effects
var color = (Color)newValue;
var attachedEffect = control.Effects.FirstOrDefault (e => e is ChangeColorSwitchEffect);
var attachedEffect = control.Effects.FirstOrDefault (e => e is SwitchChangeColorEffect);
if (color != Color.Transparent && attachedEffect == null)
control.Effects.Add (new ChangeColorSwitchEffect ());
control.Effects.Add (new SwitchChangeColorEffect ());
else if (color == Color.Transparent && attachedEffect != null)
control.Effects.Remove (attachedEffect);
}
@ -44,9 +44,9 @@ namespace FormsCommunityToolkit.Effects
}
}
public class ChangeColorSwitchEffect : RoutingEffect
public class SwitchChangeColorEffect : RoutingEffect
{
public ChangeColorSwitchEffect () : base (EffectIds.ChangeColorSwitchEffect)
public SwitchChangeColorEffect () : base (EffectIds.SwitchChangeColor)
{
}
}

Просмотреть файл

@ -3,9 +3,9 @@ using Xamarin.Forms;
namespace FormsCommunityToolkit.Effects
{
public static class BlurEffect
public static class ViewBlur
{
public static readonly BindableProperty BlurAmountProperty = BindableProperty.CreateAttached("BlurAmount", typeof(double), typeof(BlurEffect), 0.0, propertyChanged: OnBlurAmountChanged);
public static readonly BindableProperty BlurAmountProperty = BindableProperty.CreateAttached("BlurAmount", typeof(double), typeof(ViewBlur), 0.0, propertyChanged: OnBlurAmountChanged);
private static void OnBlurAmountChanged(BindableObject bindable, object oldValue, object newValue)
{
@ -38,7 +38,7 @@ namespace FormsCommunityToolkit.Effects
public class ViewBlurEffect : RoutingEffect
{
public ViewBlurEffect() : base(EffectIds.ViewBlurEffect)
public ViewBlurEffect() : base(EffectIds.ViewBlur)
{
}
}