Giter VIP home page Giter VIP logo

aloestackview's Introduction

AloeStackView

A simple class for laying out a collection of views with a convenient API, while leveraging the power of Auto Layout.

Carthage compatible Version License Platform

Introduction

AloeStackView is a class that allows a collection of views to be laid out in a vertical or horizontal list. In a broad sense, it is similar to UITableView, however its implementation is quite different and it makes a different set of trade-offs.

AloeStackView focuses first and foremost on making UI very quick, simple, and straightforward to implement. It does this in two ways:

  • It leverages the power of Auto Layout to automatically update the UI when making changes to views.

  • It forgoes some features of UITableView, such as view recycling, in order to achieve a much simpler and safer API.

We've found AloeStackView to be a useful piece of infrastructure and hope you find it useful too!

Table of Contents

Features

  • Allows you to keep strong references to views and dynamically change their properties, while Auto Layout automatically keeps the UI up-to-date.

  • Allows views to be dynamically added, removed, hidden and shown, with optional animation.

  • Includes built-in support for customizable separators between views.

  • Provides an extensible API, allowing specialized features to be added without modifying AloeStackView itself.

  • Widely used and vetted in a highly-trafficked iOS app.

  • Small, easy-to-understand codebase (under 600 lines of code) with no external dependencies keeps binary size increase to a minimum and makes code contributions and debugging painless.

System Requirements

  • Deployment target iOS 9.0+
  • Xcode 10.0+
  • Swift 4.0+

Example App

The repository includes a simple example iOS app.

You can try it out by cloning the repo, opening AloeStackViewExample.xcworkspace, and running the app.

The example app shows a few ways AloeStackView can be used to implement a screen in an iOS app.

Example app

Usage

Creating an AloeStackView

The primary API is accessed via the AloeStackView class.

You can create an instance of AloeStackView quite easily in your code:

import AloeStackView

let stackView = AloeStackView()

AloeStackView is a UIView (specifically a UIScrollView), and thus can be used in the same way as any other view in your app.

Alternatively, if you want to build an entire UIViewController using AloeStackView, you can use the convenient AloeStackViewController class:

import AloeStackView

public class MyViewController: AloeStackViewController {

  public override func viewDidLoad() {
    super.viewDidLoad()
    stackView.addRow(...)
  }

}

AloeStackViewController is very similar to classes such as UITableViewController and UICollectionViewController in that it creates and manages an AloeStackView for you. You can access the AloeStackView via the stackView property. Using AloeStackViewController rather than creating your own AloeStackView inside a UIViewController simply saves you some typing.

Adding, Removing, and Managing Rows

The API of AloeStackView generally deals with "rows". A row can be any UIView that you want to use in your UI.

By default, rows are arranged in a vertical column, and each row stretches the full width of the AloeStackView.

The axis property on AloeStackView can be used to change the orientation. When axis is set to .horizontal, rows are arranged next to each other, left-to-right, and the AloeStackView scrolls horizontally, with each row stretching the full height of the AloeStackView.

To build a UI with AloeStackView, you generally begin by adding the rows that make up your UI:

for i in 1...3 {
  let label = UILabel()
  label.text = "Label \(i)"
  stackView.addRow(label)
}

Add rows

If the length of an AloeStackView ever grows too long for the available screen space, the content automatically becomes scrollable.

Add rows

AloeStackView provides a comprehensive set of methods for managing rows, including inserting rows at the beginning and end, inserting rows above or below other rows, hiding and showing rows, removing rows, and retrieving rows.

You can customize the spacing around a row with the rowInset property, and the setInset(forRow:) and setInset(forRows:) methods.

The class documentation in AloeStackView.swift provides full details of all the APIs available.

Handling User Interaction

AloeStackView provides support for handling tap gestures on a row:

stackView.setTapHandler(
  forRow: label,
  handler: { [weak self] label in
    self?.showAlert(title: "Row Tapped", message: "Tapped on: \(label.text ?? "")")
  })

