Vaadin flow AppLayout and full height grid as content - vaadin-flow

I'm currently porting over a vaadin 8 app and wish to use the AppLayout for this. So far everthing is, ok, with one exception.
The AppLayout does not support a full height gri/tree grid as it's main content, as documented in the component guide.
Any work arround this nasty problem?
https://vaadin.com/docs/latest/ds/components/app-layout/#scrolling-behavior
Setting the grid too 100% height and the content to 100% height gives me two scrollbars

To support full height components within App Layout, set its height to 100%.
See the (now updated) documentation for App Layout: https://vaadin.com/docs/latest/ds/components/app-layout/#scrolling-behavior

Related

Two-step auto layout

I am currently building a UI component for an iOS application. Generally, the component is supposed to be 350pt in width, which I set up inside the component using auto layout:
self.widthAnchor.constraint(equalToConstant: 350.0).isActive = true
Now, if there is not enough space (due to other constraints outside of the component), I want the component to become smaller, but not fluidly - I want the component to alternate between two possible sizes only - 350pt normally and 300pt width if there is no room to fit 350pt. Is this achievable somehow?
Example project:
https://www.icloud.com/iclouddrive/055TkWS8aLqDhFDOPi-7qi8EA#LayoutExample.zip
I created a very simplistic example project to illustrate the problem. It contains a custom component (MyComponent), which is a stack view with four buttons. This component is embedded in the main view controller and auto layout is setup to ensure it doesn't flow out of the screen.
This works well on larger devices, but the component is too large for the screen of iPhone SE and iPhone 4. In these cases, I would like the component to become another size (in the project, the component is 500pt regularly and should be 300pt on smaller devices).
Reasons
The reason I am looking for this behaviour are pretty much all design related. This component is not supposed to exist in a variety of sizes, but only in two specific sizes - a "normal" size and a smaller size for cases where the normal size doesn't fit.

Alignment Issue in AutoLayout in IOS Swift

I have 3 sections, Top Banner with Logo, Mapview in the middle and then a few labels under the MapView.
I have used Constraints for accomplishing this for 6s sizes. But when I try this out for 4s, 5, 5s the below section the Labels is not seen on the screen. In design view they are also only partially shown and seems to be somewhere hidden in 4 and 5 ios versions.
I have set height for the Top banner as 0.2 with the SuperView and MapView with 0.4 and trying to get the remaining labels to fill in the remaining 0.4 height of the total SuperView.
I have tried to contain all the labels in a Tableview also this is not even showing anything in Design time or even at runtime.
Another Approach is to Add a view in which place all the labels so that can add a contraint of 0.4 height for the view. But all in vain.
Layout Design :
http://imgur.com/aIjBJsq
I am an iOS and auto layout Noob so it maybe something silly that I might have missed. Appreciate any help or advise on the same
Ok, first it seems that you need a break down of the fundamentals of Auto Layout. Below are some resources that can help you with that. Working with Auto Layout can take quite a bit of effort so you really should get a solid understanding, otherwise you will constantly be running into problems.
Adaptive User Interfaces
Auto Layout Guide
View controllers and adaptivity and size changes
WWDC2012: Auto Layout by Example
WWDC 2015: Mysteries of Auto Layout, Part 1
WWDC 2015: Mysteries of Auto Layout, Part 2
Key to understanding your issues is the role layout constraints play in your design. You use them to make small to medium changes, for bigger changes such as different devices you need to use size classes as well as constraints. In Xcode 8's Interface Builder you have the option to set the device for your layout, see the picture below. It's in the bottom left-hand corner. The device's selection relates to size classes.
So how do we go about solving your issues? We would start by laying out the view for a selected device in interface builder, then we would select another device, say iPhone 4s and then make any adjustments to your view there. This is the basic outline and there are many steps in between. The single best step you can take at this point is to get a better understanding of Interface Builder. Learning how to use interface builder will touch on all the areas covered by the resources listed above.
Interface Builder
wwdc2015: Implementing UI Designs in Interface Builder
I understand this is a broad answer to your question, but I am trying to help you build an understanding of the concepts, so you can happily build your own layouts from here on out!

iOS grid UI control

