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

[iOS] Implement iOS Platform Specifics #5879

Merged
merged 20 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e3b01ac
Implement iOS Entry CursorColor Platform Specific
jsuarezruiz Apr 7, 2022
22d7c4e
Implement iOS SearchBar SearchBarStyle Platform Specific
jsuarezruiz Apr 7, 2022
8e408d6
Added Platform Specifics sample
jsuarezruiz Apr 7, 2022
d824e05
Implement UpdateMode Platform Specific in iOS DatePicker, Picker and …
jsuarezruiz Apr 8, 2022
158771e
Implement iOS ScrollView ShouldDelayContentTouches Platform Specific
jsuarezruiz Apr 8, 2022
94b3532
Implement iOS Entry AdjustsFontSizeToFitWidth Platform Specific
jsuarezruiz Apr 8, 2022
f5bff4c
Implement iOS NavigationPage PrefersLargeTitles Platform Specific
jsuarezruiz Apr 8, 2022
dbc459b
Implement iOS NavigationPage IsNavigationBarTranslucent Platform Spec…
jsuarezruiz Apr 8, 2022
c507569
Merge branch 'main' into platform-specific-ios
jsuarezruiz Apr 12, 2022
365576f
Merge branch 'main' into platform-specific-ios
jsuarezruiz Apr 26, 2022
b2792fd
Merge branch 'main' into platform-specific-ios
jsuarezruiz Apr 26, 2022
5267a5b
Merge branch 'main' into platform-specific-ios
mattleibow May 9, 2022
6637456
renamed
mattleibow May 9, 2022
6b9d4ab
[iOS] Fix Picker update when changed with correct SelectedIndex
rmarinho May 10, 2022
aa63543
[iOS] Update TimePicker when internal UIDatePicker changes
rmarinho May 10, 2022
30bf597
Add samples of PlatformSpecifics to MacCatalyst also
rmarinho May 10, 2022
9c140c9
[MacCatalyst] UpdateImmediately defaults to true
rmarinho May 10, 2022
3a4cb68
Default to true for TimePicker UpdateMode
rmarinho May 10, 2022
467e501
Update DatePickerHandler.iOS.cs
mattleibow May 11, 2022
f509d9a
Update DatePickerHandler.iOS.cs
mattleibow May 11, 2022
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 @@ -152,6 +152,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
}
}

[PortHandler]
void HandleValueChanged(object sender, EventArgs e)
{
if (Element.OnThisPlatform().UpdateMode() == UpdateMode.Immediately)
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 @@ -286,6 +286,7 @@ protected virtual void UpdateColor()
}
}

[PortHandler]
void UpdateAdjustsFontSizeToFitWidth()
{
Control.AdjustsFontSizeToFitWidth = Element.OnThisPlatform().AdjustsFontSizeToFitWidth();
Expand Down Expand Up @@ -511,6 +512,7 @@ UITextPosition GetSelectionStart(int cursorPosition, out int startOffset)
return start;
}

[PortHandler]
void UpdateCursorColor()
{
var control = Control;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,14 @@ void UpdateCurrentPagePreferredStatusBarUpdateAnimation()
PlatformConfiguration.iOSSpecific.Page.SetPreferredStatusBarUpdateAnimation(Current.OnThisPlatform(), animation);
}

[PortHandler]
void UpdateUseLargeTitles()
{
if (Forms.IsiOS11OrNewer && NavPage != null)
NavigationBar.PrefersLargeTitles = NavPage.OnThisPlatform().PrefersLargeTitles();
}

[PortHandler]
void UpdateTranslucent()
{
NavigationBar.Translucent = NavPage.OnThisPlatform().IsNavigationBarTranslucent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
ScrollView.SendScrollFinished();
}

[PortHandler]
void UpdateDelaysContentTouches()
{
DelaysContentTouches = ((ScrollView)Element).OnThisPlatform().ShouldDelayContentTouches();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ UIToolbar CreateNumericKeyboardAccessoryView()
return accessoryView;
}