label.isUserInteractionEnabled = true

Add rows

A tap handler will only fire if isUserInteractionEnabled is true for a row.

Another way of handling tap gestures is to conform to the Tappable protocol:

public class ToggleLabel: UILabel, Tappable {

  public func didTapView() {
    textColor = textColor == .red ? .black : .red
  }

}

for i in 1...3 {
  let label = ToggleLabel()
  label.text = "Label \(i)"
  label.isUserInteractionEnabled = true
  stackView.addRow(label)
}

Add rows

Conforming to Tappable allows common tap gesture handling behavior to be encapsulated inside a view. This way you can reuse a view in an AloeStackView many times, without writing the same tap gesture handling code each time.

Dynamically Changing Row Content

One of the advantages of using AloeStackView is that you can keep a strong reference to a view even after you've added it to an AloeStackView.

If you change a property of a view that affects the layout of the overall UI, AloeStackView will automatically relayout all of its rows:

stackView.setTapHandler(forRow: label, handler: { label in
  label.text = (label.text ?? "") + "\n\nSome more text!"
})

Add rows

As you can see, there's no need to notify AloeStackView before or after making changes to a view. Auto Layout will ensure that the UI remains in an up-to-date state.

Styling and Controlling Separators

AloeStackView adds separators between rows by default:

Add rows

Turning Separators On and Off

You can easily hide separators for any rows that are added to an AloeStackView:

stackView.hidesSeparatorsByDefault = true

Add rows

The hidesSeparatorsByDefault property only applies to new rows that are added. Rows already in the AloeStackView won't be affected.

You can hide or show separators for existing rows with the hideSeparator(forRow:), hideSeparators(forRows:), showSeparator(forRow:), and showSeparators(forRows:) methods.

AloeStackView also provides a convenient property to automatically hide the last separator:

stackView.automaticallyHidesLastSeparator = true

Add rows

Customizing Separators

You can change the spacing on the left and right of separators:

stackView.separatorInset = .zero

Add rows

In vertical orientation, only the left and right properties of separatorInset are used.

In horizontal orientation, separators are displayed vertically between rows. In this case, only the top and bottom properties of separatorInset are used, and they control the spacing on the top and bottom of separators.

As with hidesSeparatorsByDefault, the separatorInset property only applies to new rows that are added. Rows already in the AloeStackView won't be affected.

You can change the separator inset for existing rows with the setSeparatorInset(forRow:) and setSeparatorInset(forRows:) methods.

AloeStackView also provides properties for customizing the color and width (or thickness) of separators:

stackView.separatorColor = .blue
stackView.separatorWidth = 2

Add rows

These properties affect all of the separators in the AloeStackView.

Extending AloeStackView

AloeStackView is an open class, so it's easy to subclass to add custom functionality without changing the original source code. Additionally, AloeStackView provides two methods that can be used to further extend its capabilities.

configureCell(_:)

Every row in an AloeStackView is wrapped in a UIView subclass called StackViewCell. This view is used for per-row bookkeeping and also manages UI such as separators and insets.

Whenever a row is added or inserted into an AloeStackView, the configureCell(_:) method is called. This method is passed the newly created StackViewCell for the row.

You can override this method to perform any customization of cells as needed, for example to support custom features you've added to AloeStackView or control the appearance of rows on the screen.

This method is always called after any default values for the cell have been set, so any changes you make in this method won't be overwritten by the system.

cellForRow(_:)

Whenever a row is inserted into an AloeStackView, the cellForRow(_:) method is called to obtain a new cell for the row. By default, cellForRow(_:) simply returns a new StackViewCell that contains the row passed in.

StackViewCell, however, is an open class that can be subclassed to add custom behavior and functionality as needed. To have AloeStackView use your custom cell, override cellForRow(_:) and return an instance of your custom subclass.

