Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,19 @@ 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);
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<FluentLayout> FullWidthOf(this UIView view, UIView parent, nfloat? margin = null)
{
Expand Down
1 change: 1 addition & 0 deletions QuickLayout.Core/QuickLayout.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Compile Include="ViewModels\FullSizeViewModel.cs" />
<Compile Include="ViewModels\SearchViewModel.cs" />
<Compile Include="ViewModels\TipViewModel.cs" />
<Compile Include="ViewModels\ToCenterConstraintsViewModel.cs" />
<Compile Include="ViewModels\UpdateConstraintsViewModel.cs" />
<Compile Include="ViewModels\AdvancedVerticalStackViewModel.cs" />
<Compile Include="ViewModels\DirectionFormViewModel.cs" />
Expand Down
2 changes: 2 additions & 0 deletions QuickLayout.Core/ViewModels/FirstViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ public class FirstViewModel
public void GoRightToLeft() => ShowViewModel<RightToLeftViewModel>();

public void GoViewWithSafeArea() => ShowViewModel<ViewWithSafeAreaViewModel>();

public void GoCenterConstraints() => ShowViewModel<ToCenterConstraintsViewModel>();
}
}
8 changes: 8 additions & 0 deletions QuickLayout.Core/ViewModels/ToCenterConstraintsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using MvvmCross.Core.ViewModels;

namespace QuickLayout.Core.ViewModels
{
public class ToCenterConstraintsViewModel : MvxViewModel
{
}
}
21 changes: 16 additions & 5 deletions QuickLayout.Touch/QuickLayout.Touch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Setup.cs" />
<Compile Include="Views\ToCenterConstraintsView.cs" />
<Compile Include="Views\DetailsView.cs" />
<Compile Include="Views\FirstView.cs" />
<Compile Include="Views\FormGridView.cs" />
Expand Down Expand Up @@ -159,11 +160,21 @@
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Contents.json" />
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default.png" />
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default%402x.png" />
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Contents.json">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default%402x.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\LaunchImage.launchimage\Default-568h%402x.png">
<Visible>false</Visible>
</ImageAsset>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json">
<Visible>false</Visible>
</ImageAsset>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
7 changes: 6 additions & 1 deletion QuickLayout.Touch/Views/FirstView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace QuickLayout.Touch.Views
[Register("FirstView")]
public class FirstView : MvxViewController
{
private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea;
private UIButton _viewForm, _viewFormGrid, _viewDetails, _viewSearch, _viewTip, _viewUpdateConstaints, _viewAdvancedVerticalStack, _fullSize, _directionFormView, _rightToLeft, _viewSafeArea, _viewCenterConstraints;

public override void ViewDidLoad()
{
Expand Down Expand Up @@ -66,6 +66,10 @@ public override void ViewDidLoad()
_viewSafeArea.SetTitle("View with Safe Area", UIControlState.Normal);
Add(_viewSafeArea);

_viewCenterConstraints = new UIButton(UIButtonType.RoundedRect);
_viewCenterConstraints.SetTitle("View Contraining to centers", UIControlState.Normal);
Add(_viewCenterConstraints);

View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

var set = this.CreateBindingSet<FirstView, FirstViewModel>();
Expand All @@ -80,6 +84,7 @@ public override void ViewDidLoad()
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(
Expand Down
55 changes: 55 additions & 0 deletions QuickLayout.Touch/Views/ToCenterConstraintsView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Cirrious.FluentLayouts.Touch;
using Foundation;
using MvvmCross.iOS.Views;
using QuickLayout.Core.ViewModels;
using UIKit;

namespace QuickLayout.Touch.Views
{
[Register("ToCenterConstraintsView")]
public class ToCenterConstraintsView : MvxViewController<ToCenterConstraintsViewModel>
{
public override void ViewDidLoad()
{

UIView firstContainer = new UIView
{
TranslatesAutoresizingMaskIntoConstraints = false,
BackgroundColor = UIColor.Blue
},

secondContainer = new UIView
{
TranslatesAutoresizingMaskIntoConstraints = false,
BackgroundColor = UIColor.Red
},

thirdContainer = new UIView
{
TranslatesAutoresizingMaskIntoConstraints = false,
BackgroundColor = UIColor.Yellow,
Alpha = .5f
};

View.AddSubviews(firstContainer, secondContainer, thirdContainer);

View.AddConstraints(new FluentLayout[]
{
firstContainer.AtTopOf(View),
firstContainer.AtLeftOf(View),
firstContainer.AboveCenterOf(View, 10f),
firstContainer.ToLeftOfCenterOf(View, 10f),

secondContainer.AtBottomOf(View),
secondContainer.AtRightOf(View),
secondContainer.ToRightOfCenterOf(View, 10f),
secondContainer.BelowCenterOf(View, 10f),

thirdContainer.ToRightOfCenterOf(firstContainer),
thirdContainer.ToLeftOfCenterOf(secondContainer),
thirdContainer.AboveCenterOf(secondContainer),
thirdContainer.BelowCenterOf(firstContainer)
});
}
}
}