commit 47a9dd37983345b0c58051f3fa42c57588a854f5 Author: Dmitriy Demchenko Date: Mon Jul 4 14:46:51 2016 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7b722d --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# OS X +.DS_Store + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ +*.xccheckout +profile +*.moved-aside +DerivedData +*.hmap +*.ipa + +# Bundler +.bundle + +Carthage +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +# Note: if you ignore the Pods directory, make sure to uncomment +# `pod install` in .travis.yml +# +# Pods/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c1c8bc1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +# references: +# * http://www.objc.io/issue-6/travis-ci.html +# * https://github.com/supermarin/xcpretty#usage + +osx_image: xcode7.3 +language: objective-c +# cache: cocoapods +# podfile: Example/Podfile +# before_install: +# - gem install cocoapods # Since Travis is not always on latest version +# - pod install --project-directory=Example +script: +- set -o pipefail && xcodebuild test -workspace Example/Segmentio.xcworkspace -scheme Segmentio-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty +- pod lib lint diff --git a/Example/Podfile b/Example/Podfile new file mode 100644 index 0000000..820a5a7 --- /dev/null +++ b/Example/Podfile @@ -0,0 +1,12 @@ +platform :ios, '8.0' +use_frameworks! + +target 'Segmentio_Example' do + pod 'Segmentio', :path => '../' + + target 'Segmentio_Tests' do + inherit! :search_paths + + + end +end diff --git a/Example/Podfile.lock b/Example/Podfile.lock new file mode 100644 index 0000000..21f86cd --- /dev/null +++ b/Example/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - Segmentio (0.1.0) + +DEPENDENCIES: + - Segmentio (from `../`) + +EXTERNAL SOURCES: + Segmentio: + :path: ../ + +SPEC CHECKSUMS: + Segmentio: 8a27ead74e53d7617c3130eb511ea4c965b0798f + +PODFILE CHECKSUM: 191147ab57f909dd239f59b5bebde4bcab89243e + +COCOAPODS: 1.0.1 diff --git a/Example/Pods/Local Podspecs/Segmentio.podspec.json b/Example/Pods/Local Podspecs/Segmentio.podspec.json new file mode 100644 index 0000000..459212b --- /dev/null +++ b/Example/Pods/Local Podspecs/Segmentio.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "Segmentio", + "version": "0.1.0", + "homepage": "https://github.com/Yalantis/Segmentio", + "summary": "Animated top/bottom segmented control written in Swift!", + "screenshots": "https://raw.githubusercontent.com/Yalantis/Persei/master/Assets/animation.gif", + "authors": "Yalantis", + "license": { + "type": "MIT", + "file": "LICENSE" + }, + "social_media_url": "https://twitter.com/yalantis", + "platforms": { + "ios": "8.0" + }, + "source": { + "git": "https://github.com/Yalantis/Segmentio.git", + "tag": "0.1.0" + }, + "source_files": "Segmentio/Source/**/*.swift", + "module_name": "Segmentio", + "requires_arc": true +} diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock new file mode 100644 index 0000000..21f86cd --- /dev/null +++ b/Example/Pods/Manifest.lock @@ -0,0 +1,16 @@ +PODS: + - Segmentio (0.1.0) + +DEPENDENCIES: + - Segmentio (from `../`) + +EXTERNAL SOURCES: + Segmentio: + :path: ../ + +SPEC CHECKSUMS: + Segmentio: 8a27ead74e53d7617c3130eb511ea4c965b0798f + +PODFILE CHECKSUM: 191147ab57f909dd239f59b5bebde4bcab89243e + +COCOAPODS: 1.0.1 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4392dd4 --- /dev/null +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,739 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 08F3ADCD6D2B9007082089826E712007 /* UIView+Appearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F88F99DAA1420A4448E3F028F0C8E7F /* UIView+Appearance.swift */; }; + 0BC7695D61D9046BFBE6CFD6B47FFFE1 /* Pods-Segmentio_Example-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 556AA0B62BF4398859D56C7F281F05FD /* Pods-Segmentio_Example-dummy.m */; }; + 124C21C2A8B015C1BB87D30F4EEA0214 /* SegmentioCellWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42697752DA8A65CBAB3CC0BB442A8C6 /* SegmentioCellWithImage.swift */; }; + 1B164D4FADAAAD401CDAFB8541C7AC00 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */; }; + 386B142514D75786C9544322094E00BB /* Pods-Segmentio_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F52E8E5326A4E61091A05424A66750B /* Pods-Segmentio_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5DE5F4B816F4E062B3C9278607C5E632 /* SegmentioCellWithImageUnderLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC4EC586E74DCFF8232A11FFEA0592BC /* SegmentioCellWithImageUnderLabel.swift */; }; + 639A4D6A5BD89BFDD5ED7603F1D18262 /* SegmentioCellWithImageOverLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D491E2303B96AB5AB9AACDBDD0D96BA1 /* SegmentioCellWithImageOverLabel.swift */; }; + 7535676B6DAAED27C9E51F128BA31498 /* SegmentioOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1E1181660922799D84A9AC7A93E4C17 /* SegmentioOptions.swift */; }; + 8B2E8009B9692DF362678E6FE094A084 /* SegmentioCellWithImageAfterLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89381DA5973AFCAEDD65131B6F801D80 /* SegmentioCellWithImageAfterLabel.swift */; }; + 8C08B2CAFA57AFB848065BA4E7CA8F27 /* Segmentio-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 5720677F504FDAE0BB2FF236B2A89893 /* Segmentio-dummy.m */; }; + 933D56EF2ECC35F1387B739170AFE07B /* Segmentio-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 588D0BD8821CEBC9689C137D843FA812 /* Segmentio-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9E50E7327C0F6358FC61855C0205CC8E /* Pods-Segmentio_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8DA8F49FD19F4BD6429F5AA0267180 /* Pods-Segmentio_Tests-dummy.m */; }; + C1518E27E6C853C813006C349427A4CC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */; }; + C5C3FE3FCC48A1460787D130DF0CF12E /* Segmentio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D794DA325FA95310FAD589F0A6A3BC8 /* Segmentio.swift */; }; + D29DE39BAA26D8E4DA7534F05DFB78F4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */; }; + DC7CDA37564D49D1443EFF857FB8B794 /* SegmentioCellWithImageBeforeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08337E1EFCACB5981A6FB8F0A5F1D05D /* SegmentioCellWithImageBeforeLabel.swift */; }; + E0F68CB059B49448534FFDCF5267CCD0 /* SegmentioCellWithLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C30B1407F4DECA9198B795A4C2F8942 /* SegmentioCellWithLabel.swift */; }; + E15160B05BBD4763B9DD87EAFA105B3B /* SegmentioCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F0CCCB5EF6793D4D584AEF64499C9CC /* SegmentioCell.swift */; }; + EA89BD32CAE3C825C749261B9D4A2031 /* Pods-Segmentio_Example-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 401FE729B830FF723B647781804D1F85 /* Pods-Segmentio_Example-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + A6C32E782852D555836218D4A7416DD0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = D69CC732EFB91EE42BE73E5030BD387C; + remoteInfo = Segmentio; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 08337E1EFCACB5981A6FB8F0A5F1D05D /* SegmentioCellWithImageBeforeLabel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithImageBeforeLabel.swift; sourceTree = ""; }; + 0C30B1407F4DECA9198B795A4C2F8942 /* SegmentioCellWithLabel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithLabel.swift; sourceTree = ""; }; + 0F88F99DAA1420A4448E3F028F0C8E7F /* UIView+Appearance.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIView+Appearance.swift"; sourceTree = ""; }; + 16922E380BC9D1F07E81271A1F0B9F27 /* Pods-Segmentio_Tests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Segmentio_Tests-frameworks.sh"; sourceTree = ""; }; + 268A02043997F7B259BA6A6642A97BFB /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2C6B3BD660EA40765EA46F0735002B06 /* Pods_Segmentio_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Segmentio_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 401FE729B830FF723B647781804D1F85 /* Pods-Segmentio_Example-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Segmentio_Example-umbrella.h"; sourceTree = ""; }; + 419FF94288A2110D00FAA1CE571FE9FC /* Pods-Segmentio_Example-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Segmentio_Example-frameworks.sh"; sourceTree = ""; }; + 4938DA306399C05E56EDBA62544340BE /* Pods-Segmentio_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Segmentio_Tests.debug.xcconfig"; sourceTree = ""; }; + 556AA0B62BF4398859D56C7F281F05FD /* Pods-Segmentio_Example-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Segmentio_Example-dummy.m"; sourceTree = ""; }; + 5720677F504FDAE0BB2FF236B2A89893 /* Segmentio-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Segmentio-dummy.m"; sourceTree = ""; }; + 588D0BD8821CEBC9689C137D843FA812 /* Segmentio-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Segmentio-umbrella.h"; sourceTree = ""; }; + 5F0CCCB5EF6793D4D584AEF64499C9CC /* SegmentioCell.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCell.swift; sourceTree = ""; }; + 658964FCFD27351CDFF8EBE97B8459B6 /* Pods-Segmentio_Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-Segmentio_Tests.modulemap"; sourceTree = ""; }; + 67714CDF4FF7EE5C90A0F1AB1AAAD011 /* Pods-Segmentio_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Segmentio_Example.release.xcconfig"; sourceTree = ""; }; + 7400982A0FA63A0BBCEAC3AC177EAD2E /* Segmentio-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Segmentio-prefix.pch"; sourceTree = ""; }; + 78A7E87C7803313F0A7310B468DFFCEA /* Segmentio.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Segmentio.xcconfig; sourceTree = ""; }; + 7F52E8E5326A4E61091A05424A66750B /* Pods-Segmentio_Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Segmentio_Tests-umbrella.h"; sourceTree = ""; }; + 89381DA5973AFCAEDD65131B6F801D80 /* SegmentioCellWithImageAfterLabel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithImageAfterLabel.swift; sourceTree = ""; }; + 8D794DA325FA95310FAD589F0A6A3BC8 /* Segmentio.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Segmentio.swift; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 982EB7C450661AE87828BC4011C51E5B /* Pods-Segmentio_Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Segmentio_Tests-acknowledgements.plist"; sourceTree = ""; }; + 9E0F52B6EE035F8DC32250C8800B6878 /* Pods_Segmentio_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Segmentio_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9E292B4C29D95C54CEC5B8BC3C6C9189 /* Pods-Segmentio_Example-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Segmentio_Example-resources.sh"; sourceTree = ""; }; + A0A2FACDEADFA4A30C47F0C37BCE0211 /* Pods-Segmentio_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Segmentio_Tests-acknowledgements.markdown"; sourceTree = ""; }; + ADC48C4E9F258114BD508838EF31778D /* Pods-Segmentio_Example-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Segmentio_Example-acknowledgements.plist"; sourceTree = ""; }; + AF767C5305A74E237D044DB939285A7E /* Pods-Segmentio_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Segmentio_Tests.release.xcconfig"; sourceTree = ""; }; + C332BBDBF329D75B42E3D4DFBC367750 /* Segmentio.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Segmentio.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + D173F1BEABAEE16C03D2454763755F7F /* Pods-Segmentio_Tests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Segmentio_Tests-resources.sh"; sourceTree = ""; }; + D39DD292AD471BA3FE7A27E198143BD8 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D491E2303B96AB5AB9AACDBDD0D96BA1 /* SegmentioCellWithImageOverLabel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithImageOverLabel.swift; sourceTree = ""; }; + DC4EC586E74DCFF8232A11FFEA0592BC /* SegmentioCellWithImageUnderLabel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithImageUnderLabel.swift; sourceTree = ""; }; + E1E1181660922799D84A9AC7A93E4C17 /* SegmentioOptions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioOptions.swift; sourceTree = ""; }; + ED9CA87F92ABA496B1E37F56B1948C95 /* Pods-Segmentio_Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-Segmentio_Example.modulemap"; sourceTree = ""; }; + EF8DA8F49FD19F4BD6429F5AA0267180 /* Pods-Segmentio_Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Segmentio_Tests-dummy.m"; sourceTree = ""; }; + F14C0898393B1E9176017283D91269D8 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F19F298463BD01E9E89AB6CF25EA81A5 /* Pods-Segmentio_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Segmentio_Example.debug.xcconfig"; sourceTree = ""; }; + F3B2A210AED19F381858EA69A5588808 /* Segmentio.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Segmentio.modulemap; sourceTree = ""; }; + F42697752DA8A65CBAB3CC0BB442A8C6 /* SegmentioCellWithImage.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SegmentioCellWithImage.swift; sourceTree = ""; }; + F4C7373D0CC433083738F6FFB0808DDD /* Pods-Segmentio_Example-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Segmentio_Example-acknowledgements.markdown"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 99B28BB930C96B4D06CABF8D3B8832D5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1B164D4FADAAAD401CDAFB8541C7AC00 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DD95959AB8521184CAFA5D68D3F0C0BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C1518E27E6C853C813006C349427A4CC /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + FD59EF5B4845512C0FE01CF908756FB5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D29DE39BAA26D8E4DA7534F05DFB78F4 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 262CA74000605615391CA6EC4293E986 /* Segmentio */ = { + isa = PBXGroup; + children = ( + E3C287FD31CE5425024C393185997E3E /* Segmentio */, + B301CE3581EA441B88CE7A4817B8D17E /* Support Files */, + ); + name = Segmentio; + path = ../..; + sourceTree = ""; + }; + 31FE64FF9D2E3D0D88D47DB5DEFE398A /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 545652130C56132D6876397F52E283C4 /* Pods-Segmentio_Example */, + 9FD684E4FD33C116E64DE188DB108EB9 /* Pods-Segmentio_Tests */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + 3DCAB2B7CDE207B3958B6CB957FCC758 /* iOS */ = { + isa = PBXGroup; + children = ( + CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 47DD221E11AD5E3ABBE22D1B01521963 /* Extensions */ = { + isa = PBXGroup; + children = ( + 0F88F99DAA1420A4448E3F028F0C8E7F /* UIView+Appearance.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + 545652130C56132D6876397F52E283C4 /* Pods-Segmentio_Example */ = { + isa = PBXGroup; + children = ( + 268A02043997F7B259BA6A6642A97BFB /* Info.plist */, + ED9CA87F92ABA496B1E37F56B1948C95 /* Pods-Segmentio_Example.modulemap */, + F4C7373D0CC433083738F6FFB0808DDD /* Pods-Segmentio_Example-acknowledgements.markdown */, + ADC48C4E9F258114BD508838EF31778D /* Pods-Segmentio_Example-acknowledgements.plist */, + 556AA0B62BF4398859D56C7F281F05FD /* Pods-Segmentio_Example-dummy.m */, + 419FF94288A2110D00FAA1CE571FE9FC /* Pods-Segmentio_Example-frameworks.sh */, + 9E292B4C29D95C54CEC5B8BC3C6C9189 /* Pods-Segmentio_Example-resources.sh */, + 401FE729B830FF723B647781804D1F85 /* Pods-Segmentio_Example-umbrella.h */, + F19F298463BD01E9E89AB6CF25EA81A5 /* Pods-Segmentio_Example.debug.xcconfig */, + 67714CDF4FF7EE5C90A0F1AB1AAAD011 /* Pods-Segmentio_Example.release.xcconfig */, + ); + name = "Pods-Segmentio_Example"; + path = "Target Support Files/Pods-Segmentio_Example"; + sourceTree = ""; + }; + 5938CEA6F620530E483550DA66B62AC9 /* Products */ = { + isa = PBXGroup; + children = ( + 9E0F52B6EE035F8DC32250C8800B6878 /* Pods_Segmentio_Example.framework */, + 2C6B3BD660EA40765EA46F0735002B06 /* Pods_Segmentio_Tests.framework */, + C332BBDBF329D75B42E3D4DFBC367750 /* Segmentio.framework */, + ); + name = Products; + sourceTree = ""; + }; + 5F203D3D23230D83E76F47D6F1912013 /* Development Pods */ = { + isa = PBXGroup; + children = ( + 262CA74000605615391CA6EC4293E986 /* Segmentio */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 6A17966A17091F11F4DC34B63A2A4ED4 /* Cells */ = { + isa = PBXGroup; + children = ( + 5F0CCCB5EF6793D4D584AEF64499C9CC /* SegmentioCell.swift */, + F42697752DA8A65CBAB3CC0BB442A8C6 /* SegmentioCellWithImage.swift */, + 89381DA5973AFCAEDD65131B6F801D80 /* SegmentioCellWithImageAfterLabel.swift */, + 08337E1EFCACB5981A6FB8F0A5F1D05D /* SegmentioCellWithImageBeforeLabel.swift */, + D491E2303B96AB5AB9AACDBDD0D96BA1 /* SegmentioCellWithImageOverLabel.swift */, + DC4EC586E74DCFF8232A11FFEA0592BC /* SegmentioCellWithImageUnderLabel.swift */, + 0C30B1407F4DECA9198B795A4C2F8942 /* SegmentioCellWithLabel.swift */, + ); + path = Cells; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + 5F203D3D23230D83E76F47D6F1912013 /* Development Pods */, + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, + 5938CEA6F620530E483550DA66B62AC9 /* Products */, + 31FE64FF9D2E3D0D88D47DB5DEFE398A /* Targets Support Files */, + ); + sourceTree = ""; + }; + 9FD684E4FD33C116E64DE188DB108EB9 /* Pods-Segmentio_Tests */ = { + isa = PBXGroup; + children = ( + F14C0898393B1E9176017283D91269D8 /* Info.plist */, + 658964FCFD27351CDFF8EBE97B8459B6 /* Pods-Segmentio_Tests.modulemap */, + A0A2FACDEADFA4A30C47F0C37BCE0211 /* Pods-Segmentio_Tests-acknowledgements.markdown */, + 982EB7C450661AE87828BC4011C51E5B /* Pods-Segmentio_Tests-acknowledgements.plist */, + EF8DA8F49FD19F4BD6429F5AA0267180 /* Pods-Segmentio_Tests-dummy.m */, + 16922E380BC9D1F07E81271A1F0B9F27 /* Pods-Segmentio_Tests-frameworks.sh */, + D173F1BEABAEE16C03D2454763755F7F /* Pods-Segmentio_Tests-resources.sh */, + 7F52E8E5326A4E61091A05424A66750B /* Pods-Segmentio_Tests-umbrella.h */, + 4938DA306399C05E56EDBA62544340BE /* Pods-Segmentio_Tests.debug.xcconfig */, + AF767C5305A74E237D044DB939285A7E /* Pods-Segmentio_Tests.release.xcconfig */, + ); + name = "Pods-Segmentio_Tests"; + path = "Target Support Files/Pods-Segmentio_Tests"; + sourceTree = ""; + }; + B301CE3581EA441B88CE7A4817B8D17E /* Support Files */ = { + isa = PBXGroup; + children = ( + D39DD292AD471BA3FE7A27E198143BD8 /* Info.plist */, + F3B2A210AED19F381858EA69A5588808 /* Segmentio.modulemap */, + 78A7E87C7803313F0A7310B468DFFCEA /* Segmentio.xcconfig */, + 5720677F504FDAE0BB2FF236B2A89893 /* Segmentio-dummy.m */, + 7400982A0FA63A0BBCEAC3AC177EAD2E /* Segmentio-prefix.pch */, + 588D0BD8821CEBC9689C137D843FA812 /* Segmentio-umbrella.h */, + ); + name = "Support Files"; + path = "Example/Pods/Target Support Files/Segmentio"; + sourceTree = ""; + }; + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3DCAB2B7CDE207B3958B6CB957FCC758 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + E3C287FD31CE5425024C393185997E3E /* Segmentio */ = { + isa = PBXGroup; + children = ( + E7168896F6A0EF9FBB759CB16C1ED3C5 /* Source */, + ); + path = Segmentio; + sourceTree = ""; + }; + E7168896F6A0EF9FBB759CB16C1ED3C5 /* Source */ = { + isa = PBXGroup; + children = ( + 8D794DA325FA95310FAD589F0A6A3BC8 /* Segmentio.swift */, + E1E1181660922799D84A9AC7A93E4C17 /* SegmentioOptions.swift */, + 6A17966A17091F11F4DC34B63A2A4ED4 /* Cells */, + 47DD221E11AD5E3ABBE22D1B01521963 /* Extensions */, + ); + path = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 1CABCEA6C1BC88EB07B535ECF534A9AD /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 386B142514D75786C9544322094E00BB /* Pods-Segmentio_Tests-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5ADAE197C16A9C5A10D0C5F779D181D8 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 933D56EF2ECC35F1387B739170AFE07B /* Segmentio-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C1CCF605E0A81C17A47094F5032DBFAE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + EA89BD32CAE3C825C749261B9D4A2031 /* Pods-Segmentio_Example-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1773C65AAC9F8837BB8142660D7320E0 /* Pods-Segmentio_Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = CC37EAE0F58FC2B11F123B84FE6B0FAC /* Build configuration list for PBXNativeTarget "Pods-Segmentio_Example" */; + buildPhases = ( + 5B2B601769FDD1B81F6ECD3FBC7CAF20 /* Sources */, + DD95959AB8521184CAFA5D68D3F0C0BA /* Frameworks */, + C1CCF605E0A81C17A47094F5032DBFAE /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + D49BEB0E5AAF16F8BE48EA55C820C1A4 /* PBXTargetDependency */, + ); + name = "Pods-Segmentio_Example"; + productName = "Pods-Segmentio_Example"; + productReference = 9E0F52B6EE035F8DC32250C8800B6878 /* Pods_Segmentio_Example.framework */; + productType = "com.apple.product-type.framework"; + }; + D69CC732EFB91EE42BE73E5030BD387C /* Segmentio */ = { + isa = PBXNativeTarget; + buildConfigurationList = 785D3215E776BE829EB1D98F89F1A8C1 /* Build configuration list for PBXNativeTarget "Segmentio" */; + buildPhases = ( + BF3D1C157A9652275CB130825D8E7120 /* Sources */, + FD59EF5B4845512C0FE01CF908756FB5 /* Frameworks */, + 5ADAE197C16A9C5A10D0C5F779D181D8 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Segmentio; + productName = Segmentio; + productReference = C332BBDBF329D75B42E3D4DFBC367750 /* Segmentio.framework */; + productType = "com.apple.product-type.framework"; + }; + E4CEDB3D980134198684315F99D1F345 /* Pods-Segmentio_Tests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1796B5A3A489231D28C16CDA0DBD7F52 /* Build configuration list for PBXNativeTarget "Pods-Segmentio_Tests" */; + buildPhases = ( + A579A79AB96EA13266CB18A28A23753F /* Sources */, + 99B28BB930C96B4D06CABF8D3B8832D5 /* Frameworks */, + 1CABCEA6C1BC88EB07B535ECF534A9AD /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Pods-Segmentio_Tests"; + productName = "Pods-Segmentio_Tests"; + productReference = 2C6B3BD660EA40765EA46F0735002B06 /* Pods_Segmentio_Tests.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = 5938CEA6F620530E483550DA66B62AC9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1773C65AAC9F8837BB8142660D7320E0 /* Pods-Segmentio_Example */, + E4CEDB3D980134198684315F99D1F345 /* Pods-Segmentio_Tests */, + D69CC732EFB91EE42BE73E5030BD387C /* Segmentio */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 5B2B601769FDD1B81F6ECD3FBC7CAF20 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0BC7695D61D9046BFBE6CFD6B47FFFE1 /* Pods-Segmentio_Example-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A579A79AB96EA13266CB18A28A23753F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9E50E7327C0F6358FC61855C0205CC8E /* Pods-Segmentio_Tests-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BF3D1C157A9652275CB130825D8E7120 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8C08B2CAFA57AFB848065BA4E7CA8F27 /* Segmentio-dummy.m in Sources */, + C5C3FE3FCC48A1460787D130DF0CF12E /* Segmentio.swift in Sources */, + 7535676B6DAAED27C9E51F128BA31498 /* SegmentioOptions.swift in Sources */, + 08F3ADCD6D2B9007082089826E712007 /* UIView+Appearance.swift in Sources */, + E15160B05BBD4763B9DD87EAFA105B3B /* SegmentioCell.swift in Sources */, + 124C21C2A8B015C1BB87D30F4EEA0214 /* SegmentioCellWithImage.swift in Sources */, + 8B2E8009B9692DF362678E6FE094A084 /* SegmentioCellWithImageAfterLabel.swift in Sources */, + DC7CDA37564D49D1443EFF857FB8B794 /* SegmentioCellWithImageBeforeLabel.swift in Sources */, + 639A4D6A5BD89BFDD5ED7603F1D18262 /* SegmentioCellWithImageOverLabel.swift in Sources */, + 5DE5F4B816F4E062B3C9278607C5E632 /* SegmentioCellWithImageUnderLabel.swift in Sources */, + E0F68CB059B49448534FFDCF5267CCD0 /* SegmentioCellWithLabel.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D49BEB0E5AAF16F8BE48EA55C820C1A4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Segmentio; + target = D69CC732EFB91EE42BE73E5030BD387C /* Segmentio */; + targetProxy = A6C32E782852D555836218D4A7416DD0 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 34F3882D28F8CE61245C5A12E47EE64E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4938DA306399C05E56EDBA62544340BE /* Pods-Segmentio_Tests.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-Segmentio_Tests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_Segmentio_Tests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 47BEF9D903506B003EA5C2B249729489 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + ONLY_ACTIVE_ARCH = YES; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 6A27E340E24D615063AB597774F259B4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AF767C5305A74E237D044DB939285A7E /* Pods-Segmentio_Tests.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-Segmentio_Tests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_Segmentio_Tests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 6A88DE4855BF46A99DED1138AC50611B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F19F298463BD01E9E89AB6CF25EA81A5 /* Pods-Segmentio_Example.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-Segmentio_Example/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_Segmentio_Example; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 847944553F66C9C9C8CF5EA5A12838E5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 67714CDF4FF7EE5C90A0F1AB1AAAD011 /* Pods-Segmentio_Example.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-Segmentio_Example/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_Segmentio_Example; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + AAF678CED40D3499169D10F63CA0719E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B54261FEDDC960542CA187AA5E14BC7D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 78A7E87C7803313F0A7310B468DFFCEA /* Segmentio.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Segmentio/Segmentio-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Segmentio/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Segmentio/Segmentio.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = Segmentio; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + F03A1D5CC9DD916A3B05610779B9C8F0 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 78A7E87C7803313F0A7310B468DFFCEA /* Segmentio.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/Segmentio/Segmentio-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Segmentio/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Segmentio/Segmentio.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = Segmentio; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1796B5A3A489231D28C16CDA0DBD7F52 /* Build configuration list for PBXNativeTarget "Pods-Segmentio_Tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 34F3882D28F8CE61245C5A12E47EE64E /* Debug */, + 6A27E340E24D615063AB597774F259B4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 47BEF9D903506B003EA5C2B249729489 /* Debug */, + AAF678CED40D3499169D10F63CA0719E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 785D3215E776BE829EB1D98F89F1A8C1 /* Build configuration list for PBXNativeTarget "Segmentio" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B54261FEDDC960542CA187AA5E14BC7D /* Debug */, + F03A1D5CC9DD916A3B05610779B9C8F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CC37EAE0F58FC2B11F123B84FE6B0FAC /* Build configuration list for PBXNativeTarget "Pods-Segmentio_Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6A88DE4855BF46A99DED1138AC50611B /* Debug */, + 847944553F66C9C9C8CF5EA5A12838E5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Info.plist b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Info.plist new file mode 100644 index 0000000..2243fe6 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.markdown b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.markdown new file mode 100644 index 0000000..5e6c9e3 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.markdown @@ -0,0 +1,27 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## Segmentio + +The MIT License (MIT) + +Copyright © 2015 Yalantis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +Generated by CocoaPods - https://cocoapods.org diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.plist b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.plist new file mode 100644 index 0000000..2051b42 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-acknowledgements.plist @@ -0,0 +1,57 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + The MIT License (MIT) + +Copyright © 2015 Yalantis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + Title + Segmentio + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-dummy.m b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-dummy.m new file mode 100644 index 0000000..0d0aadf --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_Segmentio_Example : NSObject +@end +@implementation PodsDummy_Pods_Segmentio_Example +@end diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-frameworks.sh b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-frameworks.sh new file mode 100755 index 0000000..c3ec8f4 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-frameworks.sh @@ -0,0 +1,91 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/Segmentio/Segmentio.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/Segmentio/Segmentio.framework" +fi diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-resources.sh b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-resources.sh new file mode 100755 index 0000000..0a15615 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-resources.sh @@ -0,0 +1,102 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-umbrella.h b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-umbrella.h new file mode 100644 index 0000000..1deef9d --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-umbrella.h @@ -0,0 +1,6 @@ +#import + + +FOUNDATION_EXPORT double Pods_Segmentio_ExampleVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_Segmentio_ExampleVersionString[]; + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.debug.xcconfig b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.debug.xcconfig new file mode 100644 index 0000000..88a9323 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.debug.xcconfig @@ -0,0 +1,10 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Segmentio" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Segmentio/Segmentio.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Segmentio" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.modulemap b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.modulemap new file mode 100644 index 0000000..867ce51 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.modulemap @@ -0,0 +1,6 @@ +framework module Pods_Segmentio_Example { + umbrella header "Pods-Segmentio_Example-umbrella.h" + + export * + module * { export * } +} diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.release.xcconfig b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.release.xcconfig new file mode 100644 index 0000000..88a9323 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.release.xcconfig @@ -0,0 +1,10 @@ +EMBEDDED_CONTENT_CONTAINS_SWIFT = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Segmentio" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Segmentio/Segmentio.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Segmentio" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Info.plist b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Info.plist new file mode 100644 index 0000000..2243fe6 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.markdown b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.markdown new file mode 100644 index 0000000..102af75 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.markdown @@ -0,0 +1,3 @@ +# Acknowledgements +This application makes use of the following third party libraries: +Generated by CocoaPods - https://cocoapods.org diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.plist b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.plist new file mode 100644 index 0000000..7acbad1 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-acknowledgements.plist @@ -0,0 +1,29 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-dummy.m b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-dummy.m new file mode 100644 index 0000000..c2af4e9 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_Segmentio_Tests : NSObject +@end +@implementation PodsDummy_Pods_Segmentio_Tests +@end diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-frameworks.sh b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-frameworks.sh new file mode 100755 index 0000000..893c16a --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-frameworks.sh @@ -0,0 +1,84 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-resources.sh b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-resources.sh new file mode 100755 index 0000000..0a15615 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-resources.sh @@ -0,0 +1,102 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "$RESOURCE_PATH") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-umbrella.h b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-umbrella.h new file mode 100644 index 0000000..40765b6 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests-umbrella.h @@ -0,0 +1,6 @@ +#import + + +FOUNDATION_EXPORT double Pods_Segmentio_TestsVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_Segmentio_TestsVersionString[]; + diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.debug.xcconfig b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.debug.xcconfig new file mode 100644 index 0000000..a3bfc9e --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.debug.xcconfig @@ -0,0 +1,7 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Segmentio" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Segmentio/Segmentio.framework/Headers" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.modulemap b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.modulemap new file mode 100644 index 0000000..5431e99 --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.modulemap @@ -0,0 +1,6 @@ +framework module Pods_Segmentio_Tests { + umbrella header "Pods-Segmentio_Tests-umbrella.h" + + export * + module * { export * } +} diff --git a/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.release.xcconfig b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.release.xcconfig new file mode 100644 index 0000000..a3bfc9e --- /dev/null +++ b/Example/Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.release.xcconfig @@ -0,0 +1,7 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Segmentio" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Segmentio/Segmentio.framework/Headers" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example/Pods/Target Support Files/Segmentio/Info.plist b/Example/Pods/Target Support Files/Segmentio/Info.plist new file mode 100644 index 0000000..161a9d3 --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 0.1.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example/Pods/Target Support Files/Segmentio/Segmentio-dummy.m b/Example/Pods/Target Support Files/Segmentio/Segmentio-dummy.m new file mode 100644 index 0000000..4c259a7 --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Segmentio-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Segmentio : NSObject +@end +@implementation PodsDummy_Segmentio +@end diff --git a/Example/Pods/Target Support Files/Segmentio/Segmentio-prefix.pch b/Example/Pods/Target Support Files/Segmentio/Segmentio-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Segmentio-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Example/Pods/Target Support Files/Segmentio/Segmentio-umbrella.h b/Example/Pods/Target Support Files/Segmentio/Segmentio-umbrella.h new file mode 100644 index 0000000..f3c2c6b --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Segmentio-umbrella.h @@ -0,0 +1,6 @@ +#import + + +FOUNDATION_EXPORT double SegmentioVersionNumber; +FOUNDATION_EXPORT const unsigned char SegmentioVersionString[]; + diff --git a/Example/Pods/Target Support Files/Segmentio/Segmentio.modulemap b/Example/Pods/Target Support Files/Segmentio/Segmentio.modulemap new file mode 100644 index 0000000..402c454 --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Segmentio.modulemap @@ -0,0 +1,6 @@ +framework module Segmentio { + umbrella header "Segmentio-umbrella.h" + + export * + module * { export * } +} diff --git a/Example/Pods/Target Support Files/Segmentio/Segmentio.xcconfig b/Example/Pods/Target Support Files/Segmentio/Segmentio.xcconfig new file mode 100644 index 0000000..2b782f7 --- /dev/null +++ b/Example/Pods/Target Support Files/Segmentio/Segmentio.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Segmentio +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Example/README.md b/Example/README.md new file mode 100644 index 0000000..a2fb7ba --- /dev/null +++ b/Example/README.md @@ -0,0 +1,183 @@ +##Segmentio +[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/Yalantis/Segmentio/blob/master/LICENSE) +[![Swift 2.2.x](https://img.shields.io/badge/Swift-2.2.x-orange.svg) + +Animated top/bottom segmented control written in Swift. + +[![Yalantis](https://raw.githubusercontent.com/Yalantis/PullToMakeSoup/master/PullToMakeSoupDemo/Resouces/badge_dark.png)](https://Yalantis.com/?utm_source=github) + +##Requirements + +iOS 8.x, Swift 2.2 + +##Installation + +####[CocoaPods](http://cocoapods.org) +```ruby +use_frameworks! + +# Swift 2.2 +pod 'Segmentio', '~> 0.1.0' +``` + +*(CocoaPods v1.0.1 or later required. See [this blog post](http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/) for details.)* + +##Usage +####Import `Segmentio` module +```swift +import Segmentio +``` + +####Init +You can initialize a `Segmentio` instance from code: +```swift +var segmentioView: Segmentio! + +let segmentioViewRect = CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: 125) +segmentioView = Segmentio(frame: segmentioViewRect) +view.addSubview(segmentioView) +``` +or + +add a `UIView` instance in your .storyboard or .xib, set `Segmentio` class and connect `IBOutlet`: +```swift +@IBOutlet weak var segmentioView: Segmentio! +``` + +####Setup `Segmentio` +```swift +segmentioView.setupContent( + content: [SegmentioItem], + style: SegmentioStyle, + options: SegmentioOptions? +) +``` + +To start with default options you can just pass `nil` to the `options` parameter. + +```swift +segmentioView.setupContent( + content: [SegmentioItem], + style: SegmentioStyle, + options: nil +) +``` + + +####Configuring items +In order to set items you need to create an array of `SegmentioItem` instances: +```swift +var content = [SegmentioItem]() + +let tornadoItem = SegmentioItem( + title: "Tornado", + image: UIImage(named: "tornado") +) +content.append(tornadoItem) +``` + +####Handling selection +You can specify selected item manually: +```swift +segmentioView.selectedSegmentIndex = 0 +``` + +####Handling callback +```swift +segmentioView.valueDidChange = { segmentio, segmentIndex in + print("Selected item: ", segmentIndex) +} +``` + +####Customization +`Segmentio` can be customized by passing an instance of `SegmentioOptions` struct: +```swift +SegmentioOptions( + backgroundColor: UIColor.whiteColor(), + maxVisibleItems: 3, + scrollEnabled: true, + indicatorOptions: SegmentioIndicatorOptions, + horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions, + verticalSeparatorOptions: SegmentioVerticalSeparatorOptions, + imageContentMode: UIViewContentMode.Center, + labelTextAlignment: NSTextAlignment.Center, + segmentStates: SegmentioStates // tuple of SegmentioState (defaultState, selectState, highlightedState) +) +``` + +Selection indicator can be customized by passing an instance of `SegmentioIndicatorOptions`: +```swift +SegmentioIndicatorOptions( + type: .Bottom, + ratio: 1, + height: 5, + color: UIColor.orangeColor() +) +``` + +Horizontal borders can be customized by passing an instance of `SegmentioHorizontalSeparatorOptions`: +```swift +SegmentioHorizontalSeparatorOptions( + type: SegmentioHorizontalSeparatorType.TopAndBottom, // Top, Bottom, TopAndBottom + height: 1, + color: UIColor.grayColor() +) +``` + +Separators between segments can be customized by passing an instance of `SegmentioVerticalSeparatorOptions`: +```swift +SegmentioVerticalSeparatorOptions( + ratio: 0.6 // from 0.1 to 1 + color: UIColor.grayColor() +) +``` + +In order to set `SegmentioStates` you need to create a tuple of `SegmentioState` instances: +```swift +SegmentioStates( + defaultState: segmentioState( + backgroundColor: UIColor.clearColor(), + titleFont: UIFont.systemFontOfSize(UIFont.smallSystemFontSize()), + titleTextColor: UIColor.blackColor() + ), + selectState: segmentioState( + backgroundColor: UIColor.orangeColor(), + titleFont: UIFont.systemFontOfSize(UIFont.smallSystemFontSize()), + titleTextColor: UIColor.whiteColor() + ), + highlinedState: segmentioState( + backgroundColor: UIColor.lightGrayColor().colorWithAlphaComponent(0.6), + titleFont: UIFont.boldSystemFontOfSize(UIFont.smallSystemFontSize()), + titleTextColor: UIColor.blackColor() + ) +) +``` + +####Let us know! +We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation. + +P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned! + +##License + +The MIT License (MIT) + +Copyright © 2016 Yalantis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Example/Segmentio.xcodeproj/project.pbxproj b/Example/Segmentio.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c673d7f --- /dev/null +++ b/Example/Segmentio.xcodeproj/project.pbxproj @@ -0,0 +1,505 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 320E4C191D2A820800A93C10 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 320E4C181D2A820800A93C10 /* README.md */; }; + 324015CC1D22C0ED0096E353 /* Hints.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324015CB1D22C0ED0096E353 /* Hints.swift */; }; + 324015CE1D22D40A0096E353 /* UIFont+ExampleFonts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324015CD1D22D40A0096E353 /* UIFont+ExampleFonts.swift */; }; + 324015D01D22FCD50096E353 /* String+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 324015CF1D22FCD50096E353 /* String+Convenience.swift */; }; + 327AF5CF1D1ABEC100534355 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5A81D1ABEC100534355 /* AppDelegate.swift */; }; + 327AF5D01D1ABEC100534355 /* UIColor+RGB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5AA1D1ABEC100534355 /* UIColor+RGB.swift */; }; + 327AF5D21D1ABEC100534355 /* UINavigationBar+Flat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5AC1D1ABEC100534355 /* UINavigationBar+Flat.swift */; }; + 327AF5D31D1ABEC100534355 /* AppearanceConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5AE1D1ABEC100534355 /* AppearanceConfigurator.swift */; }; + 327AF5D41D1ABEC100534355 /* Disaster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5B01D1ABEC100534355 /* Disaster.swift */; }; + 327AF5D51D1ABEC100534355 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 327AF5B21D1ABEC100534355 /* Assets.xcassets */; }; + 327AF5E41D1ABEC100534355 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 327AF5C31D1ABEC100534355 /* LaunchScreen.storyboard */; }; + 327AF5E51D1ABEC100534355 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 327AF5C41D1ABEC100534355 /* Main.storyboard */; }; + 327AF5E71D1ABEC100534355 /* ContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5C81D1ABEC100534355 /* ContentViewController.swift */; }; + 327AF5E81D1ABEC100534355 /* EmbedContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5C91D1ABEC100534355 /* EmbedContainerViewController.swift */; }; + 327AF5E91D1ABEC100534355 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5CA1D1ABEC100534355 /* ExampleViewController.swift */; }; + 327AF5EA1D1ABEC100534355 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5CB1D1ABEC100534355 /* HomeViewController.swift */; }; + 327AF5EB1D1ABEC100534355 /* SideMenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF5CC1D1ABEC100534355 /* SideMenuViewController.swift */; }; + 327AF6041D1AC0FE00534355 /* ColorPalette.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327AF6031D1AC0FE00534355 /* ColorPalette.swift */; }; + 5B9491B14F42A77448746E9B /* Pods_Segmentio_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 74E8553D39ECFE4883F1D2CA /* Pods_Segmentio_Example.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 031FB43EDAB25B02B2FB7406 /* Pods-Segmentio_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Segmentio_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.debug.xcconfig"; sourceTree = ""; }; + 1667ACAF5594F75E244C8E1B /* Pods-Segmentio_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Segmentio_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example.release.xcconfig"; sourceTree = ""; }; + 183F56A87F22C4DF4AB3CDCB /* Pods_Segmentio_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Segmentio_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2F629976269F20B0601D695D /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; + 320E4C181D2A820800A93C10 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 324015CB1D22C0ED0096E353 /* Hints.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Hints.swift; sourceTree = ""; }; + 324015CD1D22D40A0096E353 /* UIFont+ExampleFonts.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIFont+ExampleFonts.swift"; sourceTree = ""; }; + 324015CF1D22FCD50096E353 /* String+Convenience.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Convenience.swift"; sourceTree = ""; }; + 327AF5A81D1ABEC100534355 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 327AF5AA1D1ABEC100534355 /* UIColor+RGB.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+RGB.swift"; sourceTree = ""; }; + 327AF5AC1D1ABEC100534355 /* UINavigationBar+Flat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationBar+Flat.swift"; sourceTree = ""; }; + 327AF5AE1D1ABEC100534355 /* AppearanceConfigurator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppearanceConfigurator.swift; sourceTree = ""; }; + 327AF5B01D1ABEC100534355 /* Disaster.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disaster.swift; sourceTree = ""; }; + 327AF5B21D1ABEC100534355 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 327AF5C31D1ABEC100534355 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; + 327AF5C41D1ABEC100534355 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; + 327AF5C81D1ABEC100534355 /* ContentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentViewController.swift; sourceTree = ""; }; + 327AF5C91D1ABEC100534355 /* EmbedContainerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmbedContainerViewController.swift; sourceTree = ""; }; + 327AF5CA1D1ABEC100534355 /* ExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = ""; }; + 327AF5CB1D1ABEC100534355 /* HomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; + 327AF5CC1D1ABEC100534355 /* SideMenuViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuViewController.swift; sourceTree = ""; }; + 327AF6031D1AC0FE00534355 /* ColorPalette.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorPalette.swift; sourceTree = ""; }; + 607FACD01AFB9204008FA782 /* Segmentio_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Segmentio_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 74E8553D39ECFE4883F1D2CA /* Pods_Segmentio_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Segmentio_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7EBD99A4E34C02531B010FB7 /* Segmentio.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Segmentio.podspec; path = ../Segmentio.podspec; sourceTree = ""; }; + A0AD385168FB82ECC038D54D /* Pods-Segmentio_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Segmentio_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.release.xcconfig"; sourceTree = ""; }; + E42689127CBBBD94664F6296 /* Pods-Segmentio_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Segmentio_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Segmentio_Tests/Pods-Segmentio_Tests.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 607FACCD1AFB9204008FA782 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5B9491B14F42A77448746E9B /* Pods_Segmentio_Example.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 327AF5A71D1ABEC100534355 /* Application */ = { + isa = PBXGroup; + children = ( + 327AF5A81D1ABEC100534355 /* AppDelegate.swift */, + ); + path = Application; + sourceTree = ""; + }; + 327AF5A91D1ABEC100534355 /* Extensions */ = { + isa = PBXGroup; + children = ( + 327AF5AA1D1ABEC100534355 /* UIColor+RGB.swift */, + 327AF5AC1D1ABEC100534355 /* UINavigationBar+Flat.swift */, + 324015CD1D22D40A0096E353 /* UIFont+ExampleFonts.swift */, + 324015CF1D22FCD50096E353 /* String+Convenience.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + 327AF5AD1D1ABEC100534355 /* Helpers */ = { + isa = PBXGroup; + children = ( + 327AF5AE1D1ABEC100534355 /* AppearanceConfigurator.swift */, + ); + path = Helpers; + sourceTree = ""; + }; + 327AF5AF1D1ABEC100534355 /* Models */ = { + isa = PBXGroup; + children = ( + 327AF5B01D1ABEC100534355 /* Disaster.swift */, + ); + path = Models; + sourceTree = ""; + }; + 327AF5B11D1ABEC100534355 /* Resorces */ = { + isa = PBXGroup; + children = ( + 327AF5B21D1ABEC100534355 /* Assets.xcassets */, + 327AF6031D1AC0FE00534355 /* ColorPalette.swift */, + 324015CB1D22C0ED0096E353 /* Hints.swift */, + ); + path = Resorces; + sourceTree = ""; + }; + 327AF5C21D1ABEC100534355 /* Storyboards */ = { + isa = PBXGroup; + children = ( + 327AF5C31D1ABEC100534355 /* LaunchScreen.storyboard */, + 327AF5C41D1ABEC100534355 /* Main.storyboard */, + ); + path = Storyboards; + sourceTree = ""; + }; + 327AF5C71D1ABEC100534355 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 327AF5CB1D1ABEC100534355 /* HomeViewController.swift */, + 327AF5CC1D1ABEC100534355 /* SideMenuViewController.swift */, + 327AF5C91D1ABEC100534355 /* EmbedContainerViewController.swift */, + 327AF5CA1D1ABEC100534355 /* ExampleViewController.swift */, + 327AF5C81D1ABEC100534355 /* ContentViewController.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; + 45CA913E13914443DB2552B6 /* Pods */ = { + isa = PBXGroup; + children = ( + 031FB43EDAB25B02B2FB7406 /* Pods-Segmentio_Example.debug.xcconfig */, + 1667ACAF5594F75E244C8E1B /* Pods-Segmentio_Example.release.xcconfig */, + E42689127CBBBD94664F6296 /* Pods-Segmentio_Tests.debug.xcconfig */, + A0AD385168FB82ECC038D54D /* Pods-Segmentio_Tests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 607FACC71AFB9204008FA782 = { + isa = PBXGroup; + children = ( + 607FACF51AFB993E008FA782 /* Podspec Metadata */, + 607FACD21AFB9204008FA782 /* Example for Segmentio */, + 607FACD11AFB9204008FA782 /* Products */, + 45CA913E13914443DB2552B6 /* Pods */, + 7089E8ABA0D38A7C04D64B7F /* Frameworks */, + ); + sourceTree = ""; + }; + 607FACD11AFB9204008FA782 /* Products */ = { + isa = PBXGroup; + children = ( + 607FACD01AFB9204008FA782 /* Segmentio_Example.app */, + ); + name = Products; + sourceTree = ""; + }; + 607FACD21AFB9204008FA782 /* Example for Segmentio */ = { + isa = PBXGroup; + children = ( + 327AF5A71D1ABEC100534355 /* Application */, + 327AF5A91D1ABEC100534355 /* Extensions */, + 327AF5AD1D1ABEC100534355 /* Helpers */, + 327AF5AF1D1ABEC100534355 /* Models */, + 327AF5B11D1ABEC100534355 /* Resorces */, + 327AF5C71D1ABEC100534355 /* ViewControllers */, + 327AF5C21D1ABEC100534355 /* Storyboards */, + 607FACD31AFB9204008FA782 /* Supporting Files */, + ); + name = "Example for Segmentio"; + path = Segmentio; + sourceTree = ""; + }; + 607FACD31AFB9204008FA782 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 607FACD41AFB9204008FA782 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { + isa = PBXGroup; + children = ( + 7EBD99A4E34C02531B010FB7 /* Segmentio.podspec */, + 2F629976269F20B0601D695D /* LICENSE */, + 320E4C181D2A820800A93C10 /* README.md */, + ); + name = "Podspec Metadata"; + sourceTree = ""; + }; + 7089E8ABA0D38A7C04D64B7F /* Frameworks */ = { + isa = PBXGroup; + children = ( + 74E8553D39ECFE4883F1D2CA /* Pods_Segmentio_Example.framework */, + 183F56A87F22C4DF4AB3CDCB /* Pods_Segmentio_Tests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 607FACCF1AFB9204008FA782 /* Segmentio_Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Segmentio_Example" */; + buildPhases = ( + 269ECFC9CB046D6FAC3B00EC /* [CP] Check Pods Manifest.lock */, + 607FACCC1AFB9204008FA782 /* Sources */, + 607FACCD1AFB9204008FA782 /* Frameworks */, + 607FACCE1AFB9204008FA782 /* Resources */, + 0F262642822A946CA50DC25B /* [CP] Embed Pods Frameworks */, + 252D3AEAEF13B143A7D04B54 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Segmentio_Example; + productName = Segmentio; + productReference = 607FACD01AFB9204008FA782 /* Segmentio_Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 607FACC81AFB9204008FA782 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0720; + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = CocoaPods; + TargetAttributes = { + 607FACCF1AFB9204008FA782 = { + CreatedOnToolsVersion = 6.3.1; + }; + }; + }; + buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Segmentio" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 607FACC71AFB9204008FA782; + productRefGroup = 607FACD11AFB9204008FA782 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 607FACCF1AFB9204008FA782 /* Segmentio_Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 607FACCE1AFB9204008FA782 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 327AF5D51D1ABEC100534355 /* Assets.xcassets in Resources */, + 327AF5E51D1ABEC100534355 /* Main.storyboard in Resources */, + 327AF5E41D1ABEC100534355 /* LaunchScreen.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 0F262642822A946CA50DC25B /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 252D3AEAEF13B143A7D04B54 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Segmentio_Example/Pods-Segmentio_Example-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 269ECFC9CB046D6FAC3B00EC /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 607FACCC1AFB9204008FA782 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 324015CC1D22C0ED0096E353 /* Hints.swift in Sources */, + 327AF5E71D1ABEC100534355 /* ContentViewController.swift in Sources */, + 327AF5CF1D1ABEC100534355 /* AppDelegate.swift in Sources */, + 327AF5EB1D1ABEC100534355 /* SideMenuViewController.swift in Sources */, + 327AF5E81D1ABEC100534355 /* EmbedContainerViewController.swift in Sources */, + 327AF5D41D1ABEC100534355 /* Disaster.swift in Sources */, + 327AF5D31D1ABEC100534355 /* AppearanceConfigurator.swift in Sources */, + 327AF5EA1D1ABEC100534355 /* HomeViewController.swift in Sources */, + 327AF5D21D1ABEC100534355 /* UINavigationBar+Flat.swift in Sources */, + 327AF5D01D1ABEC100534355 /* UIColor+RGB.swift in Sources */, + 324015CE1D22D40A0096E353 /* UIFont+ExampleFonts.swift in Sources */, + 327AF5E91D1ABEC100534355 /* ExampleViewController.swift in Sources */, + 320E4C191D2A820800A93C10 /* README.md in Sources */, + 324015D01D22FCD50096E353 /* String+Convenience.swift in Sources */, + 327AF6041D1AC0FE00534355 /* ColorPalette.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 607FACED1AFB9204008FA782 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 607FACEE1AFB9204008FA782 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 607FACF01AFB9204008FA782 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 031FB43EDAB25B02B2FB7406 /* Pods-Segmentio_Example.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer: Sergiy Fesenko (Y8JZQ7JQ9A)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + INFOPLIST_FILE = Segmentio/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MODULE_NAME = ExampleApp; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = "7a986b88-0eac-45ee-83d0-888b35e57459"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 607FACF11AFB9204008FA782 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1667ACAF5594F75E244C8E1B /* Pods-Segmentio_Example.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer: Sergiy Fesenko (Y8JZQ7JQ9A)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Sergiy Fesenko (Y8JZQ7JQ9A)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + INFOPLIST_FILE = Segmentio/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MODULE_NAME = ExampleApp; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = "7a986b88-0eac-45ee-83d0-888b35e57459"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Segmentio" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 607FACED1AFB9204008FA782 /* Debug */, + 607FACEE1AFB9204008FA782 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "Segmentio_Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 607FACF01AFB9204008FA782 /* Debug */, + 607FACF11AFB9204008FA782 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 607FACC81AFB9204008FA782 /* Project object */; +} diff --git a/Example/Segmentio.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/Segmentio.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..70abed6 --- /dev/null +++ b/Example/Segmentio.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/Segmentio.xcodeproj/xcshareddata/xcschemes/Segmentio-Example.xcscheme b/Example/Segmentio.xcodeproj/xcshareddata/xcschemes/Segmentio-Example.xcscheme new file mode 100644 index 0000000..6badb42 --- /dev/null +++ b/Example/Segmentio.xcodeproj/xcshareddata/xcschemes/Segmentio-Example.xcscheme @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Segmentio.xcworkspace/contents.xcworkspacedata b/Example/Segmentio.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..91e918e --- /dev/null +++ b/Example/Segmentio.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/Segmentio/Application/AppDelegate.swift b/Example/Segmentio/Application/AppDelegate.swift new file mode 100644 index 0000000..4fa19b2 --- /dev/null +++ b/Example/Segmentio/Application/AppDelegate.swift @@ -0,0 +1,22 @@ +// +// AppDelegate.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + UIDevice.currentDevice().beginGeneratingDeviceOrientationNotifications() + AppearanceConfigurator.configureNavigationBar() + return true + } + +} \ No newline at end of file diff --git a/Example/Segmentio/Extensions/String+Convenience.swift b/Example/Segmentio/Extensions/String+Convenience.swift new file mode 100644 index 0000000..8dab58f --- /dev/null +++ b/Example/Segmentio/Extensions/String+Convenience.swift @@ -0,0 +1,27 @@ +// +// String+Convenience.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import Foundation + +extension String { + + func stringFromCamelCase() -> String { + var string = self + string = string.stringByReplacingOccurrencesOfString( + "([a-z])([A-Z])", + withString: "$1 $2", + options: .RegularExpressionSearch, + range: Range(string.startIndex.. UIFont { + return UIFont(name: "Avenir-Book", size: size) ?? UIFont.systemFontOfSize(size) + } + + class func exampleAvenirLightWithSize(size: CGFloat) -> UIFont { + return UIFont(name: "Avenir-Light", size: size) ?? UIFont.systemFontOfSize(size) + } + +} \ No newline at end of file diff --git a/Example/Segmentio/Extensions/UINavigationBar+Flat.swift b/Example/Segmentio/Extensions/UINavigationBar+Flat.swift new file mode 100644 index 0000000..4f6ef9d --- /dev/null +++ b/Example/Segmentio/Extensions/UINavigationBar+Flat.swift @@ -0,0 +1,42 @@ +// +// UINavigationBar+Flat.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +private var flatAssociatedObjectKey: UInt8 = 0 + +/* + An extension that adds a "flat" field to UINavigationBar. This flag, when + enabled, removes the shadow under the navigation bar. + */ + +@IBDesignable extension UINavigationBar { + + @IBInspectable var flat: Bool { + get { + guard let obj = objc_getAssociatedObject(self, &flatAssociatedObjectKey) as? NSNumber else { + return false + } + return obj.boolValue; + } + + set { + if (newValue) { + let void = UIImage() + setBackgroundImage(void, forBarPosition: .Any, barMetrics: .Default) + shadowImage = void + } else { + setBackgroundImage(nil, forBarPosition: .Any, barMetrics: .Default) + shadowImage = nil + } + objc_setAssociatedObject(self, &flatAssociatedObjectKey, NSNumber(bool: newValue), + objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + +} \ No newline at end of file diff --git a/Example/Segmentio/Helpers/AppearanceConfigurator.swift b/Example/Segmentio/Helpers/AppearanceConfigurator.swift new file mode 100644 index 0000000..9ea569c --- /dev/null +++ b/Example/Segmentio/Helpers/AppearanceConfigurator.swift @@ -0,0 +1,26 @@ +// +// AppearanceConfigurator.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +class AppearanceConfigurator { + + class func configureNavigationBar() { + UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent + + UINavigationBar.appearance().barTintColor = ColorPalette.WhiteColor + UINavigationBar.appearance().translucent = false + UINavigationBar.appearance().tintColor = ColorPalette.BlackColor + let attributes = [ + NSFontAttributeName : UIFont.exampleAvenirMediumWithSize(17), + NSForegroundColorAttributeName : ColorPalette.BlackColor + ] + UINavigationBar.appearance().titleTextAttributes = attributes + } + +} \ No newline at end of file diff --git a/Example/Segmentio/Info.plist b/Example/Segmentio/Info.plist new file mode 100644 index 0000000..bb92a77 --- /dev/null +++ b/Example/Segmentio/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 21 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/Example/Segmentio/Models/Disaster.swift b/Example/Segmentio/Models/Disaster.swift new file mode 100644 index 0000000..2b1bcc1 --- /dev/null +++ b/Example/Segmentio/Models/Disaster.swift @@ -0,0 +1,19 @@ +// +// Disaster.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +struct Disaster { + + var cardName: String? + var hints: [String]? + + init(cardName: String?, hints: [String]?) { + self.cardName = cardName + self.hints = hints + } + +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..7bed043 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,86 @@ +{ + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-Small@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-Small-40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-60@2x-1.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-60@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-29.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-40.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-Small-40@2x-1.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-83-5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29.png new file mode 100644 index 0000000..bb9205d Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png new file mode 100644 index 0000000..fab191a Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-40.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-40.png new file mode 100644 index 0000000..26dbe57 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-40.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x-1.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x-1.png new file mode 100644 index 0000000..0625346 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x-1.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png new file mode 100644 index 0000000..0625346 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png new file mode 100644 index 0000000..72319f6 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76.png new file mode 100644 index 0000000..b38527c Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png new file mode 100644 index 0000000..77b2012 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-83-5@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-83-5@2x.png new file mode 100644 index 0000000..956bc6b Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-83-5@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png new file mode 100644 index 0000000..dfc1b3f Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x-1.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png new file mode 100644 index 0000000..dfc1b3f Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png new file mode 100644 index 0000000..50eebef Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png new file mode 100644 index 0000000..6b2a0a3 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/Contents.json new file mode 100644 index 0000000..e2bd3c8 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/Contents.json @@ -0,0 +1,65 @@ +{ + "images" : [ + { + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 17, + "top" : 36, + "right" : 62, + "left" : 63 + } + }, + "idiom" : "universal", + "filename" : "cards.png", + "scale" : "1x" + }, + { + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 34, + "top" : 72, + "right" : 124, + "left" : 126 + } + }, + "idiom" : "universal", + "filename" : "cards@2x.png", + "scale" : "2x" + }, + { + "resizing" : { + "mode" : "9-part", + "center" : { + "mode" : "tile", + "width" : 1, + "height" : 1 + }, + "cap-insets" : { + "bottom" : 51, + "top" : 108, + "right" : 186, + "left" : 189 + } + }, + "idiom" : "universal", + "filename" : "cards@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards.png b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards.png new file mode 100644 index 0000000..570334d Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@2x.png new file mode 100644 index 0000000..81462a9 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@3x.png new file mode 100644 index 0000000..63b64db Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/cards.imageset/cards@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Contents.json new file mode 100644 index 0000000..ff27649 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "Oval.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Oval@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Oval@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval.png b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval.png new file mode 100644 index 0000000..68d0b1a Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@2x.png new file mode 100644 index 0000000..1b8c1e7 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@3x.png new file mode 100644 index 0000000..bd9ec26 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/defaultCheckbox.imageset/Oval@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/Contents.json new file mode 100644 index 0000000..c873034 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "eathquakes.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "eathquakes@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "eathquakes@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes.png b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes.png new file mode 100644 index 0000000..01bfa29 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@2x.png new file mode 100644 index 0000000..ac185a4 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@3x.png new file mode 100644 index 0000000..0e38c05 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/earthquakes.imageset/eathquakes@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/Contents.json new file mode 100644 index 0000000..5b0ad1b --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "eruption.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "eruption@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "eruption@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption.png b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption.png new file mode 100644 index 0000000..b0d8a41 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@2x.png new file mode 100644 index 0000000..4dd2463 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@3x.png new file mode 100644 index 0000000..0b5840f Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/eruption.imageset/eruption@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/Contents.json new file mode 100644 index 0000000..f74b399 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "floods.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "floods@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "floods@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods.png b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods.png new file mode 100644 index 0000000..dd39b8e Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@2x.png new file mode 100644 index 0000000..99fe0ab Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@3x.png new file mode 100644 index 0000000..d77c2cd Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/floods.imageset/floods@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/Contents.json new file mode 100644 index 0000000..e439aa3 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "heat.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "heat@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "heat@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat.png b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat.png new file mode 100644 index 0000000..ae17882 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@2x.png new file mode 100644 index 0000000..14e92cb Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@3x.png new file mode 100644 index 0000000..5de1ea0 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/heat.imageset/heat@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/Contents.json new file mode 100644 index 0000000..738e42b --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "menu.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "menu@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "menu@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu.png b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu.png new file mode 100644 index 0000000..b5ecd8e Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@2x.png new file mode 100644 index 0000000..6dad068 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@3x.png new file mode 100644 index 0000000..96f842e Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/menu.imageset/menu@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/Contents.json new file mode 100644 index 0000000..378ffbf --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "oval.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "oval@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "oval@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval.png b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval.png new file mode 100644 index 0000000..5d7ea40 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@2x.png new file mode 100644 index 0000000..b89be52 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@3x.png new file mode 100644 index 0000000..7588138 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/oval.imageset/oval@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/Contents.json new file mode 100644 index 0000000..934f63d --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "active.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "active@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "active@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active.png b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active.png new file mode 100644 index 0000000..235cf5b Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@2x.png new file mode 100644 index 0000000..aa690d2 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@3x.png new file mode 100644 index 0000000..d6601cc Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/selectedCheckbox.imageset/active@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/Contents.json new file mode 100644 index 0000000..9d5aaac --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "shadow.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "shadow@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "shadow@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow.png b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow.png new file mode 100644 index 0000000..0532156 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@2x.png new file mode 100644 index 0000000..bf2905f Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@3x.png new file mode 100644 index 0000000..32c52b1 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/shadow.imageset/shadow@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/Contents.json new file mode 100644 index 0000000..742338d --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tornado.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tornado@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tornado@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado.png b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado.png new file mode 100644 index 0000000..c3fb5f7 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@2x.png new file mode 100644 index 0000000..03e6aba Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@3x.png new file mode 100644 index 0000000..c76ec48 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/tornado.imageset/tornado@3x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/Contents.json b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/Contents.json new file mode 100644 index 0000000..905dcc3 --- /dev/null +++ b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "wildfires.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "wildfires@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "wildfires@3x.png" + } + ], + "info" : { + "author" : "zeplin", + "version" : "1" + } +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires.png b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires.png new file mode 100644 index 0000000..9832897 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@2x.png b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@2x.png new file mode 100644 index 0000000..e1afe7b Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@2x.png differ diff --git a/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@3x.png b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@3x.png new file mode 100644 index 0000000..d808df8 Binary files /dev/null and b/Example/Segmentio/Resorces/Assets.xcassets/wildfires.imageset/wildfires@3x.png differ diff --git a/Example/Segmentio/Resorces/ColorPalette.swift b/Example/Segmentio/Resorces/ColorPalette.swift new file mode 100644 index 0000000..ba47a93 --- /dev/null +++ b/Example/Segmentio/Resorces/ColorPalette.swift @@ -0,0 +1,17 @@ +// +// ColorPalette.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +struct ColorPalette { + static let WhiteColor = UIColor(red: 255, green: 255, blue: 255) + static let BlackColor = UIColor(red: 3, green: 3, blue: 3) + static let CoralColor = UIColor(red: 244, green: 111, blue: 96) + static let WhiteSmokeColor = UIColor(red: 245, green: 245, blue: 245) + static let GrayChateauColor = UIColor(red: 163, green: 164, blue: 168) +} \ No newline at end of file diff --git a/Example/Segmentio/Resorces/Hints.swift b/Example/Segmentio/Resorces/Hints.swift new file mode 100644 index 0000000..2d5b33a --- /dev/null +++ b/Example/Segmentio/Resorces/Hints.swift @@ -0,0 +1,53 @@ +// +// Hints.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 CocoaPods. All rights reserved. +// + +struct Hints { + static let Tornado = [ + "1. Move immediately to the special underground shelter whenever possible.", + "2. If unable to go underground, stay in a windowless, interior room on the lowest possible floor.", + "3. Remain in your shelter until the danger of tornadoes has passed.", + "4. Exit your shelter carefully, and exercise caution moving around in a tornado stricken area." + ] + + static let Earthquakes = [ + "1. Make sure you have a fire extinguisher, first aid kit, a battery-powered radio, a flashlight, and extra batteries at home.", + "2. Learn how to turn off the gas, water, and electricity.", + "3. Make up a plan of where to meet your family after an earthquake. Don't leave heavy objects on shelves.", + "4. Don’t panic." + ] + + static let ExtremeHeat = [ + "1. Know the Terms: Heat Wave, Heat Index, Heat Cramps, Heat Exhaustion, Heat Stroke, Sun Stroke.", + "2. Install window air conditioners snugly; insulate if necessary.", + "3. Check air-conditioning ducts for proper insulation.", + "4. Install temporary window reflectors (for use between windows and drapes), such as aluminum foil-covered cardboard, to reflect heat back outside." + ] + + static let Eruption = [ + "1. Know your community's warning system.", + "2. Get familiar with the evacuation procedures.", + "3. Develop a household evacuation plan. Figure out what you'll need to do if you hear the sirens go off.", + "4. Stock up on necessities. Store at least a three-day supply of food and portable water at your home." + ] + + static let Floods = [ + "1. Be aware of your area's flood risk before the expected rain is going to hit.", + "2. Check to see if you have insurance that covers flooding.", + "3. Keep insurance policies, documents, and other valuables in a safe-deposit box, that is located up high and out of harm's way.", + "4. Assemble a Disaster Supplies Kit.", + "5. Identify where you could go if told to evacuate." + ] + + static let Wildfires = [ + "1. Make a disaster supply kit and have a family plan.", + "2. Design and landscape your home with wildfire safety in mind: select materials and plants that can help contain fire rather than fuel it.", + "3. Teach each family member how to use a fire extinguisher (ABC type) and show them where it's kept.", + "4. Don’t panic." + ] + +} \ No newline at end of file diff --git a/Example/Segmentio/Storyboards/LaunchScreen.storyboard b/Example/Segmentio/Storyboards/LaunchScreen.storyboard new file mode 100644 index 0000000..32c5ff4 --- /dev/null +++ b/Example/Segmentio/Storyboards/LaunchScreen.storyboard @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Segmentio/Storyboards/Main.storyboard b/Example/Segmentio/Storyboards/Main.storyboard new file mode 100644 index 0000000..5db929c --- /dev/null +++ b/Example/Segmentio/Storyboards/Main.storyboard @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Segmentio/ViewControllers/ContentViewController.swift b/Example/Segmentio/ViewControllers/ContentViewController.swift new file mode 100644 index 0000000..acf5e77 --- /dev/null +++ b/Example/Segmentio/ViewControllers/ContentViewController.swift @@ -0,0 +1,73 @@ +// +// ContentViewController.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +private func yal_isPhone6() -> Bool { + let size = UIScreen.mainScreen().bounds.size + let minSide = min(size.height, size.width) + let maxSide = max(size.height, size.width) + return (fabs(minSide - 375.0) < 0.01) && (fabs(maxSide - 667.0) < 0.01) +} + +class ExampleTableViewCell: UITableViewCell { + @IBOutlet private weak var hintLabel: UILabel! +} + +class ContentViewController: UIViewController { + + @IBOutlet private weak var cardNameLabel: UILabel! + @IBOutlet private weak var hintTableView: UITableView! + @IBOutlet private weak var bottomCardConstraint: NSLayoutConstraint! + @IBOutlet private weak var heightConstraint: NSLayoutConstraint! + + var disaster: Disaster? + private var hints: [String]? + + class func create() -> ContentViewController { + let mainStoryboard = UIStoryboard(name: "Main", bundle: nil) + return mainStoryboard.instantiateViewControllerWithIdentifier(String(self)) as! ContentViewController + } + + // MARK: - Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + hintTableView.rowHeight = UITableViewAutomaticDimension + hintTableView.estimatedRowHeight = 100 + + if yal_isPhone6() { + bottomCardConstraint.priority = 900 + heightConstraint.priority = 1000 + heightConstraint.constant = 430 + } else { + bottomCardConstraint.priority = 1000 + heightConstraint.priority = 900 + } + + if let disaster = disaster { + cardNameLabel.text = disaster.cardName + hints = disaster.hints + } + } + +} + +extension ContentViewController: UITableViewDataSource { + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return hints?.count ?? 0 + } + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ExampleTableViewCell + cell.hintLabel?.text = hints?[indexPath.row] + return cell + } + +} \ No newline at end of file diff --git a/Example/Segmentio/ViewControllers/EmbedContainerViewController.swift b/Example/Segmentio/ViewControllers/EmbedContainerViewController.swift new file mode 100644 index 0000000..1f474f7 --- /dev/null +++ b/Example/Segmentio/ViewControllers/EmbedContainerViewController.swift @@ -0,0 +1,79 @@ +// +// EmbedContainerViewController.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit +import Segmentio + +private let animateDuration: NSTimeInterval = 0.6 + +class EmbedContainerViewController: UIViewController { + + var style = SegmentioStyle.OnlyImage + + private var currentViewController: UIViewController? + + // MARK: - Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + presentController(controller(style)) + } + + // MARK: - Private functions + + private func presentController(controller: UIViewController) { + if let _ = currentViewController { + removeCurrentViewController() + } + + addChildViewController(controller) + view.addSubview(controller.view) + currentViewController = controller + controller.didMoveToParentViewController(self) + } + + private func controller(style: SegmentioStyle) -> ExampleViewController { + let controller = ExampleViewController.create() + controller.segmentioStyle = style + controller.view.frame = view.bounds + return controller + } + + private func removeCurrentViewController() { + currentViewController?.willMoveToParentViewController(nil) + currentViewController?.view.removeFromSuperview() + currentViewController?.removeFromParentViewController() + } + + private func swapCurrentController(controller: UIViewController) { + currentViewController?.willMoveToParentViewController(nil) + addChildViewController(controller) + view.addSubview(controller.view) + + UIView.animateWithDuration( + animateDuration, + animations: { + controller.view.alpha = 1 + self.currentViewController?.view.alpha = 0 + }, + completion: { _ in + self.currentViewController?.view.removeFromSuperview() + self.currentViewController?.removeFromParentViewController() + self.currentViewController = controller + self.currentViewController?.didMoveToParentViewController(self) + } + ) + } + + // MARK: - Public functions + + func swapViewControllers(style: SegmentioStyle) { + swapCurrentController(controller(style)) + } + +} \ No newline at end of file diff --git a/Example/Segmentio/ViewControllers/ExampleViewController.swift b/Example/Segmentio/ViewControllers/ExampleViewController.swift new file mode 100644 index 0000000..44b4090 --- /dev/null +++ b/Example/Segmentio/ViewControllers/ExampleViewController.swift @@ -0,0 +1,231 @@ +// +// ExampleViewController.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit +import Segmentio + +class ExampleViewController: UIViewController { + + var segmentioStyle = SegmentioStyle.ImageOverLabel + + @IBOutlet private weak var segmentViewHeightConstraint: NSLayoutConstraint! + @IBOutlet private weak var segmentioView: Segmentio! + @IBOutlet private weak var containerView: UIView! + @IBOutlet private weak var scrollView: UIScrollView! + + private lazy var viewControllers: [UIViewController] = { + return self.preparedViewControllers() + }() + + // MARK: - Init + + class func create() -> ExampleViewController { + let board = UIStoryboard(name: "Main", bundle: nil) + return board.instantiateViewControllerWithIdentifier(String(self)) as! ExampleViewController + } + + // MARK: - Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + + switch segmentioStyle { + case .OnlyLabel, .ImageBeforeLabel, .ImageAfterLabel: + segmentViewHeightConstraint.constant = 50 + case .OnlyImage: + segmentViewHeightConstraint.constant = 100 + default: + break + } + } + + override func viewDidAppear(animated: Bool) { + super.viewDidAppear(animated) + setupSegmentioView() + setupScrollView() + } + + private func setupSegmentioView() { + segmentioView.setup( + content: segmentioContent(), + style: segmentioStyle, + options: segmentioOptions() + ) + + segmentioView.selectedSegmentioIndex = selectedSegmentioIndex() + + segmentioView.valueDidChange = { [weak self] _, segmentIndex in + if let scrollViewWidth = self?.scrollView.frame.width { + let contentOffsetX = scrollViewWidth * CGFloat(segmentIndex) + self?.scrollView.setContentOffset( + CGPoint(x: contentOffsetX, y: 0), + animated: true + ) + } + } + } + + private func segmentioContent() -> [SegmentioItem] { + return [ + SegmentioItem(title: "Tornado", image: UIImage(named: "tornado")), + SegmentioItem(title: "Earthquakes", image: UIImage(named: "earthquakes")), + SegmentioItem(title: "Extreme heat", image: UIImage(named: "heat")), + SegmentioItem(title: "Eruption", image: UIImage(named: "eruption")), + SegmentioItem(title: "Floods", image: UIImage(named: "floods")), + SegmentioItem(title: "Wildfires", image: UIImage(named: "wildfires")) + ] + } + + private func segmentioOptions() -> SegmentioOptions { + var imageContentMode = UIViewContentMode.Center + switch segmentioStyle { + case .ImageBeforeLabel, .ImageAfterLabel: + imageContentMode = .ScaleAspectFit + default: + break + } + + return SegmentioOptions( + backgroundColor: ColorPalette.WhiteColor, + maxVisibleItems: 3, + scrollEnabled: true, + indicatorOptions: segmentioIndicatorOptions(), + horizontalSeparatorOptions: segmentioHorizontalSeparatorOptions(), + verticalSeparatorOptions: segmentioVerticalSeparatorOptions(), + imageContentMode: imageContentMode, + labelTextAlignment: .Center, + segmentStates: segmentioStates() + ) + } + + private func segmentioStates() -> SegmentioStates { + let font = UIFont.exampleAvenirMediumWithSize(13) + return SegmentioStates( + defaultState: segmentioState( + backgroundColor: UIColor.clearColor(), + titleFont: font, + titleTextColor: ColorPalette.GrayChateauColor + ), + selectedState: segmentioState( + backgroundColor: UIColor.clearColor(), + titleFont: font, + titleTextColor: ColorPalette.BlackColor + ), + highlightedState: segmentioState( + backgroundColor: ColorPalette.WhiteSmokeColor, + titleFont: font, + titleTextColor: ColorPalette.GrayChateauColor + ) + ) + } + + private func segmentioState(backgroundColor backgroundColor: UIColor, titleFont: UIFont, titleTextColor: UIColor) -> SegmentioState { + return SegmentioState(backgroundColor: backgroundColor, titleFont: titleFont, titleTextColor: titleTextColor) + } + + private func segmentioIndicatorOptions() -> SegmentioIndicatorOptions { + return SegmentioIndicatorOptions( + type: .Bottom, + ratio: 1, + height: 5, + color: ColorPalette.CoralColor + ) + } + + private func segmentioHorizontalSeparatorOptions() -> SegmentioHorizontalSeparatorOptions { + return SegmentioHorizontalSeparatorOptions( + type: .TopAndBottom, + height: 1, + color: ColorPalette.WhiteSmokeColor + ) + } + + private func segmentioVerticalSeparatorOptions() -> SegmentioVerticalSeparatorOptions { + return SegmentioVerticalSeparatorOptions( + ratio: 1, + color: ColorPalette.WhiteSmokeColor + ) + } + + // Example viewControllers + + private func preparedViewControllers() -> [ContentViewController] { + let tornadoController = ContentViewController.create() + tornadoController.disaster = Disaster(cardName: "Before tornado", hints: Hints.Tornado) + + let earthquakesController = ContentViewController.create() + earthquakesController.disaster = Disaster(cardName: "Before earthquakes", hints: Hints.Earthquakes) + + let extremeHeatController = ContentViewController.create() + extremeHeatController.disaster = Disaster(cardName: "Before extreme heat", hints: Hints.ExtremeHeat) + + let eruptionController = ContentViewController.create() + eruptionController.disaster = Disaster(cardName: "Before eruption", hints: Hints.Eruption) + + let floodsController = ContentViewController.create() + floodsController.disaster = Disaster(cardName: "Before floods", hints: Hints.Floods) + + let wildfiresController = ContentViewController.create() + wildfiresController.disaster = Disaster(cardName: "Before wildfires", hints: Hints.Wildfires) + + return [ + tornadoController, + earthquakesController, + extremeHeatController, + eruptionController, + floodsController, + wildfiresController + ] + } + + private func selectedSegmentioIndex() -> Int { + return 0 + } + + + // MARK: - Setup container view + + private func setupScrollView() { + scrollView.contentSize = CGSize( + width: UIScreen.mainScreen().bounds.width * CGFloat(viewControllers.count), + height: containerView.frame.height + ) + + for (index, viewController) in viewControllers.enumerate() { + viewController.view.frame = CGRect( + x: UIScreen.mainScreen().bounds.width * CGFloat(index), + y: 0, + width: scrollView.frame.width, + height: scrollView.frame.height + ) + addChildViewController(viewController) + scrollView.addSubview(viewController.view, options: .UseAutoresize) // module's extension + viewController.didMoveToParentViewController(self) + } + } + + // MARK: - Actions + + private func goToControllerAtIndex(index: Int) { + segmentioView.selectedSegmentioIndex = index + } + +} + +extension ExampleViewController: UIScrollViewDelegate { + + func scrollViewDidEndDecelerating(scrollView: UIScrollView) { + let currentPage = floor(scrollView.contentOffset.x / scrollView.frame.width) + segmentioView.selectedSegmentioIndex = Int(currentPage) + } + + func scrollViewDidScroll(scrollView: UIScrollView) { + scrollView.contentSize = CGSize(width: scrollView.contentSize.width, height: 0) + } + +} \ No newline at end of file diff --git a/Example/Segmentio/ViewControllers/HomeViewController.swift b/Example/Segmentio/ViewControllers/HomeViewController.swift new file mode 100644 index 0000000..d04057d --- /dev/null +++ b/Example/Segmentio/ViewControllers/HomeViewController.swift @@ -0,0 +1,54 @@ +// +// HomeViewController.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit +import Segmentio + +class HomeViewController: UIViewController { + + private var currentStyle = SegmentioStyle.OnlyImage + private var containerViewController: EmbedContainerViewController? + + // MARK: - Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + } + + override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool { + return true + } + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == String(EmbedContainerViewController.self) { + containerViewController = segue.destinationViewController as? EmbedContainerViewController + containerViewController?.style = currentStyle + } + } + + // MARK: - Actions + + @IBAction private func showMenu(sender: UIBarButtonItem) { + SideMenuViewController.create().showSideMenu( + viewController: self, + currentStyle: currentStyle, + sideMenuDidHide: { [weak self] style in + self?.dismissViewControllerAnimated( + false, + completion: { + if self?.currentStyle != style { + self?.currentStyle = style + self?.containerViewController?.swapViewControllers(style) + } + } + ) + } + ) + } + +} \ No newline at end of file diff --git a/Example/Segmentio/ViewControllers/SideMenuViewController.swift b/Example/Segmentio/ViewControllers/SideMenuViewController.swift new file mode 100644 index 0000000..6bb341f --- /dev/null +++ b/Example/Segmentio/ViewControllers/SideMenuViewController.swift @@ -0,0 +1,173 @@ +// +// SideMenuViewController.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit +import Segmentio + +typealias SideMenuHandler = ((style: SegmentioStyle) -> Void) + +private let animationDuration: NSTimeInterval = 0.3 +private let selectedCheckboxImage = UIImage(named: "selectedCheckbox") +private let defaultCheckboxImage = UIImage(named: "defaultCheckbox") + +class SideMenuViewController: UIViewController { + + var sideMenuDidHide: SideMenuHandler? + + @IBOutlet private weak var shadowView: UIView! + @IBOutlet private weak var menuTableView: UITableView! + @IBOutlet private weak var menuTableViewWidthConstraint: NSLayoutConstraint! + + private var menuItems = SegmentioStyle.allStyles + private var currentStyle = SegmentioStyle.OnlyImage + + // MARK: - Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + menuTableView.hidden = true + view.hidden = true + menuTableViewWidthConstraint.constant = UIScreen.mainScreen().bounds.width * 0.7 + setupGestureRecognizers() + } + + // MARK: - Public functions + + class func create() -> SideMenuViewController { + let board = UIStoryboard(name: "Main", bundle: nil) + return board.instantiateViewControllerWithIdentifier(String(self)) as! SideMenuViewController + } + + func showSideMenu(viewController viewController: UIViewController, currentStyle: SegmentioStyle, sideMenuDidHide: SideMenuHandler?) { + self.currentStyle = currentStyle + self.sideMenuDidHide = sideMenuDidHide + self.modalPresentationStyle = .OverCurrentContext + let size = view.frame.size + viewController.presentViewController(self, animated: false) { [weak self] in + self?.view.hidden = false + self?.menuTableView.frame.origin = CGPoint(x: -size.width, y: 0) + UIView.animateWithDuration( + animationDuration, + animations: { + self?.view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.63) + self?.slideAnimationToPoint(CGPointZero) + self?.menuTableView.hidden = false + } + ) + } + } + + // MARK: - Private functions + + private func setupGestureRecognizers() { + let dissmisSideMenuSelector = #selector(SideMenuViewController.dissmisSideMenu) + + let tapRecognizer = UITapGestureRecognizer( + target: self, + action: dissmisSideMenuSelector + ) + tapRecognizer.delegate = self + shadowView.addGestureRecognizer(tapRecognizer) + + let swipeRecognizer = UISwipeGestureRecognizer( + target: self, + action: dissmisSideMenuSelector + ) + swipeRecognizer.direction = .Left + swipeRecognizer.delegate = self + view.addGestureRecognizer(swipeRecognizer) + } + + private func didSelectItemAtIndexPath(indexPath: NSIndexPath) { + currentStyle = SegmentioStyle.allStyles[indexPath.row] + dissmisSideMenu() + } + + @objc private func dissmisSideMenu() { + let size = view.frame.size + + UIView.animateWithDuration( + animationDuration, + animations: { + self.slideAnimationToPoint(CGPoint(x: -size.width, y: 0)) + self.view.backgroundColor = UIColor.clearColor() + }, + completion: { _ in + self.view.hidden = true + self.menuTableView.hidden = true + self.sideMenuDidHide?(style: self.currentStyle) + } + ) + } + + private func slideAnimationToPoint(point: CGPoint) { + UIView.animateWithDuration(animationDuration) { + self.menuTableView.frame.origin = point + } + } + + private func uncheckCurrentStyle() { + guard let currentStyleIndex = menuItems.indexOf(currentStyle) else { + return + } + + let activeIndexPath = NSIndexPath( + forRow: currentStyleIndex, + inSection: menuTableView.numberOfSections - 1 + ) + + let activeCell = menuTableView.cellForRowAtIndexPath(activeIndexPath) + activeCell?.imageView?.image = defaultCheckboxImage + } + +} + +extension SideMenuViewController: UITableViewDataSource { + + func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return menuItems.count ?? 0 + } + + + func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let reuseIdentifier = "Cell" + let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) + let isCurrentStyle = currentStyle == menuItems[indexPath.row] + + cell!.textLabel?.text = menuItems[indexPath.row].rawValue.stringFromCamelCase() + cell!.imageView?.image = isCurrentStyle ? selectedCheckboxImage : defaultCheckboxImage + + return cell! + } + +} + +extension SideMenuViewController: UITableViewDelegate { + + func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + let cell = tableView.cellForRowAtIndexPath(indexPath) + + if currentStyle != menuItems[indexPath.row] { + uncheckCurrentStyle() + cell?.imageView?.image = selectedCheckboxImage + } + didSelectItemAtIndexPath(indexPath) + } + + func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { + return UIView() + } + +} + +extension SideMenuViewController: UIGestureRecognizerDelegate { + func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { + return true + } + +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dd4e023 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2015 Yalantis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/Segmentio.podspec b/Segmentio.podspec new file mode 100644 index 0000000..98a6fad --- /dev/null +++ b/Segmentio.podspec @@ -0,0 +1,20 @@ +Pod::Spec.new do |spec| +spec.name = "Segmentio" +spec.version = "0.1.0" + +spec.homepage = "https://github.com/Yalantis/Segmentio" +spec.summary = "Animated top/bottom segmented control written in Swift!" + +spec.author = "Yalantis" +spec.license = { :type => "MIT", :file => "LICENSE" } +spec.social_media_url = "https://twitter.com/yalantis" + +spec.platform = :ios, '8.0' +spec.ios.deployment_target = '8.0' + +spec.source = { :git => "https://github.com/Yalantis/Segmentio.git", :tag => "0.1.0" } + +spec.source_files = 'Segmentio/Source/**/*.swift' +spec.module_name = 'Segmentio' +spec.requires_arc = true +end \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCell.swift b/Segmentio/Source/Cells/SegmentioCell.swift new file mode 100644 index 0000000..6432d66 --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCell.swift @@ -0,0 +1,254 @@ +// +// SegmentioCell.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +class SegmentioCell: UICollectionViewCell { + + let padding: CGFloat = 8 + let segmentTitleLabelHeight: CGFloat = 22 + + var verticalSeparatorView: UIView? + var segmentTitleLabel: UILabel? + var segmentImageView: UIImageView? + + var topConstraint: NSLayoutConstraint? + var bottomConstraint: NSLayoutConstraint? + var cellSelected = false + + private var options = SegmentioOptions() + private var style = SegmentioStyle.ImageOverLabel + private let verticalSeparatorLayer = CAShapeLayer() + + override var highlighted: Bool { + get { + return super.highlighted + } + + set { + if newValue != highlighted { + super.highlighted = newValue + + let highlightedState = options.states.highlightedState + let defaultState = options.states.defaultState + let selectedState = options.states.selectedState + + if style.isWithText() { + let highlightedTitleTextColor = cellSelected ? selectedState.titleTextColor : defaultState.titleTextColor + let highlightedTitleFont = cellSelected ? selectedState.titleFont : defaultState.titleFont + + segmentTitleLabel?.textColor = highlighted ? highlightedState.titleTextColor : highlightedTitleTextColor + segmentTitleLabel?.font = highlighted ? highlightedState.titleFont : highlightedTitleFont + } + + backgroundColor = highlighted ? highlightedState.backgroundColor : defaultState.backgroundColor + } + } + } + + // MARK: - Init + + override init(frame: CGRect) { + super.init(frame: frame) + + segmentImageView = UIImageView(frame: CGRectZero) + if let segmentImageView = segmentImageView { + contentView.addSubview(segmentImageView) + } + + segmentTitleLabel = UILabel(frame: CGRectZero) + if let segmentTitleLabel = segmentTitleLabel { + contentView.addSubview(segmentTitleLabel) + } + + segmentImageView?.translatesAutoresizingMaskIntoConstraints = false + segmentTitleLabel?.translatesAutoresizingMaskIntoConstraints = false + + segmentImageView?.layer.masksToBounds = true + segmentTitleLabel?.font = UIFont.systemFontOfSize(UIFont.smallSystemFontSize()) + + setupConstraintsForSubviews() + addVerticalSeparator() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func prepareForReuse() { + verticalSeparatorLayer.removeFromSuperlayer() + super.prepareForReuse() + + switch style { + case .OnlyLabel: + segmentTitleLabel?.text = nil + case .OnlyImage: + segmentImageView?.image = nil + default: + segmentTitleLabel?.text = nil + segmentImageView?.image = nil + } + } + + // MARK: - Configure + + func configure(content content: SegmentioItem, style: SegmentioStyle, options: SegmentioOptions, isLastCell: Bool) { + self.options = options + self.style = style + setupContent(content: content) + + if let indicatorOptions = self.options.indicatorOptions { + setupConstraint(indicatorOptions: indicatorOptions) + } + + if let _ = options.verticalSeparatorOptions { + if isLastCell == false { + setupVerticalSeparators() + } + } + } + + func configure(selected selected: Bool) { + cellSelected = selected + + let selectedState = options.states.selectedState + let defaultState = options.states.defaultState + + if style.isWithText() { + segmentTitleLabel?.textColor = selected ? selectedState.titleTextColor : defaultState.titleTextColor + segmentTitleLabel?.font = selected ? selectedState.titleFont : defaultState.titleFont + } + } + + func setupConstraintsForSubviews() { + return // implement in subclasses + } + + // MARK: - Private functions + + private func setupContent(content content: SegmentioItem) { + if style.isWithImage() { + segmentImageView?.contentMode = options.imageContentMode + segmentImageView?.image = content.image + } + + if style.isWithText() { + segmentTitleLabel?.textAlignment = options.labelTextAlignment + let defaultState = options.states.defaultState + segmentTitleLabel?.textColor = defaultState.titleTextColor + segmentTitleLabel?.font = defaultState.titleFont + segmentTitleLabel?.text = content.title + } + } + + private func setupConstraint(indicatorOptions indicatorOptions: SegmentioIndicatorOptions) { + switch indicatorOptions.type { + case .Top: + topConstraint?.constant = padding + indicatorOptions.height + case .Bottom: + bottomConstraint?.constant = padding + indicatorOptions.height + } + } + + // MARK: - Vertical separator + + private func addVerticalSeparator() { + let contentViewWidth = contentView.bounds.width + let rect = CGRect( + x: contentView.bounds.width - 1, + y: 0, + width: 1, + height: contentViewWidth + ) + verticalSeparatorView = UIView(frame: rect) + + guard let verticalSeparatorView = verticalSeparatorView else { + return + } + + if let lastView = contentView.subviews.last { + contentView.insertSubview(verticalSeparatorView, aboveSubview: lastView) + } else { + contentView.addSubview(verticalSeparatorView) + } + + // setup constraints + + verticalSeparatorView.translatesAutoresizingMaskIntoConstraints = false + + let widthConstraint = NSLayoutConstraint( + item: verticalSeparatorView, + attribute: .Width, + relatedBy: .Equal, + toItem: nil, + attribute: .NotAnAttribute, + multiplier: 1, + constant: 1 + ) + widthConstraint.active = true + + let trailingConstraint = NSLayoutConstraint( + item: verticalSeparatorView, + attribute: .Trailing, + relatedBy: .Equal, + toItem: contentView, + attribute: .Trailing, + multiplier: 1, + constant: 0 + ) + trailingConstraint.active = true + + let topConstraint = NSLayoutConstraint( + item: verticalSeparatorView, + attribute: .Top, relatedBy: .Equal, + toItem: contentView, attribute: .Top, + multiplier: 1, + constant: 0 + ) + topConstraint.active = true + + let bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: verticalSeparatorView, + attribute: .Bottom, + multiplier: 1, + constant: 0 + ) + bottomConstraint.active = true + } + + private func setupVerticalSeparators() { + guard let verticalSeparatorOptions = options.verticalSeparatorOptions else { + return + } + + guard let verticalSeparatorView = verticalSeparatorView else { + return + } + + let heightWithRatio = bounds.height * CGFloat(verticalSeparatorOptions.ratio) + let difference = (bounds.height - heightWithRatio) / 2 + + let startY = difference + let endY = bounds.height - difference + + let path = UIBezierPath() + path.moveToPoint(CGPoint(x: verticalSeparatorView.frame.width / 2, y: startY)) + path.addLineToPoint(CGPoint(x: verticalSeparatorView.frame.width / 2, y: endY)) + + verticalSeparatorLayer.path = path.CGPath + verticalSeparatorLayer.lineWidth = 1 + verticalSeparatorLayer.strokeColor = verticalSeparatorOptions.color.CGColor + verticalSeparatorLayer.fillColor = verticalSeparatorOptions.color.CGColor + + verticalSeparatorView.layer.addSublayer(verticalSeparatorLayer) + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithImage.swift b/Segmentio/Source/Cells/SegmentioCellWithImage.swift new file mode 100644 index 0000000..b117817 --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithImage.swift @@ -0,0 +1,54 @@ +// +// SegmentioCellWithImage.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +final class SegmentioCellWithImage: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentImageView = segmentImageView else { + return + } + + let views = ["segmentImageView": segmentImageView] + + // main constraints + + let segmentImageViewlHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentImageView]-|", + options: [], + metrics: nil, + views: views) + NSLayoutConstraint.activateConstraints(segmentImageViewlHorizontConstraint) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentImageView, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentImageView, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift new file mode 100644 index 0000000..2a22e79 --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithImageAfterLabel.swift @@ -0,0 +1,68 @@ +// +// SegmentioCellWithImageAfterLabel.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +final class SegmentioCellWithImageAfterLabel: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentImageView = segmentImageView else { + return + } + guard let segmentTitleLabel = segmentTitleLabel else { + return + } + + let metrics = ["labelHeight": segmentTitleLabelHeight] + let views = [ + "segmentImageView": segmentImageView, + "segmentTitleLabel": segmentTitleLabel + ] + + // main constraints + + let segmentImageViewVerticalConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "V:[segmentImageView(labelHeight)]", + options: [.AlignAllCenterY], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(segmentImageViewVerticalConstraint) + + let contentViewHorizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentTitleLabel]-[segmentImageView(labelHeight)]-|", + options: [.AlignAllCenterY], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(contentViewHorizontalConstraints) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentTitleLabel, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift new file mode 100644 index 0000000..c135ece --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithImageBeforeLabel.swift @@ -0,0 +1,68 @@ +// +// SegmentioCellWithImageBeforeLabel.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +class SegmentioCellWithImageBeforeLabel: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentImageView = segmentImageView else { + return + } + guard let segmentTitleLabel = segmentTitleLabel else { + return + } + + let metrics = ["labelHeight": segmentTitleLabelHeight] + let views = [ + "segmentImageView": segmentImageView, + "segmentTitleLabel": segmentTitleLabel + ] + + // main constraints + + let segmentImageViewVerticalConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "V:[segmentImageView(labelHeight)]", + options: [.AlignAllCenterY], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(segmentImageViewVerticalConstraint) + + let contentViewHorizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentImageView(labelHeight)]-[segmentTitleLabel]-|", + options: [.AlignAllCenterY], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(contentViewHorizontalConstraints) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentTitleLabel, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift new file mode 100644 index 0000000..60fd8d8 --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithImageOverLabel.swift @@ -0,0 +1,75 @@ +// +// SegmentioCellWithImageOverLabel.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +class SegmentioCellWithImageOverLabel: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentImageView = segmentImageView else { + return + } + guard let segmentTitleLabel = segmentTitleLabel else { + return + } + + let metrics = ["labelHeight": segmentTitleLabelHeight] + let views = [ + "segmentImageView": segmentImageView, + "segmentTitleLabel": segmentTitleLabel + ] + + // main constraints + + let segmentImageViewHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentImageView]-|", + options: [], + metrics: nil, + views: views) + NSLayoutConstraint.activateConstraints(segmentImageViewHorizontConstraint) + + let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentTitleLabel]-|", + options: [], + metrics: nil, + views: views) + NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) + + let contentViewVerticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "V:[segmentImageView]-[segmentTitleLabel(labelHeight)]", + options: [], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(contentViewVerticalConstraints) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentImageView, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentTitleLabel, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift new file mode 100644 index 0000000..e0d098a --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithImageUnderLabel.swift @@ -0,0 +1,75 @@ +// +// SegmentioCellWithImageUnderLabel.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +class SegmentioCellWithImageUnderLabel: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentImageView = segmentImageView else { + return + } + guard let segmentTitleLabel = segmentTitleLabel else { + return + } + + let metrics = ["labelHeight": segmentTitleLabelHeight] + let views = [ + "segmentImageView": segmentImageView, + "segmentTitleLabel": segmentTitleLabel + ] + + // main constraints + + let segmentImageViewHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentImageView]-|", + options: [], + metrics: nil, + views: views) + NSLayoutConstraint.activateConstraints(segmentImageViewHorizontConstraint) + + let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentTitleLabel]-|", + options: [], + metrics: nil, + views: views) + NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) + + let contentViewVerticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "V:[segmentTitleLabel(labelHeight)]-[segmentImageView]", + options: [], + metrics: metrics, + views: views) + NSLayoutConstraint.activateConstraints(contentViewVerticalConstraints) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentImageView, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Cells/SegmentioCellWithLabel.swift b/Segmentio/Source/Cells/SegmentioCellWithLabel.swift new file mode 100644 index 0000000..ea49534 --- /dev/null +++ b/Segmentio/Source/Cells/SegmentioCellWithLabel.swift @@ -0,0 +1,55 @@ +// +// SegmentioCellWithLabel.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +final class SegmentioCellWithLabel: SegmentioCell { + + override func setupConstraintsForSubviews() { + guard let segmentTitleLabel = segmentTitleLabel else { + return + } + + let views = ["segmentTitleLabel": segmentTitleLabel] + + // main constraints + + let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraintsWithVisualFormat( + "|-[segmentTitleLabel]-|", + options: [], + metrics: nil, + views: views + ) + NSLayoutConstraint.activateConstraints(segmentTitleLabelHorizontConstraint) + + // custom constraints + + topConstraint = NSLayoutConstraint( + item: segmentTitleLabel, + attribute: .Top, + relatedBy: .Equal, + toItem: contentView, + attribute: .Top, + multiplier: 1, + constant: padding + ) + topConstraint?.active = true + + bottomConstraint = NSLayoutConstraint( + item: contentView, + attribute: .Bottom, + relatedBy: .Equal, + toItem: segmentTitleLabel, + attribute: .Bottom, + multiplier: 1, + constant: padding + ) + bottomConstraint?.active = true + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Extensions/UIView+Appearance.swift b/Segmentio/Source/Extensions/UIView+Appearance.swift new file mode 100644 index 0000000..70a759d --- /dev/null +++ b/Segmentio/Source/Extensions/UIView+Appearance.swift @@ -0,0 +1,82 @@ +// +// UIView+Appearance.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +private typealias SubviewTreeModifier = (Void -> UIView) + +public struct AppearanceOptions: OptionSetType { + public let rawValue: UInt + public init(rawValue: UInt) { self.rawValue = rawValue } + public static let Overlay = AppearanceOptions(rawValue: 1 << 0) + public static let UseAutoresize = AppearanceOptions(rawValue: 1 << 1) +} + +extension UIView { + + private func addSubviewUsingOptions(options: AppearanceOptions, modifier: SubviewTreeModifier) { + let subview = modifier() + if options.union(.Overlay) == .Overlay { + if options.union(.UseAutoresize) != .UseAutoresize { + subview.translatesAutoresizingMaskIntoConstraints = false + let views = dictionaryOfNames([subview]) + + let horisontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "|[subview]|", + options: [], + metrics: nil, + views: views + ) + addConstraints(horisontalConstraints) + + let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat( + "V:|[subview]|", + options: [], + metrics: nil, + views: views + ) + addConstraints(verticalConstraints) + + } else { + frame = bounds + subview.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + } + } + } + + private func dictionaryOfNames(views:[UIView]) -> [String: UIView] { + var container = [String: UIView]() + for (_, value) in views.enumerate() { + container["subview"] = value + } + return container + } + + // MARK: - Interface methods + + public func addSubview(subview: UIView, options: AppearanceOptions) { + if subview.superview == self { + return + } + addSubviewUsingOptions(options) { [weak self] in + self?.addSubview(subview) + return subview + } + } + + public func insertSubview(subview: UIView, index: Int, options: AppearanceOptions) { + if subview.superview == self { + return + } + addSubviewUsingOptions(options) { [weak self] in + self?.insertSubview(subview, atIndex: index) + return subview + } + } + +} \ No newline at end of file diff --git a/Segmentio/Source/Segmentio.swift b/Segmentio/Source/Segmentio.swift new file mode 100644 index 0000000..1606098 --- /dev/null +++ b/Segmentio/Source/Segmentio.swift @@ -0,0 +1,649 @@ +// +// Segmentio.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit +import QuartzCore + +public typealias SegmentioSelectionCallback = ((segmentio: Segmentio, selectedSegmentioIndex: Int) -> Void) + +private let animationDuration: CFTimeInterval = 0.3 + +public class Segmentio: UIView { + + internal struct Points { + var startPoint: CGPoint + var endPoint: CGPoint + } + + internal struct Context { + var isFirstCell: Bool + var isLastCell: Bool + var isLastOrPrelastVisibleCell: Bool + var isFirstOrSecondVisibleCell: Bool + var isFirstIndex: Bool + } + + internal struct ItemInSuperview { + var collectionViewWidth: CGFloat + var cellFrameInSuperview: CGRect + var shapeLayerWidth: CGFloat + var startX: CGFloat + var endX: CGFloat + } + + public var valueDidChange: SegmentioSelectionCallback? + public var selectedSegmentioIndex = -1 { + didSet { + if selectedSegmentioIndex != oldValue { + reloadSegmentio() + valueDidChange?(segmentio: self, selectedSegmentioIndex: selectedSegmentioIndex) + } + } + } + + private var segmentioCollectionView: UICollectionView? + private var segmentioItems = [SegmentioItem]() + private var segmentioOptions = SegmentioOptions() + private var segmentioStyle = SegmentioStyle.ImageOverLabel + private var isPerformingScrollAnimation = false + + private var topSeparatorView: UIView? + private var bottomSeparatorView: UIView? + private var indicatorLayer: CAShapeLayer? + private var selectedLayer: CAShapeLayer? + + private var cachedOrientation: UIInterfaceOrientation? = UIApplication.sharedApplication().statusBarOrientation { + didSet { + if cachedOrientation != oldValue { + reloadSegmentio() + } + } + } + + // MARK: - Lifecycle + + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + commonInit() + } + + override public init(frame: CGRect) { + super.init(frame: frame) + commonInit() + } + + private func commonInit() { + setupSegmentedCollectionView() + NSNotificationCenter.defaultCenter().addObserver( + self, + selector: #selector(Segmentio.handleOrientationNotification), + name: UIDeviceOrientationDidChangeNotification, + object: nil + ) + } + + private func setupSegmentedCollectionView() { + let layout = UICollectionViewFlowLayout() + layout.sectionInset = UIEdgeInsetsZero + layout.scrollDirection = .Horizontal + layout.minimumInteritemSpacing = 0 + layout.minimumLineSpacing = 0 + + let collectionView = UICollectionView( + frame: frameForSegmentCollectionView(), + collectionViewLayout: layout + ) + + collectionView.dataSource = self + collectionView.delegate = self + collectionView.pagingEnabled = false + collectionView.showsHorizontalScrollIndicator = false + collectionView.showsVerticalScrollIndicator = false + collectionView.bounces = true + collectionView.scrollEnabled = segmentioOptions.scrollEnabled + collectionView.backgroundColor = UIColor.clearColor() + + segmentioCollectionView = collectionView + + if let segmentioCollectionView = segmentioCollectionView { + addSubview(segmentioCollectionView, options: .Overlay) + } + } + + private func frameForSegmentCollectionView() -> CGRect { + var separatorsHeight: CGFloat = 0 + var collectionViewFrameMinY: CGFloat = 0 + + if let horizontalSeparatorOptions = segmentioOptions.horizontalSeparatorOptions { + let separatorHeight = horizontalSeparatorOptions.height + + switch horizontalSeparatorOptions.type { + case .Top: + collectionViewFrameMinY = separatorHeight + separatorsHeight = separatorHeight + case .Bottom: + separatorsHeight = separatorHeight + case .TopAndBottom: + collectionViewFrameMinY = separatorHeight + separatorsHeight = separatorHeight * 2 + } + } + + return CGRect( + x: 0, + y: collectionViewFrameMinY, + width: bounds.width, + height: bounds.height - separatorsHeight + ) + } + + // MARK: - Handle orientation notification + + @objc private func handleOrientationNotification() { + cachedOrientation = UIApplication.sharedApplication().statusBarOrientation + } + + // MARK: - Setups: + // MARK: Main setup + + public func setup(content content: [SegmentioItem], style: SegmentioStyle, options: SegmentioOptions?) { + segmentioItems = content + segmentioStyle = style + + selectedLayer?.removeFromSuperlayer() + indicatorLayer?.removeFromSuperlayer() + + if let options = options { + segmentioOptions = options + segmentioCollectionView?.scrollEnabled = segmentioOptions.scrollEnabled + backgroundColor = options.backgroundColor + } + + if segmentioOptions.states.selectedState.backgroundColor != UIColor.clearColor() { + selectedLayer = CAShapeLayer() + if let selectedLayer = selectedLayer, sublayer = segmentioCollectionView?.layer { + setupShapeLayer( + shapeLayer: selectedLayer, + backgroundColor: segmentioOptions.states.selectedState.backgroundColor, + height: bounds.height, + sublayer: sublayer + ) + } + } + + if let indicatorOptions = segmentioOptions.indicatorOptions { + indicatorLayer = CAShapeLayer() + if let indicatorLayer = indicatorLayer { + setupShapeLayer( + shapeLayer: indicatorLayer, + backgroundColor: indicatorOptions.color, + height: indicatorOptions.height, + sublayer: layer + ) + } + } + + if let _ = segmentioOptions.horizontalSeparatorOptions { + setupHorizontalSeparator() + } + + setupCellWithStyle(segmentioStyle) + segmentioCollectionView?.reloadData() + } + + // MARK: Collection view setup + + private func setupCellWithStyle(style: SegmentioStyle) { + var cellClass: SegmentioCell.Type { + switch style { + case .OnlyLabel: + return SegmentioCellWithLabel.self + case .OnlyImage: + return SegmentioCellWithImage.self + case .ImageOverLabel: + return SegmentioCellWithImageOverLabel.self + case .ImageUnderLabel: + return SegmentioCellWithImageUnderLabel.self + case .ImageBeforeLabel: + return SegmentioCellWithImageBeforeLabel.self + case .ImageAfterLabel: + return SegmentioCellWithImageAfterLabel.self + } + } + + segmentioCollectionView?.registerClass( + cellClass, + forCellWithReuseIdentifier: segmentioStyle.rawValue + ) + + segmentioCollectionView?.layoutIfNeeded() + } + + // MARK: Horizontal separators setup + + private func setupHorizontalSeparator() { + topSeparatorView?.removeFromSuperview() + bottomSeparatorView?.removeFromSuperview() + + guard let horizontalSeparatorOptions = segmentioOptions.horizontalSeparatorOptions else { + return + } + + let height = horizontalSeparatorOptions.height + let type = horizontalSeparatorOptions.type + + if type == .Top || type == .TopAndBottom { + topSeparatorView = UIView(frame: CGRectZero) + setupConstraintsForSeparatorView( + separatorView: topSeparatorView, + originY: 0 + ) + } + + if type == .Bottom || type == .TopAndBottom { + bottomSeparatorView = UIView(frame: CGRectZero) + setupConstraintsForSeparatorView( + separatorView: bottomSeparatorView, + originY: frame.maxY - height + ) + } + } + + private func setupConstraintsForSeparatorView(separatorView separatorView: UIView?, originY: CGFloat) { + guard let horizontalSeparatorOptions = segmentioOptions.horizontalSeparatorOptions, separatorView = separatorView else { + return + } + + separatorView.translatesAutoresizingMaskIntoConstraints = false + separatorView.backgroundColor = horizontalSeparatorOptions.color + addSubview(separatorView) + + let topConstraint = NSLayoutConstraint( + item: separatorView, + attribute: .Top, + relatedBy: .Equal, + toItem: superview, + attribute: .Top, + multiplier: 1, + constant: originY + ) + topConstraint.active = true + + let leadingConstraint = NSLayoutConstraint( + item: separatorView, + attribute: .Leading, + relatedBy: .Equal, + toItem: self, + attribute: .Leading, + multiplier: 1, + constant: 0 + ) + leadingConstraint.active = true + + let trailingConstraint = NSLayoutConstraint( + item: separatorView, + attribute: .Trailing, + relatedBy: .Equal, + toItem: self, + attribute: .Trailing, + multiplier: 1, + constant: 0 + ) + trailingConstraint.active = true + + let heightConstraint = NSLayoutConstraint( + item: separatorView, + attribute: .Height, + relatedBy: .Equal, + toItem: nil, + attribute: .NotAnAttribute, + multiplier: 1, + constant: horizontalSeparatorOptions.height + ) + heightConstraint.active = true + } + + // MARK: CAShapeLayers setup + + private func setupShapeLayer(shapeLayer shapeLayer: CAShapeLayer, backgroundColor: UIColor, height: CGFloat, sublayer: CALayer) { + shapeLayer.fillColor = backgroundColor.CGColor + shapeLayer.strokeColor = backgroundColor.CGColor + shapeLayer.lineWidth = height + layer.insertSublayer(shapeLayer, below: sublayer) + } + + // MARK: - Actions: + // MARK: Reload segmentio + private func reloadSegmentio() { + segmentioCollectionView?.reloadData() + scrollToItemAtContext() + moveShapeLayerAtContext() + } + + // MARK: Move shape layer to item + + private func moveShapeLayerAtContext() { + if let indicatorLayer = indicatorLayer, let options = segmentioOptions.indicatorOptions { + let item = itemInSuperview(ratio: options.ratio) + let context = contextForItem(item) + + let points = Points( + context: context, + item: item, + pointY: indicatorPointY() + ) + + moveShapeLayer( + indicatorLayer, + startPoint: points.startPoint, + endPoint: points.endPoint, + animated: true + ) + } + + if let selectedLayer = selectedLayer { + let item = itemInSuperview() + let context = contextForItem(item) + + let points = Points( + context: context, + item: item, + pointY: bounds.midY + ) + + moveShapeLayer( + selectedLayer, + startPoint: points.startPoint, + endPoint: points.endPoint, + animated: true + ) + } + } + + // MARK: Scroll to item + + private func scrollToItemAtContext() { + guard let numberOfSections = segmentioCollectionView?.numberOfSections() else { + return + } + + let item = itemInSuperview() + let context = contextForItem(item) + + if context.isLastOrPrelastVisibleCell == true { + let newIndex = selectedSegmentioIndex + (context.isLastCell ? 0 : 1) + let newIndexPath = NSIndexPath(forItem: newIndex, inSection: numberOfSections - 1) + segmentioCollectionView?.scrollToItemAtIndexPath( + newIndexPath, + atScrollPosition: .None, + animated: true + ) + } + + if context.isFirstOrSecondVisibleCell == true { + let newIndex = selectedSegmentioIndex - (context.isFirstIndex ? 1 : 0) + let newIndexPath = NSIndexPath(forItem: newIndex, inSection: numberOfSections - 1) + segmentioCollectionView?.scrollToItemAtIndexPath( + newIndexPath, + atScrollPosition: .None, + animated: true + ) + } + } + + // MARK: Move shape layer + + private func moveShapeLayer(shapeLayer: CAShapeLayer, startPoint startPoint: CGPoint, endPoint: CGPoint, animated: Bool = false) { + var endPointWithVerticalSeparator = endPoint + let isLastItem = selectedSegmentioIndex + 1 == segmentioItems.count + endPointWithVerticalSeparator.x = endPoint.x - (isLastItem ? 0 : 1) + + let shapeLayerPath = UIBezierPath() + shapeLayerPath.moveToPoint(startPoint) + shapeLayerPath.addLineToPoint(endPointWithVerticalSeparator) + + if animated == true { + isPerformingScrollAnimation = true + userInteractionEnabled = false + + CATransaction.begin() + let animation = CABasicAnimation(keyPath: "path") + animation.fromValue = shapeLayer.path + animation.toValue = shapeLayerPath.CGPath + animation.duration = animationDuration + CATransaction.setCompletionBlock() { + self.isPerformingScrollAnimation = false + self.userInteractionEnabled = true + } + shapeLayer.addAnimation(animation, forKey: "path") + CATransaction.commit() + } + + shapeLayer.path = shapeLayerPath.CGPath + } + + // MARK: - Context for item + + private func contextForItem(item: ItemInSuperview) -> Context { + let cellFrame = item.cellFrameInSuperview + let cellWidth = cellFrame.width + let lastCellMinX = floor(item.collectionViewWidth - cellWidth) + let minX = floor(cellFrame.minX) + let maxX = floor(cellFrame.maxX) + + let isLastVisibleCell = maxX >= item.collectionViewWidth + let isLastVisibleCellButOne = minX < lastCellMinX && maxX > lastCellMinX + + let isFirstVisibleCell = minX <= 0 + let isNextAfterFirstVisibleCell = minX < cellWidth && maxX > cellWidth + + return Context( + isFirstCell: selectedSegmentioIndex == 0, + isLastCell: selectedSegmentioIndex == segmentioItems.count - 1, + isLastOrPrelastVisibleCell: isLastVisibleCell || isLastVisibleCellButOne, + isFirstOrSecondVisibleCell: isFirstVisibleCell || isNextAfterFirstVisibleCell, + isFirstIndex: selectedSegmentioIndex > 0 + ) + } + + // MARK: - Item in superview + + private func itemInSuperview(ratio ratio: CGFloat = 1) -> ItemInSuperview { + var collectionViewWidth: CGFloat = 0 + var cellWidth: CGFloat = 0 + var cellRect = CGRectZero + var shapeLayerWidth: CGFloat = 0 + + if let collectionView = segmentioCollectionView { + collectionViewWidth = collectionView.frame.width + let maxVisibleItems = CGFloat(segmentioOptions.maxVisibleItems) + cellWidth = floor(collectionViewWidth / maxVisibleItems) + + cellRect = CGRect( + x: floor(CGFloat(selectedSegmentioIndex) * cellWidth - collectionView.contentOffset.x), + y: 0, + width: floor(collectionViewWidth / maxVisibleItems), + height: collectionView.frame.height + ) + + shapeLayerWidth = floor(cellWidth * ratio) + } + + return ItemInSuperview( + collectionViewWidth: collectionViewWidth, + cellFrameInSuperview: cellRect, + shapeLayerWidth: shapeLayerWidth, + startX: floor(cellRect.midX - (shapeLayerWidth / 2)), + endX: floor(cellRect.midX + (shapeLayerWidth / 2)) + ) + } + + // MARK: - Indicator point Y + + private func indicatorPointY() -> CGFloat { + var indicatorPointY: CGFloat = 0 + + guard let indicatorOptions = segmentioOptions.indicatorOptions else { + return indicatorPointY + } + + switch indicatorOptions.type { + case .Top: + indicatorPointY = (indicatorOptions.height / 2) + case .Bottom: + indicatorPointY = frame.height - (indicatorOptions.height / 2) + } + + guard let horizontalSeparatorOptions = segmentioOptions.horizontalSeparatorOptions else { + return indicatorPointY + } + + let separatorHeight = horizontalSeparatorOptions.height + let isIndicatorTop = indicatorOptions.type == .Top + + switch horizontalSeparatorOptions.type { + case .Top: + indicatorPointY = isIndicatorTop ? indicatorPointY + separatorHeight : indicatorPointY + case .Bottom: + indicatorPointY = isIndicatorTop ? indicatorPointY : indicatorPointY - separatorHeight + case .TopAndBottom: + indicatorPointY = isIndicatorTop ? indicatorPointY + separatorHeight : indicatorPointY - separatorHeight + } + + return indicatorPointY + } +} + +// MARK: - UICollectionViewDataSource + +extension Segmentio: UICollectionViewDataSource { + + public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return segmentioItems.count ?? 0 + } + + public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCellWithReuseIdentifier( + segmentioStyle.rawValue, + forIndexPath: indexPath) as! SegmentioCell + + cell.configure( + content: segmentioItems[indexPath.row], + style: segmentioStyle, + options: segmentioOptions, + isLastCell: indexPath.row == segmentioItems.count - 1 + ) + + cell.configure(selected: (indexPath.row == selectedSegmentioIndex)) + + return cell + } + +} + +// MARK: - UICollectionViewDelegate + +extension Segmentio: UICollectionViewDelegate { + + public func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool { + return true + } + + public func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { + selectedSegmentioIndex = indexPath.row + } + +} + +// MARK: - UICollectionViewDelegateFlowLayout + +extension Segmentio: UICollectionViewDelegateFlowLayout { + + public func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { + return CGSize( + width: floor(collectionView.frame.width / CGFloat(segmentioOptions.maxVisibleItems)), + height: collectionView.frame.height + ) + } + +} + +// MARK: - UIScrollViewDelegate + +extension Segmentio: UIScrollViewDelegate { + + public func scrollViewDidScroll(scrollView: UIScrollView) { + if isPerformingScrollAnimation == true { + return + } + + if let options = segmentioOptions.indicatorOptions, indicatorLayer = indicatorLayer { + let item = itemInSuperview(ratio: options.ratio) + moveShapeLayer( + indicatorLayer, + startPoint: CGPointMake(item.startX, indicatorPointY()), + endPoint: CGPointMake(item.endX, indicatorPointY()), + animated: false + ) + } + + if let selectedLayer = selectedLayer { + let item = itemInSuperview() + moveShapeLayer( + selectedLayer, + startPoint: CGPoint(x: item.startX, y: bounds.midY), + endPoint: CGPoint(x: item.endX, y: bounds.midY), + animated: false + ) + } + } + +} + +extension Segmentio.Points { + init(context: Segmentio.Context, item: Segmentio.ItemInSuperview, pointY: CGFloat) { + let cellWidth = item.cellFrameInSuperview.width + + var startX = item.startX + var endX = item.endX + + if context.isFirstCell == false && context.isLastCell == false { + if context.isLastOrPrelastVisibleCell == true { + let updatedStartX = item.collectionViewWidth - (cellWidth * 2) + ((cellWidth - item.shapeLayerWidth) / 2) + startX = updatedStartX + let updatedEndX = updatedStartX + item.shapeLayerWidth + endX = updatedEndX + } + + if context.isFirstOrSecondVisibleCell == true { + let updatedEndX = (cellWidth * 2) - ((cellWidth - item.shapeLayerWidth) / 2) + endX = updatedEndX + let updatedStartX = updatedEndX - item.shapeLayerWidth + startX = updatedStartX + } + } + + if context.isFirstCell == true { + startX = (cellWidth - item.shapeLayerWidth) / 2 + endX = startX + item.shapeLayerWidth + } + + if context.isLastCell == true { + startX = item.collectionViewWidth - cellWidth + (cellWidth - item.shapeLayerWidth) / 2 + endX = startX + item.shapeLayerWidth + } + + startPoint = CGPoint(x: startX, y: pointY) + endPoint = CGPoint(x: endX, y: pointY) + } + +} \ No newline at end of file diff --git a/Segmentio/Source/SegmentioOptions.swift b/Segmentio/Source/SegmentioOptions.swift new file mode 100644 index 0000000..4cf0395 --- /dev/null +++ b/Segmentio/Source/SegmentioOptions.swift @@ -0,0 +1,180 @@ +// +// SegmentioOptions.swift +// Segmentio +// +// Created by Dmitriy Demchenko +// Copyright © 2016 Yalantis Mobile. All rights reserved. +// + +import UIKit + +// MARK: - Item + +public struct SegmentioItem { + var title: String? + var image: UIImage? + + public init(title: String?, image: UIImage?) { + self.title = title + self.image = image + } + +} + +// MARK: - Content view + +public struct SegmentioState { + var backgroundColor: UIColor + var titleFont: UIFont + var titleTextColor: UIColor + + public init( + backgroundColor: UIColor = UIColor.clearColor(), + titleFont: UIFont = UIFont.systemFontOfSize(UIFont.smallSystemFontSize()), + titleTextColor: UIColor = UIColor.blackColor()) { + self.backgroundColor = backgroundColor + self.titleFont = titleFont + self.titleTextColor = titleTextColor + } + +} + +// MARK: - Horizontal separator + +public enum SegmentioHorizontalSeparatorType { + case Top, Bottom, TopAndBottom +} + +public struct SegmentioHorizontalSeparatorOptions { + var type: SegmentioHorizontalSeparatorType + var height: CGFloat + var color: UIColor + + public init( + type: SegmentioHorizontalSeparatorType = .TopAndBottom, + height: CGFloat = 1.0, + color: UIColor = UIColor.darkGrayColor()) { + self.type = type + self.height = height + self.color = color + } + +} + +// MARK: - Vertical separator + +public struct SegmentioVerticalSeparatorOptions { + var ratio: CGFloat + var color: UIColor + + public init(ratio: CGFloat = 1.0, color: UIColor = UIColor.darkGrayColor()) { + self.ratio = ratio + self.color = color + } + +} + +// MARK: - Indicator + +public enum SegmentioIndicatorType { + case Top, Bottom +} + +public struct SegmentioIndicatorOptions { + var type: SegmentioIndicatorType + var ratio: CGFloat + var height: CGFloat + var color: UIColor + + public init( + type: SegmentioIndicatorType = .Bottom, + ratio: CGFloat = 1.0, + height: CGFloat = 2.0, + color: UIColor = UIColor.orangeColor()) { + self.type = type + self.ratio = ratio + self.height = height + self.color = color + } + +} + +// MARK: - Control options + +public enum SegmentioStyle: String { + case OnlyLabel, OnlyImage, ImageOverLabel, ImageUnderLabel, ImageBeforeLabel, ImageAfterLabel + + public static let allStyles = [ + OnlyLabel, + OnlyImage, + ImageOverLabel, + ImageUnderLabel, + ImageBeforeLabel, + ImageAfterLabel + ] + + public func isWithText() -> Bool { + switch self { + case .OnlyLabel, .ImageOverLabel, .ImageUnderLabel, .ImageBeforeLabel, .ImageAfterLabel: + return true + default: + return false + } + } + + public func isWithImage() -> Bool { + switch self { + case .ImageOverLabel, .ImageUnderLabel, .ImageBeforeLabel, .ImageAfterLabel, .OnlyImage: + return true + default: + return false + } + } +} + +public typealias SegmentioStates = (defaultState: SegmentioState, selectedState: SegmentioState, highlightedState: SegmentioState) + +public struct SegmentioOptions { + var backgroundColor: UIColor + var maxVisibleItems: Int + var scrollEnabled: Bool + var horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions? + var verticalSeparatorOptions: SegmentioVerticalSeparatorOptions? + var indicatorOptions: SegmentioIndicatorOptions? + var imageContentMode: UIViewContentMode + var labelTextAlignment: NSTextAlignment + var states: SegmentioStates + + public init() { + self.backgroundColor = UIColor.lightGrayColor() + self.maxVisibleItems = 4 + self.scrollEnabled = true + + self.horizontalSeparatorOptions = SegmentioHorizontalSeparatorOptions() + self.verticalSeparatorOptions = SegmentioVerticalSeparatorOptions() + + self.indicatorOptions = SegmentioIndicatorOptions() + + self.imageContentMode = .Center + self.labelTextAlignment = .Center + + self.states = SegmentioStates( + defaultState: SegmentioState(), + selectedState: SegmentioState(), + highlightedState: SegmentioState() + ) + } + + public init(backgroundColor: UIColor, maxVisibleItems: Int, scrollEnabled: Bool, indicatorOptions: SegmentioIndicatorOptions?, horizontalSeparatorOptions: SegmentioHorizontalSeparatorOptions?, verticalSeparatorOptions: SegmentioVerticalSeparatorOptions?, imageContentMode: UIViewContentMode, labelTextAlignment: NSTextAlignment, segmentStates: SegmentioStates) { + self.backgroundColor = backgroundColor + self.maxVisibleItems = maxVisibleItems + self.scrollEnabled = scrollEnabled + self.indicatorOptions = indicatorOptions + self.horizontalSeparatorOptions = horizontalSeparatorOptions + self.verticalSeparatorOptions = verticalSeparatorOptions + self.imageContentMode = imageContentMode + self.labelTextAlignment = labelTextAlignment + self.states = segmentStates + } + +} \ No newline at end of file diff --git a/_Pods.xcodeproj b/_Pods.xcodeproj new file mode 120000 index 0000000..3c5a8e7 --- /dev/null +++ b/_Pods.xcodeproj @@ -0,0 +1 @@ +Example/Pods/Pods.xcodeproj \ No newline at end of file