Providing a custom StackViewCell subclass allows much more find-grained control over how rows are displayed. It also allows custom data to be stored along with each row, which can be useful to support any functionality you add to AloeStackView.

One thing to remember is that AloeStackView will apply default values to a cell after it is returned from cellForRow(_:). Hence, if you need to apply any further customizations to your cell, you should consider doing it in configureCell(_:).

When to Extend AloeStackView

These methods together provide quite a lot of flexibility for extending AloeStackView to add custom behavior and functionality.

For example, you can add new methods to AloeStackView to control the way rows are managed, or to support new types of user interaction. You can customize properties on StackViewCell to control the individual appearance of each row. You can subclass StackViewCell to store new data and properties with each row in order to support custom features you add. Subclassing StackViewCell also provides more fine-grained control over how rows are displayed.

However, this flexibility inevitably comes with a trade-off in terms of complexity and maintenance. AloeStackView has a comprehensive API that can support a wide variety of use cases out-of-the-box. Hence, it's often better to see if the behavior you need is available through an existing API before resorting to extending the class to add new features. This can often save time and effort, both in terms of the cost of developing custom functionality as well as ongoing maintenance.

When to use AloeStackView

The Short Answer

AloeStackView is best used for shorter screens with less than a screenful or two of content. It is particularly suited to screens that accept user input, implement forms, or are comprised of a heterogeneous set of views.

However, it's also helpful to dig a bit deeper into the technical details of AloeStackView, as this can help develop a better understanding of appropriate use cases.

More Details

AloeStackView is a very useful tool to have in the toolbox. Its straightforward, flexible API allows you to build UI quickly and easily.

Unlike UITableView and UICollectionView, you can keep strong references to views in an AloeStackView and make changes to them at any point. This will automatically update the entire UI thanks to Auto Layout - there is no need to notify AloeStackView of the changes.

This makes AloeStackView great for use cases such as forms and screens that take user input. In these situations, it's often convenient to keep a strong reference to the fields a user is editing, and directly update the UI with validation feedback.

AloeStackView has no reloadData method, or any way to notify it about changes to your views. This makes it less error-prone and easier to debug than a class like UITableView. For example, AloeStackView won't crash if not notified of changes to the underlying data of the views it manages.

Since AloeStackView uses UIStackView under the hood, it doesn't recycle views as you scroll. This eliminates common bugs caused by not recycling views correctly. You also don't need to independently maintain the state of views as the user interacts with them, which makes it simpler to implement certain kinds of UI.

However, AloeStackView is not suitable in all situations. AloeStackView lays out the entire UI in a single pass when your screen loads. As such, longer screens will start seeing a noticeable delay before the UI is displayed for the first time. This is not a great experience for users and can make an app feel unresponsive to navigation actions. Hence, AloeStackView should not be used when implementing UI with more than a screenful or two of content.

Forgoing view recycling is also a trade-off: while AloeStackView is faster to write UI with and less error-prone, it will perform worse and use more memory for longer screens than a class like UITableView. Hence, AloeStackView is generally not appropriate for screens that contain many views of the same type, all showing similar data. Classes like UITableView or UICollectionView often perform better in those situations.

Installation

AloeStackView can be installed with Carthage. Simply add github "marlimox/AloeStackView" to your Cartfile.

AloeStackView can be installed with CocoaPods. Simply add pod 'AloeStackView' to your Podfile.

Contributions

AloeStackView is feature complete for the use cases it was originally designed to address. However, UI development on iOS is never a solved problem, and we expect new use cases to arise and old bugs to be uncovered.

As such we fully welcome contributions, including new features, feature requests, bug reports, and fixes. If you'd like to contribute, simply push a PR with a description of your changes. You can also file a GitHub Issue for any bug reports or feature requests.

Please feel free to email the project maintainers if you'd like to get in touch. We'd love to hear from you if you or your company has found this library useful!

Maintainers

