Popularity
3.8
Declining
Activity
0.0
Stable
249
5
10

Programming language: Swift
License: GNU General Public License v3.0 or later
Tags: UI    
Latest version: v2.1.2

Family alternatives and similar libraries

Based on the "UI" category.
Alternatively, view Family alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Family or a related project?

Add another 'UI' Library

README

Family logo

CI Status Version Carthage Compatible codecov License Platform Swift

Description

Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful public API, you can build complex layouts without losing maintainability, leaving you to focus on what matters: making your applications pop and your business logic shine.

This framework was built to make it easier to build and maintain parent controllers, also known as flow controllers. Using child view controllers can make your code more modular, flexible and testable. It addresses one of the biggest shortcomings of the vanilla approach: how do you get a continuous scrolling experience while keeping dequeuing intact?

This is where Family framework comes in. With the help of its layout algorithm, all your regular- and scroll views get stacked in the same linear vertical order you add them to the hierarchy. To achieve a continuous scrolling view, your child scroll views no longer scroll themselves, but get their new content offset passed to them by the parent scroll view, which the framework handles for you. The framework also modifies the views' frames on the fly, constraining the height to the window.

The story behind Family

If you are interested in the origin story behind Family, then you can read this Medium article.

Features

  • [x] 🍩Animation support.
  • [x] 🤳🏻Continuous scrolling with multiple scroll views.
  • [x] 📏Margins between child view controllers.
  • [x] 🌀Table view and collection view dequeuing.
  • [x] 🍭Supports custom spacing between views.
  • [x] 📱iOS support.
  • [x] 💻macOS support.
  • [x] 📺tvOS support.

Supporting the project

If you want to support the development of this framework, you can do so by becoming a sponsor. ❤️

Usage

The new public API:

body(withDuration: 0) {
  add(detailViewController)
  .background(.view(backgroundView))
  .padding(.init(top: 20, left: 20, bottom: 20, right: 20))
  .margin(.init(top: 20, left: 0, bottom: 20, right: 0))
}

Add a regular child view controller:

let familyController = FamilyViewController()
let viewController = UIViewController()

familyController.addChild(viewController)

Add a child view controller constrained by height:

let familyController = FamilyViewController()
let viewController = UIViewController()

familyController.addChild(viewController, height: 175)

Add a child view controller with a custom view on the controller:

let familyController = FamilyViewController()
let customController = CustomViewController()

// This will add the scroll view of the custom controller
// instead of the controllers view.
familyController.addChild(customController, view: { $0.scrollView })

Move a view controller:

familyController.moveChild(customController, to: 1)

Perform batch updates (it is encouraged to use performBatchUpdates when updaing more than one view controller):

familyController.performBatchUpdates({ controller in
  controller.addChild(controller1)
  controller.addChild(controller2)
  controller.moveChild(controller2, to: 0)
  controller3.removeFromParent()
})

Adding animations

When adding animations, not that you have to give them a key.

let basicAnimation = CABasicAnimation()
basicAnimation.duration = 0.5
controller.view.layer.add(springAnimation, forKey: "Basic Animations")

let springAnimation = CASpringAnimation()
springAnimation.damping = 0.6
springAnimation.initialVelocity = 0.6
springAnimation.mass = 0.4
springAnimation.duration = 0.6
springAnimation.isRemovedOnCompletion = false
controller.view.layer.add(springAnimation, forKey: "Spring Animations")

Installation

Family is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Family'

and then run

pod install

Family is also available through Carthage. To install just write into your Cartfile:

github "zenangst/Family"

and then run

carthage install

When it's finished, install the built framework (which can be found in the Carthage/Build folder) into your Xcode project.

Family can also be installed manually. Just download and drop Sources folders in your project.

Author

Christoffer Winterkvist, [email protected]

Contributing

We would love you to contribute to Family, check the CONTRIBUTING file for more info.

Credits

License

Family is available under the MIT license. See the LICENSE file for more info.


*Note that all licence references and agreements mentioned in the Family README section above are relevant to that project's source code only.