Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/dotnet/maui into pj/editor-…
Browse files Browse the repository at this point in the history
…font

# Conflicts:
#	src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.Android.cs
  • Loading branch information
pictos committed Mar 19, 2021
2 parents c958b01 + 6402f5c commit 23d49e9
Show file tree
Hide file tree
Showing 61 changed files with 281 additions and 135 deletions.
13 changes: 7 additions & 6 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ 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(Button),
typeof(Editor),
typeof(Entry) ,
typeof(ContentPage) ,
typeof(Page) ,
typeof(Label) ,
typeof(Entry),
typeof(ContentPage),
typeof(Page),
typeof(Label),
typeof(Slider),
typeof(Stepper),
typeof(Switch)
typeof(Switch),
typeof(SearchBar)
};

Forms.RegisterCompatRenderers(
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/samples/Controls.Sample/Pages/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void SetupMauiLayout()
verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2 });
verticalStack.Add(new Label { Text = loremIpsum, LineBreakMode = LineBreakMode.TailTruncation });
verticalStack.Add(new Label { Text = loremIpsum, MaxLines = 2, LineBreakMode = LineBreakMode.TailTruncation });
verticalStack.Add(new Label { Text = "This should have five times the line height!", LineHeight = 5});
verticalStack.Add(new Label { Text = "This should have five times the line height!", LineHeight = 5 });

var editor = new Editor
{
Expand Down
6 changes: 6 additions & 0 deletions src/Controls/src/Core/EffectiveFlowDirectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ public static bool IsExplicit(this EffectiveFlowDirection self)
{
return (self & EffectiveFlowDirection.Explicit) == EffectiveFlowDirection.Explicit;
}

public static Maui.FlowDirection ToPlatformFlowDirection(this FlowDirection flowDirection)
{
return flowDirection.ToEffectiveFlowDirection().IsLeftToRight()
? Maui.FlowDirection.LeftToRight : Maui.FlowDirection.RightToLeft;
}
}
}
20 changes: 20 additions & 0 deletions src/Controls/src/Core/HandlerImpl/SearchBar.Impl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Microsoft.Maui.Controls
{
public partial class SearchBar : ISearchBar
{
Font? _font;

Font IText.Font
{
get
{
if (_font == null)
{
_font = Font.OfSize(FontFamily, FontSize).WithAttributes(FontAttributes);
}

return _font.Value;
}
}
}
}
2 changes: 2 additions & 0 deletions src/Controls/src/Core/HandlerImpl/VisualElement.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ protected virtual Size MeasureOverride(double widthConstraint, double heightCons
IsMeasureValid = true;
return DesiredSize;
}

Maui.FlowDirection IFrameworkElement.FlowDirection => FlowDirection.ToPlatformFlowDirection();
}
}
29 changes: 16 additions & 13 deletions src/Controls/src/Core/SearchBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Maui.Controls
{
public class SearchBar : InputView, IFontElement, ITextAlignmentElement, ISearchBarController, IElementConfiguration<SearchBar>
public partial class SearchBar : InputView, IFontElement, ITextAlignmentElement, ISearchBarController, IElementConfiguration<SearchBar>
{
public static readonly BindableProperty SearchCommandProperty = BindableProperty.Create("SearchCommand", typeof(ICommand), typeof(SearchBar), null, propertyChanged: OnCommandChanged);

Expand Down Expand Up @@ -89,23 +89,26 @@ public double FontSize
set { SetValue(FontSizeProperty, value); }
}

void IFontElement.OnFontFamilyChanged(string oldValue, string newValue)
{
}

void IFontElement.OnFontSizeChanged(double oldValue, double newValue)
{
}

double IFontElement.FontSizeDefaultValueCreator() =>
Device.GetNamedSize(NamedSize.Default, (SearchBar)this);

void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue)
{
}
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
HandleFontChanged();

void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
HandleFontChanged();

void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
HandleFontChanged();

void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
HandleFontChanged();