AloeStackView is developed and maintained by:

Marli Oshlack ([email protected])

Arthur Pang

Contributors

AloeStackView has benefited from the contributions of many other engineers:

Daniel Crampton, Francisco Diaz, David He, Jeff Hodnett, Eric Horacek, Garrett Larson, Jasmine Lee, Isaac Lim, Jacky Lu, Noah Martin, Phil Nachum, Gonzalo Nuñez, Laura Skelton, Cal Stephens, and Ortal Yahdav

In addition, open sourcing this project wouldn't have been possible without the help and support of Jordan Harband, Tyler Hedrick, Michael Bachand, Laura Skelton, Dan Federman, and John Pottebaum.

License

AloeStackView is released under the Apache License 2.0. See LICENSE for details.

Why is it called AloeStackView?

We like succulents and find the name soothing 😉

aloestackview's People

Contributors

alexbredy avatar aloestackview-admin avatar apang42 avatar arlupin avatar colinhumber avatar dfed avatar florianldt avatar fonkadelic avatar jeehut avatar kaunamohammed avatar marlimox avatar tadija avatar thedrick avatar yanamura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aloestackview's Issues

Insert row animation is different to remove row animation

Currently when adding a row to the StackView using insertRow(_ row: UIView, after afterRow: UIView, animated: Bool), the stackview increases the space for the next row without animation, and then animates the alpha of the new row.

Is there a reason why it's not using the same method as the removeRow(_ row: UIView, animated: Bool) function? This is utilising the standard ios stackview animations by simply animating the isHidden property of the UIStackView, providing us with a much smoother animation.

If there is no specific reason why the insert animation doesn't mirror this, I can put up a PR with the changes.

Thanks!

Get access to UIStackview

Hi. I want to use Skeleton animation on AloeStackView. I need stackview to be visible outside its framework. Is it possible to change its modifier to
private(set) public var stackView = UIStackView()

Setting the stack view in a tableHeaderView

Trying to set the stackView as the view of my tableHeaderview, The height becomes 0. See code example below. I tried settings constraints on my headerView, the stackview and even the tableHeaderView but I can't seem to get it to work. Am I overseeing something?

let headerStackView = AloeStackView()
        headerStackView.hidesSeparatorsByDefault = true
        headerStackView.addRow(headerView)
        
  
        tableView.tableHeaderView = headerView // using this works
        tableView.tableHeaderView = headerStackView // using this doesn't

[Feature Suggestion] Reorder cells

It would be incredibly useful for the stackview to be able to enable reordering of cells. I'd suggest an API like UITableView's such as:

stackView.isReorderEnabled = true

This would allow for an interaction like in a tableView drag and drop reorder.

SwiftPM support broken since update to Swift 5 format

When I try to use AloeStackView with SwiftPM, I get this error:

https://github.com/airbnb/AloeStackView.git @ master: error: manifest parse error(s):
/var/folders/4s/rkh28cgs55z2s0cxdsphnfzw0000gn/T/TemporaryFile.3pAAby.swift:8:9: error: type 'SupportedPlatform' has no member 'ios'
       .ios(.v9),

This is indicating that the casing of ios is wrong and should actually be iOS.

Cannot build with `swift build`

When AloeStackView is used as a dependency in a Swift Package, the build fails with:
AloeStackView/AloeStackView.swift:16:8: error: no such module 'UIKit'

It's because Swift Package is universal and so, UIKit might not be available.
The fix is adding code in #if canImport(UIKit) ... #endif block.

Storyboard use?

Great library, thanks for sharing! I hope it inspires Apple to release it natively :)

Is there a way to use this in Storyboard? I pretty much want to use this like watchOS's interface builder; drag and drop items and let it grow in storyboard. Is this possible?

No way to get the RowCount

Currently, there is no functionality in AloeStackView which will give us number of rows present in AloeStackView.
As of now to get the total number of rows I used aloeStackView.getAllRows().count which is not an efficient solution as it always creates a new list of UIView