[PortHandler]
void UpdateSearchBarStyle()
{
Control.SearchBarStyle = Element.OnThisPlatform().GetSearchBarStyle().ToPlatformSearchBarStyle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override IEnumerable<SectionModel> CreateItems()
new SectionModel(typeof(AndroidWebViewZoomPage), "WebView Zoom Controls",
"This Android platform-specific enables pinch-to-zoom and a zoom control on a WebView."),
};
#elif IOS
#elif IOS || MACCATALYST
return new[]
{
new SectionModel(typeof(iOSBlurEffectPage), "Blur Effect",
Expand Down
8 changes: 0 additions & 8 deletions src/Controls/src/Core/HandlerImpl/DatePicker.Impl.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class DatePicker
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class DatePicker : IDatePicker
{
Font ITextStyle.Font => this.ToFont();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class DatePicker
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class DatePicker
{

}
}
18 changes: 18 additions & 0 deletions src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Microsoft.Maui.Controls
{
public partial class DatePicker
{
public static IPropertyMapper<IDatePicker, DatePickerHandler> ControlsDatePickerMapper = new PropertyMapper<DatePicker, DatePickerHandler>(DatePickerHandler.Mapper)
{
#if IOS
[PlatformConfiguration.iOSSpecific.DatePicker.UpdateModeProperty.PropertyName] = MapUpdateMode,
#endif
};

internal static new void RemapForControls()
{
// Adjust the mappings to preserve Controls.DatePicker legacy behaviors
DatePickerHandler.Mapper = ControlsDatePickerMapper;
}
}
}
13 changes: 13 additions & 0 deletions src/Controls/src/Core/HandlerImpl/DatePicker/DatePicker.iOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;

namespace Microsoft.Maui.Controls
{
public partial class DatePicker
{
public static void MapUpdateMode(DatePickerHandler handler, DatePicker datePicker)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
handler.UpdateImmediately = datePicker.OnThisPlatform().UpdateMode() == UpdateMode.Immediately;
}
}
}
3 changes: 3 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Entry/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public partial class Entry
[PlatformConfiguration.AndroidSpecific.Entry.ImeOptionsProperty.PropertyName] = MapImeOptions,
#elif WINDOWS
[PlatformConfiguration.WindowsSpecific.InputView.DetectReadingOrderFromContentProperty.PropertyName] = MapDetectReadingOrderFromContent,
#elif IOS
[PlatformConfiguration.iOSSpecific.Entry.CursorColorProperty.PropertyName] = MapCursorColor,
[PlatformConfiguration.iOSSpecific.Entry.AdjustsFontSizeToFitWidthProperty.PropertyName] = MapAdjustsFontSizeToFitWidth,
#endif
[nameof(Text)] = MapText,
[nameof(TextTransform)] = MapText,
Expand Down
12 changes: 11 additions & 1 deletion src/Controls/src/Core/HandlerImpl/Entry/Entry.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
{
public partial class Entry
{
public static void MapText(EntryHandler handler, Entry entry)
public static void MapCursorColor(EntryHandler handler, Entry entry)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
Platform.TextExtensions.UpdateCursorColor(handler.PlatformView, entry);
}

public static void MapAdjustsFontSizeToFitWidth(EntryHandler handler, Entry entry)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
Platform.TextExtensions.UpdateAdjustsFontSizeToFitWidth(handler.PlatformView, entry);
}

public static void MapText(EntryHandler handler, Entry entry)
{
Platform.TextExtensions.UpdateText(handler.PlatformView, entry);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Microsoft.Maui.Controls
{
public partial class NavigationPage
{
public static IPropertyMapper<IStackNavigationView, NavigationViewHandler> ControlsNavigationPageMapper =
new PropertyMapper<NavigationPage, NavigationViewHandler>(NavigationViewHandler.Mapper)
{
#if IOS
[PlatformConfiguration.iOSSpecific.NavigationPage.PrefersLargeTitlesProperty.PropertyName] = MapPrefersLargeTitles,
[PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName] = MapIsNavigationBarTranslucent,
#endif
};

internal static new void RemapForControls()
{
// Adjust the mappings to preserve Controls.NavigationPage legacy behaviors
NavigationViewHandler.Mapper = ControlsNavigationPageMapper;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Microsoft.Maui.Controls
{
public partial class NavigationPage
{
public static void MapPrefersLargeTitles(NavigationViewHandler handler, NavigationPage navigationPage)
{
if (handler.ViewController is ControlsNavigationController navigationController)
Platform.NavigationPageExtensions.UpdatePrefersLargeTitles(navigationController, navigationPage);
}

public static void MapIsNavigationBarTranslucent(NavigationViewHandler handler, NavigationPage navigationPage)
{
if (handler.ViewController is ControlsNavigationController navigationController)
Platform.NavigationPageExtensions.UpdateIsNavigationBarTranslucent(navigationController, navigationPage);
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Picker/Picker.Android.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class Picker
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Microsoft.Maui.Controls
{
/// <include file="../../../docs/Microsoft.Maui.Controls/Picker.xml" path="Type[@FullName='Microsoft.Maui.Controls.Picker']/Docs" />
public partial class Picker : IPicker
{
Font ITextStyle.Font => this.ToFont();
Expand Down
7 changes: 7 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Picker/Picker.Standard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class Picker
{

}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Picker/Picker.Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class Picker
{

}
}
18 changes: 18 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Picker/Picker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Microsoft.Maui.Controls
{
public partial class Picker
{
public static IPropertyMapper<IPicker, PickerHandler> ControlsPickerMapper = new PropertyMapper<Picker, PickerHandler>(PickerHandler.Mapper)
{
#if IOS
[PlatformConfiguration.iOSSpecific.Picker.UpdateModeProperty.PropertyName] = MapUpdateMode,
#endif
};

internal static new void RemapForControls()
{
// Adjust the mappings to preserve Controls.Picker legacy behaviors
PickerHandler.Mapper = ControlsPickerMapper;
}
}
}
13 changes: 13 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Picker/Picker.iOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;

namespace Microsoft.Maui.Controls
{
public partial class Picker
{
public static void MapUpdateMode(PickerHandler handler, Picker picker)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
handler.UpdateImmediately = picker.OnThisPlatform().UpdateMode() == UpdateMode.Immediately;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class ScrollView
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Microsoft.Maui.Controls
{
/// <include file="../../../docs/Microsoft.Maui.Controls/ScrollView.xml" path="Type[@FullName='Microsoft.Maui.Controls.ScrollView']/Docs" />
public partial class ScrollView : IScrollView, IContentView
{
object IContentView.Content => Content;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class ScrollView
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class ScrollView
{

}
}
19 changes: 19 additions & 0 deletions src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Microsoft.Maui.Controls
{
public partial class ScrollView
{
public static IPropertyMapper<IScrollView, ScrollViewHandler> ControlsScrollViewMapper =
new PropertyMapper<ScrollView, ScrollViewHandler>(ScrollViewHandler.Mapper)
{
#if IOS
[PlatformConfiguration.iOSSpecific.ScrollView.ShouldDelayContentTouchesProperty.PropertyName] = MapShouldDelayContentTouches,
#endif
};

internal static new void RemapForControls()
{
// Adjust the mappings to preserve Controls.ScrollView legacy behaviors
ScrollViewHandler.Mapper = ControlsScrollViewMapper;
}
}
}
10 changes: 10 additions & 0 deletions src/Controls/src/Core/HandlerImpl/ScrollView/ScrollView.iOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Microsoft.Maui.Controls
{
public partial class ScrollView
{
public static void MapShouldDelayContentTouches(ScrollViewHandler handler, ScrollView scrollView)
{
Platform.ScrollViewExtensions.UpdateShouldDelayContentTouches(handler.PlatformView, scrollView);
}
}
}
2 changes: 2 additions & 0 deletions src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public partial class SearchBar
{
#if WINDOWS
[PlatformConfiguration.WindowsSpecific.SearchBar.IsSpellCheckEnabledProperty.PropertyName] = MapIsSpellCheckEnabled,
#elif IOS
[PlatformConfiguration.iOSSpecific.SearchBar.SearchBarStyleProperty.PropertyName] = MapSearchBarStyle,
#endif
[nameof(Text)] = MapText,
[nameof(TextTransform)] = MapText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
{
public partial class SearchBar
{
public static void MapText(SearchBarHandler handler, SearchBar searchBar)
public static void MapSearchBarStyle(SearchBarHandler handler, SearchBar searchBar)
{
Platform.SearchBarExtensions.UpdateSearchBarStyle(handler.PlatformView, searchBar);
}

public static void MapText(SearchBarHandler handler, SearchBar searchBar)
{
Platform.SearchBarExtensions.UpdateText(handler.PlatformView, searchBar);
}
Expand Down
8 changes: 0 additions & 8 deletions src/Controls/src/Core/HandlerImpl/TimePicker.Impl.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Microsoft.Maui.Controls
{
public partial class TimePicker
{

}
}
Loading