Skip to content

Commit

Permalink
Merge pull request Yalantis#72 from ilyailya/master
Browse files Browse the repository at this point in the history
Add initialiser with default values for SegmentioOptions
  • Loading branch information
AndriiPetrovDev authored Nov 1, 2017
2 parents 3963460 + c67db4e commit b29c320
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions Segmentio/Source/SegmentioOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,17 @@ public struct SegmentioOptions {
var states: SegmentioStates
var animationDuration: CFTimeInterval

public init() {
self.backgroundColor = .lightGray
self.maxVisibleItems = 4
self.scrollEnabled = true

self.horizontalSeparatorOptions = SegmentioHorizontalSeparatorOptions()
self.verticalSeparatorOptions = SegmentioVerticalSeparatorOptions()

self.indicatorOptions = SegmentioIndicatorOptions()

self.imageContentMode = .center
self.labelTextAlignment = .center
self.labelTextNumberOfLines = 0

self.states = SegmentioStates(
defaultState: SegmentioState(),
selectedState: SegmentioState(),
highlightedState: SegmentioState()
)
self.animationDuration = 0.1
}

public init(backgroundColor: UIColor, maxVisibleItems: Int, scrollEnabled: Bool, indicatorOptions: SegmentioIndicatorOptions?, horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions?, verticalSeparatorOptions: SegmentioVerticalSeparatorOptions?, imageContentMode: UIViewContentMode, labelTextAlignment: NSTextAlignment, labelTextNumberOfLines: Int, segmentStates: SegmentioStates, animationDuration: CFTimeInterval) {
public init(backgroundColor: UIColor = .lightGray,
maxVisibleItems: Int = 4,
scrollEnabled: Bool = true,
indicatorOptions: SegmentioIndicatorOptions? = SegmentioIndicatorOptions(),
horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions? = SegmentioHorizontalSeparatorOptions(),
verticalSeparatorOptions: SegmentioVerticalSeparatorOptions? = SegmentioVerticalSeparatorOptions(),
imageContentMode: UIViewContentMode = .center,
labelTextAlignment: NSTextAlignment = .center,
labelTextNumberOfLines: Int = 0,
segmentStates: SegmentioStates = SegmentioStates(defaultState: SegmentioState(), selectedState: SegmentioState(), highlightedState: SegmentioState()),
animationDuration: CFTimeInterval = 0.1) {
self.backgroundColor = backgroundColor
self.maxVisibleItems = maxVisibleItems
self.scrollEnabled = scrollEnabled
Expand All @@ -203,5 +191,4 @@ public struct SegmentioOptions {
self.states = segmentStates
self.animationDuration = animationDuration
}

}

0 comments on commit b29c320

Please sign in to comment.