Embedding TableView as row

Can I embed a UITableView as a row? I am unable to accomplish this currently. The containing AloeStackView seems to ignore the TableView contents. TableView datasource function (func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell) is never called.

Add swipe gesture recognizer

Hi,

I have a plan to use the framework in one of my projects, but I'd like to have an option to handle swipe gestures on "cells". That will allow to make a cell of an "image gallery" kind or something simillar.

I'd suggest adding a swipe recognizer to a StackViewCell class. I can do that and it seems to be relatively easy to do. The only thing to concern is the fact that right now I don't see an option to make a cell be both higlightable and swipable, mostly because of overriden touchesBegan, touchesEnded methods.

Would be glad to hear yout thoughts on that. Thank you.

Want to add it to a VC build with the Storyboard

Hello,
I'm trying to implement your component in one part of my project (in one of the the VC, and I'm using Storyboard)
So one of the VC inherit from AloeStackViewController, but I get the fatalError("init(coder:) has not been implemented")
What should I do to solve the issue ?

Thanks !

Suggested additional features

AloeStackView will be a more powerful library if you provide features that allow contentView to animate views in situations when remove, add, or hidden animation occurs.
I would like to implement this function once.

Layout Issue

While using debug view hierarchy, it is showing "Layout Issues: Scrollable content size is ambiguous for AloeStackView.AloeStackView."

Scrolling always on?

I was trying to use scrollViewDidScroll in order to make a stretchy header, and i could manage to do except that when the header shrinks enough for the scrolling to disappear, the method wont be called anymore and then the header will remain tiny forever cause i can't scroll anymore.

Just wondering, is there anyway i could set isScrollEnabled = true for ever? I've tried setting it up in the same method or in the AloeStackView init, didn't work.

Avoiding Keyboard

enjoying this small but very handy framework a lot. thanks for the effort and making it os.

i wonder if there is a simple built in way to avoid the keyboard or do we have to handle the content insets our own via keyboardWillShowNotification?

adding stackView.addRow(UITextField()) as the last element of your demo shows this issue nicely:
the TextField gets obscured by the keyboard as soon as it becomes the first responder.

  private func setUpRows() {
    setUpDescriptionRow()
    setUpSwitchRow()
    setUpHiddenRows()
    setUpExpandingRowView()
    setUpPhotoRow()

    stackView.addRow(UITextField())
  }

Swift 5 support?

There is some warnings in library, are you planning to fix them?

Adding complex view

It's possible to add complex view like FSCalendar view? I try it but only a small empty row are displayed.

SafeArea insets for offscreen views

There is a problem with safe area insets for embedded views (viewControllers).

How to reproduce (you need phone or simulator with a notch):

  1. Fill stack view with views that take at least one screen in Portrait.
  2. Inside each view put at least one element that depends on safeArea (could be a label)
  3. Rotate to Landscape and scroll to bottom

See, that safe area is correct for those views that were visible and incorrect for those that weren't.

Seems like it's UIKit bug, but maybe you have a workaround for this issue.

the only solution i've found was inspired by this answer on SO:
https://stackoverflow.com/questions/46505999/using-a-stack-view-in-a-scroll-view-and-respecting-safe-area-insets?rq=1

- view
-- scroll view [constrained to superview]
--- view [constrained to superview]
---- stack view [constrained to safeArea]

but in this case you don't have TableView-like behaviour when background takes full width and content is located inside the safe area

safearea_issue

Stackview size

Hi there! --

Following my previous question about auto-layout, I'm wondering how it could be possible to get the actual size of the AloeStackview once all the rows and separators have been laid out.

I'm using them a lot in modal pop-ups and cells to display information. My goal is to have the modal or cell resize to the aloestackview size if I add or remove a row.

Thanks a lot!
Ladislas

Example form implementation?

This library is outstanding, thanks so much for releasing it!

