LeadKit/TIUIElements
Ivan Smolin 5f7e0bf273 feat: Auto documentation generation for `TIFoundationUtils` playground and compile checks for playground before release
`AsyncOperation` fixed ordering of chain operations execution
2023-02-28 14:56:36 +03:00
..
Assets fix: change gif 2021-06-05 12:32:06 +03:00
Sources fix: code review notes 2023-02-13 21:19:35 +03:00
README.md fix: move alerts into TIUIKitCore 2022-07-26 15:09:42 +03:00
TIUIElements.podspec feat: Auto documentation generation for `TIFoundationUtils` playground and compile checks for playground before release 2023-02-28 14:56:36 +03:00

README.md

TIUIElements

Bunch of useful protocols and views:

  • RefreshControl - a basic UIRefreshControl with fixed refresh action.

HeaderTransitionDelegate

Use for transition table header to navigationBar view while scrolling

Your class must implement CollapsibleViewsContainer protocol

HeaderViewHandlerProtocol

public protocol CollapsibleViewsContainer {
    var topHeaderView: UIView? { get } // titleView
    var bottomHeaderView: UIView? { get } // tableHeaderView

    var fixedTopOffet: CGFloat { get } // status bar + nav bar height
}

UIViewController have default realization for fixedTopOffet.

TransitioningHandler

TransitioningHandler Binds animators to the container.

public protocol TransitioningHandler: UIScrollViewDelegate {
    var animator: CollapsibleViewsAnimator? { get set }

    init(collapsibleViewsContainer: CollapsibleViewsContainer)
}

Customization

You can use both the various types of animation already implemented to change the view, or create your own. To create an animator, you need to implement the CollapsibleViewsAnimator protocol.

public protocol CollapsibleViewsAnimator {
   var fractionComplete: CGFloat { get set } // progress of animation
   var currentContentOffset: CGPoint { get set } // offset on content in table view/collection view or plain scroll view
}

Already implemented animators

  • ParalaxAnimator - applies only parallax effect to the header of table
  • ParalaxWithTransitionAnimator - applies parallax effect to the header of table with transition effect down up of the navigationBar titleView
  • TransitionAnimator - applies only transition effect down up of the navigationBar titleView
  • ScaleAnimator - applies only scale effect down up of the navigationBar titleView
  • ParalaxWithScaleAnimator - applies parallax effect to the header of table with scale effect down up of the navigationBar titleView
  • nil(default value) - dont applies any effects

TableViewHeaderTransitioningHandler is the default implementation for TransitioningHandler. It creates an animation action when scrolling the table.

Usage default realization with tableView

class ViewController: UITableViewController, CollapsibleViewsContainer {
    private lazy var handler = TableViewHeaderTransitioningHandler(collapsibleViewsContainer: self)
    
    private lazy var parallaxTableHeaderView = ParallaxTableHeaderView(wrappedView: bottomHeaderView ?? UIView())

    var topHeaderView = SomeCustomTopView()

    var bottomHeaderView = SomeCustomBottomView()

    func addViews() {
        tableView.tableHeaderView = parallaxTableHeaderView
        navigationController?.navigationBar.topItem?.titleView = topHeaderView
    }
    
    func bindViews() {
        handler.animator = ParalaxWithTransitionAnimator(tableHeaderView: parallaxTableHeaderView,
                                                         navBar: navigationController?.navigationBar,
                                                         currentContentOffset: tableView.contentOffset)

        tableView.delegate = self
        tableView.dataSource = self
    }
    
    override func scrollViewDidScroll(_ scrollView: UIScrollView) {
        handler.scrollViewDidScroll(scrollView)
    }
}

Examples

none

onlyParalax

paralaxWithTransition

transition

scale

paralaxWithScale

Installation via SPM

You can install this framework as a target of LeadKit.