void IFontElement.OnFontChanged(Font oldValue, Font newValue)
void HandleFontChanged()
{
// Null out the Maui font value so it will be recreated next time it's accessed
_font = null;
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}

public event EventHandler SearchButtonPressed;
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Stepper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public double Value

public IPlatformElementConfiguration<T, Stepper> On<T>() where T : IConfigPlatform => _platformConfigurationRegistry.Value.On<T>();

double IStepper.Step => Increment;
double IStepper.Interval => Increment;
}
}
9 changes: 7 additions & 2 deletions src/Core/src/Core/IFrameworkElement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.Maui
namespace Microsoft.Maui
{
/// <summary>
/// Represents a framework-level set of properties, events, and methods for .NET MAUI elements.
Expand Down Expand Up @@ -73,7 +73,7 @@ public interface IFrameworkElement
/// Gets a value indicating whether the computed size and position of child elements in this element's layout are valid.
/// </summary>
void InvalidateMeasure();

/// <summary>
/// Method that is called to invalidate the layout of this FrameworkElement.
/// </summary>
Expand All @@ -83,5 +83,10 @@ public interface IFrameworkElement
/// Id used by automation tools to interact with this FrameworkElement
/// </summary>
string AutomationId { get; }

/// <summary>
/// Direction in which the UI elements on the page are scanned by the eye
/// </summary>
FlowDirection FlowDirection { get; }
}
}
2 changes: 1 addition & 1 deletion src/Core/src/Core/IPlaceholder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Provides functionality to be able to use a Placeholder.
/// </summary>
public interface IPlaceholder
public interface IPlaceholder
{
/// <summary>
/// Gets the placeholder or hint text.
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Core/ISearchBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
/// </summary>
public interface ISearchBar : IView, IText, IPlaceholder, ITextAlignment
{

}
}
2 changes: 1 addition & 1 deletion src/Core/src/Core/IStepper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public interface IStepper : IView, IRange
/// <summary>
/// Gets the amount by which Value is increased or decreased.
/// </summary>
double Step { get; }
double Interval { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace Microsoft.Maui.Handlers
{
public partial class ActivityIndicatorHandler : AbstractViewHandler<IActivityIndicator, NativeActivityIndicator>
public partial class ActivityIndicatorHandler : AbstractViewHandler<IActivityIndicator, MauiActivityIndicator>
{
protected override NativeActivityIndicator CreateNativeView() => new NativeActivityIndicator(CGRect.Empty, VirtualView)
protected override MauiActivityIndicator CreateNativeView() => new MauiActivityIndicator(CGRect.Empty, VirtualView)
{
ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
};
Expand Down
12 changes: 6 additions & 6 deletions src/Core/src/Handlers/CheckBox/CheckBoxHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

namespace Microsoft.Maui.Handlers
{
public partial class CheckBoxHandler : AbstractViewHandler<ICheckBox, NativeCheckBox>
public partial class CheckBoxHandler : AbstractViewHandler<ICheckBox, MauiCheckBox>
{
protected virtual float MinimumSize => 44f;

protected override NativeCheckBox CreateNativeView()
protected override MauiCheckBox CreateNativeView()
{
return new NativeCheckBox
return new MauiCheckBox
{
MinimumViewSize = MinimumSize
};
}

protected override void ConnectHandler(NativeCheckBox nativeView)
protected override void ConnectHandler(MauiCheckBox nativeView)
{
base.ConnectHandler(nativeView);

nativeView.CheckedChanged += OnCheckedChanged;
}

protected override void DisconnectHandler(NativeCheckBox nativeView)
protected override void DisconnectHandler(MauiCheckBox nativeView)
{
base.DisconnectHandler(nativeView);

Expand Down Expand Up @@ -65,7 +65,7 @@ public override Size GetDesiredSize(double widthConstraint, double heightConstra

void OnCheckedChanged(object? sender, EventArgs e)
{
if (sender is NativeCheckBox nativeView && VirtualView != null)
if (sender is MauiCheckBox nativeView && VirtualView != null)
{
VirtualView.IsChecked = nativeView.IsChecked;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Editor/EditorHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void MapCharacterSpacing(EditorHandler handler, IEditor editor)
{
handler.TypedNativeView?.UpdateCharacterSpacing(editor);
}

public static void MapIsTextPredictionEnabled(EditorHandler handler, IEditor editor)
{
handler.TypedNativeView?.UpdateIsTextPredictionEnabled(editor);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Editor/EditorHandler.Standard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial class EditorHandler : AbstractViewHandler<IEditor, object>
public static void MapText(IViewHandler handler, IEditor editor) { }

public static void MapCharacterSpacing(IViewHandler handler, IEditor editor) { }

public static void MapIsTextPredictionEnabled(EditorHandler handler, IEditor editor) { }

public static void MapFont(IViewHandler handler, IEditor editor) { }
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Editor/EditorHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void MapCharacterSpacing(EditorHandler handler, IEditor editor)
{
handler.TypedNativeView?.UpdateCharacterSpacing(editor);
}

public static void MapIsTextPredictionEnabled(EditorHandler handler, IEditor editor)
{
handler.TypedNativeView?.UpdatePredictiveText(editor);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Picker/PickerHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void OnClick(object? sender, EventArgs e)
using (var builder = new AlertDialog.Builder(Context))
{
builder.SetTitle(VirtualView.Title ?? string.Empty);

string[] items = VirtualView.Items.ToArray();

builder.SetItems(items, (s, e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void MapPlaceholder(SearchBarHandler handler, ISearchBar searchBar
{
handler.TypedNativeView?.UpdatePlaceholder(searchBar);
}

public static void MapFont(SearchBarHandler handler, ISearchBar searchBar)
{
var services = App.Current?.Services
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Stepper/StepperHandler.Android.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Android.Widget;
using Android.Views;
using Android.Widget;
using AButton = Android.Widget.Button;
using AOrientation = Android.Widget.Orientation;

Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Stepper/StepperHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial class StepperHandler
{
[nameof(IStepper.Minimum)] = MapMinimum,
[nameof(IStepper.Maximum)] = MapMaximum,
[nameof(IStepper.Step)] = MapIncrement,
[nameof(IStepper.Interval)] = MapIncrement,
[nameof(IStepper.Value)] = MapValue
};

Expand Down
3 changes: 2 additions & 1 deletion src/Core/src/Handlers/TimePicker/TimePickerHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public partial class TimePickerHandler : AbstractViewHandler<ITimePicker, MauiTi
{
protected override MauiTimePicker CreateNativeView()
{
return new MauiTimePicker(() => {
return new MauiTimePicker(() =>
{
SetVirtualViewTime();
TypedNativeView?.ResignFirstResponder();
});
Expand Down
5 changes: 3 additions & 2 deletions src/Core/src/Hosting/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ public static IAppHostBuilder UseMauiHandlers(this IAppHostBuilder builder)
{
builder.RegisterHandlers(new Dictionary<Type, Type>
{
{ typeof(IActivityIndicator), typeof(ActivityIndicatorHandler) },
{ typeof(IActivityIndicator), typeof(ActivityIndicatorHandler) },
{ typeof(IButton), typeof(ButtonHandler) },
{ typeof(ICheckBox), typeof(CheckBoxHandler) },
{ typeof(IEditor), typeof(EditorHandler) },
{ typeof(IEntry), typeof(EntryHandler) },
{ typeof(ILayout), typeof(LayoutHandler) },
{ typeof(ILabel), typeof(LabelHandler) },
{ typeof(IPicker), typeof(PickerHandler) },
{ typeof(IPicker), typeof(PickerHandler) },
{ typeof(IProgress), typeof(ProgressBarHandler) },
{ typeof(ISearchBar), typeof(SearchBarHandler) },
{ typeof(ISlider), typeof(SliderHandler) },
{ typeof(IStepper), typeof(StepperHandler) },
{ typeof(ISwitch), typeof(SwitchHandler) },
Expand Down
Loading

0 comments on commit 23d49e9

Please sign in to comment.