In the readme, you mention one of the use cases for AloeStackView is for forms. That feels like a prime use case to me as well, and I'm working on implementing some forms with it now. Was wondering though - any thoughts on adding some form functionality to the example app? E.g., you have a switch in there already, but I'd like to an example implementation of a form from you all instead of figuring out best practices myself.

An example implementation of
https://github.com/airbnb/AloeStackView/blob/master/Docs/Images/airbnb_app_10.png?raw=true for example I think would be a great addition.

Is this a mini version Epoxy for iOS?

Hello, coming from Android using Epoxy for our views, can AloStackView be considered a small variation of what Epoxy can do ? I read in the docs that this stack view is not suitable for longer screen. So are we going to see another library for iOS that achieve the same as Epoxy in Android? Thanks.

Is this library maintained?

A lot of open PR and issues havent had any comment or reaction. Is this library maintained or should we move on from it?

[Question] Access to the cell

I would like to have access to the cell that contains a row.
I wanted to create an extension similar to this one, but stackView is private.

extension AloeStackView {
    func cell(with row: UIView) -> StackViewCell? {
        return stackView.arrangedSubviews.first(where: { arrangedSubview in
            guard let cell = arrangedSubview as? StackViewCell, cell.contentView == row else { return false }
            return true
        }) as? StackViewCell
    }
}

I want this access because I want to change second cell's topLeft and topRight corner radius.

Is there a way to do what I mentioned without making stackView public? If no, would it be possible to make it public?

Thank you!

Improved touch and tap handling of cells

There are a couple of issues that would be great to see improved:

  • while a content view is highlighted, moving your finger in and out of the cell should adjust the highlight state accordingly. This would be consistent with how highlight states work with UITableViews
  • UIControls within a content view do not receive touches when the tap gesture on the cell is enabled

Carthage build error with Xcode 11.0 beta 4

I just upgraded to Xcode 11.0 beta 4 earlier today, and I'm rebuilding my project (which uses AloeStackView and tracks the master branch) with it now.

From Cartfile.resolved: github "airbnb/AloeStackView" "b64e577e862d74d191e4fd28928dc9fbc29ad43c"

$ carthage build --platform iOS --no-use-binaries
*** xcodebuild output can be found in /var/folders/_2/_jp0qd3j4hl48fz5j8pfwnbr0000gn/T/carthage-xcodebuild.Ophtgw.log

*** Building scheme "AloeStackView" in AloeStackViewExample.xcworkspace
Build Failed
	Task failed with exit code 65:
	/usr/bin/xcrun xcodebuild -workspace /Users/aaron/repos/obakit/Carthage/Checkouts/AloeStackView/Example/AloeStackViewExample.xcworkspace -scheme AloeStackView -configuration Release -derivedDataPath /Users/aaron/Library/Caches/org.carthage.CarthageKit/DerivedData/11.0_11M374r/AloeStackView/06f9a8f4b96cceed09b11edfb57d260712d7e144 -sdk iphoneos ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/_2/_jp0qd3j4hl48fz5j8pfwnbr0000gn/T/AloeStackView SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /Users/aaron/repos/obakit/Carthage/Checkouts/AloeStackView)

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/_2/_jp0qd3j4hl48fz5j8pfwnbr0000gn/T/carthage-xcodebuild.Ophtgw.log

Log file:

carthage-xcodebuild.Ophtgw.log

  • Notably, when I try opening AloeStackView.xcodeproj and building from inside the project, it works fine.
  • I've tried removing the Carthage/Build folder, Carthage's cache files (in ~/Library), and Xcode's derived data, but none of these had an effect.

AloeStackView as subview & Auto-Layout

Hi there! First let me thank you for this great piece of work, I'm using it a lot in my apps and it's great!

I'm having some troubles though with the following settings:

  • I have a UIViewControler
  • in which I add a bunch of views as subviews
  • one of those is an AloeStackView that should fill the bottom part of the window and be scrollable.