In XCode Swift Storyboard with auto layout enabled I need to put a row of buttons (let it be 6 buttons) filling screen by width. The buttons must be of the same width, keeping aspect ration the same (so row height will change when screen width changes).
I think that I need to use an UI control like GridLayout in Android, but so far I can't find anything suitable in iOS.
Please advice.
There's nothing in Interface Builder that allows you to do that automatically, that is, without having to position and set constraints for each your buttons yourself. For iOS 9.0, UIStackView might be helpful for you, but until then (and possibly even still) I'd do it programmatically using UICollectionView.

Xcode 6 Do I have to make an application for every screen size?

So I have created my webapplication and when I build it in xcode I have to under "Simulated Metrics" > "Size" set it to 3.5 inch since I have a iPhone 4s.
When I build it and run on the iPhone everything looks perfect, but I want this application to run on iPhone 5/6 aswell, but when I change the size to something else in the Simulated Metrics it gets really messed up on my iPhone. I'm using a webview of my responsive website which shouldn't really care about the screensize but I believe Xcode does. So, is there a solution where xcode automatically detects screensize and makes the webview take the whole viewcontroller? Or do I have to create a application for every screensize?
So, is there a solution where xcode automatically detects screensize
and makes the webview take the whole viewcontroller?
Yes - xcode provides ways to do this. Either through auto layout or using springs and struts. With auto layout you will define a set of rules that your UI will follow. If you want 1 layout for all devices it's fairly straightforward and any tutorial will get you started. with springs and struts you just tell your views how they should grow/stay put depending on screen growing. check this out for a quick introduction to auto layout: http://www.raywenderlich.com/83129/beginning-auto-layout-tutorial-swift-part-1
Or do I have to create a application for every screensize?
Nope.. but you can set different constraints in auto layout for your views to behave very different on different sizes. This gets a little more tricky..
No you do not make a new app for every potential screen size, instead you uses XCode's "auto layout" with a set of "constraints" controlling the size and placement of your widgets. A constraint can be a fixed size for the widget or a given distance relative to another widget (or the parent's border). It is not necessarily a fixed distance, it can also be "my widget needs to be less than 10 pixels apart from this other widget".
The "Simulated Metrics" you refer to in the bottom of the drawing area is only a visual help when laying out you your GUI, it has no effect at runtime. You can safely stick with "Any" width and height.
Read this tutorial to understand XCode's auto layout and constraints:
http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1
Quickly, these are the tools used to setup constraints:
In your case, assuming you have only one big view (your webview), you need to set up 4 constraints stating that the webview's left, right, top and bottom sides are 0 pixels away from the parent's left, right, top and bottom borders respectively:
Lay your webview in the middle of your drawing area
Click on it
Click the "pin" button; you will see this view:
Look at the upper part of the dialog: the small square in the middle represents the view you just clicked and the four red lines represent the distances to the parent's side. Set them all to 0 and click "Add 4 constraints". (Note: the lines are initially dashed when not selected; they turn into solid lines when activated.)
Now the frames in the drawing area do not represent what you were expecting: your webview is still in the middle where you placed it initially and does not fill all the available space; XCode is aware that there is a mismatch between the frames and the constraints and shows a warning. You need to update the frames: click the "issues" button and "update all frames".
The image comes from this question on SO:
What is "Constrain to margin" in Storyboard in Xcode 6
Read it to learn about the "Constraints to margin" switch.

Margin and padding for UI elements in iOS

I have so far developed for Android. There, you can set layoutMargin and padding for almost every UI element (when you describe UI in xml file).
How is this done in code for UIViews in iOS (if there is a common command)?
Tnx
iOS employs a different approach to control placement - there's no layouting engine, you specify absolute coordinates and size for all controls. Kinda like the AbsoluteLayout in Android.
So the concepts of margin and padding don't really apply - the gaps between adjacent controls are completely up to you, they're not computed by the system. Same for sizes.
This makes it more difficult to implement the scenario of "make this control as large as it needs to be for its text". However, you won't run into rogue line wraps.
EDIT: AbsoluteLayout is deprecated these days.
You lay out your UI elements either in code or using Interface Builder (or the .xib editor in Xcode 4). You'll specify actual coordinates for your views, but you can also specify the resizing behavior for each view. So, you can say that a particular view should always keep the same size and remain horizontally centered, or that it should keep it's size and maintain the margin on the left, or that it should stretch to keep both left and right margins, etc. Look for the "autosizing" section in IB, or set the autoresizingMask property of any view in code.
In ios you can use Interface Builder for design. You can still use xml, but no one use this.

Resources