Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handler staging #547

Merged
merged 23 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b5665a3
TimePicker Handlers (#454)
jsuarezruiz Mar 16, 2021
68987b1
CheckBoxHandlers (#432)
jsuarezruiz Mar 16, 2021
efd792b
Rename ICheck -> ICheckBox, remove Color stuff (to be replaced with B…
hartez Mar 16, 2021
753e8ae
Implement CharacterSpacing property in EditorHandlers (#516)
jsuarezruiz Mar 16, 2021
e992050
Fix broken test and incorrect CharacterSpacing on iOS
hartez Mar 16, 2021
bc5722c
Implement HorizontalTextAlignment property in EntryHandlers (#524)
jsuarezruiz Mar 16, 2021
e5b2278
Better text on example
hartez Mar 16, 2021
6ae6e56
Remove IView from ITextAlignment
hartez Mar 16, 2021
3dd218f
Remove IView from IPlaceholder
hartez Mar 16, 2021
a9a4900
Implement IsTextPredictionEnabled property on Editor (#515)
hevey Mar 16, 2021
b4f6a76
Implement ReturnType property in EntryHandlers (#518)
jsuarezruiz Mar 17, 2021
1d8b317
Implement CharacterSpacing property in SearchBarHandlers (#494)
jsuarezruiz Mar 17, 2021
07ca2a2
Stepper Handlers (#517)
jsuarezruiz Mar 17, 2021
b6f3c17
IStepper.Increment -> IStepper.Step
hartez Mar 17, 2021
f1298b4
Picker Handlers (#433)
jsuarezruiz Mar 17, 2021
2798eb9
ActivityIndicator Handlers (#417)
jsuarezruiz Mar 17, 2021
6ec9b0e
Implement Font properties in SearchBarHandlers (#533)
jsuarezruiz Mar 17, 2021
e0c4403
Implemented LineHeight on Label (#538)
AmrAlSayed0 Mar 17, 2021
70af9b5
Fix broken label tests; add some missing label tests; attributed stri…
hartez Mar 18, 2021
72b6b08
Consolidate and rename extension method classes
hartez Mar 18, 2021
ef7fb50
Fix class names and de-duplicate methods
hartez Mar 18, 2021
856738d
Centralize time extensions
hartez Mar 18, 2021
5b0416f
Fix mapping
hartez Mar 18, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class CheckBoxRendererBase :
IPlatformElementConfiguration<PlatformConfiguration.Android, CheckBox> _platformElementConfiguration;
CheckBox _checkBox;

[PortHandler]
static int[][] _checkedStates = new int[][]
{
new int[] { AAttribute.StateEnabled, AAttribute.StateChecked },
Expand Down Expand Up @@ -185,6 +186,7 @@ void IOnCheckedChangeListener.OnCheckedChanged(CompoundButton buttonView, bool i
((IElementController)Element).SetValueFromRenderer(CheckBox.IsCheckedProperty, isChecked);
}

[PortHandler]
void UpdateIsChecked()
{
if (Element == null || Control == null)
Expand All @@ -210,6 +212,7 @@ protected virtual ColorStateList GetColorStateList()
return list;
}

[PortHandler]
void UpdateBackgroundColor()
{
if (Element.BackgroundColor == Color.Default)
Expand All @@ -225,6 +228,7 @@ void UpdateBackground()
this.UpdateBackground(background);
}

[PortHandler]
void UpdateOnColor()
{
if (Element == null || Control == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected override void OnFocusChangeRequested(object sender, VisualElement.Focu
}
}

[PortHandler("Partially ported, still missing code related to TitleColor, etc.")]
void IPickerRenderer.OnClick()
{
Picker model = Element;
Expand Down Expand Up @@ -168,6 +169,7 @@ protected void UpdateCharacterSpacing()
}
}

[PortHandler("Partially ported, still missing code related to TitleColor, etc.")]
void UpdatePicker()
{
UpdatePlaceHolderText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Android
{
internal static class EntryRendererExtensions
{

[PortHandler]
internal static ImeAction ToAndroidImeAction(this ReturnType returnType)
{
switch (returnType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public ActivityIndicatorRenderer(Context context) : base(context)
AutoPackage = false;
}

[PortHandler]
protected override AProgressBar CreateNativeControl()
{
return new AProgressBar(Context) { Indeterminate = true };
Expand Down Expand Up @@ -42,6 +43,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateColor();
}

[PortHandler]
void UpdateColor()
{
if (Element == null || Control == null)
Expand All @@ -55,6 +57,7 @@ void UpdateColor()
Control.IndeterminateDrawable?.ClearColorFilter();
}

[PortHandler]
void UpdateVisibility()
{
if (Element == null || Control == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ protected virtual void UpdateFont()
EditText.SetTextSize(ComplexUnitType.Sp, (float)Element.FontSize);
}

[PortHandler("Partially Ported")]
void UpdateInputType()
{
Editor model = Element;
Expand Down Expand Up @@ -243,6 +244,7 @@ void UpdateInputType()
}
}

[PortHandler]
void UpdateCharacterSpacing()
{
if (Forms.IsLollipopOrNewer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ protected virtual void UpdateImeOptions()
EditText.ImeOptions = _currentInputImeFlag;
}

[PortHandler]
void UpdateHorizontalTextAlignment()
{
EditText.UpdateTextAlignment(Element.HorizontalTextAlignment, Element.VerticalTextAlignment);
Expand Down Expand Up @@ -396,6 +397,7 @@ void UpdateCharacterSpacing()
}
}

[PortHandler]
void UpdateReturnType()
{
if (Control == null || Element == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ void UpdateCharacterSpacing()
}
}

[PortHandler]
void UpdateLineHeight()
{
_lastSizeRequest = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void ClearFocus(SearchView view)
view.ClearFocus();
}

[PortHandler]
void UpdateFont()
{
_editText = _editText ?? Control.GetChildrenOfType<EditText>().FirstOrDefault();
Expand Down Expand Up @@ -264,6 +265,7 @@ void UpdateText()
Control.SetQuery(text, false);
}

[PortHandler]
void UpdateCharacterSpacing()
{
if (!Forms.IsLollipopOrNewer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public StepperRenderer(Context context) : base(context)
AutoPackage = false;
}

[PortHandler]
protected override LinearLayout CreateNativeControl()
{
return new LinearLayout(Context)
Expand All @@ -26,6 +27,7 @@ protected override LinearLayout CreateNativeControl()
};
}

[PortHandler]
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{
base.OnElementChanged(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public abstract class TimePickerRendererBase<TControl> : ViewRenderer<TimePicker
AlertDialog _dialog;
bool _disposed;

[PortHandler]
bool Is24HourView
{
get => (DateFormat.Is24HourFormat(Context) && Element.Format == (string)TimePicker.FormatProperty.DefaultValue) || Element.Format?.Contains('H') == true;
Expand Down Expand Up @@ -154,6 +155,7 @@ void OnCancelButtonClicked(object sender, EventArgs e)
Element.Unfocus();
}

[PortHandler]
void SetTime(TimeSpan time)
{
if (String.IsNullOrEmpty(Element.Format))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.Android
{
[PortHandler]
public static class StepperRendererManager
{
public static void CreateStepperButtons<TButton>(IStepperRenderer renderer, out TButton downButton, out TButton upButton)
Expand Down
17 changes: 9 additions & 8 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ public static IAppHostBuilder RegisterCompatibilityRenderers(this IAppHostBuilde
// This won't really be a thing once we have all the handlers built
var defaultHandlers = new List<Type>
{
typeof(Button) ,
typeof(Editor),
typeof(Entry) ,
typeof(ContentPage) ,
typeof(Page) ,
typeof(Label) ,
typeof(Slider),
typeof(Switch)
typeof(Button) ,
typeof(Editor),
typeof(Entry) ,
typeof(ContentPage) ,
typeof(Page) ,
typeof(Label) ,
typeof(Slider),
typeof(Stepper),
typeof(Switch)
};

Forms.RegisterCompatRenderers(
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/iOS/Extensions/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ internal static UISearchBarStyle ToNativeSearchBarStyle(this PlatformConfigurati
}
}

[PortHandler]
internal static UIReturnKeyType ToUIReturnKeyType(this ReturnType returnType)
{
switch (returnType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS
{
[PortHandler]
public sealed class UIActivityIndicatorViewDelegate : UIActivityIndicatorView
{
ActivityIndicator _element;
Expand Down Expand Up @@ -40,6 +41,7 @@ public ActivityIndicatorRenderer()

}

[PortHandler]
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
{
if (e.NewElement != null)
Expand Down Expand Up @@ -69,11 +71,13 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateIsRunning();
}

[PortHandler]
void UpdateColor()
{
Control.Color = Element.Color == Color.Default ? null : Element.Color.ToUIColor();
}

[PortHandler]
void UpdateIsRunning()
{
if (Control?.Superview == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<CheckBox> e)
base.OnElementChanged(e);
}

[PortHandler]
protected virtual void UpdateTintColor()
{
if (Element == null)
Expand All @@ -129,6 +130,7 @@ protected virtual void UpdateTintColor()
Control.CheckBoxTintColor = Element.Color;
}

[PortHandler]
void OnControlCheckedChanged(object sender, EventArgs e)
{
Element.IsChecked = Control.IsChecked;
Expand Down
2 changes: 2 additions & 0 deletions src/Compatibility/Core/src/iOS/Renderers/EditorRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ protected internal override void UpdatePlaceholderText()
_placeholderLabel.SizeToFit();
}

[PortHandler("Partially ported")]
protected internal override void UpdateCharacterSpacing()
{
var textAttr = TextView.AttributedText.AddCharacterSpacing(Element.Text, Element.CharacterSpacing);
Expand Down Expand Up @@ -305,6 +306,7 @@ protected internal virtual void UpdateFont()
TextView.Font = font;
}

[PortHandler("Partially Ported")]
void UpdateKeyboard()
{
var keyboard = Element.Keyboard;
Expand Down
2 changes: 2 additions & 0 deletions src/Compatibility/Core/src/iOS/Renderers/EntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ protected virtual bool OnShouldReturn(UITextField view)
return false;
}

[PortHandler]
void UpdateHorizontalTextAlignment()
{
Control.TextAlignment = Element.HorizontalTextAlignment.ToNativeTextAlignment(((IVisualElementController)Element).EffectiveFlowDirection);
Expand Down Expand Up @@ -401,6 +402,7 @@ bool ShouldChangeCharacters(UITextField textField, NSRange range, string replace
return newLength <= Element?.MaxLength;
}

[PortHandler]
void UpdateReturnType()
{
if (Control == null || Element == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS
{
[PortHandler("NativeCheckBox")]
public class FormsCheckBox : UIButton
{
static UIImage _checked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ void UpdateCharacterSpacing()
_perfectSizeValid = false;
}

[PortHandler("Partially. Mapped LineHeight")]
void UpdateText()
{
if (IsElementOrControlEmpty)
Expand Down
7 changes: 7 additions & 0 deletions src/Compatibility/Core/src/iOS/Renderers/PickerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS
{
[PortHandler]
internal class ReadOnlyField : NoCaretField
{
readonly HashSet<string> enableActions;
Expand All @@ -32,6 +33,7 @@ public PickerRenderer()

}

[PortHandler]
protected override UITextField CreateNativeControl()
{
return new ReadOnlyField { BorderStyle = UITextBorderStyle.RoundedRect };
Expand All @@ -56,6 +58,8 @@ public PickerRendererBase()
}

protected abstract override TControl CreateNativeControl();

[PortHandler("Partially ported, still missing code related to TitleColor, etc.")]
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
if (e.OldElement != null)
Expand Down Expand Up @@ -231,6 +235,7 @@ protected internal virtual void UpdatePlaceholder()
protected virtual void UpdateAttributedPlaceholder(NSAttributedString nsAttributedString) =>
Control.AttributedPlaceholder = nsAttributedString;

[PortHandler]
void UpdatePicker()
{
var selectedIndex = Element.SelectedIndex;
Expand Down Expand Up @@ -266,6 +271,7 @@ void UpdatePickerNativeSize(string oldText)
((IVisualElementController)Element).NativeSizeChanged();
}

[PortHandler]
void UpdatePickerSelectedIndex(int formsIndex)
{
var source = (PickerSource)_picker.Model;
Expand Down Expand Up @@ -334,6 +340,7 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

[PortHandler]
class PickerSource : UIPickerViewModel
{
PickerRendererBase<TControl> _renderer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ void OnTextChanged(object sender, UISearchBarTextChangedEventArgs a)
UpdateOnTextChanged();
}

[PortHandler("The code related to Placeholder remains to be ported")]
void UpdateCharacterSpacing()
{
_textField = _textField ?? Control.FindDescendantView<UITextField>();
Expand Down Expand Up @@ -290,6 +291,7 @@ public virtual void UpdateCancelButton()
}
}

[PortHandler]
void UpdateFont()
{
_textField = _textField ?? Control.FindDescendantView<UITextField>();
Expand Down
5 changes: 5 additions & 0 deletions src/Compatibility/Core/src/iOS/Renderers/StepperRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,31 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateIncrement();
}

[PortHandler]
void OnValueChanged(object sender, EventArgs e)
{
((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, Control.Value);
}

[PortHandler]
void UpdateIncrement()
{
Control.StepValue = Element.Increment;
}

[PortHandler]
void UpdateMaximum()
{
Control.MaximumValue = Element.Maximum;
}

[PortHandler]
void UpdateMinimum()
{
Control.MinimumValue = Element.Minimum;
}

[PortHandler]
void UpdateValue()
{
if (Control.Value != Element.Value)
Expand Down
Loading