Giter Club home page Giter Club logo

slidecontroller's Introduction

LOGO

Language Build Status codecov.io Version License Platform

SlideController is a simple and flexible UI component fully written in Swift. Built using power of generic types, it is a nice alternative to UIPageViewController.

Horizontal Vertical Carousel

Requirements

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate SlideController into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'SlideController'
end

Then, run the following command:

$ pod install

Usage

import SlideController
  1. Create content
let content = [
            SlideLifeCycleObjectBuilder<PageLifeCycleObject>(),
            SlideLifeCycleObjectBuilder<PageLifeCycleObject>(),
            SlideLifeCycleObjectBuilder<PageLifeCycleObject>()
        ]
  • PageLifeCycleObject is any object conforms to Initializable, Viewable, SlidePageLifeCycle protocols
  1. Initialize SlideController
slideController = SlideController<CustomTitleView, CustomTitleItem>(
    pagesContent: content,
    startPageIndex: 0,
    slideDirection: .horizontal)
  • CustomTitleView is subclass of TitleScrollView<CustomTitleItem>
  • CustomTitleItem is subclass of UIView and conforms to Initializable, ItemViewable, Selectable protocols
  1. Add slideController.view to view hierarchy

  2. Call slideController.viewDidAppear() and slideController.viewDidDisappear() in appropriate UIViewController methods:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    slideController.viewDidAppear()
}
override func viewDidDisappear(_ animated: Bool) {
   super.viewDidDisappear(animated)
   slideController.viewDidDisappear()
}

Documentation

SlideController

Default initializer of SlideController.
pagesContent - initial content of controller, can be empty.
startPageIndex - page index that should be displayed initially.
slideDirection - slide direction. .horizontal or .vertical.

public init(pagesContent: [SlideLifeCycleObjectProvidable],
            startPageIndex: Int = 0,
            slideDirection: SlideDirection)

Returns titleView instanсe of TitleScrollView.

public var titleView: T { get }

Returns LifeCycleObject for currently displayed page.

public var currentModel: SlideLifeCycleObjectProvidable? { get }

Returns array of LifeCycleObject that corresponds to SlideController's content.

public private(set) var content: [SlideLifeCycleObjectProvidable]

When set to true unloads content when it is out of screen bounds. The default value is true.

public var isContentUnloadingEnabled: Bool { get set }

When set to true scrolling in the direction of last item will result jumping to the first item. Makes scrolling infinite. The default value is false.

public var isCarousel: Bool { get set }

If the value of this property is true, content scrolling is enabled, and if it is false, content scrolling is disabled. The default is true.

public var isScrollEnabled: Bool { get set }

Appends pages array of SlideLifeCycleObjectProvidable to the end of sliding content.

public func append(object objects: [SlideLifeCycleObjectProvidable])

Inserts SlideLifeCycleObjectProvidable page object at index in sliding content.

public func insert(object: SlideLifeCycleObjectProvidable, index: Int)

Removes a page at index.

public func removeAtIndex(index: Int)

Slides content to page at pageIndex with sliding animation if animated is set to true. Using forced is not recommended, it will perform shift even if other shift animation in progress or pageIndex equals current page. The default value of animated is true. The default value of forced is false.

public func shift(pageIndex: Int, animated: Bool = default, forced: Bool = default)

Slides content the next page with sliding animation if animated is set to true. The default value of animated is true.

public func showNext(animated: Bool = default)

Lets the SlideController know when it is displayed on the screen. Used for correctly triggering LifeCycle events.

public func viewDidAppear()

Lets the SlideController know when it is not displayed on the screen. Used for correctly triggering LifeCycle events.

public func viewDidDisappear()

TitleScrollView

Alignment of title view. Supports .top, .bottom, .left, .right. The default value of alignment is .top.

public var alignment: SlideController.TitleViewAlignment { get set }

The size of TitleScrollView. For .horizontal slide direction of SlideController the titleSize corresponds to height. For .vertical slide direction of SlideController the titleSize corresponds to width. The default value of titleSize is 84.

open var titleSize: CGFloat { get set }

Array of title items that displayed in TitleScrollView.

open var items: [TitleItem] { get }

slidecontroller's People

Contributors

alexyanski avatar ayanski-touchlane avatar ededovets avatar evgenydedovets avatar olegbolshakov avatar oroom avatar pkandrashkou avatar vadzimmarozau avatar vasileuskivadzim avatar vkondrashkov 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

slidecontroller's Issues

Example improvements

To improve the visual example the following could be added:

  • navigation bar with title describing the functionality.

Content positioned incorrectly after animated shift

What to do?

Shift animated through some pages.

What expected?

The content is scrolled to the destination position.

What happened?

The content is scrolled with a little offset to correct position and later scrolled up.

Example improvements

To improve the visual perception of the horizontal example the following could be changed:

  • do not change text of title items when page was removed;
  • remove current page instead of the first one;

Title item selection follow up

What to do?

Quickly scroll content view.

What expected?

Title item is following up the content scrolling.

What happened?

Title item is not following content scrolling.

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.