I manage to display things the way I want using autolayout but I have a lot of errors in the console.

(
    "<NSAutoresizingMaskLayoutConstraint:0x600003a1e440 h=--& v=--& AloeStackView.AloeStackView:0x7fd89d82ac00.width == 0   (active)>",
    "<NSLayoutConstraint:0x6000039e85a0 UILabel:0x7fd89d760670'Label 0'.leading == UILayoutGuide:0x600002317480'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x6000039e85f0 UILabel:0x7fd89d760670'Label 0'.trailing == UILayoutGuide:0x600002317480'UIViewLayoutMarginsGuide'.trailing   (active)>",
    "<NSLayoutConstraint:0x6000039ecaa0 UIStackView:0x7fd89d45c2f0.width == AloeStackView.AloeStackView:0x7fd89d82ac00.width   (active)>",
    "<NSLayoutConstraint:0x600003a1c370 'UISV-canvas-connection' UIStackView:0x7fd89d45c2f0.leading == AloeStackView.StackViewCell:0x7fd89d76e1b0.leading   (active)>",
    "<NSLayoutConstraint:0x600003a1c3c0 'UISV-canvas-connection' H:[AloeStackView.StackViewCell:0x7fd89d76e1b0]-(0)-|   (active, names: '|':UIStackView:0x7fd89d45c2f0 )>",
    "<NSLayoutConstraint:0x6000039e8410 'UIView-leftMargin-guide-constraint' H:|-(15)-[UILayoutGuide:0x600002317480'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':AloeStackView.StackViewCell:0x7fd89d76e1b0 )>",
    "<NSLayoutConstraint:0x6000039e84b0 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600002317480'UIViewLayoutMarginsGuide']-(15)-|(LTR)   (active, names: '|':AloeStackView.StackViewCell:0x7fd89d76e1b0 )>"
)

As I said, my UI is working but I'm worried about those errors.

How should one setup autolayout for an AloeStackView used as a subview?

Thanks a lot!
Ladislas

Presenting in popover on iOS 13 displays with incorrect insets

On iOS 13, the view that's displayed within a popover now extends to include the popover arrow. As a result, additional safeAreaInsets are applied to include the arrow.

When presenting an AloeStackView in a popover with the arrow pointing left or right, this currently isn't being taken into account. As a result, the cell insets (content and separator) are too close to the edges. I've tracked this down to insetsLayoutMarginsFromSafeArea = false being partially the culprit, as well as the separator leading/trailing constraints not taking the safe area into account.

I haven't seen any visual issues in the sample app, or my own projects with insetsLayoutMarginsFromSafeArea enabled, so I'm not sure if there is a specific reason for this being disabled in the Airbnb app. When I test this out with the default value set (true), everything works as expected (tested on iOS 11, 12, and 13).

I've included a screenshot of the issue on iOS 13. As you can see, the content is too close to the left side of the popover.
image

With insetsLayoutMarginsFromSafeArea enabled and the separators taking the safe area into account, everything looks as expected (tested on iOS 11, 12, and 13).
image

Ignore the switch cell extending off the right hand side. That's not an issue with the stack view, just some internal constraints in one of the sample cells.

[question] Add stackView to container (with Storyboard)

I have a storyboard with a container UIView that I would like to insert AloeStackView. I was looking at this but adding translatesAutoresizingMaskIntoConstraints = false is not working either. Unlike the sample in the issue, I don't need to specify the constraints since I already configured it on the Storyboard. Any ideas why this is not working?

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        view.addSubview(stackView)
        stackView.translatesAutoresizingMaskIntoConstraints = false
        stackView.separatorInset = .zero
        stackView.rowInset = .zero
        setupItems()
    }

    func setupItems() { stackView.addRows(...) }

Sticky Headers

Is there a way to create an effect similar to stick section headers in UITableView?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.