Skip to content

Commit db24c34

Browse files
committed
Merge branch 'develop'
2 parents 37cea89 + 0de8e90 commit db24c34

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

AuroraControlsMaui/NumericEntry.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ public NumericEntryValueType ValueType
3030
get => (NumericEntryValueType)GetValue(ValueTypeProperty);
3131
set => SetValue(ValueTypeProperty, value);
3232
}
33+
34+
public NumericEntry()
35+
{
36+
Keyboard = Keyboard.Numeric;
37+
IsTextPredictionEnabled = false;
38+
}
3339
}

AuroraControlsMaui/Platforms/iOS/NumericEntryHandler.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
1-
using Foundation;
1+
using System.Drawing;
2+
using Foundation;
23
using Microsoft.Maui.Handlers;
34
using Microsoft.Maui.Platform;
45
using UIKit;
56

67
namespace AuroraControls;
78

8-
public partial class NumericEntryHandler : EntryHandler
9+
public partial class NumericEntryHandler : EntryHandler, IDisposable
910
{
11+
private UIBarButtonItem _doneButton;
12+
1013
protected override void ConnectHandler(MauiTextField platformView)
1114
{
1215
base.ConnectHandler(platformView);
1316

17+
var toolbar = new UIToolbar(new RectangleF(0, 0, (float)UIScreen.MainScreen.Bounds.Width, 44)) { BarStyle = UIBarStyle.Default, Translucent = true };
18+
_doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done);
19+
_doneButton.Clicked += DoneButtonOnClicked;
20+
21+
toolbar.Items = [new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _doneButton,];
22+
platformView.InputAccessoryView = toolbar;
23+
1424
platformView.ShouldChangeCharacters += OnShouldChangeCharacters;
1525
}
1626

1727
protected override void DisconnectHandler(MauiTextField platformView)
1828
{
1929
platformView.ShouldChangeCharacters -= OnShouldChangeCharacters;
30+
_doneButton.Clicked -= DoneButtonOnClicked;
31+
32+
PlatformView.InputAccessoryView?.Dispose();
33+
PlatformView.InputAccessoryView = null;
2034

2135
base.DisconnectHandler(platformView);
2236
}
2337

38+
private void DoneButtonOnClicked(object? sender, EventArgs e)
39+
{
40+
this.PlatformView.ResignFirstResponder();
41+
}
42+
2443
private bool OnShouldChangeCharacters(UITextField textField, NSRange range, string replacementString)
2544
{
2645
string originalSource = replacementString;
@@ -36,4 +55,18 @@ private bool OnShouldChangeCharacters(UITextField textField, NSRange range, stri
3655

3756
return IsValid(final, NumericEntryVirtualView.CultureInfo, NumericEntryVirtualView.ValueType);
3857
}
58+
59+
protected virtual void Dispose(bool disposing)
60+
{
61+
if (disposing)
62+
{
63+
_doneButton.Dispose();
64+
}
65+
}
66+
67+
public void Dispose()
68+
{
69+
Dispose(true);
70+
GC.SuppressFinalize(this);
71+
}
3972
}

0 commit comments

Comments
 (0)