From 621957e3383a19fbb28cf6dce3763f5eff07a386 Mon Sep 17 00:00:00 2001 From: Eugene Pravda Date: Wed, 28 Sep 2016 17:50:32 +0300 Subject: [PATCH] add badges --- Example/Pods/Pods.xcodeproj/project.pbxproj | 28 +++++++++++ Segmentio/Source/BadgeWithCounterView.swift | 41 ---------------- .../Source/BadgeWithCounterViewBigSized.xib | 48 ------------------- .../BadgeWithCounterViewStandardSized.xib | 48 ------------------- 4 files changed, 28 insertions(+), 137 deletions(-) delete mode 100644 Segmentio/Source/BadgeWithCounterView.swift delete mode 100644 Segmentio/Source/BadgeWithCounterViewBigSized.xib delete mode 100644 Segmentio/Source/BadgeWithCounterViewStandardSized.xib diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 4392dd4..8d30c59 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 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, ); }; }; + 4482DBD41D9C1019004FA9FF /* BadgeViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4482DBCF1D9C1019004FA9FF /* BadgeViewPresenter.swift */; }; + 4482DBD51D9C1019004FA9FF /* BadgeWithCounterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4482DBD11D9C1019004FA9FF /* BadgeWithCounterView.swift */; }; 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 */; }; @@ -47,6 +49,10 @@ 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 = ""; }; + 4482DBCF1D9C1019004FA9FF /* BadgeViewPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BadgeViewPresenter.swift; sourceTree = ""; }; + 4482DBD11D9C1019004FA9FF /* BadgeWithCounterView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BadgeWithCounterView.swift; sourceTree = ""; }; + 4482DBD21D9C1019004FA9FF /* BadgeWithCounterViewBigSized.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BadgeWithCounterViewBigSized.xib; sourceTree = ""; }; + 4482DBD31D9C1019004FA9FF /* BadgeWithCounterViewStandardSized.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BadgeWithCounterViewStandardSized.xib; 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 = ""; }; @@ -137,6 +143,25 @@ name = iOS; sourceTree = ""; }; + 4482DBCE1D9C1019004FA9FF /* Badge */ = { + isa = PBXGroup; + children = ( + 4482DBCF1D9C1019004FA9FF /* BadgeViewPresenter.swift */, + 4482DBD01D9C1019004FA9FF /* Views */, + ); + path = Badge; + sourceTree = ""; + }; + 4482DBD01D9C1019004FA9FF /* Views */ = { + isa = PBXGroup; + children = ( + 4482DBD11D9C1019004FA9FF /* BadgeWithCounterView.swift */, + 4482DBD21D9C1019004FA9FF /* BadgeWithCounterViewBigSized.xib */, + 4482DBD31D9C1019004FA9FF /* BadgeWithCounterViewStandardSized.xib */, + ); + path = Views; + sourceTree = ""; + }; 47DD221E11AD5E3ABBE22D1B01521963 /* Extensions */ = { isa = PBXGroup; children = ( @@ -260,6 +285,7 @@ 8D794DA325FA95310FAD589F0A6A3BC8 /* Segmentio.swift */, E1E1181660922799D84A9AC7A93E4C17 /* SegmentioOptions.swift */, 6A17966A17091F11F4DC34B63A2A4ED4 /* Cells */, + 4482DBCE1D9C1019004FA9FF /* Badge */, 47DD221E11AD5E3ABBE22D1B01521963 /* Extensions */, ); path = Source; @@ -400,7 +426,9 @@ C5C3FE3FCC48A1460787D130DF0CF12E /* Segmentio.swift in Sources */, 7535676B6DAAED27C9E51F128BA31498 /* SegmentioOptions.swift in Sources */, 08F3ADCD6D2B9007082089826E712007 /* UIView+Appearance.swift in Sources */, + 4482DBD51D9C1019004FA9FF /* BadgeWithCounterView.swift in Sources */, E15160B05BBD4763B9DD87EAFA105B3B /* SegmentioCell.swift in Sources */, + 4482DBD41D9C1019004FA9FF /* BadgeViewPresenter.swift in Sources */, 124C21C2A8B015C1BB87D30F4EEA0214 /* SegmentioCellWithImage.swift in Sources */, 8B2E8009B9692DF362678E6FE094A084 /* SegmentioCellWithImageAfterLabel.swift in Sources */, DC7CDA37564D49D1443EFF857FB8B794 /* SegmentioCellWithImageBeforeLabel.swift in Sources */, diff --git a/Segmentio/Source/BadgeWithCounterView.swift b/Segmentio/Source/BadgeWithCounterView.swift deleted file mode 100644 index 1bf4bfa..0000000 --- a/Segmentio/Source/BadgeWithCounterView.swift +++ /dev/null @@ -1,41 +0,0 @@ -import Foundation - -private let BadgeCounterMaxValue = 99 -private let BadgeCounterOverMaxValueText = "99+" -private let standardSizedNibName = "BadgeWithCounterViewStandardSized" -private let bigSizedNibName = "BadgeWithCounterViewBigSized" - -enum CounterBadgeSize { - case Standard - case Big -} - -class BadgeWithCounterView: UIView { - - @IBOutlet private weak var counterValueLabel: UILabel! - @IBOutlet private weak var backgroundImageView: UIImageView! - - class func instanceFromNib(size size: CounterBadgeSize) -> BadgeWithCounterView { - let nibName = nibNameForSize(size) - return UINib(nibName: nibName, bundle: nil).instantiateWithOwner(nil, options: nil)[0] as! BadgeWithCounterView - } - - func setBadgeCounterValue(counterValue: Int) { - var counterText: String! - if counterValue > BadgeCounterMaxValue { - counterText = BadgeCounterOverMaxValueText - } else { - counterText = String(counterValue) - } - counterValueLabel.text = counterText - } - - func setBadgeBackgroundColor(color: UIColor) { - backgroundImageView.backgroundColor = color - } - - private class func nibNameForSize(size: CounterBadgeSize) -> String { - return (size == .Standard) ? standardSizedNibName : bigSizedNibName - } - -} \ No newline at end of file diff --git a/Segmentio/Source/BadgeWithCounterViewBigSized.xib b/Segmentio/Source/BadgeWithCounterViewBigSized.xib deleted file mode 100644 index 14d506b..0000000 --- a/Segmentio/Source/BadgeWithCounterViewBigSized.xib +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Segmentio/Source/BadgeWithCounterViewStandardSized.xib b/Segmentio/Source/BadgeWithCounterViewStandardSized.xib deleted file mode 100644 index 698642b..0000000 --- a/Segmentio/Source/BadgeWithCounterViewStandardSized.xib +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -