From 74023d273fee07295b3a3d0be222fe9dd0035602 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:39:47 +0500 Subject: [PATCH 01/11] switch to .net6 --- .../AdvancedFluentLayoutExtensions.cs | 176 +++++++++--------- .../Cirrious.FluentLayouts.Touch.csproj | 35 +--- .../Properties/AssemblyInfo.cs | 46 ----- QuickLayout.Core/QuickLayout.Core.csproj | 7 +- QuickLayout.Touch/Properties/AssemblyInfo.cs | 36 ---- QuickLayout.Touch/QuickLayout.Touch.csproj | 68 +------ 6 files changed, 103 insertions(+), 265 deletions(-) delete mode 100644 Cirrious.FluentLayout/Properties/AssemblyInfo.cs delete mode 100644 QuickLayout.Touch/Properties/AssemblyInfo.cs diff --git a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs index 5981529..790c7c6 100644 --- a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs @@ -5,100 +5,96 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using System; -using System.Collections.Generic; -using System.Linq; -using UIKit; using Cirrious.FluentLayouts.Touch.Extensions; namespace Cirrious.FluentLayouts.Touch { - public static class AdvancedFluentLayoutExtensions - { - const float DefaultMargin = 0; - const float DefaultScale = 1; + public static class AdvancedFluentLayoutExtensions + { + const float DefaultMargin = 0; + const float DefaultScale = 1; - public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtTopOf(parentView, margin); + public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtTopOf(parentView, margin); - public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => + public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => view.Left().EqualTo().LeftOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtLeftOf(parentView, margin); + public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtLeftOf(parentView, margin); - public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => + public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => view.Right().EqualTo().RightOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtRightOf(parentView, margin); + public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtRightOf(parentView, margin); - public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => + public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => view.Bottom().EqualTo().BottomOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtBottomOf(parentView, margin); + public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtBottomOf(parentView, margin); - public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => + public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => view.Top().EqualTo().BottomOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => + public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => view.Bottom().EqualTo().TopOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); + public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); - public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); + public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); - public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); + public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); - public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); + public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); - public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); + public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); - public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); + public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); - public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); + public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); - public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); + public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); - public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); + public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); - public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => + public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => view.Width().EqualTo().WidthOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); + public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); - public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => + public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => view.Height().EqualTo().HeightOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => + public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => view.Left().EqualTo().RightOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => + public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => view.Right().EqualTo().LeftOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); public static FluentLayout ToLeftMargin(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingMarginOf(previous); @@ -111,32 +107,32 @@ public static FluentLayout ToTopMargin(this UIView view, UIView previous) => public static FluentLayout ToBottomMargin(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomMarginOf(previous); - - public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); - - public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); - - public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); - - public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); - - public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) - { + + public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); + + public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); + + public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); + + public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); + + public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) + { var marginValue = margin.GetValueOrDefault(DefaultMargin); - return new List - { + return new List + { view.AtLeftOf(parent, marginValue).WithIdentifier("Left"), - view.AtRightOf(parent, marginValue).WithIdentifier("Right") - }; - } + view.AtRightOf(parent, marginValue).WithIdentifier("Right") + }; + } - public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) - { + public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) + { var marginValue = margin.GetValueOrDefault(DefaultMargin); return new List @@ -144,12 +140,12 @@ public static IEnumerable FullHeightOf(this UIView view, UIView pa view.AtTopOf(parent, marginValue).WithIdentifier("Top"), view.AtBottomOf(parent, marginValue).WithIdentifier("Bottom") }; - } + } - public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => + public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => FullSizeOf(view, parent, new Margins((float)margin.GetValueOrDefault(DefaultMargin))); - public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) + public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) { margins = margins ?? new Margins(); @@ -162,12 +158,12 @@ public static IEnumerable FullSizeOf(this UIView view, UIView pare }; } - public static FluentLayout GetLayoutById(this IEnumerable layouts, string identifier) => + public static FluentLayout GetLayoutById(this IEnumerable layouts, string identifier) => layouts.FirstOrDefault(x => x.Identifier.Equals(identifier)); - public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => + public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => AdvancedVerticalStackPanelConstraints(parentView, margins, views: views); - + /// /// Vertical stack panel constraints with support for children independent left, right and top margins /// and a multiplier factor for all margins applied. The multiplier can be useful when dealing with iPad screens. @@ -181,12 +177,12 @@ public static IEnumerable VerticalStackPanelConstraints(this UIVie /// ); /// public static IEnumerable AdvancedVerticalStackPanelConstraints(this UIView parentView, - Margins margins, - float[] childrenLeftMargins = null, - float[] childrenTopMargins = null, - float[] childrenRightMargins = null, - float marginMultiplier = 1, - params UIView[] views) + Margins margins, + float[] childrenLeftMargins = null, + float[] childrenTopMargins = null, + float[] childrenRightMargins = null, + float marginMultiplier = 1, + params UIView[] views) { string previousIdentifierPrefix = null; margins = margins ?? new Margins(); @@ -223,12 +219,12 @@ public static IEnumerable AdvancedVerticalStackPanelConstraints(th ? view.Top() .EqualTo() .TopOf(parentView) - .Plus(Math.Max(margins.Top, childTopMargin)*marginMultiplier) + .Plus(Math.Max(margins.Top, childTopMargin) * marginMultiplier) .WithIdentifier(viewIdentifierPrefix + "Top") : view.Top() .EqualTo() .BottomOf(views[i - 1]) - .Plus(Math.Max(margins.VSpacing, childTopMargin)*marginMultiplier) + .Plus(Math.Max(margins.VSpacing, childTopMargin) * marginMultiplier) .WithIdentifier(viewIdentifierPrefix + "Top")); previousIdentifierPrefix = viewIdentifierPrefix; @@ -243,5 +239,5 @@ public static IEnumerable AdvancedVerticalStackPanelConstraints(th return layouts; } - } + } } diff --git a/Cirrious.FluentLayout/Cirrious.FluentLayouts.Touch.csproj b/Cirrious.FluentLayout/Cirrious.FluentLayouts.Touch.csproj index 3dba747..339242d 100644 --- a/Cirrious.FluentLayout/Cirrious.FluentLayouts.Touch.csproj +++ b/Cirrious.FluentLayout/Cirrious.FluentLayouts.Touch.csproj @@ -1,5 +1,11 @@ - - + + + net6.0-ios + Exe + enable + true + 10.0 + Debug AnyCPU @@ -9,8 +15,6 @@ Cirrious.FluentLayouts.Touch Resources Cirrious.FluentLayouts.Touch - Xamarin.iOS - v1.0 true @@ -33,27 +37,4 @@ false None - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Cirrious.FluentLayout/Properties/AssemblyInfo.cs b/Cirrious.FluentLayout/Properties/AssemblyInfo.cs deleted file mode 100644 index b56a76e..0000000 --- a/Cirrious.FluentLayout/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,46 +0,0 @@ -// AssemblyInfo.cs -// (c) Copyright Cirrious Ltd. http://www.cirrious.com -// MvvmCross is licensed using Microsoft Public License (Ms-PL) -// Contributions and inspirations noted in readme.md and license.txt -// -// Project Lead - Stuart Lodge, @slodge, me@slodge.com - -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Cirrious.FluentLayout")] -[assembly: AssemblyDescription("Easy API for using AutoLayout in iOS")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Cirrious.FluentLayout")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("deb03d05-a92d-4319-b09d-3f890065a6ce")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("2.6.0.0")] -[assembly: AssemblyFileVersion("2.6.0.0")] \ No newline at end of file diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index dca1e5c..b02e4e0 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,9 +1,6 @@ - - - + - netstandard2.0 - 7.1 + net6 diff --git a/QuickLayout.Touch/Properties/AssemblyInfo.cs b/QuickLayout.Touch/Properties/AssemblyInfo.cs deleted file mode 100644 index 6c7c12e..0000000 --- a/QuickLayout.Touch/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("QuickLayout.Touch")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("QuickLayout.Touch")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3a84593a-7477-4a43-a4d3-35092b1a79a6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/QuickLayout.Touch/QuickLayout.Touch.csproj b/QuickLayout.Touch/QuickLayout.Touch.csproj index e8ffcaf..377417a 100644 --- a/QuickLayout.Touch/QuickLayout.Touch.csproj +++ b/QuickLayout.Touch/QuickLayout.Touch.csproj @@ -1,16 +1,10 @@ - - + - Debug - iPhoneSimulator - {5739EE87-45C0-496A-8388-A09CDB906501} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + net6.0-ios Exe - QuickLayout.Touch - Resources - QuickLayoutTouch - Xamarin.iOS - v1.0 + enable + true + 10.0 true @@ -84,35 +78,6 @@ ARMv7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6.4.0 @@ -125,31 +90,12 @@ {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} Cirrious.FluentLayouts.Touch + false + false {849AFB57-994A-42D9-A786-EF34FC951CDE} QuickLayout.Core - - - - - - false - - - false - - - false - - - false - - - false - - - \ No newline at end of file From ba064670f9ead4d804aa229eda5d98c5b948e113 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:40:05 +0500 Subject: [PATCH 02/11] code cleanup --- .../AdvancedFluentLayoutExtensions.cs | 392 +++++++++--------- .../Extensions/ArrayExtensions.cs | 36 +- Cirrious.FluentLayout/FluentLayout.cs | 199 +++++---- .../FluentLayoutExtensions.cs | 26 +- Cirrious.FluentLayout/Margins.cs | 2 +- Cirrious.FluentLayout/NfloatExtensions.cs | 10 +- .../RowSet-WorkInProgress/RowSet.cs | 7 +- .../UIViewAndLayoutAttribute.cs | 9 +- .../Services/CalculationService.cs | 2 +- .../AdvancedVerticalStackViewModel.cs | 6 +- .../ViewModels/BaseDetailsViewModel.cs | 24 +- .../ViewModels/DetailsViewModel.cs | 4 +- .../ViewModels/DirectionFormViewModel.cs | 8 +- QuickLayout.Core/ViewModels/FirstViewModel.cs | 18 +- .../ViewModels/FullSizeViewModel.cs | 8 +- .../ViewModels/SearchViewModel.cs | 4 +- .../ViewModels/UpdateConstraintsViewModel.cs | 44 +- QuickLayout.Touch/AppDelegate.cs | 3 - QuickLayout.Touch/LinkerPleaseInclude.cs | 8 +- QuickLayout.Touch/Main.cs | 4 +- .../Views/AdvancedVerticalStackView.cs | 148 ++++--- QuickLayout.Touch/Views/DetailsView.cs | 30 +- QuickLayout.Touch/Views/DirectionFormView.cs | 91 ++-- QuickLayout.Touch/Views/FirstView.cs | 84 ++-- QuickLayout.Touch/Views/FormGridView.cs | 36 +- QuickLayout.Touch/Views/FormView.cs | 16 +- QuickLayout.Touch/Views/FullSizeView.cs | 105 +++-- QuickLayout.Touch/Views/RightToLeftView.cs | 16 +- QuickLayout.Touch/Views/SearchView.cs | 4 - QuickLayout.Touch/Views/TipView.cs | 12 +- .../Views/ToCenterConstraintsView.cs | 5 +- .../Views/UpdateConstraintsView.cs | 107 +++-- .../Views/ViewWithSafeAreaView.cs | 10 +- 33 files changed, 699 insertions(+), 779 deletions(-) diff --git a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs index 790c7c6..503b5fb 100644 --- a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs @@ -9,235 +9,235 @@ namespace Cirrious.FluentLayouts.Touch { - public static class AdvancedFluentLayoutExtensions - { - const float DefaultMargin = 0; - const float DefaultScale = 1; + public static class AdvancedFluentLayoutExtensions + { + const float DefaultMargin = 0; + const float DefaultScale = 1; - public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtTopOf(parentView, margin); + public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtTopOf(parentView, margin); - public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Left().EqualTo().LeftOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Left().EqualTo().LeftOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtLeftOf(parentView, margin); + public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtLeftOf(parentView, margin); - public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Right().EqualTo().RightOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Right().EqualTo().RightOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtRightOf(parentView, margin); + public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtRightOf(parentView, margin); - public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Bottom().EqualTo().BottomOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Bottom().EqualTo().BottomOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtBottomOf(parentView, margin); + public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtBottomOf(parentView, margin); - public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => - view.Top().EqualTo().BottomOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => + view.Top().EqualTo().BottomOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => - view.Bottom().EqualTo().TopOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => + view.Bottom().EqualTo().TopOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); + public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); - public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); + public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); - public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); + public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); - public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); + public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); - public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); + public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); - public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); + public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); - public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); + public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); - public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); + public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); - public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); + public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); - public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => - view.Width().EqualTo().WidthOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); + public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => + view.Width().EqualTo().WidthOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); + public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); - public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => - view.Height().EqualTo().HeightOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); + public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => + view.Height().EqualTo().HeightOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Left().EqualTo().RightOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Left().EqualTo().RightOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Right().EqualTo().LeftOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Right().EqualTo().LeftOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeftMargin(this UIView view, UIView previous) => - view.Leading().EqualTo().LeadingMarginOf(previous); + public static FluentLayout ToLeftMargin(this UIView view, UIView previous) => + view.Leading().EqualTo().LeadingMarginOf(previous); - public static FluentLayout ToRightMargin(this UIView view, UIView previous) => - view.Trailing().EqualTo().TrailingMarginOf(previous); + public static FluentLayout ToRightMargin(this UIView view, UIView previous) => + view.Trailing().EqualTo().TrailingMarginOf(previous); - public static FluentLayout ToTopMargin(this UIView view, UIView previous) => - view.Top().EqualTo().TopMarginOf(previous); + public static FluentLayout ToTopMargin(this UIView view, UIView previous) => + view.Top().EqualTo().TopMarginOf(previous); - public static FluentLayout ToBottomMargin(this UIView view, UIView previous) => - view.Bottom().EqualTo().BottomMarginOf(previous); + public static FluentLayout ToBottomMargin(this UIView view, UIView previous) => + view.Bottom().EqualTo().BottomMarginOf(previous); - public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); - - public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); + public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); + + public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); - public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); + public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); - public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); - - public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) - { - var marginValue = margin.GetValueOrDefault(DefaultMargin); - - return new List - { - view.AtLeftOf(parent, marginValue).WithIdentifier("Left"), - view.AtRightOf(parent, marginValue).WithIdentifier("Right") - }; - } - - public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) - { - var marginValue = margin.GetValueOrDefault(DefaultMargin); - - return new List - { - view.AtTopOf(parent, marginValue).WithIdentifier("Top"), - view.AtBottomOf(parent, marginValue).WithIdentifier("Bottom") - }; - } - - public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => - FullSizeOf(view, parent, new Margins((float)margin.GetValueOrDefault(DefaultMargin))); - - public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) - { - margins = margins ?? new Margins(); - - return new List - { - view.AtTopOf(parent, margins.Top).WithIdentifier("Top"), - view.AtBottomOf(parent, margins.Bottom).WithIdentifier("Bottom"), - view.AtLeftOf(parent, margins.Left).WithIdentifier("Left"), - view.AtRightOf(parent, margins.Right).WithIdentifier("Right") - }; - } - - public static FluentLayout GetLayoutById(this IEnumerable layouts, string identifier) => - layouts.FirstOrDefault(x => x.Identifier.Equals(identifier)); - - public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => - AdvancedVerticalStackPanelConstraints(parentView, margins, views: views); - - /// - /// Vertical stack panel constraints with support for children independent left, right and top margins - /// and a multiplier factor for all margins applied. The multiplier can be useful when dealing with iPad screens. - /// Example: - /// - /// scrollView.AddConstraints(scrollView.AdvancedVerticalStackPanelConstraints(null, - /// childrenLeftMargins: new float[] { 15, 0, 15, 0, 0, 15 }, - /// childrenTopMargins: new float[] { 15, 5, 15, 5, 8, 15, 22, 8, 8, 28, 28 }, - /// marginMultiplier: 2f, - /// views: scrollView.Subviews) - /// ); - /// - public static IEnumerable AdvancedVerticalStackPanelConstraints(this UIView parentView, - Margins margins, - float[] childrenLeftMargins = null, - float[] childrenTopMargins = null, - float[] childrenRightMargins = null, - float marginMultiplier = 1, - params UIView[] views) - { - string previousIdentifierPrefix = null; - margins = margins ?? new Margins(); - var layouts = new List(); - - var count = views.Length; - for (var i = 0; i < count; i++) - { - var view = views[i]; - var viewIdentifierPrefix = $"{parentView.AccessibilityIdentifier ?? "VerticalStackPanel"}-{view.AccessibilityIdentifier ?? i.ToString()}-"; - - float childLeftMargin; - childrenLeftMargins.TryGetElement(i, out childLeftMargin); - var marginLeft = Math.Max(margins.Left, childLeftMargin) * marginMultiplier; - layouts.Add(view.Left() - .EqualTo() - .LeftOf(parentView) - .Plus(marginLeft) - .WithIdentifier(viewIdentifierPrefix + "Left")); - - float childRightMargin; - childrenRightMargins.TryGetElement(i, out childRightMargin); - var marginRight = Math.Max(margins.Right, childRightMargin) * marginMultiplier; - layouts.Add(view.Width() - .EqualTo() - .WidthOf(parentView) - .Minus(marginRight + marginLeft) - .WithIdentifier(viewIdentifierPrefix + "Width")); - - float childTopMargin; - childrenTopMargins.TryGetElement(i, out childTopMargin); - - layouts.Add(i == 0 - ? view.Top() - .EqualTo() - .TopOf(parentView) - .Plus(Math.Max(margins.Top, childTopMargin) * marginMultiplier) - .WithIdentifier(viewIdentifierPrefix + "Top") - : view.Top() - .EqualTo() - .BottomOf(views[i - 1]) - .Plus(Math.Max(margins.VSpacing, childTopMargin) * marginMultiplier) - .WithIdentifier(viewIdentifierPrefix + "Top")); - - previousIdentifierPrefix = viewIdentifierPrefix; - } - - if (parentView is UIScrollView) - layouts.Add(views[views.Length - 1].Bottom() - .EqualTo() - .BottomOf(parentView) - .Minus(margins.Bottom * marginMultiplier) - .WithIdentifier(previousIdentifierPrefix + "Bottom")); - - return layouts; - } - } + public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); + + public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) + { + var marginValue = margin.GetValueOrDefault(DefaultMargin); + + return new List + { + view.AtLeftOf(parent, marginValue).WithIdentifier("Left"), + view.AtRightOf(parent, marginValue).WithIdentifier("Right") + }; + } + + public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) + { + var marginValue = margin.GetValueOrDefault(DefaultMargin); + + return new List + { + view.AtTopOf(parent, marginValue).WithIdentifier("Top"), + view.AtBottomOf(parent, marginValue).WithIdentifier("Bottom") + }; + } + + public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => + FullSizeOf(view, parent, new Margins((float)margin.GetValueOrDefault(DefaultMargin))); + + public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) + { + margins = margins ?? new Margins(); + + return new List + { + view.AtTopOf(parent, margins.Top).WithIdentifier("Top"), + view.AtBottomOf(parent, margins.Bottom).WithIdentifier("Bottom"), + view.AtLeftOf(parent, margins.Left).WithIdentifier("Left"), + view.AtRightOf(parent, margins.Right).WithIdentifier("Right") + }; + } + + public static FluentLayout GetLayoutById(this IEnumerable layouts, string identifier) => + layouts.FirstOrDefault(x => x.Identifier.Equals(identifier)); + + public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => + AdvancedVerticalStackPanelConstraints(parentView, margins, views: views); + + /// + /// Vertical stack panel constraints with support for children independent left, right and top margins + /// and a multiplier factor for all margins applied. The multiplier can be useful when dealing with iPad screens. + /// Example: + /// + /// scrollView.AddConstraints(scrollView.AdvancedVerticalStackPanelConstraints(null, + /// childrenLeftMargins: new float[] { 15, 0, 15, 0, 0, 15 }, + /// childrenTopMargins: new float[] { 15, 5, 15, 5, 8, 15, 22, 8, 8, 28, 28 }, + /// marginMultiplier: 2f, + /// views: scrollView.Subviews) + /// ); + /// + public static IEnumerable AdvancedVerticalStackPanelConstraints(this UIView parentView, + Margins margins, + float[] childrenLeftMargins = null, + float[] childrenTopMargins = null, + float[] childrenRightMargins = null, + float marginMultiplier = 1, + params UIView[] views) + { + string previousIdentifierPrefix = null; + margins = margins ?? new Margins(); + var layouts = new List(); + + var count = views.Length; + for (var i = 0; i < count; i++) + { + var view = views[i]; + var viewIdentifierPrefix = $"{parentView.AccessibilityIdentifier ?? "VerticalStackPanel"}-{view.AccessibilityIdentifier ?? i.ToString()}-"; + + float childLeftMargin; + childrenLeftMargins.TryGetElement(i, out childLeftMargin); + var marginLeft = Math.Max(margins.Left, childLeftMargin) * marginMultiplier; + layouts.Add(view.Left() + .EqualTo() + .LeftOf(parentView) + .Plus(marginLeft) + .WithIdentifier(viewIdentifierPrefix + "Left")); + + float childRightMargin; + childrenRightMargins.TryGetElement(i, out childRightMargin); + var marginRight = Math.Max(margins.Right, childRightMargin) * marginMultiplier; + layouts.Add(view.Width() + .EqualTo() + .WidthOf(parentView) + .Minus(marginRight + marginLeft) + .WithIdentifier(viewIdentifierPrefix + "Width")); + + float childTopMargin; + childrenTopMargins.TryGetElement(i, out childTopMargin); + + layouts.Add(i == 0 + ? view.Top() + .EqualTo() + .TopOf(parentView) + .Plus(Math.Max(margins.Top, childTopMargin) * marginMultiplier) + .WithIdentifier(viewIdentifierPrefix + "Top") + : view.Top() + .EqualTo() + .BottomOf(views[i - 1]) + .Plus(Math.Max(margins.VSpacing, childTopMargin) * marginMultiplier) + .WithIdentifier(viewIdentifierPrefix + "Top")); + + previousIdentifierPrefix = viewIdentifierPrefix; + } + + if (parentView is UIScrollView) + layouts.Add(views[views.Length - 1].Bottom() + .EqualTo() + .BottomOf(parentView) + .Minus(margins.Bottom * marginMultiplier) + .WithIdentifier(previousIdentifierPrefix + "Bottom")); + + return layouts; + } + } } diff --git a/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs b/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs index 8183932..114606c 100644 --- a/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs +++ b/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs @@ -1,26 +1,26 @@ namespace Cirrious.FluentLayouts.Touch.Extensions { - internal static class ArrayExtensions - { - public static bool TryGetElement(this T[] array, int index, out T element) - { - if (array == null) - { - element = default(T); + internal static class ArrayExtensions + { + public static bool TryGetElement(this T[] array, int index, out T element) + { + if (array == null) + { + element = default(T); - return false; - } + return false; + } - if (index < array.Length) - { - element = array[index]; + if (index < array.Length) + { + element = array[index]; - return true; - } + return true; + } - element = default(T); + element = default(T); - return false; - } - } + return false; + } + } } \ No newline at end of file diff --git a/Cirrious.FluentLayout/FluentLayout.cs b/Cirrious.FluentLayout/FluentLayout.cs index 4b3d858..4bbc72f 100644 --- a/Cirrious.FluentLayout/FluentLayout.cs +++ b/Cirrious.FluentLayout/FluentLayout.cs @@ -5,11 +5,6 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using System; -using System.Collections.Generic; -using UIKit; -using Foundation; - namespace Cirrious.FluentLayouts.Touch { public class FluentLayout @@ -21,110 +16,110 @@ public FluentLayout( NSObject secondItem, NSLayoutAttribute secondAttribute) { - Constraint = new Lazy(CreateConstraint); + Constraint = new Lazy(CreateConstraint); View = view; Attribute = attribute; Relation = relation; SecondItem = secondItem; SecondAttribute = secondAttribute; - Priority = (float) UILayoutPriority.Required; + Priority = (float)UILayoutPriority.Required; } public FluentLayout(UIView view, NSLayoutAttribute attribute, NSLayoutRelation relation, - nfloat constant = default(nfloat)) + nfloat constant = default(nfloat)) { - Constraint = new Lazy(CreateConstraint); + Constraint = new Lazy(CreateConstraint); View = view; Attribute = attribute; Relation = relation; Constant = constant; - Priority = (float) UILayoutPriority.Required; + Priority = (float)UILayoutPriority.Required; } public UIView View { get; } - public nfloat Multiplier { get; private set; } = 1f; - - private nfloat _constant; - public nfloat Constant - { - get { return _constant; } - set - { - _constant = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Constant = _constant; - } - } - - private float _priority; - public float Priority - { - get { return _priority; } - set - { - _priority = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Priority = _priority; - } - } - - private bool _active = true; - public bool Active - { - get { return _active; } - set - { - _active = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Active = _active; - } - } - - private string _identifier; - public string Identifier - { - get { return _identifier; } - set - { - _identifier = value; - - if (Constraint.IsValueCreated) - Constraint.Value.SetIdentifier(_identifier); - } - } + public nfloat Multiplier { get; private set; } = 1f; + + private nfloat _constant; + public nfloat Constant + { + get { return _constant; } + set + { + _constant = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Constant = _constant; + } + } + + private float _priority; + public float Priority + { + get { return _priority; } + set + { + _priority = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Priority = _priority; + } + } + + private bool _active = true; + public bool Active + { + get { return _active; } + set + { + _active = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Active = _active; + } + } + + private string _identifier; + public string Identifier + { + get { return _identifier; } + set + { + _identifier = value; + + if (Constraint.IsValueCreated) + Constraint.Value.SetIdentifier(_identifier); + } + } public NSLayoutAttribute Attribute { get; private set; } public NSLayoutRelation Relation { get; private set; } public NSObject SecondItem { get; private set; } public NSLayoutAttribute SecondAttribute { get; private set; } - internal Lazy Constraint { get; } + internal Lazy Constraint { get; } - private NSLayoutConstraint CreateConstraint() - { - var constraint = NSLayoutConstraint.Create( - View, - Attribute, - Relation, - SecondItem, - SecondAttribute, - Multiplier, - Constant); - constraint.Priority = Priority; - - if (!string.IsNullOrWhiteSpace(Identifier)) - constraint.SetIdentifier(Identifier); - - return constraint; - } + private NSLayoutConstraint CreateConstraint() + { + var constraint = NSLayoutConstraint.Create( + View, + Attribute, + Relation, + SecondItem, + SecondAttribute, + Multiplier, + Constant); + constraint.Priority = Priority; + + if (!string.IsNullOrWhiteSpace(Identifier)) + constraint.SetIdentifier(Identifier); + + return constraint; + } - public FluentLayout Plus(nfloat constant) + public FluentLayout Plus(nfloat constant) { Constant += constant; return this; @@ -150,21 +145,21 @@ public FluentLayout SetPriority(float priority) public FluentLayout SetPriority(UILayoutPriority priority) { - Priority = (float) priority; + Priority = (float)priority; return this; } - public FluentLayout SetActive(bool active) - { - Active = active; - return this; - } + public FluentLayout SetActive(bool active) + { + Active = active; + return this; + } - public FluentLayout WithIdentifier(string identifier) - { - Identifier = identifier; - return this; - } + public FluentLayout WithIdentifier(string identifier) + { + Identifier = identifier; + return this; + } public FluentLayout LeftOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Left); @@ -188,13 +183,13 @@ public FluentLayout WithIdentifier(string identifier) public FluentLayout WidthOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Width); - public FluentLayout TrailingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TrailingMargin); + public FluentLayout TrailingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TrailingMargin); - public FluentLayout LeadingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.LeadingMargin); + public FluentLayout LeadingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.LeadingMargin); - public FluentLayout TopMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TopMargin); + public FluentLayout TopMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TopMargin); - public FluentLayout BottomMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.BottomMargin); + public FluentLayout BottomMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.BottomMargin); private FluentLayout SetSecondItem(NSObject view2, NSLayoutAttribute attribute2) { @@ -210,10 +205,10 @@ private void ThrowIfSecondItemAlreadySet() throw new Exception("You cannot set the second item in a layout relation more than once"); } - [Obsolete("This method will be removed in future versions, please let us know if you still need it!")] - public IEnumerable ToLayoutConstraints() - { - yield return Constraint.Value; - } + [Obsolete("This method will be removed in future versions, please let us know if you still need it!")] + public IEnumerable ToLayoutConstraints() + { + yield return Constraint.Value; + } } } \ No newline at end of file diff --git a/Cirrious.FluentLayout/FluentLayoutExtensions.cs b/Cirrious.FluentLayout/FluentLayoutExtensions.cs index 6c7f3b4..46f8817 100644 --- a/Cirrious.FluentLayout/FluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/FluentLayoutExtensions.cs @@ -5,10 +5,6 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using System.Collections.Generic; -using System.Linq; -using UIKit; - namespace Cirrious.FluentLayouts.Touch { public static class FluentLayoutExtensions @@ -25,7 +21,7 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute Right(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Right); - public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); + public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); public static UIViewAndLayoutAttribute Bottom(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Bottom); @@ -45,26 +41,26 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute WithLayoutAttribute(this UIView view, NSLayoutAttribute attribute) => new UIViewAndLayoutAttribute(view, attribute); - public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); + public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); - public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); + public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); - public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); + public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); - public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); + public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); - public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); + public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); public static void AddConstraints(this UIView view, IEnumerable fluentLayouts) => - view.AddConstraints(fluentLayouts + view.AddConstraints(fluentLayouts .Where(fluent => fluent != null) - .Select(fluent => fluent.Constraint.Value) + .Select(fluent => fluent.Constraint.Value) .ToArray()); - public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); + public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); - public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => - view.RemoveConstraints(fluentLayouts + public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => + view.RemoveConstraints(fluentLayouts .Where(fluent => fluent != null) .Select(fluent => fluent.Constraint.Value) .ToArray()); diff --git a/Cirrious.FluentLayout/Margins.cs b/Cirrious.FluentLayout/Margins.cs index ce2d60e..5779831 100644 --- a/Cirrious.FluentLayout/Margins.cs +++ b/Cirrious.FluentLayout/Margins.cs @@ -40,7 +40,7 @@ public Margins(float allHorizontal, float allVertical) HSpacing = allHorizontal; } - public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) + public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) { Top = top; Bottom = bottom; diff --git a/Cirrious.FluentLayout/NfloatExtensions.cs b/Cirrious.FluentLayout/NfloatExtensions.cs index 5ac6617..fa98f5d 100644 --- a/Cirrious.FluentLayout/NfloatExtensions.cs +++ b/Cirrious.FluentLayout/NfloatExtensions.cs @@ -1,10 +1,10 @@ namespace System { - internal static class NfloatExtensions - { - public static nfloat GetValueOrDefault(this nfloat? value) => value.GetValueOrDefault(0); + internal static class NfloatExtensions + { + public static nfloat GetValueOrDefault(this nfloat? value) => value.GetValueOrDefault(0); - public static nfloat GetValueOrDefault(this nfloat? value, nfloat defaultValue) => value ?? defaultValue; - } + public static nfloat GetValueOrDefault(this nfloat? value, nfloat defaultValue) => value ?? defaultValue; + } } diff --git a/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs b/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs index 3f65675..8cbf816 100644 --- a/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs +++ b/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UIKit; - -namespace Cirrious.FluentLayouts.Touch.RowSet +namespace Cirrious.FluentLayouts.Touch.RowSet { public class RowSetTemplate { diff --git a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs index 308bcc0..c6a041a 100644 --- a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs +++ b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs @@ -5,9 +5,6 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using UIKit; -using System; - namespace Cirrious.FluentLayouts.Touch { public class UIViewAndLayoutAttribute @@ -21,13 +18,13 @@ public UIViewAndLayoutAttribute(UIView view, NSLayoutAttribute attribute) public UIView View { get; } public NSLayoutAttribute Attribute { get; } - public FluentLayout EqualTo(nfloat constant = default(nfloat)) => + public FluentLayout EqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.Equal, constant); - public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.GreaterThanOrEqual, constant); - public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.LessThanOrEqual, constant); } } \ No newline at end of file diff --git a/QuickLayout.Core/Services/CalculationService.cs b/QuickLayout.Core/Services/CalculationService.cs index cdef2d5..c92bede 100644 --- a/QuickLayout.Core/Services/CalculationService.cs +++ b/QuickLayout.Core/Services/CalculationService.cs @@ -2,6 +2,6 @@ { public class CalculationService : ICalculationService { - public double TipAmount(double subTotal, int generosity) => (generosity*subTotal)/100.0; + public double TipAmount(double subTotal, int generosity) => (generosity * subTotal) / 100.0; } } \ No newline at end of file diff --git a/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs b/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs index 0945804..7a43b67 100644 --- a/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs +++ b/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs @@ -1,6 +1,6 @@ namespace QuickLayout.Core.ViewModels { - public class AdvancedVerticalStackViewModel : BaseDetailsViewModel - { - } + public class AdvancedVerticalStackViewModel : BaseDetailsViewModel + { + } } diff --git a/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs b/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs index abfbb56..d30e019 100644 --- a/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs +++ b/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs @@ -2,47 +2,47 @@ namespace QuickLayout.Core.ViewModels { - public abstract class BaseDetailsViewModel + public abstract class BaseDetailsViewModel : MvxViewModel { private string firstName = "Mvvm"; public string FirstName - { + { get { return firstName; } set { firstName = value; RaisePropertyChanged(() => FirstName); } } private string _lastName = "Cross"; - public string LastName - { + public string LastName + { get { return _lastName; } set { _lastName = value; RaisePropertyChanged(() => LastName); } } private string _number = "12"; - public string Number - { + public string Number + { get { return _number; } set { _number = value; RaisePropertyChanged(() => Number); } } private string _street = "Strathmore"; - public string Street - { + public string Street + { get { return _street; } set { _street = value; RaisePropertyChanged(() => Street); } } private string _town = "Teddington"; - public string Town - { + public string Town + { get { return _town; } set { _town = value; RaisePropertyChanged(() => Town); } } private string _zip = "TW12 2SA"; - public string Zip - { + public string Zip + { get { return _zip; } set { _zip = value; RaisePropertyChanged(() => Zip); } } diff --git a/QuickLayout.Core/ViewModels/DetailsViewModel.cs b/QuickLayout.Core/ViewModels/DetailsViewModel.cs index 8a1c56f..9599a03 100644 --- a/QuickLayout.Core/ViewModels/DetailsViewModel.cs +++ b/QuickLayout.Core/ViewModels/DetailsViewModel.cs @@ -1,7 +1,7 @@ namespace QuickLayout.Core.ViewModels { - public class DetailsViewModel - : BaseDetailsViewModel + public class DetailsViewModel + : BaseDetailsViewModel { } } diff --git a/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs b/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs index 0a1d6d3..63edab0 100644 --- a/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs +++ b/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs @@ -1,7 +1,7 @@ namespace QuickLayout.Core.ViewModels { - public class DirectionFormViewModel - : BaseDetailsViewModel - { - } + public class DirectionFormViewModel + : BaseDetailsViewModel + { + } } \ No newline at end of file diff --git a/QuickLayout.Core/ViewModels/FirstViewModel.cs b/QuickLayout.Core/ViewModels/FirstViewModel.cs index da13501..96db470 100644 --- a/QuickLayout.Core/ViewModels/FirstViewModel.cs +++ b/QuickLayout.Core/ViewModels/FirstViewModel.cs @@ -20,15 +20,15 @@ public FirstViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigat public void GoSearch() => NavigationService.Navigate(); - public void GoTip() => NavigationService.Navigate(); - - public void GoUpdateConstraints() => NavigationService.Navigate(); - - public void GoAdvancedVerticalStack() => NavigationService.Navigate(); - - public void GoFullSize() => NavigationService.Navigate(); - - public void GoDirectionForm() => NavigationService.Navigate(); + public void GoTip() => NavigationService.Navigate(); + + public void GoUpdateConstraints() => NavigationService.Navigate(); + + public void GoAdvancedVerticalStack() => NavigationService.Navigate(); + + public void GoFullSize() => NavigationService.Navigate(); + + public void GoDirectionForm() => NavigationService.Navigate(); public void GoRightToLeft() => NavigationService.Navigate(); diff --git a/QuickLayout.Core/ViewModels/FullSizeViewModel.cs b/QuickLayout.Core/ViewModels/FullSizeViewModel.cs index a670632..8c34b44 100644 --- a/QuickLayout.Core/ViewModels/FullSizeViewModel.cs +++ b/QuickLayout.Core/ViewModels/FullSizeViewModel.cs @@ -2,8 +2,8 @@ namespace QuickLayout.Core.ViewModels { - public class FullSizeViewModel - : MvxViewModel - { - } + public class FullSizeViewModel + : MvxViewModel + { + } } diff --git a/QuickLayout.Core/ViewModels/SearchViewModel.cs b/QuickLayout.Core/ViewModels/SearchViewModel.cs index fdb62ca..37ff9da 100644 --- a/QuickLayout.Core/ViewModels/SearchViewModel.cs +++ b/QuickLayout.Core/ViewModels/SearchViewModel.cs @@ -6,8 +6,8 @@ public class SearchViewModel : MvxViewModel { private string _searchText = "Here"; - public string SearchText - { + public string SearchText + { get { return _searchText; } set { _searchText = value; RaisePropertyChanged(() => SearchText); } } diff --git a/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs b/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs index 1ac9d96..c3af016 100644 --- a/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs +++ b/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs @@ -3,28 +3,28 @@ namespace QuickLayout.Core.ViewModels { public class UpdateConstraintsViewModel : MvxViewModel - { - private bool _active = true; - public bool Active - { - get { return _active; } - set - { - _active = value; - RaisePropertyChanged(() => Active); - } - } + { + private bool _active = true; + public bool Active + { + get { return _active; } + set + { + _active = value; + RaisePropertyChanged(() => Active); + } + } - private float _constant = 200; - public float Constant - { - get { return _constant; } - set - { - _constant = value; - RaisePropertyChanged(() => Constant); - } - } - } + private float _constant = 200; + public float Constant + { + get { return _constant; } + set + { + _constant = value; + RaisePropertyChanged(() => Constant); + } + } + } } diff --git a/QuickLayout.Touch/AppDelegate.cs b/QuickLayout.Touch/AppDelegate.cs index ea9a946..f255bf2 100644 --- a/QuickLayout.Touch/AppDelegate.cs +++ b/QuickLayout.Touch/AppDelegate.cs @@ -1,6 +1,3 @@ -using Foundation; -using MvvmCross.Platforms.Ios.Core; - namespace QuickLayout.Touch { [Register("AppDelegate")] diff --git a/QuickLayout.Touch/LinkerPleaseInclude.cs b/QuickLayout.Touch/LinkerPleaseInclude.cs index 8a25390..0d14cae 100644 --- a/QuickLayout.Touch/LinkerPleaseInclude.cs +++ b/QuickLayout.Touch/LinkerPleaseInclude.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Specialized; -using System.Windows.Input; -using Foundation; using MvvmCross.Binding.BindingContext; using MvvmCross.Navigation; -using MvvmCross.Platforms.Ios.Views; using MvvmCross.ViewModels; -using UIKit; +using System.Collections.Specialized; +using System.Windows.Input; namespace QuickLayout.Touch { diff --git a/QuickLayout.Touch/Main.cs b/QuickLayout.Touch/Main.cs index e1ffca5..22784b0 100644 --- a/QuickLayout.Touch/Main.cs +++ b/QuickLayout.Touch/Main.cs @@ -1,6 +1,4 @@ -using UIKit; - -namespace QuickLayout.Touch +namespace QuickLayout.Touch { public class Application { diff --git a/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs b/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs index 2acfedd..d3624b7 100644 --- a/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs +++ b/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs @@ -1,93 +1,89 @@ -using System.Collections.Generic; -using System.Reflection; -using Cirrious.FluentLayouts.Touch; -using UIKit; -using Foundation; -using QuickLayout.Core.ViewModels; -using ObjCRuntime; -using MvvmCross.Platforms.Ios.Views; +using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using ObjCRuntime; +using QuickLayout.Core.ViewModels; +using System.Reflection; namespace QuickLayout.Touch { [Register("AdvancedVerticalStackView")] - public class AdvancedVerticalStackView : MvxViewController - { - public override void ViewDidLoad() - { - var scrollView = new UIScrollView() - { - BackgroundColor = UIColor.White, - ShowsHorizontalScrollIndicator = false, - AutoresizingMask = UIViewAutoresizing.FlexibleHeight, - }; - View = scrollView; - scrollView.TranslatesAutoresizingMaskIntoConstraints = true; - base.ViewDidLoad(); + public class AdvancedVerticalStackView : MvxViewController + { + public override void ViewDidLoad() + { + var scrollView = new UIScrollView() + { + BackgroundColor = UIColor.White, + ShowsHorizontalScrollIndicator = false, + AutoresizingMask = UIViewAutoresizing.FlexibleHeight, + }; + View = scrollView; + scrollView.TranslatesAutoresizingMaskIntoConstraints = true; + base.ViewDidLoad(); - // ios7 layout - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; + // ios7 layout + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; - var set = this.CreateBindingSet(); + var set = this.CreateBindingSet(); - var topMargins = new List(); - var leftMargins = new List(); - var rightMargins = new List(); + var topMargins = new List(); + var leftMargins = new List(); + var rightMargins = new List(); - foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) - { - if (propertyInfo.PropertyType != typeof (string)) - continue; + foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) + { + if (propertyInfo.PropertyType != typeof(string)) + continue; - topMargins.Add(20); - leftMargins.Add(0); - rightMargins.Add(0); - var introLabel = new UILabel - { - Text = propertyInfo.Name + ":", - TranslatesAutoresizingMaskIntoConstraints = false, - }; - Add(introLabel); + topMargins.Add(20); + leftMargins.Add(0); + rightMargins.Add(0); + var introLabel = new UILabel + { + Text = propertyInfo.Name + ":", + TranslatesAutoresizingMaskIntoConstraints = false, + }; + Add(introLabel); - topMargins.Add(0); - leftMargins.Add(25); - rightMargins.Add(25); - var textField = new UITextField - { - BorderStyle = UITextBorderStyle.RoundedRect, - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.LightGray - }; - Add(textField); + topMargins.Add(0); + leftMargins.Add(25); + rightMargins.Add(25); + var textField = new UITextField + { + BorderStyle = UITextBorderStyle.RoundedRect, + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.LightGray + }; + Add(textField); - topMargins.Add(0); - leftMargins.Add(40); - rightMargins.Add(40); - var label = new UILabel - { - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.Yellow, - TextAlignment = UITextAlignment.Center - }; - Add(label); + topMargins.Add(0); + leftMargins.Add(40); + rightMargins.Add(40); + var label = new UILabel + { + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.Yellow, + TextAlignment = UITextAlignment.Center + }; + Add(label); - set.Bind(label).To(propertyInfo.Name); - set.Bind(textField).To(propertyInfo.Name); - } - set.Apply(); + set.Bind(label).To(propertyInfo.Name); + set.Bind(textField).To(propertyInfo.Name); + } + set.Apply(); - var marginMultiplier = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 2 : 1; + var marginMultiplier = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 2 : 1; - var constraints = View.AdvancedVerticalStackPanelConstraints( - new Margins(20, 10, 20, 10, 5, 5), - leftMargins.ToArray(), - topMargins.ToArray(), - rightMargins.ToArray(), - marginMultiplier, - View.Subviews); - View.AddConstraints(constraints); - } - } + var constraints = View.AdvancedVerticalStackPanelConstraints( + new Margins(20, 10, 20, 10, 5, 5), + leftMargins.ToArray(), + topMargins.ToArray(), + rightMargins.ToArray(), + marginMultiplier, + View.Subviews); + View.AddConstraints(constraints); + } + } } diff --git a/QuickLayout.Touch/Views/DetailsView.cs b/QuickLayout.Touch/Views/DetailsView.cs index 9897322..9543509 100644 --- a/QuickLayout.Touch/Views/DetailsView.cs +++ b/QuickLayout.Touch/Views/DetailsView.cs @@ -1,12 +1,8 @@ -using System.Reflection; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using UIKit; -using Foundation; -using QuickLayout.Core.ViewModels; using ObjCRuntime; -using Cirrious.FluentLayouts; +using QuickLayout.Core.ViewModels; +using System.Reflection; namespace QuickLayout.Touch.Views { @@ -16,11 +12,11 @@ public class DetailsView : MvxViewController public override void ViewDidLoad() { var scrollView = new UIScrollView() - { - BackgroundColor = UIColor.White, - ShowsHorizontalScrollIndicator = false, - AutoresizingMask = UIViewAutoresizing.FlexibleHeight, - }; + { + BackgroundColor = UIColor.White, + ShowsHorizontalScrollIndicator = false, + AutoresizingMask = UIViewAutoresizing.FlexibleHeight, + }; View = scrollView; scrollView.TranslatesAutoresizingMaskIntoConstraints = true; base.ViewDidLoad(); @@ -33,7 +29,7 @@ public override void ViewDidLoad() foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) { - if (propertyInfo.PropertyType != typeof (string)) + if (propertyInfo.PropertyType != typeof(string)) continue; var introLabel = new UILabel @@ -43,11 +39,11 @@ public override void ViewDidLoad() }; Add(introLabel); var textField = new UITextField - { - BorderStyle = UITextBorderStyle.RoundedRect, - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.LightGray - }; + { + BorderStyle = UITextBorderStyle.RoundedRect, + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.LightGray + }; Add(textField); var label = new UILabel { diff --git a/QuickLayout.Touch/Views/DirectionFormView.cs b/QuickLayout.Touch/Views/DirectionFormView.cs index 904df56..d53c73d 100644 --- a/QuickLayout.Touch/Views/DirectionFormView.cs +++ b/QuickLayout.Touch/Views/DirectionFormView.cs @@ -1,17 +1,10 @@ -using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; -using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; using ObjCRuntime; -using UIKit; - -using QuickLayout.Core.ViewModels; namespace QuickLayout.Touch.Views { - [Register("DirectionFormView")] - public class DirectionFormView : MvxViewController + [Register("DirectionFormView")] + public class DirectionFormView : MvxViewController { public override void ViewDidLoad() { @@ -22,67 +15,67 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var x = View.Center.X; - var y = View.Center.Y; + var x = View.Center.X; + var y = View.Center.Y; - var east = new UILabel {Text = "East"}; - Add(east); + var east = new UILabel { Text = "East" }; + Add(east); - var west = new UILabel {Text = "West"}; - Add(west); + var west = new UILabel { Text = "West" }; + Add(west); - var north = new UILabel {Text = "North"}; - Add(north); + var north = new UILabel { Text = "North" }; + Add(north); - var south = new UILabel {Text = "South"}; - Add(south); + var south = new UILabel { Text = "South" }; + Add(south); - var northEast = new UILabel {Text = "NorthEast"}; - Add(northEast); + var northEast = new UILabel { Text = "NorthEast" }; + Add(northEast); - var northWest = new UILabel {Text = "NorthWest"}; - Add(northWest); + var northWest = new UILabel { Text = "NorthWest" }; + Add(northWest); - var southEast = new UILabel {Text = "SouthEast"}; - Add(southEast); + var southEast = new UILabel { Text = "SouthEast" }; + Add(southEast); - var southWest = new UILabel {Text = "SouthWest"}; - Add(southWest); + var southWest = new UILabel { Text = "SouthWest" }; + Add(southWest); - var center = new UILabel {Text = "Center"}; - Add(center); + var center = new UILabel { Text = "Center" }; + Add(center); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - + View.AddConstraints( - west.ToLeftMargin(View), - west.WithSameCenterY(View), + west.ToLeftMargin(View), + west.WithSameCenterY(View), - east.ToRightMargin(View), - east.WithSameCenterY(View), + east.ToRightMargin(View), + east.WithSameCenterY(View), - north.ToTopMargin(View), - north.WithSameCenterX(View), + north.ToTopMargin(View), + north.WithSameCenterX(View), - south.ToBottomMargin(View), - south.WithSameCenterX(View), + south.ToBottomMargin(View), + south.WithSameCenterX(View), - northWest.ToLeftMargin(View), - northWest.ToTopMargin(View), + northWest.ToLeftMargin(View), + northWest.ToTopMargin(View), - northEast.ToRightMargin(View), - northEast.ToTopMargin(View), + northEast.ToRightMargin(View), + northEast.ToTopMargin(View), - southWest.ToLeftMargin(View), - southWest.ToBottomMargin(View), + southWest.ToLeftMargin(View), + southWest.ToBottomMargin(View), - southEast.ToRightMargin(View), - southEast.ToBottomMargin(View), + southEast.ToRightMargin(View), + southEast.ToBottomMargin(View), - center.WithSameCenterX(View), - center.WithSameCenterY(View) - ); + center.WithSameCenterX(View), + center.WithSameCenterY(View) + ); } } } \ No newline at end of file diff --git a/QuickLayout.Touch/Views/FirstView.cs b/QuickLayout.Touch/Views/FirstView.cs index 7ee8c7d..e19df94 100644 --- a/QuickLayout.Touch/Views/FirstView.cs +++ b/QuickLayout.Touch/Views/FirstView.cs @@ -1,19 +1,15 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; -using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; -using MvvmCross.Platforms.Ios.Presenters.Attributes; namespace QuickLayout.Touch.Views { - [Register("FirstView")] + [Register("FirstView")] [MvxRootPresentation(WrapInNavigationController = true)] public class FirstView : MvxViewController { - private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea, _viewCenterConstraints; + private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea, _viewCenterConstraints; public override void ViewDidLoad() { @@ -24,41 +20,41 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - _viewForm = new UIButton(UIButtonType.RoundedRect); - _viewForm.SetTitle("Form", UIControlState.Normal); - Add(_viewForm); + _viewForm = new UIButton(UIButtonType.RoundedRect); + _viewForm.SetTitle("Form", UIControlState.Normal); + Add(_viewForm); - _viewFormGrid = new UIButton(UIButtonType.RoundedRect); - _viewFormGrid.SetTitle("FormGrid", UIControlState.Normal); - Add(_viewFormGrid); + _viewFormGrid = new UIButton(UIButtonType.RoundedRect); + _viewFormGrid.SetTitle("FormGrid", UIControlState.Normal); + Add(_viewFormGrid); - _viewDetails = new UIButton(UIButtonType.RoundedRect); - _viewDetails.SetTitle("Details", UIControlState.Normal); - Add(_viewDetails); + _viewDetails = new UIButton(UIButtonType.RoundedRect); + _viewDetails.SetTitle("Details", UIControlState.Normal); + Add(_viewDetails); - _viewSearch = new UIButton(UIButtonType.RoundedRect); - _viewSearch.SetTitle("Search", UIControlState.Normal); - Add(_viewSearch); + _viewSearch = new UIButton(UIButtonType.RoundedRect); + _viewSearch.SetTitle("Search", UIControlState.Normal); + Add(_viewSearch); - _viewTip = new UIButton(UIButtonType.RoundedRect); - _viewTip.SetTitle("Tip", UIControlState.Normal); - Add(_viewTip); + _viewTip = new UIButton(UIButtonType.RoundedRect); + _viewTip.SetTitle("Tip", UIControlState.Normal); + Add(_viewTip); - _viewUpdateConstaints = new UIButton(UIButtonType.RoundedRect); - _viewUpdateConstaints.SetTitle("Update Live Constraints", UIControlState.Normal); - Add(_viewUpdateConstaints); + _viewUpdateConstaints = new UIButton(UIButtonType.RoundedRect); + _viewUpdateConstaints.SetTitle("Update Live Constraints", UIControlState.Normal); + Add(_viewUpdateConstaints); - _viewAdvancedVerticalStack = new UIButton(UIButtonType.RoundedRect); - _viewAdvancedVerticalStack.SetTitle("Advanced Vertical Stack Panel", UIControlState.Normal); - Add(_viewAdvancedVerticalStack); + _viewAdvancedVerticalStack = new UIButton(UIButtonType.RoundedRect); + _viewAdvancedVerticalStack.SetTitle("Advanced Vertical Stack Panel", UIControlState.Normal); + Add(_viewAdvancedVerticalStack); - _fullSize = new UIButton(UIButtonType.RoundedRect); - _fullSize.SetTitle("Full Size (animated)", UIControlState.Normal); - Add(_fullSize); + _fullSize = new UIButton(UIButtonType.RoundedRect); + _fullSize.SetTitle("Full Size (animated)", UIControlState.Normal); + Add(_fullSize); - _directionFormView = new UIButton(UIButtonType.RoundedRect); - _directionFormView.SetTitle("Directions", UIControlState.Normal); - Add(_directionFormView); + _directionFormView = new UIButton(UIButtonType.RoundedRect); + _directionFormView.SetTitle("Directions", UIControlState.Normal); + Add(_directionFormView); _rightToLeft = new UIButton(UIButtonType.RoundedRect); _rightToLeft.SetTitle("Right-To-Left Support", UIControlState.Normal); @@ -72,25 +68,25 @@ public override void ViewDidLoad() _viewCenterConstraints.SetTitle("View Contraining to centers", UIControlState.Normal); Add(_viewCenterConstraints); - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); var set = this.CreateBindingSet(); - set.Bind(_viewForm).To("GoForm"); - set.Bind(_viewFormGrid).To("GoFormGrid"); - set.Bind(_viewDetails).To("GoDetails"); - set.Bind(_viewSearch).To("GoSearch"); - set.Bind(_viewTip).To("GoTip"); - set.Bind(_viewUpdateConstaints).To("GoUpdateConstraints"); - set.Bind(_viewAdvancedVerticalStack).To("GoAdvancedVerticalStack"); - set.Bind(_fullSize).To("GoFullSize"); - set.Bind(_directionFormView).To("GoDirectionForm"); + set.Bind(_viewForm).To("GoForm"); + set.Bind(_viewFormGrid).To("GoFormGrid"); + set.Bind(_viewDetails).To("GoDetails"); + set.Bind(_viewSearch).To("GoSearch"); + set.Bind(_viewTip).To("GoTip"); + set.Bind(_viewUpdateConstaints).To("GoUpdateConstraints"); + set.Bind(_viewAdvancedVerticalStack).To("GoAdvancedVerticalStack"); + set.Bind(_fullSize).To("GoFullSize"); + set.Bind(_directionFormView).To("GoDirectionForm"); set.Bind(_rightToLeft).To("GoRightToLeft"); set.Bind(_viewSafeArea).To("GoViewWithSafeArea"); set.Bind(_viewCenterConstraints).To("GoCenterConstraints"); set.Apply(); var constraints = View.VerticalStackPanelConstraints( - new Margins(20, 10, 20, 10, 5, 5), + new Margins(20, 10, 20, 10, 5, 5), View.Subviews); View.AddConstraints(constraints); } diff --git a/QuickLayout.Touch/Views/FormGridView.cs b/QuickLayout.Touch/Views/FormGridView.cs index d53751b..a7868f3 100644 --- a/QuickLayout.Touch/Views/FormGridView.cs +++ b/QuickLayout.Touch/Views/FormGridView.cs @@ -1,10 +1,6 @@ -using System.Drawing; using Cirrious.FluentLayouts.Touch; using Cirrious.FluentLayouts.Touch.RowSet; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; -using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; @@ -32,7 +28,7 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var _forceTheWidthView = new UIView() {BackgroundColor = UIColor.Clear}; + var _forceTheWidthView = new UIView() { BackgroundColor = UIColor.Clear }; Add(_forceTheWidthView); var fNameLabel = new UILabel { Text = "First" }; @@ -87,23 +83,23 @@ public override void ViewDidLoad() View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); var rowSet = new RowSetTemplate() - { - TopMargin = 10f, - BottomMargin = 20f, - VInterspacing = 10f - }; + { + TopMargin = 10f, + BottomMargin = 20f, + VInterspacing = 10f + }; var equalWeightRowTemplate = new RowTemplate() - { - HInterspacing = 12f, - LeftMargin = 6f, - RightMargin = 24f - }; + { + HInterspacing = 12f, + LeftMargin = 6f, + RightMargin = 24f + }; var addressRowTemplate = new RowTemplate() - { - HInterspacing = 12f, - LeftMargin = 6f, - RightMargin = 24f - }; + { + HInterspacing = 12f, + LeftMargin = 6f, + RightMargin = 24f + }; addressRowTemplate.ColumnWeight(0, 0.3f); var townAndZipRowTemplate = new RowTemplate() { diff --git a/QuickLayout.Touch/Views/FormView.cs b/QuickLayout.Touch/Views/FormView.cs index 69865ef..e7acd36 100644 --- a/QuickLayout.Touch/Views/FormView.cs +++ b/QuickLayout.Touch/Views/FormView.cs @@ -1,10 +1,6 @@ -using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; using ObjCRuntime; -using UIKit; using QuickLayout.Core.ViewModels; @@ -22,22 +18,22 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var fNameLabel = new UILabel {Text = "First"}; + var fNameLabel = new UILabel { Text = "First" }; Add(fNameLabel); - var sNameLabel = new UILabel {Text = "Last"}; + var sNameLabel = new UILabel { Text = "Last" }; Add(sNameLabel); - var numberLabel = new UILabel {Text = "#"}; + var numberLabel = new UILabel { Text = "#" }; Add(numberLabel); - var streetLabel = new UILabel {Text = "Street"}; + var streetLabel = new UILabel { Text = "Street" }; Add(streetLabel); - var townLabel = new UILabel {Text = "Town"}; + var townLabel = new UILabel { Text = "Town" }; Add(townLabel); - var zipLabel = new UILabel {Text = "Zip"}; + var zipLabel = new UILabel { Text = "Zip" }; Add(zipLabel); var fNameField = new UITextField() { BackgroundColor = UIColor.LightGray, BorderStyle = UITextBorderStyle.RoundedRect }; diff --git a/QuickLayout.Touch/Views/FullSizeView.cs b/QuickLayout.Touch/Views/FullSizeView.cs index adb7bca..f91370f 100644 --- a/QuickLayout.Touch/Views/FullSizeView.cs +++ b/QuickLayout.Touch/Views/FullSizeView.cs @@ -1,61 +1,56 @@ -using System; -using System.Collections.Generic; -using Cirrious.FluentLayouts.Touch; -using Foundation; -using MvvmCross.Platforms.Ios.Views; +using Cirrious.FluentLayouts.Touch; using ObjCRuntime; -using UIKit; namespace QuickLayout.Touch.Views { [Register("FullSizeView")] - public class FullSizeView : MvxViewController - { - private IEnumerable _cyanLayouts; - - public override void ViewDidLoad() - { - View.BackgroundColor = UIColor.White; - base.ViewDidLoad(); - - // ios7 layout - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; - - var cyan = new UIView { BackgroundColor = UIColor.Cyan }; - var red = new UIView { BackgroundColor = UIColor.Red }; - var yellow = new UIView { BackgroundColor = UIColor.Yellow }; - var brown = new UIView { BackgroundColor = UIColor.Brown }; - var green = new UIView { BackgroundColor = UIColor.Green }; - var clickMe = new UILabel { Text = "Tap me", TextAlignment = UITextAlignment.Center }; - - View.AddSubviews(cyan, red, yellow, brown, green, clickMe); - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - - _cyanLayouts = cyan.FullSizeOf(View, 20); - - View.AddConstraints(_cyanLayouts); - View.AddConstraints(red.FullSizeOf(cyan, new Margins(10, 30))); - View.AddConstraints(yellow.FullSizeOf(red, 5)); - View.AddConstraints(brown.FullSizeOf(yellow, new Margins(20, 40, 50, 10))); - View.AddConstraints(green.FullSizeOf(brown, 10)); - View.AddConstraints( - clickMe.WithSameCenterX(green), - clickMe.WithSameCenterY(green) - ); - - View.AddGestureRecognizer(new UITapGestureRecognizer(AnimateRandom)); - } - - private void AnimateRandom() - { - var random = new Random(); - _cyanLayouts.GetLayoutById("Top").Constant = random.Next(5, 150); - _cyanLayouts.GetLayoutById("Bottom").Constant = random.Next(-150, -5); - _cyanLayouts.GetLayoutById("Left").Constant = random.Next(5, 50); - _cyanLayouts.GetLayoutById("Right").Constant = random.Next(-50, -5); - - UIView.Animate(0.3, View.LayoutIfNeeded); - } - } + public class FullSizeView : MvxViewController + { + private IEnumerable _cyanLayouts; + + public override void ViewDidLoad() + { + View.BackgroundColor = UIColor.White; + base.ViewDidLoad(); + + // ios7 layout + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; + + var cyan = new UIView { BackgroundColor = UIColor.Cyan }; + var red = new UIView { BackgroundColor = UIColor.Red }; + var yellow = new UIView { BackgroundColor = UIColor.Yellow }; + var brown = new UIView { BackgroundColor = UIColor.Brown }; + var green = new UIView { BackgroundColor = UIColor.Green }; + var clickMe = new UILabel { Text = "Tap me", TextAlignment = UITextAlignment.Center }; + + View.AddSubviews(cyan, red, yellow, brown, green, clickMe); + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + + _cyanLayouts = cyan.FullSizeOf(View, 20); + + View.AddConstraints(_cyanLayouts); + View.AddConstraints(red.FullSizeOf(cyan, new Margins(10, 30))); + View.AddConstraints(yellow.FullSizeOf(red, 5)); + View.AddConstraints(brown.FullSizeOf(yellow, new Margins(20, 40, 50, 10))); + View.AddConstraints(green.FullSizeOf(brown, 10)); + View.AddConstraints( + clickMe.WithSameCenterX(green), + clickMe.WithSameCenterY(green) + ); + + View.AddGestureRecognizer(new UITapGestureRecognizer(AnimateRandom)); + } + + private void AnimateRandom() + { + var random = new Random(); + _cyanLayouts.GetLayoutById("Top").Constant = random.Next(5, 150); + _cyanLayouts.GetLayoutById("Bottom").Constant = random.Next(-150, -5); + _cyanLayouts.GetLayoutById("Left").Constant = random.Next(5, 50); + _cyanLayouts.GetLayoutById("Right").Constant = random.Next(-50, -5); + + UIView.Animate(0.3, View.LayoutIfNeeded); + } + } } diff --git a/QuickLayout.Touch/Views/RightToLeftView.cs b/QuickLayout.Touch/Views/RightToLeftView.cs index 8436214..e1a4f21 100644 --- a/QuickLayout.Touch/Views/RightToLeftView.cs +++ b/QuickLayout.Touch/Views/RightToLeftView.cs @@ -1,13 +1,9 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; using ObjCRuntime; -using UIKit; using QuickLayout.Core.ViewModels; using System.Runtime.InteropServices; -using System; namespace QuickLayout.Touch.Views { @@ -28,22 +24,22 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var fNameLabel = new UILabel {Text = "First"}; + var fNameLabel = new UILabel { Text = "First" }; Add(fNameLabel); - var sNameLabel = new UILabel {Text = "Last"}; + var sNameLabel = new UILabel { Text = "Last" }; Add(sNameLabel); - var numberLabel = new UILabel {Text = "#"}; + var numberLabel = new UILabel { Text = "#" }; Add(numberLabel); - var streetLabel = new UILabel {Text = "Street"}; + var streetLabel = new UILabel { Text = "Street" }; Add(streetLabel); - var townLabel = new UILabel {Text = "Town"}; + var townLabel = new UILabel { Text = "Town" }; Add(townLabel); - var zipLabel = new UILabel {Text = "Zip"}; + var zipLabel = new UILabel { Text = "Zip" }; Add(zipLabel); var fNameField = new UITextField() { BackgroundColor = UIColor.LightGray, BorderStyle = UITextBorderStyle.RoundedRect }; diff --git a/QuickLayout.Touch/Views/SearchView.cs b/QuickLayout.Touch/Views/SearchView.cs index 47e6555..35c2b92 100644 --- a/QuickLayout.Touch/Views/SearchView.cs +++ b/QuickLayout.Touch/Views/SearchView.cs @@ -1,9 +1,5 @@ -using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; -using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; diff --git a/QuickLayout.Touch/Views/TipView.cs b/QuickLayout.Touch/Views/TipView.cs index c98afee..796c7d4 100644 --- a/QuickLayout.Touch/Views/TipView.cs +++ b/QuickLayout.Touch/Views/TipView.cs @@ -1,9 +1,5 @@ -using System.Drawing; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using Foundation; -using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; @@ -26,10 +22,10 @@ public override void ViewDidLoad() Add(subTotal); var seek = new UISlider() - { - MinValue = 0, - MaxValue = 100, - }; + { + MinValue = 0, + MaxValue = 100, + }; Add(seek); var seekLabel = new UILabel(); diff --git a/QuickLayout.Touch/Views/ToCenterConstraintsView.cs b/QuickLayout.Touch/Views/ToCenterConstraintsView.cs index 6982695..5fad7af 100644 --- a/QuickLayout.Touch/Views/ToCenterConstraintsView.cs +++ b/QuickLayout.Touch/Views/ToCenterConstraintsView.cs @@ -1,8 +1,5 @@ using Cirrious.FluentLayouts.Touch; -using Foundation; -using MvvmCross.Platforms.Ios.Views; using QuickLayout.Core.ViewModels; -using UIKit; namespace QuickLayout.Touch.Views { @@ -24,7 +21,7 @@ public override void ViewDidLoad() TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = UIColor.Red }, - + thirdContainer = new UIView { TranslatesAutoresizingMaskIntoConstraints = false, diff --git a/QuickLayout.Touch/Views/UpdateConstraintsView.cs b/QuickLayout.Touch/Views/UpdateConstraintsView.cs index fcfc38a..fef5386 100644 --- a/QuickLayout.Touch/Views/UpdateConstraintsView.cs +++ b/QuickLayout.Touch/Views/UpdateConstraintsView.cs @@ -1,64 +1,61 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using MvvmCross.Platforms.Ios.Views; -using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; -using Foundation; namespace QuickLayout.Touch { - [Register("UpdateConstraintsView")] - public class UpdateConstraintsView : MvxViewController - { - public override void ViewDidLoad() - { - base.ViewDidLoad(); - - View.BackgroundColor = UIColor.White; - - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; - - var label = new UILabel - { - Text = "Update this label's height constraint height constant and active settings", - BackgroundColor = UIColor.LightGray, - TextColor = UIColor.Black, - LineBreakMode = UILineBreakMode.WordWrap, - Lines = 0 - }; - var toggleHeight = new UISwitch(); - var heightConstant = new UISlider { MinValue = 0, MaxValue = 400 }; - - View.AddSubviews(label, toggleHeight, heightConstant); - - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - - var heightLayout = label.Height().EqualTo(ViewModel.Constant).WithIdentifier("foo"); - - var margin = 10; - View.AddConstraints( - heightConstant.AtTopOf(View, margin), - heightConstant.AtLeftOf(View, margin), - heightConstant.AtRightOf(View, margin), - - toggleHeight.Below(heightConstant, margin), - toggleHeight.WithSameLeft(heightConstant), - - label.AtLeftOf(View, margin), - label.Below(toggleHeight, margin), - label.AtRightOf(View, margin), - heightLayout - ); - - var set = this.CreateBindingSet(); - set.Bind(heightLayout).For(layout => layout.Active).To(vm => vm.Active); - set.Bind(heightLayout).For(layout => layout.Constant).To(vm => vm.Constant); - set.Bind(toggleHeight).To(vm => vm.Active); - set.Bind(heightConstant).To(vm => vm.Constant); - set.Apply(); - } - } + [Register("UpdateConstraintsView")] + public class UpdateConstraintsView : MvxViewController + { + public override void ViewDidLoad() + { + base.ViewDidLoad(); + + View.BackgroundColor = UIColor.White; + + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; + + var label = new UILabel + { + Text = "Update this label's height constraint height constant and active settings", + BackgroundColor = UIColor.LightGray, + TextColor = UIColor.Black, + LineBreakMode = UILineBreakMode.WordWrap, + Lines = 0 + }; + var toggleHeight = new UISwitch(); + var heightConstant = new UISlider { MinValue = 0, MaxValue = 400 }; + + View.AddSubviews(label, toggleHeight, heightConstant); + + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + + var heightLayout = label.Height().EqualTo(ViewModel.Constant).WithIdentifier("foo"); + + var margin = 10; + View.AddConstraints( + heightConstant.AtTopOf(View, margin), + heightConstant.AtLeftOf(View, margin), + heightConstant.AtRightOf(View, margin), + + toggleHeight.Below(heightConstant, margin), + toggleHeight.WithSameLeft(heightConstant), + + label.AtLeftOf(View, margin), + label.Below(toggleHeight, margin), + label.AtRightOf(View, margin), + heightLayout + ); + + var set = this.CreateBindingSet(); + set.Bind(heightLayout).For(layout => layout.Active).To(vm => vm.Active); + set.Bind(heightLayout).For(layout => layout.Constant).To(vm => vm.Constant); + set.Bind(toggleHeight).To(vm => vm.Active); + set.Bind(heightConstant).To(vm => vm.Constant); + set.Apply(); + } + } } diff --git a/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs b/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs index 0a24a80..673b710 100644 --- a/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs +++ b/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs @@ -1,8 +1,4 @@ -using System; -using Cirrious.FluentLayouts.Touch; -using Foundation; -using MvvmCross.Platforms.Ios.Views; -using UIKit; +using Cirrious.FluentLayouts.Touch; namespace QuickLayout.Touch.Views { @@ -16,7 +12,7 @@ public override void ViewDidLoad() View.BackgroundColor = UIColor.FromRGB(248, 191, 120); var viewContainer = new UIView { BackgroundColor = UIColor.Clear }; - + var sampleText = new UITextView { Editable = false, @@ -49,7 +45,7 @@ public override void ViewDidLoad() sampleText.AtRightOfSafeArea(viewContainer), //sampleText.AtRightOf(viewContainer), -> if this is used, content overlaps under notch on landscape sampleText.AtBottomOfSafeArea(viewContainer) - //sampleText.AtBottomOf(viewContainer) -> if this is used, content overlaps under notch on landscape + //sampleText.AtBottomOf(viewContainer) -> if this is used, content overlaps under notch on landscape ); } } From c2a46e7e0712ca4addfc8062400c223a919bd08a Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:54:00 +0500 Subject: [PATCH 03/11] fix nullable issues --- .../AdvancedFluentLayoutExtensions.cs | 355 +++++++++--------- .../Extensions/ArrayExtensions.cs | 26 -- Cirrious.FluentLayout/FluentLayout.cs | 322 ++++++++-------- Cirrious.FluentLayout/NfloatExtensions.cs | 10 - .../RowSet-WorkInProgress/RowSet.cs | 225 ++++++----- QuickLayout.sln | 67 ++-- 6 files changed, 480 insertions(+), 525 deletions(-) delete mode 100644 Cirrious.FluentLayout/Extensions/ArrayExtensions.cs delete mode 100644 Cirrious.FluentLayout/NfloatExtensions.cs diff --git a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs index 503b5fb..53ef560 100644 --- a/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs @@ -5,239 +5,232 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using Cirrious.FluentLayouts.Touch.Extensions; +namespace Cirrious.FluentLayouts.Touch; -namespace Cirrious.FluentLayouts.Touch +public static class AdvancedFluentLayoutExtensions { - public static class AdvancedFluentLayoutExtensions - { - const float DefaultMargin = 0; - const float DefaultScale = 1; + const float DefaultMargin = 0; + const float DefaultScale = 1; + + public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTopOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Top().EqualTo().TopOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtTopOf(parentView, margin); - public static FluentLayout AtTopOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Top().EqualTo().TopOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtTopOf(parentView, margin); + public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Left().EqualTo().LeftOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtLeftOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Left().EqualTo().LeftOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtLeftOf(parentView, margin); - public static FluentLayout AtLeftOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Left().EqualTo().LeftOf(parentView.SafeAreaLayoutGuide).Plus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtLeftOf(parentView, margin); + public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Right().EqualTo().RightOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtRightOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Right().EqualTo().RightOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtRightOf(parentView, margin); - public static FluentLayout AtRightOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Right().EqualTo().RightOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtRightOf(parentView, margin); + public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Bottom().EqualTo().BottomOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtBottomOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Bottom().EqualTo().BottomOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => + UIDevice.CurrentDevice.CheckSystemVersion(11, 0) + ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) + : view.AtBottomOf(parentView, margin); - public static FluentLayout AtBottomOfSafeArea(this UIView view, UIView parentView, nfloat? margin = null) => - UIDevice.CurrentDevice.CheckSystemVersion(11, 0) - ? view.Bottom().EqualTo().BottomOf(parentView.SafeAreaLayoutGuide).Minus(margin.GetValueOrDefault(DefaultMargin)) - : view.AtBottomOf(parentView, margin); + public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtLeadingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Leading().EqualTo().LeadingOf(parentView).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => + view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout AtTrailingOf(this UIView view, UIView parentView, nfloat? margin = null) => - view.Trailing().EqualTo().TrailingOf(parentView).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => + view.Top().EqualTo().BottomOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Below(this UIView view, UIView previous, nfloat? margin = null) => - view.Top().EqualTo().BottomOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => + view.Bottom().EqualTo().TopOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout Above(this UIView view, UIView previous, nfloat? margin = null) => - view.Bottom().EqualTo().TopOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); - public static FluentLayout WithSameLeft(this UIView view, UIView previous) => view.Left().EqualTo().LeftOf(previous); + public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); - public static FluentLayout WithSameTop(this UIView view, UIView previous) => view.Top().EqualTo().TopOf(previous); + public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); - public static FluentLayout WithSameCenterX(this UIView view, UIView previous) => view.CenterX().EqualTo().CenterXOf(previous); + public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); - public static FluentLayout WithSameCenterY(this UIView view, UIView previous) => view.CenterY().EqualTo().CenterYOf(previous); + public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); - public static FluentLayout WithSameRight(this UIView view, UIView previous) => view.Right().EqualTo().RightOf(previous); + public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); - public static FluentLayout WithSameWidth(this UIView view, UIView previous) => view.Width().EqualTo().WidthOf(previous); + public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); - public static FluentLayout WithSameBottom(this UIView view, UIView previous) => view.Bottom().EqualTo().BottomOf(previous); + public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); - public static FluentLayout WithSameLeading(this UIView view, UIView previous) => view.Leading().EqualTo().LeadingOf(previous); + public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); - public static FluentLayout WithSameTrailing(this UIView view, UIView previous) => view.Trailing().EqualTo().TrailingOf(previous); + public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => + view.Width().EqualTo().WidthOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout WithRelativeWidth(this UIView view, UIView previous, nfloat? scale = null) => - view.Width().EqualTo().WidthOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); + public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); - public static FluentLayout WithSameHeight(this UIView view, UIView previous) => view.Height().EqualTo().HeightOf(previous); + public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => + view.Height().EqualTo().HeightOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); - public static FluentLayout WithRelativeHeight(this UIView view, UIView previous, nfloat? scale = null) => - view.Height().EqualTo().HeightOf(previous).WithMultiplier(scale.GetValueOrDefault(DefaultScale)); + public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Left().EqualTo().RightOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToRightOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Left().EqualTo().RightOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Right().EqualTo().LeftOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeftOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Right().EqualTo().LeftOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToTrailingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Leading().EqualTo().TrailingOf(previous).Plus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); - public static FluentLayout ToLeadingOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Trailing().EqualTo().LeadingOf(previous).Minus(margin.GetValueOrDefault(DefaultMargin)); + public static FluentLayout ToLeftMargin(this UIView view, UIView previous) => + view.Leading().EqualTo().LeadingMarginOf(previous); - public static FluentLayout ToLeftMargin(this UIView view, UIView previous) => - view.Leading().EqualTo().LeadingMarginOf(previous); + public static FluentLayout ToRightMargin(this UIView view, UIView previous) => + view.Trailing().EqualTo().TrailingMarginOf(previous); - public static FluentLayout ToRightMargin(this UIView view, UIView previous) => - view.Trailing().EqualTo().TrailingMarginOf(previous); + public static FluentLayout ToTopMargin(this UIView view, UIView previous) => + view.Top().EqualTo().TopMarginOf(previous); - public static FluentLayout ToTopMargin(this UIView view, UIView previous) => - view.Top().EqualTo().TopMarginOf(previous); + public static FluentLayout ToBottomMargin(this UIView view, UIView previous) => + view.Bottom().EqualTo().BottomMarginOf(previous); - public static FluentLayout ToBottomMargin(this UIView view, UIView previous) => - view.Bottom().EqualTo().BottomMarginOf(previous); + public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); - public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0)); + public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); - public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Left().EqualTo().CenterXOf(previous).Plus(margin.GetValueOrDefault(0)); + public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); - public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0)); + public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => + view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); - public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) => - view.Top().EqualTo().CenterYOf(previous).Plus(margin.GetValueOrDefault(0)); + public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) + { + var marginValue = margin.GetValueOrDefault(DefaultMargin); - public static IEnumerable FullWidthOf(this UIView view, UIView parent, nfloat? margin = null) + return new List { - var marginValue = margin.GetValueOrDefault(DefaultMargin); + view.AtLeftOf(parent, marginValue).WithIdentifier("Left"), + view.AtRightOf(parent, marginValue).WithIdentifier("Right") + }; + } - return new List - { - view.AtLeftOf(parent, marginValue).WithIdentifier("Left"), - view.AtRightOf(parent, marginValue).WithIdentifier("Right") - }; - } + public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) + { + var marginValue = margin.GetValueOrDefault(DefaultMargin); - public static IEnumerable FullHeightOf(this UIView view, UIView parent, nfloat? margin = null) + return new List { - var marginValue = margin.GetValueOrDefault(DefaultMargin); + view.AtTopOf(parent, marginValue).WithIdentifier("Top"), + view.AtBottomOf(parent, marginValue).WithIdentifier("Bottom") + }; + } - return new List - { - view.AtTopOf(parent, marginValue).WithIdentifier("Top"), - view.AtBottomOf(parent, marginValue).WithIdentifier("Bottom") - }; - } + public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => + FullSizeOf(view, parent, new Margins((float)margin.GetValueOrDefault(DefaultMargin))); - public static IEnumerable FullSizeOf(this UIView view, UIView parent, nfloat? margin = null) => - FullSizeOf(view, parent, new Margins((float)margin.GetValueOrDefault(DefaultMargin))); + public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) + { + margins = margins ?? new Margins(); - public static IEnumerable FullSizeOf(this UIView view, UIView parent, Margins margins) + return new List { - margins = margins ?? new Margins(); - - return new List - { - view.AtTopOf(parent, margins.Top).WithIdentifier("Top"), - view.AtBottomOf(parent, margins.Bottom).WithIdentifier("Bottom"), - view.AtLeftOf(parent, margins.Left).WithIdentifier("Left"), - view.AtRightOf(parent, margins.Right).WithIdentifier("Right") - }; - } + view.AtTopOf(parent, margins.Top).WithIdentifier("Top"), + view.AtBottomOf(parent, margins.Bottom).WithIdentifier("Bottom"), + view.AtLeftOf(parent, margins.Left).WithIdentifier("Left"), + view.AtRightOf(parent, margins.Right).WithIdentifier("Right") + }; + } + + public static FluentLayout? GetLayoutById(this IEnumerable layouts, string identifier) => + layouts.FirstOrDefault(x => x.Identifier?.Equals(identifier) is true); + + public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => + AdvancedVerticalStackPanelConstraints(parentView, margins, views: views); + + /// + /// Vertical stack panel constraints with support for children independent left, right and top margins + /// and a multiplier factor for all margins applied. The multiplier can be useful when dealing with iPad screens. + /// Example: + /// + /// scrollView.AddConstraints(scrollView.AdvancedVerticalStackPanelConstraints(null, + /// childrenLeftMargins: new float[] { 15, 0, 15, 0, 0, 15 }, + /// childrenTopMargins: new float[] { 15, 5, 15, 5, 8, 15, 22, 8, 8, 28, 28 }, + /// marginMultiplier: 2f, + /// views: scrollView.Subviews) + /// ); + /// + public static IEnumerable AdvancedVerticalStackPanelConstraints(this UIView parentView, + Margins margins, + float[]? childrenLeftMargins = null, + float[]? childrenTopMargins = null, + float[]? childrenRightMargins = null, + float marginMultiplier = 1, + params UIView[] views) + { + string? previousIdentifierPrefix = default; + margins ??= new Margins(); + var layouts = new List(); - public static FluentLayout GetLayoutById(this IEnumerable layouts, string identifier) => - layouts.FirstOrDefault(x => x.Identifier.Equals(identifier)); - - public static IEnumerable VerticalStackPanelConstraints(this UIView parentView, Margins margins, params UIView[] views) => - AdvancedVerticalStackPanelConstraints(parentView, margins, views: views); - - /// - /// Vertical stack panel constraints with support for children independent left, right and top margins - /// and a multiplier factor for all margins applied. The multiplier can be useful when dealing with iPad screens. - /// Example: - /// - /// scrollView.AddConstraints(scrollView.AdvancedVerticalStackPanelConstraints(null, - /// childrenLeftMargins: new float[] { 15, 0, 15, 0, 0, 15 }, - /// childrenTopMargins: new float[] { 15, 5, 15, 5, 8, 15, 22, 8, 8, 28, 28 }, - /// marginMultiplier: 2f, - /// views: scrollView.Subviews) - /// ); - /// - public static IEnumerable AdvancedVerticalStackPanelConstraints(this UIView parentView, - Margins margins, - float[] childrenLeftMargins = null, - float[] childrenTopMargins = null, - float[] childrenRightMargins = null, - float marginMultiplier = 1, - params UIView[] views) + var count = views.Length; + for (var i = 0; i < count; i++) { - string previousIdentifierPrefix = null; - margins = margins ?? new Margins(); - var layouts = new List(); - - var count = views.Length; - for (var i = 0; i < count; i++) - { - var view = views[i]; - var viewIdentifierPrefix = $"{parentView.AccessibilityIdentifier ?? "VerticalStackPanel"}-{view.AccessibilityIdentifier ?? i.ToString()}-"; - - float childLeftMargin; - childrenLeftMargins.TryGetElement(i, out childLeftMargin); - var marginLeft = Math.Max(margins.Left, childLeftMargin) * marginMultiplier; - layouts.Add(view.Left() - .EqualTo() - .LeftOf(parentView) - .Plus(marginLeft) - .WithIdentifier(viewIdentifierPrefix + "Left")); - - float childRightMargin; - childrenRightMargins.TryGetElement(i, out childRightMargin); - var marginRight = Math.Max(margins.Right, childRightMargin) * marginMultiplier; - layouts.Add(view.Width() + var view = views[i]; + var viewIdentifierPrefix = $"{parentView.AccessibilityIdentifier ?? "VerticalStackPanel"}-{view.AccessibilityIdentifier ?? i.ToString()}-"; + + var childLeftMargin = childrenLeftMargins?[i] ?? default; + var marginLeft = Math.Max(margins.Left, childLeftMargin) * marginMultiplier; + layouts.Add(view.Left() + .EqualTo() + .LeftOf(parentView) + .Plus(marginLeft) + .WithIdentifier(viewIdentifierPrefix + "Left")); + + var childRightMargin = childrenRightMargins?[i] ?? default; + var marginRight = Math.Max(margins.Right, childRightMargin) * marginMultiplier; + layouts.Add(view.Width() + .EqualTo() + .WidthOf(parentView) + .Minus(marginRight + marginLeft) + .WithIdentifier(viewIdentifierPrefix + "Width")); + + var childTopMargin = childrenTopMargins?[i] ?? default; + layouts.Add(i == 0 + ? view.Top() .EqualTo() - .WidthOf(parentView) - .Minus(marginRight + marginLeft) - .WithIdentifier(viewIdentifierPrefix + "Width")); - - float childTopMargin; - childrenTopMargins.TryGetElement(i, out childTopMargin); - - layouts.Add(i == 0 - ? view.Top() - .EqualTo() - .TopOf(parentView) - .Plus(Math.Max(margins.Top, childTopMargin) * marginMultiplier) - .WithIdentifier(viewIdentifierPrefix + "Top") - : view.Top() - .EqualTo() - .BottomOf(views[i - 1]) - .Plus(Math.Max(margins.VSpacing, childTopMargin) * marginMultiplier) - .WithIdentifier(viewIdentifierPrefix + "Top")); - - previousIdentifierPrefix = viewIdentifierPrefix; - } - - if (parentView is UIScrollView) - layouts.Add(views[views.Length - 1].Bottom() + .TopOf(parentView) + .Plus(Math.Max(margins.Top, childTopMargin) * marginMultiplier) + .WithIdentifier(viewIdentifierPrefix + "Top") + : view.Top() .EqualTo() - .BottomOf(parentView) - .Minus(margins.Bottom * marginMultiplier) - .WithIdentifier(previousIdentifierPrefix + "Bottom")); + .BottomOf(views[i - 1]) + .Plus(Math.Max(margins.VSpacing, childTopMargin) * marginMultiplier) + .WithIdentifier(viewIdentifierPrefix + "Top")); - return layouts; + previousIdentifierPrefix = viewIdentifierPrefix; } + + if (parentView is UIScrollView) + layouts.Add(views[^1].Bottom() + .EqualTo() + .BottomOf(parentView) + .Minus(margins.Bottom * marginMultiplier) + .WithIdentifier(previousIdentifierPrefix + "Bottom")); + + return layouts; } } diff --git a/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs b/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs deleted file mode 100644 index 114606c..0000000 --- a/Cirrious.FluentLayout/Extensions/ArrayExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Cirrious.FluentLayouts.Touch.Extensions -{ - internal static class ArrayExtensions - { - public static bool TryGetElement(this T[] array, int index, out T element) - { - if (array == null) - { - element = default(T); - - return false; - } - - if (index < array.Length) - { - element = array[index]; - - return true; - } - - element = default(T); - - return false; - } - } -} \ No newline at end of file diff --git a/Cirrious.FluentLayout/FluentLayout.cs b/Cirrious.FluentLayout/FluentLayout.cs index 4bbc72f..057ae12 100644 --- a/Cirrious.FluentLayout/FluentLayout.cs +++ b/Cirrious.FluentLayout/FluentLayout.cs @@ -5,210 +5,210 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -namespace Cirrious.FluentLayouts.Touch +namespace Cirrious.FluentLayouts.Touch; + +public class FluentLayout { - public class FluentLayout - { - public FluentLayout( - UIView view, - NSLayoutAttribute attribute, - NSLayoutRelation relation, - NSObject secondItem, - NSLayoutAttribute secondAttribute) - { - Constraint = new Lazy(CreateConstraint); - View = view; - Attribute = attribute; - Relation = relation; - SecondItem = secondItem; - SecondAttribute = secondAttribute; - Priority = (float)UILayoutPriority.Required; - } + public FluentLayout( + UIView view, + NSLayoutAttribute attribute, + NSLayoutRelation relation, + NSObject secondItem, + NSLayoutAttribute secondAttribute) + { + Constraint = new Lazy(CreateConstraint); + View = view; + Attribute = attribute; + Relation = relation; + SecondItem = secondItem; + SecondAttribute = secondAttribute; + Priority = (float)UILayoutPriority.Required; + } - public FluentLayout(UIView view, - NSLayoutAttribute attribute, - NSLayoutRelation relation, - nfloat constant = default(nfloat)) - { - Constraint = new Lazy(CreateConstraint); - View = view; - Attribute = attribute; - Relation = relation; - Constant = constant; - Priority = (float)UILayoutPriority.Required; - } + public FluentLayout(UIView view, + NSLayoutAttribute attribute, + NSLayoutRelation relation, + nfloat constant = default(nfloat)) + { + Constraint = new Lazy(CreateConstraint); + View = view; + Attribute = attribute; + Relation = relation; + Constant = constant; + Priority = (float)UILayoutPriority.Required; + } - public UIView View { get; } + public UIView View { get; } - public nfloat Multiplier { get; private set; } = 1f; + public nfloat Multiplier { get; private set; } = 1f; - private nfloat _constant; - public nfloat Constant + private nfloat _constant; + public nfloat Constant + { + get { return _constant; } + set { - get { return _constant; } - set - { - _constant = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Constant = _constant; - } + _constant = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Constant = _constant; } + } - private float _priority; - public float Priority + private float _priority; + public float Priority + { + get { return _priority; } + set { - get { return _priority; } - set - { - _priority = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Priority = _priority; - } + _priority = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Priority = _priority; } + } - private bool _active = true; - public bool Active + private bool _active = true; + public bool Active + { + get { return _active; } + set { - get { return _active; } - set - { - _active = value; - - if (Constraint.IsValueCreated) - Constraint.Value.Active = _active; - } + _active = value; + + if (Constraint.IsValueCreated) + Constraint.Value.Active = _active; } + } + + private string? _identifier; - private string _identifier; - public string Identifier + public string? Identifier + { + get { return _identifier; } + set { - get { return _identifier; } - set - { - _identifier = value; - - if (Constraint.IsValueCreated) - Constraint.Value.SetIdentifier(_identifier); - } + _identifier = value; + + if (Constraint.IsValueCreated) + Constraint.Value.SetIdentifier(_identifier); } + } - public NSLayoutAttribute Attribute { get; private set; } - public NSLayoutRelation Relation { get; private set; } - public NSObject SecondItem { get; private set; } - public NSLayoutAttribute SecondAttribute { get; private set; } + public NSLayoutAttribute Attribute { get; private set; } + public NSLayoutRelation Relation { get; private set; } + public NSObject? SecondItem { get; private set; } + public NSLayoutAttribute SecondAttribute { get; private set; } - internal Lazy Constraint { get; } + internal Lazy Constraint { get; } - private NSLayoutConstraint CreateConstraint() - { - var constraint = NSLayoutConstraint.Create( - View, - Attribute, - Relation, - SecondItem, - SecondAttribute, - Multiplier, - Constant); - constraint.Priority = Priority; - - if (!string.IsNullOrWhiteSpace(Identifier)) - constraint.SetIdentifier(Identifier); - - return constraint; - } + private NSLayoutConstraint CreateConstraint() + { + var constraint = NSLayoutConstraint.Create( + View, + Attribute, + Relation, + SecondItem, + SecondAttribute, + Multiplier, + Constant); + constraint.Priority = Priority; + + if (!string.IsNullOrWhiteSpace(Identifier)) + constraint.SetIdentifier(Identifier); + + return constraint; + } - public FluentLayout Plus(nfloat constant) - { - Constant += constant; - return this; - } + public FluentLayout Plus(nfloat constant) + { + Constant += constant; + return this; + } - public FluentLayout Minus(nfloat constant) - { - Constant -= constant; - return this; - } + public FluentLayout Minus(nfloat constant) + { + Constant -= constant; + return this; + } - public FluentLayout WithMultiplier(nfloat multiplier) - { - Multiplier = multiplier; - return this; - } + public FluentLayout WithMultiplier(nfloat multiplier) + { + Multiplier = multiplier; + return this; + } - public FluentLayout SetPriority(float priority) - { - Priority = priority; - return this; - } + public FluentLayout SetPriority(float priority) + { + Priority = priority; + return this; + } - public FluentLayout SetPriority(UILayoutPriority priority) - { - Priority = (float)priority; - return this; - } + public FluentLayout SetPriority(UILayoutPriority priority) + { + Priority = (float)priority; + return this; + } - public FluentLayout SetActive(bool active) - { - Active = active; - return this; - } + public FluentLayout SetActive(bool active) + { + Active = active; + return this; + } - public FluentLayout WithIdentifier(string identifier) - { - Identifier = identifier; - return this; - } + public FluentLayout WithIdentifier(string identifier) + { + Identifier = identifier; + return this; + } - public FluentLayout LeftOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Left); + public FluentLayout LeftOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Left); - public FluentLayout RightOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Right); + public FluentLayout RightOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Right); - public FluentLayout TopOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Top); + public FluentLayout TopOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Top); - public FluentLayout BottomOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Bottom); + public FluentLayout BottomOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Bottom); - public FluentLayout BaselineOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Baseline); + public FluentLayout BaselineOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Baseline); - public FluentLayout TrailingOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Trailing); + public FluentLayout TrailingOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Trailing); - public FluentLayout LeadingOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Leading); + public FluentLayout LeadingOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Leading); - public FluentLayout CenterXOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.CenterX); + public FluentLayout CenterXOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.CenterX); - public FluentLayout CenterYOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.CenterY); + public FluentLayout CenterYOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.CenterY); - public FluentLayout HeightOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Height); + public FluentLayout HeightOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Height); - public FluentLayout WidthOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Width); + public FluentLayout WidthOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.Width); - public FluentLayout TrailingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TrailingMargin); + public FluentLayout TrailingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TrailingMargin); - public FluentLayout LeadingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.LeadingMargin); + public FluentLayout LeadingMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.LeadingMargin); - public FluentLayout TopMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TopMargin); + public FluentLayout TopMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.TopMargin); - public FluentLayout BottomMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.BottomMargin); + public FluentLayout BottomMarginOf(NSObject view2) => SetSecondItem(view2, NSLayoutAttribute.BottomMargin); - private FluentLayout SetSecondItem(NSObject view2, NSLayoutAttribute attribute2) - { - ThrowIfSecondItemAlreadySet(); - SecondAttribute = attribute2; - SecondItem = view2; - return this; - } + private FluentLayout SetSecondItem(NSObject view2, NSLayoutAttribute attribute2) + { + ThrowIfSecondItemAlreadySet(); + SecondAttribute = attribute2; + SecondItem = view2; + return this; + } - private void ThrowIfSecondItemAlreadySet() - { - if (SecondItem != null) - throw new Exception("You cannot set the second item in a layout relation more than once"); - } + private void ThrowIfSecondItemAlreadySet() + { + if (SecondItem != null) + throw new Exception("You cannot set the second item in a layout relation more than once"); + } - [Obsolete("This method will be removed in future versions, please let us know if you still need it!")] - public IEnumerable ToLayoutConstraints() - { - yield return Constraint.Value; - } + [Obsolete("This method will be removed in future versions, please let us know if you still need it!")] + public IEnumerable ToLayoutConstraints() + { + yield return Constraint.Value; } } \ No newline at end of file diff --git a/Cirrious.FluentLayout/NfloatExtensions.cs b/Cirrious.FluentLayout/NfloatExtensions.cs deleted file mode 100644 index fa98f5d..0000000 --- a/Cirrious.FluentLayout/NfloatExtensions.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace System -{ - internal static class NfloatExtensions - { - public static nfloat GetValueOrDefault(this nfloat? value) => value.GetValueOrDefault(0); - - public static nfloat GetValueOrDefault(this nfloat? value, nfloat defaultValue) => value ?? defaultValue; - } -} - diff --git a/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs b/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs index 8cbf816..043fe6a 100644 --- a/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs +++ b/Cirrious.FluentLayout/RowSet-WorkInProgress/RowSet.cs @@ -1,162 +1,155 @@ -namespace Cirrious.FluentLayouts.Touch.RowSet +namespace Cirrious.FluentLayouts.Touch.RowSet; + +public class RowSetTemplate { - public class RowSetTemplate - { - public float TopMargin { get; set; } - public float BottomMargin { get; set; } - public float VInterspacing { get; set; } + public float TopMargin { get; set; } + public float BottomMargin { get; set; } + public float VInterspacing { get; set; } - public IEnumerable Generate(UIView container, params Row[] rows) + public IEnumerable Generate(UIView container, params Row[] rows) + { + for (var i = 0; i < rows.Length; i++) { - for (var i = 0; i < rows.Length; i++) - { - var verticalGenerators = new List>(); + var verticalGenerators = new List>(); - var isFirst = i == 0; - if (isFirst) - verticalGenerators.Add(view => view.AtTopOf(container, TopMargin)); - else - { - var previousRowView = rows[i - 1].Views.First(); - verticalGenerators.Add(view => view.Below(previousRowView, VInterspacing)); - } - - var isLast = i == rows.Length - 1; - if (isLast) - verticalGenerators.Add(view => view.AtBottomOf(container, BottomMargin)); + var isFirst = i == 0; + if (isFirst) + verticalGenerators.Add(view => view.AtTopOf(container, TopMargin)); + else + { + var previousRowView = rows[i - 1].Views.First(); + verticalGenerators.Add(view => view.Below(previousRowView, VInterspacing)); + } - foreach (var view in rows[i].Views) - { - foreach (var verticalGenerator in verticalGenerators) - yield return verticalGenerator(view); - } + var isLast = i == rows.Length - 1; + if (isLast) + verticalGenerators.Add(view => view.AtBottomOf(container, BottomMargin)); - foreach (var horizontalConstraint in rows[i].Template.Generate(container, rows[i].Views.ToArray())) - yield return horizontalConstraint; + foreach (var view in rows[i].Views) + { + foreach (var verticalGenerator in verticalGenerators) + yield return verticalGenerator(view); } + + foreach (var horizontalConstraint in rows[i].Template.Generate(container, rows[i].Views.ToArray())) + yield return horizontalConstraint; } } +} - public class Row +public class Row +{ + public Row(IRowTemplate rowTemplate, params UIView[] views) { - public Row() - { - } + Template = rowTemplate; + Views = views; + } - public Row(IRowTemplate rowTemplate, params UIView[] views) - { - Template = rowTemplate; - Views = views; - } + public IRowTemplate Template { get; set; } - public IRowTemplate Template { get; set; } - public IEnumerable Views { get; set; } - } + public IEnumerable Views { get; set; } +} + +public interface IRowTemplate +{ + IEnumerable Generate(UIView container, params UIView[] views); +} - public interface IRowTemplate +public class RowTemplate : IRowTemplate +{ + public float LeftMargin { get; set; } + public float RightMargin { get; set; } + public float HInterspacing { get; set; } + + public class Column { - IEnumerable Generate(UIView container, params UIView[] views); + public static readonly Column Default = new WeightedWidthColumn(); } - public class RowTemplate : IRowTemplate + public class FixedWidthColumn + : Column { - public float LeftMargin { get; set; } - public float RightMargin { get; set; } - public float HInterspacing { get; set; } + public float Width { get; set; } - public class Column + public FixedWidthColumn(float width) { - public static readonly Column Default = new WeightedWidthColumn(); + Width = width; } + } - public class FixedWidthColumn - : Column - { - public float Width { get; set; } + public class WeightedWidthColumn + : Column + { + public float Weight { get; set; } - public FixedWidthColumn(float width) - { - Width = width; - } + public WeightedWidthColumn(float weight = 1.0f) + { + Weight = weight; } + } - public class WeightedWidthColumn - : Column - { - public float Weight { get; set; } + private readonly Dictionary _columnDefinitions = new Dictionary(); - public WeightedWidthColumn(float weight = 1.0f) - { - Weight = weight; - } - } + public void ColumnWidth(int position, float width) + { + _columnDefinitions[position] = new FixedWidthColumn(width); + } - private readonly Dictionary _columnDefinitions = new Dictionary(); + public void ColumnWeight(int position, float weight) + { + _columnDefinitions[position] = new WeightedWidthColumn(weight); + } - public void ColumnWidth(int position, float width) - { - _columnDefinitions[position] = new FixedWidthColumn(width); - } + public IEnumerable Generate(UIView container, params UIView[] views) + { + WeightedWidthColumn? firstWeightedColumn = default; + UIView? firstWeightedView = default; - public void ColumnWeight(int position, float weight) + for (var i = 0; i < views.Length; i++) { - _columnDefinitions[position] = new WeightedWidthColumn(weight); - } + var view = views[i]; + var column = GetColumn(i); - public IEnumerable Generate(UIView container, params UIView[] views) - { - WeightedWidthColumn firstWeightedColumn = null; - UIView firstWeightedView = null; + if (i == 0) + { + yield return view.AtLeftOf(container, LeftMargin); + } + else + { + yield return view.ToRightOf(views[i - 1], HInterspacing); + } - for (var i = 0; i < views.Length; i++) + if (i == views.Length - 1) { - var view = views[i]; - var column = GetColumn(i); + yield return view.AtRightOf(container, RightMargin); + } - if (i == 0) + if (column is WeightedWidthColumn weightedColumn) + { + if (firstWeightedColumn == null) { - yield return view.AtLeftOf(container, LeftMargin); + firstWeightedColumn = weightedColumn; + firstWeightedView = view; } else { - yield return view.ToRightOf(views[i - 1], HInterspacing); - } - - if (i == views.Length - 1) - { - yield return view.AtRightOf(container, RightMargin); - } - - var weightedColumn = column as WeightedWidthColumn; - if (weightedColumn != null) - { - if (firstWeightedColumn == null) - { - firstWeightedColumn = weightedColumn; - firstWeightedView = view; - } - else - { - var multiplier = weightedColumn.Weight / firstWeightedColumn.Weight; - yield return view.WithRelativeWidth(firstWeightedView, multiplier); - } + var multiplier = weightedColumn.Weight / firstWeightedColumn.Weight; + yield return view.WithRelativeWidth(firstWeightedView!, multiplier); } + } - var fixedColumn = column as FixedWidthColumn; - if (fixedColumn != null) - { - yield return view.Width().EqualTo(fixedColumn.Width); - } + if (column is FixedWidthColumn fixedColumn) + { + yield return view.Width().EqualTo(fixedColumn.Width); } } + } - private Column GetColumn(int index) - { - Column column; - if (_columnDefinitions.TryGetValue(index, out column)) - return column; + private Column GetColumn(int index) + { + if (_columnDefinitions.TryGetValue(index, out var column)) + return column; - return Column.Default; - } + return Column.Default; } } diff --git a/QuickLayout.sln b/QuickLayout.sln index 1d5b138..b601fcd 100644 --- a/QuickLayout.sln +++ b/QuickLayout.sln @@ -1,7 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLayout.Core", "QuickLayout.Core\QuickLayout.Core.csproj", "{849AFB57-994A-42D9-A786-EF34FC951CDE}" +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickLayout.Core", "QuickLayout.Core\QuickLayout.Core.csproj", "{849AFB57-994A-42D9-A786-EF34FC951CDE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuickLayout.Touch", "QuickLayout.Touch\QuickLayout.Touch.csproj", "{5739EE87-45C0-496A-8388-A09CDB906501}" EndProject @@ -27,6 +29,31 @@ Global Release|Mixed Platforms = Release|Mixed Platforms EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Mixed Platforms.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Mixed Platforms.Build.0 = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Any CPU.Build.0 = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Mixed Platforms.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Mixed Platforms.Build.0 = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Any CPU.Build.0 = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|iPhone.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {5739EE87-45C0-496A-8388-A09CDB906501}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone {5739EE87-45C0-496A-8388-A09CDB906501}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone {5739EE87-45C0-496A-8388-A09CDB906501}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone @@ -41,7 +68,7 @@ Global {5739EE87-45C0-496A-8388-A09CDB906501}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator {5739EE87-45C0-496A-8388-A09CDB906501}.AppStore|Mixed Platforms.ActiveCfg = AppStore|iPhone {5739EE87-45C0-496A-8388-A09CDB906501}.AppStore|Mixed Platforms.Build.0 = AppStore|iPhone - {5739EE87-45C0-496A-8388-A09CDB906501}.Debug|Any CPU.ActiveCfg = Debug|iPhone + {5739EE87-45C0-496A-8388-A09CDB906501}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5739EE87-45C0-496A-8388-A09CDB906501}.Debug|iPhone.ActiveCfg = Debug|iPhone {5739EE87-45C0-496A-8388-A09CDB906501}.Debug|iPhone.Build.0 = Debug|iPhone {5739EE87-45C0-496A-8388-A09CDB906501}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator @@ -80,36 +107,14 @@ Global {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Mixed Platforms.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Ad-Hoc|Mixed Platforms.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Any CPU.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|iPhone.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Mixed Platforms.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.AppStore|Mixed Platforms.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Any CPU.Build.0 = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|iPhone.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {849AFB57-994A-42D9-A786-EF34FC951CDE}.Release|Mixed Platforms.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = QuickLayout.Touch\QuickLayout.Touch.csproj EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E15DDE52-BCF6-4379-A6E0-0DE62C109B84} + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = QuickLayout.Touch\QuickLayout.Touch.csproj + EndGlobalSection EndGlobal From e7d26ce2154b5eb6596c95e1f531aca342b88fa1 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:55:16 +0500 Subject: [PATCH 04/11] back to xamarin.ios for demo projects --- QuickLayout.Core/QuickLayout.Core.csproj | 17 +- QuickLayout.Touch/QuickLayout.Touch.csproj | 254 +++++++++++++-------- 2 files changed, 164 insertions(+), 107 deletions(-) diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index b02e4e0..a564551 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,8 +1,11 @@ - - - net6 - - - - + + + + + netstandard2.0 + 7.1 + + + + \ No newline at end of file diff --git a/QuickLayout.Touch/QuickLayout.Touch.csproj b/QuickLayout.Touch/QuickLayout.Touch.csproj index 377417a..205a9d1 100644 --- a/QuickLayout.Touch/QuickLayout.Touch.csproj +++ b/QuickLayout.Touch/QuickLayout.Touch.csproj @@ -1,101 +1,155 @@ - - - net6.0-ios - Exe - enable - true - 10.0 - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - None - true - i386, x86_64 - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - false - None - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - true - iPhone Developer - - - - - ARMv7 - - - none - true - bin\iPhone\Release - prompt - 4 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - iPhone Distribution - True - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - iPhone Distribution - - - - - ARMv7 - - - - 6.4.0 - - - 6.4.0 - - - - - {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} - Cirrious.FluentLayouts.Touch - false - false - - - {849AFB57-994A-42D9-A786-EF34FC951CDE} - QuickLayout.Core - - + + + + Debug + iPhoneSimulator + {5739EE87-45C0-496A-8388-A09CDB906501} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + QuickLayout.Touch + Resources + QuickLayoutTouch + Xamarin.iOS + v1.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + None + true + i386, x86_64 + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + true + iPhone Developer + + + + + ARMv7 + + + none + true + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + iPhone Distribution + True + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + iPhone Distribution + + + + + ARMv7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6.4.0 + + + 6.4.0 + + + + + {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} + Cirrious.FluentLayouts.Touch + + + {849AFB57-994A-42D9-A786-EF34FC951CDE} + QuickLayout.Core + + + + + + + + false + + + false + + + false + + + false + + + false + + + \ No newline at end of file From 57a15773aead7adbc227c430b319694677a76362 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:57:28 +0500 Subject: [PATCH 05/11] Revert "back to xamarin.ios for demo projects" This reverts commit e7d26ce2154b5eb6596c95e1f531aca342b88fa1. --- QuickLayout.Core/QuickLayout.Core.csproj | 17 +- QuickLayout.Touch/QuickLayout.Touch.csproj | 254 ++++++++------------- 2 files changed, 107 insertions(+), 164 deletions(-) diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index a564551..b02e4e0 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,11 +1,8 @@ - - - - - netstandard2.0 - 7.1 - - - - + + + net6 + + + + \ No newline at end of file diff --git a/QuickLayout.Touch/QuickLayout.Touch.csproj b/QuickLayout.Touch/QuickLayout.Touch.csproj index 205a9d1..377417a 100644 --- a/QuickLayout.Touch/QuickLayout.Touch.csproj +++ b/QuickLayout.Touch/QuickLayout.Touch.csproj @@ -1,155 +1,101 @@ - - - - Debug - iPhoneSimulator - {5739EE87-45C0-496A-8388-A09CDB906501} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - QuickLayout.Touch - Resources - QuickLayoutTouch - Xamarin.iOS - v1.0 - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - None - true - i386, x86_64 - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - false - None - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - true - iPhone Developer - - - - - ARMv7 - - - none - true - bin\iPhone\Release - prompt - 4 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - iPhone Distribution - True - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - iPhone Distribution - - - - - ARMv7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6.4.0 - - - 6.4.0 - - - - - {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} - Cirrious.FluentLayouts.Touch - - - {849AFB57-994A-42D9-A786-EF34FC951CDE} - QuickLayout.Core - - - - - - - - false - - - false - - - false - - - false - - - false - - - + + + net6.0-ios + Exe + enable + true + 10.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + None + true + i386, x86_64 + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + true + iPhone Developer + + + + + ARMv7 + + + none + true + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + iPhone Distribution + True + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + iPhone Distribution + + + + + ARMv7 + + + + 6.4.0 + + + 6.4.0 + + + + + {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} + Cirrious.FluentLayouts.Touch + false + false + + + {849AFB57-994A-42D9-A786-EF34FC951CDE} + QuickLayout.Core + + \ No newline at end of file From 83fb6004d9895d7ce111d7814d501c99865b5f37 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:58:06 +0500 Subject: [PATCH 06/11] revert code cleanup --- .../FluentLayoutExtensions.cs | 26 +-- Cirrious.FluentLayout/Margins.cs | 2 +- .../UIViewAndLayoutAttribute.cs | 9 +- .../Services/CalculationService.cs | 2 +- .../AdvancedVerticalStackViewModel.cs | 6 +- .../ViewModels/BaseDetailsViewModel.cs | 24 +-- .../ViewModels/DetailsViewModel.cs | 4 +- .../ViewModels/DirectionFormViewModel.cs | 8 +- QuickLayout.Core/ViewModels/FirstViewModel.cs | 18 +-- .../ViewModels/FullSizeViewModel.cs | 8 +- .../ViewModels/SearchViewModel.cs | 4 +- .../ViewModels/UpdateConstraintsViewModel.cs | 44 +++--- QuickLayout.Touch/AppDelegate.cs | 3 + QuickLayout.Touch/LinkerPleaseInclude.cs | 8 +- QuickLayout.Touch/Main.cs | 4 +- .../Views/AdvancedVerticalStackView.cs | 148 +++++++++--------- QuickLayout.Touch/Views/DetailsView.cs | 30 ++-- QuickLayout.Touch/Views/DirectionFormView.cs | 91 ++++++----- QuickLayout.Touch/Views/FirstView.cs | 84 +++++----- QuickLayout.Touch/Views/FormGridView.cs | 36 +++-- QuickLayout.Touch/Views/FormView.cs | 16 +- QuickLayout.Touch/Views/FullSizeView.cs | 105 +++++++------ QuickLayout.Touch/Views/RightToLeftView.cs | 16 +- QuickLayout.Touch/Views/SearchView.cs | 4 + QuickLayout.Touch/Views/TipView.cs | 12 +- .../Views/ToCenterConstraintsView.cs | 5 +- .../Views/UpdateConstraintsView.cs | 107 +++++++------ .../Views/ViewWithSafeAreaView.cs | 10 +- 28 files changed, 452 insertions(+), 382 deletions(-) diff --git a/Cirrious.FluentLayout/FluentLayoutExtensions.cs b/Cirrious.FluentLayout/FluentLayoutExtensions.cs index 46f8817..6c7f3b4 100644 --- a/Cirrious.FluentLayout/FluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/FluentLayoutExtensions.cs @@ -5,6 +5,10 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com +using System.Collections.Generic; +using System.Linq; +using UIKit; + namespace Cirrious.FluentLayouts.Touch { public static class FluentLayoutExtensions @@ -21,7 +25,7 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute Right(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Right); - public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); + public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); public static UIViewAndLayoutAttribute Bottom(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Bottom); @@ -41,26 +45,26 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute WithLayoutAttribute(this UIView view, NSLayoutAttribute attribute) => new UIViewAndLayoutAttribute(view, attribute); - public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); + public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); - public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); + public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); - public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); + public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); - public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); + public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); - public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); + public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); public static void AddConstraints(this UIView view, IEnumerable fluentLayouts) => - view.AddConstraints(fluentLayouts + view.AddConstraints(fluentLayouts .Where(fluent => fluent != null) - .Select(fluent => fluent.Constraint.Value) + .Select(fluent => fluent.Constraint.Value) .ToArray()); - public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); + public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); - public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => - view.RemoveConstraints(fluentLayouts + public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => + view.RemoveConstraints(fluentLayouts .Where(fluent => fluent != null) .Select(fluent => fluent.Constraint.Value) .ToArray()); diff --git a/Cirrious.FluentLayout/Margins.cs b/Cirrious.FluentLayout/Margins.cs index 5779831..ce2d60e 100644 --- a/Cirrious.FluentLayout/Margins.cs +++ b/Cirrious.FluentLayout/Margins.cs @@ -40,7 +40,7 @@ public Margins(float allHorizontal, float allVertical) HSpacing = allHorizontal; } - public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) + public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) { Top = top; Bottom = bottom; diff --git a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs index c6a041a..308bcc0 100644 --- a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs +++ b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs @@ -5,6 +5,9 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com +using UIKit; +using System; + namespace Cirrious.FluentLayouts.Touch { public class UIViewAndLayoutAttribute @@ -18,13 +21,13 @@ public UIViewAndLayoutAttribute(UIView view, NSLayoutAttribute attribute) public UIView View { get; } public NSLayoutAttribute Attribute { get; } - public FluentLayout EqualTo(nfloat constant = default(nfloat)) => + public FluentLayout EqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.Equal, constant); - public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.GreaterThanOrEqual, constant); - public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.LessThanOrEqual, constant); } } \ No newline at end of file diff --git a/QuickLayout.Core/Services/CalculationService.cs b/QuickLayout.Core/Services/CalculationService.cs index c92bede..cdef2d5 100644 --- a/QuickLayout.Core/Services/CalculationService.cs +++ b/QuickLayout.Core/Services/CalculationService.cs @@ -2,6 +2,6 @@ { public class CalculationService : ICalculationService { - public double TipAmount(double subTotal, int generosity) => (generosity * subTotal) / 100.0; + public double TipAmount(double subTotal, int generosity) => (generosity*subTotal)/100.0; } } \ No newline at end of file diff --git a/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs b/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs index 7a43b67..0945804 100644 --- a/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs +++ b/QuickLayout.Core/ViewModels/AdvancedVerticalStackViewModel.cs @@ -1,6 +1,6 @@ namespace QuickLayout.Core.ViewModels { - public class AdvancedVerticalStackViewModel : BaseDetailsViewModel - { - } + public class AdvancedVerticalStackViewModel : BaseDetailsViewModel + { + } } diff --git a/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs b/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs index d30e019..abfbb56 100644 --- a/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs +++ b/QuickLayout.Core/ViewModels/BaseDetailsViewModel.cs @@ -2,47 +2,47 @@ namespace QuickLayout.Core.ViewModels { - public abstract class BaseDetailsViewModel + public abstract class BaseDetailsViewModel : MvxViewModel { private string firstName = "Mvvm"; public string FirstName - { + { get { return firstName; } set { firstName = value; RaisePropertyChanged(() => FirstName); } } private string _lastName = "Cross"; - public string LastName - { + public string LastName + { get { return _lastName; } set { _lastName = value; RaisePropertyChanged(() => LastName); } } private string _number = "12"; - public string Number - { + public string Number + { get { return _number; } set { _number = value; RaisePropertyChanged(() => Number); } } private string _street = "Strathmore"; - public string Street - { + public string Street + { get { return _street; } set { _street = value; RaisePropertyChanged(() => Street); } } private string _town = "Teddington"; - public string Town - { + public string Town + { get { return _town; } set { _town = value; RaisePropertyChanged(() => Town); } } private string _zip = "TW12 2SA"; - public string Zip - { + public string Zip + { get { return _zip; } set { _zip = value; RaisePropertyChanged(() => Zip); } } diff --git a/QuickLayout.Core/ViewModels/DetailsViewModel.cs b/QuickLayout.Core/ViewModels/DetailsViewModel.cs index 9599a03..8a1c56f 100644 --- a/QuickLayout.Core/ViewModels/DetailsViewModel.cs +++ b/QuickLayout.Core/ViewModels/DetailsViewModel.cs @@ -1,7 +1,7 @@ namespace QuickLayout.Core.ViewModels { - public class DetailsViewModel - : BaseDetailsViewModel + public class DetailsViewModel + : BaseDetailsViewModel { } } diff --git a/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs b/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs index 63edab0..0a1d6d3 100644 --- a/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs +++ b/QuickLayout.Core/ViewModels/DirectionFormViewModel.cs @@ -1,7 +1,7 @@ namespace QuickLayout.Core.ViewModels { - public class DirectionFormViewModel - : BaseDetailsViewModel - { - } + public class DirectionFormViewModel + : BaseDetailsViewModel + { + } } \ No newline at end of file diff --git a/QuickLayout.Core/ViewModels/FirstViewModel.cs b/QuickLayout.Core/ViewModels/FirstViewModel.cs index 96db470..da13501 100644 --- a/QuickLayout.Core/ViewModels/FirstViewModel.cs +++ b/QuickLayout.Core/ViewModels/FirstViewModel.cs @@ -20,15 +20,15 @@ public FirstViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigat public void GoSearch() => NavigationService.Navigate(); - public void GoTip() => NavigationService.Navigate(); - - public void GoUpdateConstraints() => NavigationService.Navigate(); - - public void GoAdvancedVerticalStack() => NavigationService.Navigate(); - - public void GoFullSize() => NavigationService.Navigate(); - - public void GoDirectionForm() => NavigationService.Navigate(); + public void GoTip() => NavigationService.Navigate(); + + public void GoUpdateConstraints() => NavigationService.Navigate(); + + public void GoAdvancedVerticalStack() => NavigationService.Navigate(); + + public void GoFullSize() => NavigationService.Navigate(); + + public void GoDirectionForm() => NavigationService.Navigate(); public void GoRightToLeft() => NavigationService.Navigate(); diff --git a/QuickLayout.Core/ViewModels/FullSizeViewModel.cs b/QuickLayout.Core/ViewModels/FullSizeViewModel.cs index 8c34b44..a670632 100644 --- a/QuickLayout.Core/ViewModels/FullSizeViewModel.cs +++ b/QuickLayout.Core/ViewModels/FullSizeViewModel.cs @@ -2,8 +2,8 @@ namespace QuickLayout.Core.ViewModels { - public class FullSizeViewModel - : MvxViewModel - { - } + public class FullSizeViewModel + : MvxViewModel + { + } } diff --git a/QuickLayout.Core/ViewModels/SearchViewModel.cs b/QuickLayout.Core/ViewModels/SearchViewModel.cs index 37ff9da..fdb62ca 100644 --- a/QuickLayout.Core/ViewModels/SearchViewModel.cs +++ b/QuickLayout.Core/ViewModels/SearchViewModel.cs @@ -6,8 +6,8 @@ public class SearchViewModel : MvxViewModel { private string _searchText = "Here"; - public string SearchText - { + public string SearchText + { get { return _searchText; } set { _searchText = value; RaisePropertyChanged(() => SearchText); } } diff --git a/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs b/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs index c3af016..1ac9d96 100644 --- a/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs +++ b/QuickLayout.Core/ViewModels/UpdateConstraintsViewModel.cs @@ -3,28 +3,28 @@ namespace QuickLayout.Core.ViewModels { public class UpdateConstraintsViewModel : MvxViewModel - { - private bool _active = true; - public bool Active - { - get { return _active; } - set - { - _active = value; - RaisePropertyChanged(() => Active); - } - } + { + private bool _active = true; + public bool Active + { + get { return _active; } + set + { + _active = value; + RaisePropertyChanged(() => Active); + } + } - private float _constant = 200; - public float Constant - { - get { return _constant; } - set - { - _constant = value; - RaisePropertyChanged(() => Constant); - } - } - } + private float _constant = 200; + public float Constant + { + get { return _constant; } + set + { + _constant = value; + RaisePropertyChanged(() => Constant); + } + } + } } diff --git a/QuickLayout.Touch/AppDelegate.cs b/QuickLayout.Touch/AppDelegate.cs index f255bf2..ea9a946 100644 --- a/QuickLayout.Touch/AppDelegate.cs +++ b/QuickLayout.Touch/AppDelegate.cs @@ -1,3 +1,6 @@ +using Foundation; +using MvvmCross.Platforms.Ios.Core; + namespace QuickLayout.Touch { [Register("AppDelegate")] diff --git a/QuickLayout.Touch/LinkerPleaseInclude.cs b/QuickLayout.Touch/LinkerPleaseInclude.cs index 0d14cae..8a25390 100644 --- a/QuickLayout.Touch/LinkerPleaseInclude.cs +++ b/QuickLayout.Touch/LinkerPleaseInclude.cs @@ -1,8 +1,12 @@ +using System; +using System.Collections.Specialized; +using System.Windows.Input; +using Foundation; using MvvmCross.Binding.BindingContext; using MvvmCross.Navigation; +using MvvmCross.Platforms.Ios.Views; using MvvmCross.ViewModels; -using System.Collections.Specialized; -using System.Windows.Input; +using UIKit; namespace QuickLayout.Touch { diff --git a/QuickLayout.Touch/Main.cs b/QuickLayout.Touch/Main.cs index 22784b0..e1ffca5 100644 --- a/QuickLayout.Touch/Main.cs +++ b/QuickLayout.Touch/Main.cs @@ -1,4 +1,6 @@ -namespace QuickLayout.Touch +using UIKit; + +namespace QuickLayout.Touch { public class Application { diff --git a/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs b/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs index d3624b7..2acfedd 100644 --- a/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs +++ b/QuickLayout.Touch/Views/AdvancedVerticalStackView.cs @@ -1,89 +1,93 @@ -using Cirrious.FluentLayouts.Touch; -using MvvmCross.Binding.BindingContext; -using ObjCRuntime; -using QuickLayout.Core.ViewModels; +using System.Collections.Generic; using System.Reflection; +using Cirrious.FluentLayouts.Touch; +using UIKit; +using Foundation; +using QuickLayout.Core.ViewModels; +using ObjCRuntime; +using MvvmCross.Platforms.Ios.Views; +using MvvmCross.Binding.BindingContext; namespace QuickLayout.Touch { [Register("AdvancedVerticalStackView")] - public class AdvancedVerticalStackView : MvxViewController - { - public override void ViewDidLoad() - { - var scrollView = new UIScrollView() - { - BackgroundColor = UIColor.White, - ShowsHorizontalScrollIndicator = false, - AutoresizingMask = UIViewAutoresizing.FlexibleHeight, - }; - View = scrollView; - scrollView.TranslatesAutoresizingMaskIntoConstraints = true; - base.ViewDidLoad(); + public class AdvancedVerticalStackView : MvxViewController + { + public override void ViewDidLoad() + { + var scrollView = new UIScrollView() + { + BackgroundColor = UIColor.White, + ShowsHorizontalScrollIndicator = false, + AutoresizingMask = UIViewAutoresizing.FlexibleHeight, + }; + View = scrollView; + scrollView.TranslatesAutoresizingMaskIntoConstraints = true; + base.ViewDidLoad(); - // ios7 layout - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; + // ios7 layout + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; - var set = this.CreateBindingSet(); + var set = this.CreateBindingSet(); - var topMargins = new List(); - var leftMargins = new List(); - var rightMargins = new List(); + var topMargins = new List(); + var leftMargins = new List(); + var rightMargins = new List(); - foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) - { - if (propertyInfo.PropertyType != typeof(string)) - continue; + foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) + { + if (propertyInfo.PropertyType != typeof (string)) + continue; - topMargins.Add(20); - leftMargins.Add(0); - rightMargins.Add(0); - var introLabel = new UILabel - { - Text = propertyInfo.Name + ":", - TranslatesAutoresizingMaskIntoConstraints = false, - }; - Add(introLabel); + topMargins.Add(20); + leftMargins.Add(0); + rightMargins.Add(0); + var introLabel = new UILabel + { + Text = propertyInfo.Name + ":", + TranslatesAutoresizingMaskIntoConstraints = false, + }; + Add(introLabel); - topMargins.Add(0); - leftMargins.Add(25); - rightMargins.Add(25); - var textField = new UITextField - { - BorderStyle = UITextBorderStyle.RoundedRect, - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.LightGray - }; - Add(textField); + topMargins.Add(0); + leftMargins.Add(25); + rightMargins.Add(25); + var textField = new UITextField + { + BorderStyle = UITextBorderStyle.RoundedRect, + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.LightGray + }; + Add(textField); - topMargins.Add(0); - leftMargins.Add(40); - rightMargins.Add(40); - var label = new UILabel - { - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.Yellow, - TextAlignment = UITextAlignment.Center - }; - Add(label); + topMargins.Add(0); + leftMargins.Add(40); + rightMargins.Add(40); + var label = new UILabel + { + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.Yellow, + TextAlignment = UITextAlignment.Center + }; + Add(label); - set.Bind(label).To(propertyInfo.Name); - set.Bind(textField).To(propertyInfo.Name); - } - set.Apply(); + set.Bind(label).To(propertyInfo.Name); + set.Bind(textField).To(propertyInfo.Name); + } + set.Apply(); - var marginMultiplier = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 2 : 1; + var marginMultiplier = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 2 : 1; - var constraints = View.AdvancedVerticalStackPanelConstraints( - new Margins(20, 10, 20, 10, 5, 5), - leftMargins.ToArray(), - topMargins.ToArray(), - rightMargins.ToArray(), - marginMultiplier, - View.Subviews); - View.AddConstraints(constraints); - } - } + var constraints = View.AdvancedVerticalStackPanelConstraints( + new Margins(20, 10, 20, 10, 5, 5), + leftMargins.ToArray(), + topMargins.ToArray(), + rightMargins.ToArray(), + marginMultiplier, + View.Subviews); + View.AddConstraints(constraints); + } + } } diff --git a/QuickLayout.Touch/Views/DetailsView.cs b/QuickLayout.Touch/Views/DetailsView.cs index 9543509..9897322 100644 --- a/QuickLayout.Touch/Views/DetailsView.cs +++ b/QuickLayout.Touch/Views/DetailsView.cs @@ -1,8 +1,12 @@ +using System.Reflection; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; -using ObjCRuntime; +using MvvmCross.Platforms.Ios.Views; +using UIKit; +using Foundation; using QuickLayout.Core.ViewModels; -using System.Reflection; +using ObjCRuntime; +using Cirrious.FluentLayouts; namespace QuickLayout.Touch.Views { @@ -12,11 +16,11 @@ public class DetailsView : MvxViewController public override void ViewDidLoad() { var scrollView = new UIScrollView() - { - BackgroundColor = UIColor.White, - ShowsHorizontalScrollIndicator = false, - AutoresizingMask = UIViewAutoresizing.FlexibleHeight, - }; + { + BackgroundColor = UIColor.White, + ShowsHorizontalScrollIndicator = false, + AutoresizingMask = UIViewAutoresizing.FlexibleHeight, + }; View = scrollView; scrollView.TranslatesAutoresizingMaskIntoConstraints = true; base.ViewDidLoad(); @@ -29,7 +33,7 @@ public override void ViewDidLoad() foreach (var propertyInfo in typeof(DetailsViewModel).GetProperties(BindingFlags.Instance | BindingFlags.Public)) { - if (propertyInfo.PropertyType != typeof(string)) + if (propertyInfo.PropertyType != typeof (string)) continue; var introLabel = new UILabel @@ -39,11 +43,11 @@ public override void ViewDidLoad() }; Add(introLabel); var textField = new UITextField - { - BorderStyle = UITextBorderStyle.RoundedRect, - TranslatesAutoresizingMaskIntoConstraints = false, - BackgroundColor = UIColor.LightGray - }; + { + BorderStyle = UITextBorderStyle.RoundedRect, + TranslatesAutoresizingMaskIntoConstraints = false, + BackgroundColor = UIColor.LightGray + }; Add(textField); var label = new UILabel { diff --git a/QuickLayout.Touch/Views/DirectionFormView.cs b/QuickLayout.Touch/Views/DirectionFormView.cs index d53c73d..904df56 100644 --- a/QuickLayout.Touch/Views/DirectionFormView.cs +++ b/QuickLayout.Touch/Views/DirectionFormView.cs @@ -1,10 +1,17 @@ +using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; +using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; using ObjCRuntime; +using UIKit; + +using QuickLayout.Core.ViewModels; namespace QuickLayout.Touch.Views { - [Register("DirectionFormView")] - public class DirectionFormView : MvxViewController + [Register("DirectionFormView")] + public class DirectionFormView : MvxViewController { public override void ViewDidLoad() { @@ -15,67 +22,67 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var x = View.Center.X; - var y = View.Center.Y; + var x = View.Center.X; + var y = View.Center.Y; - var east = new UILabel { Text = "East" }; - Add(east); + var east = new UILabel {Text = "East"}; + Add(east); - var west = new UILabel { Text = "West" }; - Add(west); + var west = new UILabel {Text = "West"}; + Add(west); - var north = new UILabel { Text = "North" }; - Add(north); + var north = new UILabel {Text = "North"}; + Add(north); - var south = new UILabel { Text = "South" }; - Add(south); + var south = new UILabel {Text = "South"}; + Add(south); - var northEast = new UILabel { Text = "NorthEast" }; - Add(northEast); + var northEast = new UILabel {Text = "NorthEast"}; + Add(northEast); - var northWest = new UILabel { Text = "NorthWest" }; - Add(northWest); + var northWest = new UILabel {Text = "NorthWest"}; + Add(northWest); - var southEast = new UILabel { Text = "SouthEast" }; - Add(southEast); + var southEast = new UILabel {Text = "SouthEast"}; + Add(southEast); - var southWest = new UILabel { Text = "SouthWest" }; - Add(southWest); + var southWest = new UILabel {Text = "SouthWest"}; + Add(southWest); - var center = new UILabel { Text = "Center" }; - Add(center); + var center = new UILabel {Text = "Center"}; + Add(center); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - + View.AddConstraints( - west.ToLeftMargin(View), - west.WithSameCenterY(View), + west.ToLeftMargin(View), + west.WithSameCenterY(View), - east.ToRightMargin(View), - east.WithSameCenterY(View), + east.ToRightMargin(View), + east.WithSameCenterY(View), - north.ToTopMargin(View), - north.WithSameCenterX(View), + north.ToTopMargin(View), + north.WithSameCenterX(View), - south.ToBottomMargin(View), - south.WithSameCenterX(View), + south.ToBottomMargin(View), + south.WithSameCenterX(View), - northWest.ToLeftMargin(View), - northWest.ToTopMargin(View), + northWest.ToLeftMargin(View), + northWest.ToTopMargin(View), - northEast.ToRightMargin(View), - northEast.ToTopMargin(View), + northEast.ToRightMargin(View), + northEast.ToTopMargin(View), - southWest.ToLeftMargin(View), - southWest.ToBottomMargin(View), + southWest.ToLeftMargin(View), + southWest.ToBottomMargin(View), - southEast.ToRightMargin(View), - southEast.ToBottomMargin(View), + southEast.ToRightMargin(View), + southEast.ToBottomMargin(View), - center.WithSameCenterX(View), - center.WithSameCenterY(View) - ); + center.WithSameCenterX(View), + center.WithSameCenterY(View) + ); } } } \ No newline at end of file diff --git a/QuickLayout.Touch/Views/FirstView.cs b/QuickLayout.Touch/Views/FirstView.cs index e19df94..7ee8c7d 100644 --- a/QuickLayout.Touch/Views/FirstView.cs +++ b/QuickLayout.Touch/Views/FirstView.cs @@ -1,15 +1,19 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; +using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; +using MvvmCross.Platforms.Ios.Presenters.Attributes; namespace QuickLayout.Touch.Views { - [Register("FirstView")] + [Register("FirstView")] [MvxRootPresentation(WrapInNavigationController = true)] public class FirstView : MvxViewController { - private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea, _viewCenterConstraints; + private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea, _viewCenterConstraints; public override void ViewDidLoad() { @@ -20,41 +24,41 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - _viewForm = new UIButton(UIButtonType.RoundedRect); - _viewForm.SetTitle("Form", UIControlState.Normal); - Add(_viewForm); + _viewForm = new UIButton(UIButtonType.RoundedRect); + _viewForm.SetTitle("Form", UIControlState.Normal); + Add(_viewForm); - _viewFormGrid = new UIButton(UIButtonType.RoundedRect); - _viewFormGrid.SetTitle("FormGrid", UIControlState.Normal); - Add(_viewFormGrid); + _viewFormGrid = new UIButton(UIButtonType.RoundedRect); + _viewFormGrid.SetTitle("FormGrid", UIControlState.Normal); + Add(_viewFormGrid); - _viewDetails = new UIButton(UIButtonType.RoundedRect); - _viewDetails.SetTitle("Details", UIControlState.Normal); - Add(_viewDetails); + _viewDetails = new UIButton(UIButtonType.RoundedRect); + _viewDetails.SetTitle("Details", UIControlState.Normal); + Add(_viewDetails); - _viewSearch = new UIButton(UIButtonType.RoundedRect); - _viewSearch.SetTitle("Search", UIControlState.Normal); - Add(_viewSearch); + _viewSearch = new UIButton(UIButtonType.RoundedRect); + _viewSearch.SetTitle("Search", UIControlState.Normal); + Add(_viewSearch); - _viewTip = new UIButton(UIButtonType.RoundedRect); - _viewTip.SetTitle("Tip", UIControlState.Normal); - Add(_viewTip); + _viewTip = new UIButton(UIButtonType.RoundedRect); + _viewTip.SetTitle("Tip", UIControlState.Normal); + Add(_viewTip); - _viewUpdateConstaints = new UIButton(UIButtonType.RoundedRect); - _viewUpdateConstaints.SetTitle("Update Live Constraints", UIControlState.Normal); - Add(_viewUpdateConstaints); + _viewUpdateConstaints = new UIButton(UIButtonType.RoundedRect); + _viewUpdateConstaints.SetTitle("Update Live Constraints", UIControlState.Normal); + Add(_viewUpdateConstaints); - _viewAdvancedVerticalStack = new UIButton(UIButtonType.RoundedRect); - _viewAdvancedVerticalStack.SetTitle("Advanced Vertical Stack Panel", UIControlState.Normal); - Add(_viewAdvancedVerticalStack); + _viewAdvancedVerticalStack = new UIButton(UIButtonType.RoundedRect); + _viewAdvancedVerticalStack.SetTitle("Advanced Vertical Stack Panel", UIControlState.Normal); + Add(_viewAdvancedVerticalStack); - _fullSize = new UIButton(UIButtonType.RoundedRect); - _fullSize.SetTitle("Full Size (animated)", UIControlState.Normal); - Add(_fullSize); + _fullSize = new UIButton(UIButtonType.RoundedRect); + _fullSize.SetTitle("Full Size (animated)", UIControlState.Normal); + Add(_fullSize); - _directionFormView = new UIButton(UIButtonType.RoundedRect); - _directionFormView.SetTitle("Directions", UIControlState.Normal); - Add(_directionFormView); + _directionFormView = new UIButton(UIButtonType.RoundedRect); + _directionFormView.SetTitle("Directions", UIControlState.Normal); + Add(_directionFormView); _rightToLeft = new UIButton(UIButtonType.RoundedRect); _rightToLeft.SetTitle("Right-To-Left Support", UIControlState.Normal); @@ -68,25 +72,25 @@ public override void ViewDidLoad() _viewCenterConstraints.SetTitle("View Contraining to centers", UIControlState.Normal); Add(_viewCenterConstraints); - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); var set = this.CreateBindingSet(); - set.Bind(_viewForm).To("GoForm"); - set.Bind(_viewFormGrid).To("GoFormGrid"); - set.Bind(_viewDetails).To("GoDetails"); - set.Bind(_viewSearch).To("GoSearch"); - set.Bind(_viewTip).To("GoTip"); - set.Bind(_viewUpdateConstaints).To("GoUpdateConstraints"); - set.Bind(_viewAdvancedVerticalStack).To("GoAdvancedVerticalStack"); - set.Bind(_fullSize).To("GoFullSize"); - set.Bind(_directionFormView).To("GoDirectionForm"); + set.Bind(_viewForm).To("GoForm"); + set.Bind(_viewFormGrid).To("GoFormGrid"); + set.Bind(_viewDetails).To("GoDetails"); + set.Bind(_viewSearch).To("GoSearch"); + set.Bind(_viewTip).To("GoTip"); + set.Bind(_viewUpdateConstaints).To("GoUpdateConstraints"); + set.Bind(_viewAdvancedVerticalStack).To("GoAdvancedVerticalStack"); + set.Bind(_fullSize).To("GoFullSize"); + set.Bind(_directionFormView).To("GoDirectionForm"); set.Bind(_rightToLeft).To("GoRightToLeft"); set.Bind(_viewSafeArea).To("GoViewWithSafeArea"); set.Bind(_viewCenterConstraints).To("GoCenterConstraints"); set.Apply(); var constraints = View.VerticalStackPanelConstraints( - new Margins(20, 10, 20, 10, 5, 5), + new Margins(20, 10, 20, 10, 5, 5), View.Subviews); View.AddConstraints(constraints); } diff --git a/QuickLayout.Touch/Views/FormGridView.cs b/QuickLayout.Touch/Views/FormGridView.cs index a7868f3..d53751b 100644 --- a/QuickLayout.Touch/Views/FormGridView.cs +++ b/QuickLayout.Touch/Views/FormGridView.cs @@ -1,6 +1,10 @@ +using System.Drawing; using Cirrious.FluentLayouts.Touch; using Cirrious.FluentLayouts.Touch.RowSet; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; +using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; @@ -28,7 +32,7 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var _forceTheWidthView = new UIView() { BackgroundColor = UIColor.Clear }; + var _forceTheWidthView = new UIView() {BackgroundColor = UIColor.Clear}; Add(_forceTheWidthView); var fNameLabel = new UILabel { Text = "First" }; @@ -83,23 +87,23 @@ public override void ViewDidLoad() View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); var rowSet = new RowSetTemplate() - { - TopMargin = 10f, - BottomMargin = 20f, - VInterspacing = 10f - }; + { + TopMargin = 10f, + BottomMargin = 20f, + VInterspacing = 10f + }; var equalWeightRowTemplate = new RowTemplate() - { - HInterspacing = 12f, - LeftMargin = 6f, - RightMargin = 24f - }; + { + HInterspacing = 12f, + LeftMargin = 6f, + RightMargin = 24f + }; var addressRowTemplate = new RowTemplate() - { - HInterspacing = 12f, - LeftMargin = 6f, - RightMargin = 24f - }; + { + HInterspacing = 12f, + LeftMargin = 6f, + RightMargin = 24f + }; addressRowTemplate.ColumnWeight(0, 0.3f); var townAndZipRowTemplate = new RowTemplate() { diff --git a/QuickLayout.Touch/Views/FormView.cs b/QuickLayout.Touch/Views/FormView.cs index e7acd36..69865ef 100644 --- a/QuickLayout.Touch/Views/FormView.cs +++ b/QuickLayout.Touch/Views/FormView.cs @@ -1,6 +1,10 @@ +using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; using ObjCRuntime; +using UIKit; using QuickLayout.Core.ViewModels; @@ -18,22 +22,22 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var fNameLabel = new UILabel { Text = "First" }; + var fNameLabel = new UILabel {Text = "First"}; Add(fNameLabel); - var sNameLabel = new UILabel { Text = "Last" }; + var sNameLabel = new UILabel {Text = "Last"}; Add(sNameLabel); - var numberLabel = new UILabel { Text = "#" }; + var numberLabel = new UILabel {Text = "#"}; Add(numberLabel); - var streetLabel = new UILabel { Text = "Street" }; + var streetLabel = new UILabel {Text = "Street"}; Add(streetLabel); - var townLabel = new UILabel { Text = "Town" }; + var townLabel = new UILabel {Text = "Town"}; Add(townLabel); - var zipLabel = new UILabel { Text = "Zip" }; + var zipLabel = new UILabel {Text = "Zip"}; Add(zipLabel); var fNameField = new UITextField() { BackgroundColor = UIColor.LightGray, BorderStyle = UITextBorderStyle.RoundedRect }; diff --git a/QuickLayout.Touch/Views/FullSizeView.cs b/QuickLayout.Touch/Views/FullSizeView.cs index f91370f..adb7bca 100644 --- a/QuickLayout.Touch/Views/FullSizeView.cs +++ b/QuickLayout.Touch/Views/FullSizeView.cs @@ -1,56 +1,61 @@ -using Cirrious.FluentLayouts.Touch; +using System; +using System.Collections.Generic; +using Cirrious.FluentLayouts.Touch; +using Foundation; +using MvvmCross.Platforms.Ios.Views; using ObjCRuntime; +using UIKit; namespace QuickLayout.Touch.Views { [Register("FullSizeView")] - public class FullSizeView : MvxViewController - { - private IEnumerable _cyanLayouts; - - public override void ViewDidLoad() - { - View.BackgroundColor = UIColor.White; - base.ViewDidLoad(); - - // ios7 layout - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; - - var cyan = new UIView { BackgroundColor = UIColor.Cyan }; - var red = new UIView { BackgroundColor = UIColor.Red }; - var yellow = new UIView { BackgroundColor = UIColor.Yellow }; - var brown = new UIView { BackgroundColor = UIColor.Brown }; - var green = new UIView { BackgroundColor = UIColor.Green }; - var clickMe = new UILabel { Text = "Tap me", TextAlignment = UITextAlignment.Center }; - - View.AddSubviews(cyan, red, yellow, brown, green, clickMe); - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - - _cyanLayouts = cyan.FullSizeOf(View, 20); - - View.AddConstraints(_cyanLayouts); - View.AddConstraints(red.FullSizeOf(cyan, new Margins(10, 30))); - View.AddConstraints(yellow.FullSizeOf(red, 5)); - View.AddConstraints(brown.FullSizeOf(yellow, new Margins(20, 40, 50, 10))); - View.AddConstraints(green.FullSizeOf(brown, 10)); - View.AddConstraints( - clickMe.WithSameCenterX(green), - clickMe.WithSameCenterY(green) - ); - - View.AddGestureRecognizer(new UITapGestureRecognizer(AnimateRandom)); - } - - private void AnimateRandom() - { - var random = new Random(); - _cyanLayouts.GetLayoutById("Top").Constant = random.Next(5, 150); - _cyanLayouts.GetLayoutById("Bottom").Constant = random.Next(-150, -5); - _cyanLayouts.GetLayoutById("Left").Constant = random.Next(5, 50); - _cyanLayouts.GetLayoutById("Right").Constant = random.Next(-50, -5); - - UIView.Animate(0.3, View.LayoutIfNeeded); - } - } + public class FullSizeView : MvxViewController + { + private IEnumerable _cyanLayouts; + + public override void ViewDidLoad() + { + View.BackgroundColor = UIColor.White; + base.ViewDidLoad(); + + // ios7 layout + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; + + var cyan = new UIView { BackgroundColor = UIColor.Cyan }; + var red = new UIView { BackgroundColor = UIColor.Red }; + var yellow = new UIView { BackgroundColor = UIColor.Yellow }; + var brown = new UIView { BackgroundColor = UIColor.Brown }; + var green = new UIView { BackgroundColor = UIColor.Green }; + var clickMe = new UILabel { Text = "Tap me", TextAlignment = UITextAlignment.Center }; + + View.AddSubviews(cyan, red, yellow, brown, green, clickMe); + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + + _cyanLayouts = cyan.FullSizeOf(View, 20); + + View.AddConstraints(_cyanLayouts); + View.AddConstraints(red.FullSizeOf(cyan, new Margins(10, 30))); + View.AddConstraints(yellow.FullSizeOf(red, 5)); + View.AddConstraints(brown.FullSizeOf(yellow, new Margins(20, 40, 50, 10))); + View.AddConstraints(green.FullSizeOf(brown, 10)); + View.AddConstraints( + clickMe.WithSameCenterX(green), + clickMe.WithSameCenterY(green) + ); + + View.AddGestureRecognizer(new UITapGestureRecognizer(AnimateRandom)); + } + + private void AnimateRandom() + { + var random = new Random(); + _cyanLayouts.GetLayoutById("Top").Constant = random.Next(5, 150); + _cyanLayouts.GetLayoutById("Bottom").Constant = random.Next(-150, -5); + _cyanLayouts.GetLayoutById("Left").Constant = random.Next(5, 50); + _cyanLayouts.GetLayoutById("Right").Constant = random.Next(-50, -5); + + UIView.Animate(0.3, View.LayoutIfNeeded); + } + } } diff --git a/QuickLayout.Touch/Views/RightToLeftView.cs b/QuickLayout.Touch/Views/RightToLeftView.cs index e1a4f21..8436214 100644 --- a/QuickLayout.Touch/Views/RightToLeftView.cs +++ b/QuickLayout.Touch/Views/RightToLeftView.cs @@ -1,9 +1,13 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; using ObjCRuntime; +using UIKit; using QuickLayout.Core.ViewModels; using System.Runtime.InteropServices; +using System; namespace QuickLayout.Touch.Views { @@ -24,22 +28,22 @@ public override void ViewDidLoad() if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) EdgesForExtendedLayout = UIRectEdge.None; - var fNameLabel = new UILabel { Text = "First" }; + var fNameLabel = new UILabel {Text = "First"}; Add(fNameLabel); - var sNameLabel = new UILabel { Text = "Last" }; + var sNameLabel = new UILabel {Text = "Last"}; Add(sNameLabel); - var numberLabel = new UILabel { Text = "#" }; + var numberLabel = new UILabel {Text = "#"}; Add(numberLabel); - var streetLabel = new UILabel { Text = "Street" }; + var streetLabel = new UILabel {Text = "Street"}; Add(streetLabel); - var townLabel = new UILabel { Text = "Town" }; + var townLabel = new UILabel {Text = "Town"}; Add(townLabel); - var zipLabel = new UILabel { Text = "Zip" }; + var zipLabel = new UILabel {Text = "Zip"}; Add(zipLabel); var fNameField = new UITextField() { BackgroundColor = UIColor.LightGray, BorderStyle = UITextBorderStyle.RoundedRect }; diff --git a/QuickLayout.Touch/Views/SearchView.cs b/QuickLayout.Touch/Views/SearchView.cs index 35c2b92..47e6555 100644 --- a/QuickLayout.Touch/Views/SearchView.cs +++ b/QuickLayout.Touch/Views/SearchView.cs @@ -1,5 +1,9 @@ +using Cirrious.FluentLayouts; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; +using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; diff --git a/QuickLayout.Touch/Views/TipView.cs b/QuickLayout.Touch/Views/TipView.cs index 796c7d4..c98afee 100644 --- a/QuickLayout.Touch/Views/TipView.cs +++ b/QuickLayout.Touch/Views/TipView.cs @@ -1,5 +1,9 @@ +using System.Drawing; using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using Foundation; +using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; @@ -22,10 +26,10 @@ public override void ViewDidLoad() Add(subTotal); var seek = new UISlider() - { - MinValue = 0, - MaxValue = 100, - }; + { + MinValue = 0, + MaxValue = 100, + }; Add(seek); var seekLabel = new UILabel(); diff --git a/QuickLayout.Touch/Views/ToCenterConstraintsView.cs b/QuickLayout.Touch/Views/ToCenterConstraintsView.cs index 5fad7af..6982695 100644 --- a/QuickLayout.Touch/Views/ToCenterConstraintsView.cs +++ b/QuickLayout.Touch/Views/ToCenterConstraintsView.cs @@ -1,5 +1,8 @@ using Cirrious.FluentLayouts.Touch; +using Foundation; +using MvvmCross.Platforms.Ios.Views; using QuickLayout.Core.ViewModels; +using UIKit; namespace QuickLayout.Touch.Views { @@ -21,7 +24,7 @@ public override void ViewDidLoad() TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = UIColor.Red }, - + thirdContainer = new UIView { TranslatesAutoresizingMaskIntoConstraints = false, diff --git a/QuickLayout.Touch/Views/UpdateConstraintsView.cs b/QuickLayout.Touch/Views/UpdateConstraintsView.cs index fef5386..fcfc38a 100644 --- a/QuickLayout.Touch/Views/UpdateConstraintsView.cs +++ b/QuickLayout.Touch/Views/UpdateConstraintsView.cs @@ -1,61 +1,64 @@ using Cirrious.FluentLayouts.Touch; using MvvmCross.Binding.BindingContext; +using MvvmCross.Platforms.Ios.Views; +using UIKit; using ObjCRuntime; using QuickLayout.Core.ViewModels; +using Foundation; namespace QuickLayout.Touch { - [Register("UpdateConstraintsView")] - public class UpdateConstraintsView : MvxViewController - { - public override void ViewDidLoad() - { - base.ViewDidLoad(); - - View.BackgroundColor = UIColor.White; - - if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) - EdgesForExtendedLayout = UIRectEdge.None; - - var label = new UILabel - { - Text = "Update this label's height constraint height constant and active settings", - BackgroundColor = UIColor.LightGray, - TextColor = UIColor.Black, - LineBreakMode = UILineBreakMode.WordWrap, - Lines = 0 - }; - var toggleHeight = new UISwitch(); - var heightConstant = new UISlider { MinValue = 0, MaxValue = 400 }; - - View.AddSubviews(label, toggleHeight, heightConstant); - - View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); - - var heightLayout = label.Height().EqualTo(ViewModel.Constant).WithIdentifier("foo"); - - var margin = 10; - View.AddConstraints( - heightConstant.AtTopOf(View, margin), - heightConstant.AtLeftOf(View, margin), - heightConstant.AtRightOf(View, margin), - - toggleHeight.Below(heightConstant, margin), - toggleHeight.WithSameLeft(heightConstant), - - label.AtLeftOf(View, margin), - label.Below(toggleHeight, margin), - label.AtRightOf(View, margin), - heightLayout - ); - - var set = this.CreateBindingSet(); - set.Bind(heightLayout).For(layout => layout.Active).To(vm => vm.Active); - set.Bind(heightLayout).For(layout => layout.Constant).To(vm => vm.Constant); - set.Bind(toggleHeight).To(vm => vm.Active); - set.Bind(heightConstant).To(vm => vm.Constant); - set.Apply(); - } - } + [Register("UpdateConstraintsView")] + public class UpdateConstraintsView : MvxViewController + { + public override void ViewDidLoad() + { + base.ViewDidLoad(); + + View.BackgroundColor = UIColor.White; + + if (RespondsToSelector(new Selector("edgesForExtendedLayout"))) + EdgesForExtendedLayout = UIRectEdge.None; + + var label = new UILabel + { + Text = "Update this label's height constraint height constant and active settings", + BackgroundColor = UIColor.LightGray, + TextColor = UIColor.Black, + LineBreakMode = UILineBreakMode.WordWrap, + Lines = 0 + }; + var toggleHeight = new UISwitch(); + var heightConstant = new UISlider { MinValue = 0, MaxValue = 400 }; + + View.AddSubviews(label, toggleHeight, heightConstant); + + View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); + + var heightLayout = label.Height().EqualTo(ViewModel.Constant).WithIdentifier("foo"); + + var margin = 10; + View.AddConstraints( + heightConstant.AtTopOf(View, margin), + heightConstant.AtLeftOf(View, margin), + heightConstant.AtRightOf(View, margin), + + toggleHeight.Below(heightConstant, margin), + toggleHeight.WithSameLeft(heightConstant), + + label.AtLeftOf(View, margin), + label.Below(toggleHeight, margin), + label.AtRightOf(View, margin), + heightLayout + ); + + var set = this.CreateBindingSet(); + set.Bind(heightLayout).For(layout => layout.Active).To(vm => vm.Active); + set.Bind(heightLayout).For(layout => layout.Constant).To(vm => vm.Constant); + set.Bind(toggleHeight).To(vm => vm.Active); + set.Bind(heightConstant).To(vm => vm.Constant); + set.Apply(); + } + } } diff --git a/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs b/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs index 673b710..0a24a80 100644 --- a/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs +++ b/QuickLayout.Touch/Views/ViewWithSafeAreaView.cs @@ -1,4 +1,8 @@ -using Cirrious.FluentLayouts.Touch; +using System; +using Cirrious.FluentLayouts.Touch; +using Foundation; +using MvvmCross.Platforms.Ios.Views; +using UIKit; namespace QuickLayout.Touch.Views { @@ -12,7 +16,7 @@ public override void ViewDidLoad() View.BackgroundColor = UIColor.FromRGB(248, 191, 120); var viewContainer = new UIView { BackgroundColor = UIColor.Clear }; - + var sampleText = new UITextView { Editable = false, @@ -45,7 +49,7 @@ public override void ViewDidLoad() sampleText.AtRightOfSafeArea(viewContainer), //sampleText.AtRightOf(viewContainer), -> if this is used, content overlaps under notch on landscape sampleText.AtBottomOfSafeArea(viewContainer) - //sampleText.AtBottomOf(viewContainer) -> if this is used, content overlaps under notch on landscape + //sampleText.AtBottomOf(viewContainer) -> if this is used, content overlaps under notch on landscape ); } } From 9921510b7580944f79e79deffad47ea13c31942d Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 18:59:20 +0500 Subject: [PATCH 07/11] cleanup fluentlayout only --- .../FluentLayoutExtensions.cs | 26 ++++++++----------- Cirrious.FluentLayout/Margins.cs | 2 +- .../UIViewAndLayoutAttribute.cs | 9 +++---- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Cirrious.FluentLayout/FluentLayoutExtensions.cs b/Cirrious.FluentLayout/FluentLayoutExtensions.cs index 6c7f3b4..46f8817 100644 --- a/Cirrious.FluentLayout/FluentLayoutExtensions.cs +++ b/Cirrious.FluentLayout/FluentLayoutExtensions.cs @@ -5,10 +5,6 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using System.Collections.Generic; -using System.Linq; -using UIKit; - namespace Cirrious.FluentLayouts.Touch { public static class FluentLayoutExtensions @@ -25,7 +21,7 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute Right(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Right); - public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); + public static UIViewAndLayoutAttribute Top(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Top); public static UIViewAndLayoutAttribute Bottom(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Bottom); @@ -45,26 +41,26 @@ public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UI public static UIViewAndLayoutAttribute WithLayoutAttribute(this UIView view, NSLayoutAttribute attribute) => new UIViewAndLayoutAttribute(view, attribute); - public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); + public static UIViewAndLayoutAttribute LeadingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.LeadingMargin); - public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); + public static UIViewAndLayoutAttribute TrailingMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TrailingMargin); - public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); + public static UIViewAndLayoutAttribute TopMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.TopMargin); - public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); + public static UIViewAndLayoutAttribute BottomMargin(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.BottomMargin); - public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); + public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.AddConstraints(fluentLayouts.AsEnumerable()); public static void AddConstraints(this UIView view, IEnumerable fluentLayouts) => - view.AddConstraints(fluentLayouts + view.AddConstraints(fluentLayouts .Where(fluent => fluent != null) - .Select(fluent => fluent.Constraint.Value) + .Select(fluent => fluent.Constraint.Value) .ToArray()); - public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); + public static void RemoveConstraints(this UIView view, params FluentLayout[] fluentLayouts) => view.RemoveConstraints(fluentLayouts.AsEnumerable()); - public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => - view.RemoveConstraints(fluentLayouts + public static void RemoveConstraints(this UIView view, IEnumerable fluentLayouts) => + view.RemoveConstraints(fluentLayouts .Where(fluent => fluent != null) .Select(fluent => fluent.Constraint.Value) .ToArray()); diff --git a/Cirrious.FluentLayout/Margins.cs b/Cirrious.FluentLayout/Margins.cs index ce2d60e..5779831 100644 --- a/Cirrious.FluentLayout/Margins.cs +++ b/Cirrious.FluentLayout/Margins.cs @@ -40,7 +40,7 @@ public Margins(float allHorizontal, float allVertical) HSpacing = allHorizontal; } - public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) + public Margins(float left, float top, float right, float bottom, float hspacing = 0, float vspacing = 0) { Top = top; Bottom = bottom; diff --git a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs index 308bcc0..c6a041a 100644 --- a/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs +++ b/Cirrious.FluentLayout/UIViewAndLayoutAttribute.cs @@ -5,9 +5,6 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com -using UIKit; -using System; - namespace Cirrious.FluentLayouts.Touch { public class UIViewAndLayoutAttribute @@ -21,13 +18,13 @@ public UIViewAndLayoutAttribute(UIView view, NSLayoutAttribute attribute) public UIView View { get; } public NSLayoutAttribute Attribute { get; } - public FluentLayout EqualTo(nfloat constant = default(nfloat)) => + public FluentLayout EqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.Equal, constant); - public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout GreaterThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.GreaterThanOrEqual, constant); - public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => + public FluentLayout LessThanOrEqualTo(nfloat constant = default(nfloat)) => new FluentLayout(View, Attribute, NSLayoutRelation.LessThanOrEqual, constant); } } \ No newline at end of file From 167b82755f0f3ba0d544a7fa7fd6182a318a35c9 Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:06:48 +0500 Subject: [PATCH 08/11] back to xamarin.ios --- QuickLayout.Core/QuickLayout.Core.csproj | 17 +- QuickLayout.Touch/Properties/AssemblyInfo.cs | 36 +++ QuickLayout.Touch/QuickLayout.Touch.csproj | 254 +++++++++++-------- 3 files changed, 200 insertions(+), 107 deletions(-) create mode 100644 QuickLayout.Touch/Properties/AssemblyInfo.cs diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index b02e4e0..a564551 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,8 +1,11 @@ - - - net6 - - - - + + + + + netstandard2.0 + 7.1 + + + + \ No newline at end of file diff --git a/QuickLayout.Touch/Properties/AssemblyInfo.cs b/QuickLayout.Touch/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8f4df83 --- /dev/null +++ b/QuickLayout.Touch/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("QuickLayout.Touch")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("QuickLayout.Touch")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3a84593a-7477-4a43-a4d3-35092b1a79a6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/QuickLayout.Touch/QuickLayout.Touch.csproj b/QuickLayout.Touch/QuickLayout.Touch.csproj index 377417a..290e69b 100644 --- a/QuickLayout.Touch/QuickLayout.Touch.csproj +++ b/QuickLayout.Touch/QuickLayout.Touch.csproj @@ -1,101 +1,155 @@ - - - net6.0-ios - Exe - enable - true - 10.0 - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - None - true - i386, x86_64 - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - false - None - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - true - iPhone Developer - - - - - ARMv7 - - - none - true - bin\iPhone\Release - prompt - 4 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - iPhone Distribution - True - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - iPhone Distribution - - - - - ARMv7 - - - - 6.4.0 - - - 6.4.0 - - - - - {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} - Cirrious.FluentLayouts.Touch - false - false - - - {849AFB57-994A-42D9-A786-EF34FC951CDE} - QuickLayout.Core - - + + + + Debug + iPhoneSimulator + {5739EE87-45C0-496A-8388-A09CDB906501} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + QuickLayout.Touch + Resources + QuickLayoutTouch + Xamarin.iOS + v1.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + None + true + i386, x86_64 + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + true + iPhone Developer + + + + + ARMv7 + + + none + true + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + iPhone Distribution + True + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + iPhone Distribution + + + + + ARMv7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6.4.0 + + + 6.4.0 + + + + + {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} + Cirrious.FluentLayouts.Touch + + + {849AFB57-994A-42D9-A786-EF34FC951CDE} + QuickLayout.Core + + + + + + + + false + + + false + + + false + + + false + + + false + + + \ No newline at end of file From e168bcad564b3305ee17e5fcd637f9ae412ef3ff Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:08:52 +0500 Subject: [PATCH 09/11] xamarin ios --- QuickLayout.Core/QuickLayout.Core.csproj | 11 +- QuickLayout.Touch/Properties/AssemblyInfo.cs | 2 +- QuickLayout.Touch/QuickLayout.Touch.csproj | 304 +++++++++---------- 3 files changed, 162 insertions(+), 155 deletions(-) diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index a564551..873e6cb 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,11 +1,18 @@  + + netstandard2.0 + 7.1 + + + + + netstandard2.0 7.1 - - \ No newline at end of file + \ No newline at end of file diff --git a/QuickLayout.Touch/Properties/AssemblyInfo.cs b/QuickLayout.Touch/Properties/AssemblyInfo.cs index 8f4df83..6c7c12e 100644 --- a/QuickLayout.Touch/Properties/AssemblyInfo.cs +++ b/QuickLayout.Touch/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/QuickLayout.Touch/QuickLayout.Touch.csproj b/QuickLayout.Touch/QuickLayout.Touch.csproj index 290e69b..e8ffcaf 100644 --- a/QuickLayout.Touch/QuickLayout.Touch.csproj +++ b/QuickLayout.Touch/QuickLayout.Touch.csproj @@ -1,155 +1,155 @@  - - Debug - iPhoneSimulator - {5739EE87-45C0-496A-8388-A09CDB906501} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - QuickLayout.Touch - Resources - QuickLayoutTouch - Xamarin.iOS - v1.0 - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - None - true - i386, x86_64 - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - false - None - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - true - iPhone Developer - - - - - ARMv7 - - - none - true - bin\iPhone\Release - prompt - 4 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - iPhone Distribution - True - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - iPhone Distribution - - - - - ARMv7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6.4.0 - - - 6.4.0 - - - - - {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} - Cirrious.FluentLayouts.Touch - - - {849AFB57-994A-42D9-A786-EF34FC951CDE} - QuickLayout.Core - - - - - - - - false - - - false - - - false - - - false - - - false - - - + + Debug + iPhoneSimulator + {5739EE87-45C0-496A-8388-A09CDB906501} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + QuickLayout.Touch + Resources + QuickLayoutTouch + Xamarin.iOS + v1.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + None + true + i386, x86_64 + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + true + iPhone Developer + + + + + ARMv7 + + + none + true + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + iPhone Distribution + True + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + iPhone Distribution + + + + + ARMv7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6.4.0 + + + 6.4.0 + + + + + {75D2DA9D-DFD4-49A1-98FB-FE0F0677EF0F} + Cirrious.FluentLayouts.Touch + + + {849AFB57-994A-42D9-A786-EF34FC951CDE} + QuickLayout.Core + + + + + + + + false + + + false + + + false + + + false + + + false + + + \ No newline at end of file From 3442a8e74c3dbfec283ddd18ad72ad7d39a168be Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:09:41 +0500 Subject: [PATCH 10/11] core --- QuickLayout.Core/QuickLayout.Core.csproj | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index 873e6cb..2559b86 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -1,7 +1,7 @@  - + netstandard2.0 7.1 @@ -9,10 +9,3 @@ - - netstandard2.0 - 7.1 - - - - \ No newline at end of file From 6f57850356bb8fb11ed9d8b69ebd147fc250802d Mon Sep 17 00:00:00 2001 From: Evgeny Valavin <35497422+evgenyvalavin@users.noreply.github.com> Date: Fri, 16 Sep 2022 19:10:02 +0500 Subject: [PATCH 11/11] new line --- QuickLayout.Core/QuickLayout.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/QuickLayout.Core/QuickLayout.Core.csproj b/QuickLayout.Core/QuickLayout.Core.csproj index 2559b86..dca1e5c 100644 --- a/QuickLayout.Core/QuickLayout.Core.csproj +++ b/QuickLayout.Core/QuickLayout.Core.csproj @@ -8,4 +8,4 @@ - + \ No newline at end of file