[Material] + [Android, iOS] Refactored and fixed lots of button layout issues (#4967)
authorMatthew Leibowitz <mattleibow@live.com>
Wed, 30 Jan 2019 23:44:23 +0000 (01:44 +0200)
committerShane Neuville <shane94@hotmail.com>
Wed, 30 Jan 2019 23:44:23 +0000 (16:44 -0700)
commit0dd61b71ec33c566ddcdf0fcb3aa2ec177b67399
treed92c00a36e6075f1e1060588df97e0629558c519
parentb4d12ab5f77103c4494e9655f45f3de170cd06ee
[Material] + [Android, iOS] Refactored and fixed lots of button layout issues (#4967)

* [Android] Refactored and fixed lots of button layout issues
 - All text, image and content layout logic has been extracted into a separate manager
 - Fixed the issue buttons with just an image changing size
 - Fixed a few button padding issues (still needs another look)
 - Fixed the issue with the content layout changes not updating the actual button layout
 - Fixed image positioning for all (not legacy) buttons
 - Material button no longer uses material image layout as it overrides the custom positioning
 - Fixed a few other issues where properties don't change the native button, or layouts break the positioning of the image

* [Button] Fixed a whole bunch of issues
 - added a platform specific "BorderAdjustsPadding" to Android and iOS to prevent border overlap
 - added a new gallery with all sorts of buttons
 - improvements to the Android button layout manager
 - fixed to the Android button measure/layout process

* [Android] [Button] The preservation of default padding is now a flag

* [iOS] [Button] Extracted all the layout logic for the classic button
 - yet to update Material button to use this
 - fixed a few issues with the iOS layout
    - content layout changes were not updating the control
    - top/bottom did not respect spacing
    - the native control trimmed text in the getter, so use the value from the element

* Removing the platform specifics as they were the wrong property
 - the property is part of the renderer implementation
 - Material button on iOS still needs implementing

* Updated the material button to use the layout manager
 - the iOS layout logic needs some more investigation

* remove old comments

* A fix for when there is no text and some backwards compatibility

* Added a more realistic set of values

* Restrict the material button border to 1px. See #4951.

* Fixed that issue with the buttons and the padding...
 - Removed the inset so that layout is accurate
 - set the padding to 8dp to match that of iOS and Material
 - set the minimum height to 36 according to Material (it was 48dp, with 12dp total inset, and, 48-12=36)

* Update Xamarin.Forms.Core/Button.cs

Co-Authored-By: mattleibow <mattleibow@live.com>
* Don't add members to the public type

* [Material] Added a button to change text size in the demo page

* appcompat regression fixes

* move state checks around

* fix bad merge

* adding delay to ui tests
27 files changed:
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39821.cs
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41415.cs
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2482.cs
Xamarin.Forms.Controls/CoreGallery.cs
Xamarin.Forms.Controls/GalleryPages/ButtonBorderBackgroundGalleryPage.xaml [new file with mode: 0644]
Xamarin.Forms.Controls/GalleryPages/ButtonBorderBackgroundGalleryPage.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Controls/GalleryPages/ButtonLayoutGalleryPage.xaml [new file with mode: 0644]
Xamarin.Forms.Controls/GalleryPages/ButtonLayoutGalleryPage.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Controls/ThicknessConverter.cs [new file with mode: 0644]
Xamarin.Forms.Core/Button.cs
Xamarin.Forms.Core/Thickness.cs
Xamarin.Forms.Core/VisualElement.cs
Xamarin.Forms.Material.iOS/MaterialButtonRenderer.cs
Xamarin.Forms.Platform.Android/AppCompat/ButtonRenderer.cs
Xamarin.Forms.Platform.Android/ButtonElementManager.cs [moved from Xamarin.Forms.Platform.Android/FastRenderers/ButtonElementManager.cs with 66% similarity]
Xamarin.Forms.Platform.Android/ButtonLayoutManager.cs [new file with mode: 0644]
Xamarin.Forms.Platform.Android/Extensions.cs
Xamarin.Forms.Platform.Android/FastRenderers/ButtonRenderer.cs
Xamarin.Forms.Platform.Android/IButtonLayoutRenderer.cs [new file with mode: 0644]
Xamarin.Forms.Platform.Android/Material/MaterialButtonRenderer.cs
Xamarin.Forms.Platform.Android/Resources/values/styles.xml
Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj
Xamarin.Forms.Platform.iOS/Extensions/Extensions.cs
Xamarin.Forms.Platform.iOS/Renderers/ButtonLayoutManager.cs [new file with mode: 0644]
Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
Xamarin.Forms.Platform.iOS/Renderers/IButtonLayoutRenderer.cs [new file with mode: 0644]
Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj