Skip to content

Commit 33c0f1e

Browse files
committedAug 18, 2016
Add icon style support
Add support for specifying an `IconStyle` in the `MessageView.configureTheme()` convenience function.
1 parent b7b4221 commit 33c0f1e

File tree

16 files changed

+226
-175
lines changed

16 files changed

+226
-175
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [1.0.2](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/1.0.2)
5+
6+
### Feature
7+
8+
* Add support for specifying an `IconStyle` in the `MessageView.configureTheme()` convenience function.
9+
410
## [1.0.1](https://github.com/SwiftKickMobile/SwiftMessages/releases/tag/1.0.1)
511

612
* Add code comments.

‎Demo/Demo/Base.lproj/Main.storyboard

+41-8
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<objects>
121121
<tableViewController id="NF9-wZ-lbZ" customClass="ExploreViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
122122
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="none" allowsSelection="NO" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="XwA-eF-0LG">
123-
<rect key="frame" x="0.0" y="0.0" width="600" height="1000"/>
123+
<rect key="frame" x="0.0" y="0.0" width="600" height="1200"/>
124124
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
125125
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
126126
<sections>
@@ -355,8 +355,40 @@
355355
</constraints>
356356
</tableViewCellContentView>
357357
</tableViewCell>
358+
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="65" id="0mE-sA-4rN" userLabel="Theme cell">
359+
<rect key="frame" x="0.0" y="599" width="600" height="65"/>
360+
<autoresizingMask key="autoresizingMask"/>
361+
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="0mE-sA-4rN" id="eVs-bm-01A">
362+
<rect key="frame" x="0.0" y="0.0" width="600" height="65"/>
363+
<autoresizingMask key="autoresizingMask"/>
364+
<subviews>
365+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ICON STYLE" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sXY-rl-8uH">
366+
<rect key="frame" x="18" y="8" width="79" height="16"/>
367+
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
368+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
369+
<nil key="highlightedColor"/>
370+
</label>
371+
<segmentedControl opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="c2K-94-CuB">
372+
<rect key="frame" x="29" y="29" width="309" height="29"/>
373+
<segments>
374+
<segment title="Regular"/>
375+
<segment title="Light"/>
376+
<segment title="Subtle"/>
377+
</segments>
378+
</segmentedControl>
379+
</subviews>
380+
<constraints>
381+
<constraint firstItem="c2K-94-CuB" firstAttribute="leading" secondItem="eVs-bm-01A" secondAttribute="leadingMargin" constant="10" id="57X-r6-yn8"/>
382+
<constraint firstItem="sXY-rl-8uH" firstAttribute="top" secondItem="eVs-bm-01A" secondAttribute="topMargin" id="aNb-k2-SZY"/>
383+
<constraint firstItem="c2K-94-CuB" firstAttribute="top" secondItem="sXY-rl-8uH" secondAttribute="bottom" constant="5" id="euE-AS-gZT"/>
384+
<constraint firstAttribute="bottomMargin" relation="greaterThanOrEqual" secondItem="c2K-94-CuB" secondAttribute="bottom" id="ifY-M2-nQa"/>
385+
<constraint firstAttribute="trailingMargin" relation="greaterThanOrEqual" secondItem="c2K-94-CuB" secondAttribute="trailing" constant="10" id="jMs-A0-qxE"/>
386+
<constraint firstItem="sXY-rl-8uH" firstAttribute="leading" secondItem="eVs-bm-01A" secondAttribute="leadingMargin" constant="10" id="rCc-O8-QkU"/>
387+
</constraints>
388+
</tableViewCellContentView>
389+
</tableViewCell>
358390
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="4RW-U9-BVB" userLabel="Drop shadow cell">
359-
<rect key="frame" x="0.0" y="599" width="600" height="44"/>
391+
<rect key="frame" x="0.0" y="664" width="600" height="44"/>
360392
<autoresizingMask key="autoresizingMask"/>
361393
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="4RW-U9-BVB" id="wdb-hX-CIv">
362394
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
@@ -391,7 +423,7 @@
391423
<tableViewSection headerTitle="CONTENT" id="Mih-L6-PeE">
392424
<cells>
393425
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="65" id="ddI-Jn-NgP" userLabel="Title cell">
394-
<rect key="frame" x="0.0" y="694" width="600" height="65"/>
426+
<rect key="frame" x="0.0" y="759" width="600" height="65"/>
395427
<autoresizingMask key="autoresizingMask"/>
396428
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ddI-Jn-NgP" id="4HG-zA-HtF">
397429
<rect key="frame" x="0.0" y="0.0" width="600" height="65"/>
@@ -420,7 +452,7 @@
420452
</tableViewCellContentView>
421453
</tableViewCell>
422454
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="65" id="bdE-R5-mtF" userLabel="Subtitle cell">
423-
<rect key="frame" x="0.0" y="759" width="600" height="65"/>
455+
<rect key="frame" x="0.0" y="824" width="600" height="65"/>
424456
<autoresizingMask key="autoresizingMask"/>
425457
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bdE-R5-mtF" id="E8h-YG-8UX">
426458
<rect key="frame" x="0.0" y="0.0" width="600" height="65"/>
@@ -449,7 +481,7 @@
449481
</tableViewCellContentView>
450482
</tableViewCell>
451483
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="110" id="i0m-Xn-tMe" userLabel="Hiding cell">
452-
<rect key="frame" x="0.0" y="824" width="600" height="110"/>
484+
<rect key="frame" x="0.0" y="889" width="600" height="110"/>
453485
<autoresizingMask key="autoresizingMask"/>
454486
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="i0m-Xn-tMe" id="y4L-XO-6WY">
455487
<rect key="frame" x="0.0" y="0.0" width="600" height="110"/>
@@ -571,8 +603,8 @@
571603
<action selector="show:" destination="NF9-wZ-lbZ" eventType="touchUpInside" id="M1F-VO-IXP"/>
572604
</connections>
573605
</button>
574-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vaB-mE-Rve">
575-
<rect key="frame" x="65.5" y="0.0" width="59.5" height="33"/>
606+
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vaB-mE-Rve">
607+
<rect key="frame" x="66" y="0.0" width="59" height="33"/>
576608
<color key="backgroundColor" red="0.85507499631818185" green="0.14286500584919343" blue="0.13053950878691239" alpha="1" colorSpace="calibratedRGB"/>
577609
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
578610
<state key="normal" title="HIDE"/>
@@ -601,12 +633,13 @@
601633
</barButtonItem>
602634
</navigationItem>
603635
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
604-
<size key="freeformSize" width="600" height="1000"/>
636+
<size key="freeformSize" width="600" height="1200"/>
605637
<connections>
606638
<outlet property="bodyText" destination="Ev4-j7-wY0" id="mD6-Ge-qJY"/>
607639
<outlet property="dimMode" destination="iw9-KB-Nyd" id="OiP-ss-kEO"/>
608640
<outlet property="dropShadow" destination="sqb-Fg-YR8" id="zUz-6P-IFz"/>
609641
<outlet property="duration" destination="nng-9a-v3B" id="4VC-Yi-AiA"/>
642+
<outlet property="iconStyle" destination="c2K-94-CuB" id="Qwt-xY-oZ2"/>
610643
<outlet property="interactiveHide" destination="Vdr-7b-DJB" id="pEi-RT-l7U"/>
611644
<outlet property="layout" destination="aBT-5M-2tg" id="4GZ-iP-oCa"/>
612645
<outlet property="presentationContext" destination="AYG-qj-yjv" id="oxG-AK-tTF"/>

‎Demo/Demo/ExploreViewController.swift

+15-4
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,25 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {
2727

2828
view.configureContent(title: titleText.text, body: bodyText.text, iconImage: nil, iconText: nil, buttonImage: nil, buttonTitle: "Hide", buttonTapHandler: { _ in SwiftMessages.hide() })
2929

30+
let iconStyle: IconStyle
31+
switch self.iconStyle.selectedSegmentIndex {
32+
case 1:
33+
iconStyle = .Light
34+
case 2:
35+
iconStyle = .Subtle
36+
default:
37+
iconStyle = .Default
38+
}
39+
3040
switch theme.selectedSegmentIndex {
3141
case 0:
32-
view.configureTheme(.Info)
42+
view.configureTheme(.Info, iconStyle: iconStyle)
3343
case 1:
34-
view.configureTheme(.Success)
44+
view.configureTheme(.Success, iconStyle: iconStyle)
3545
case 2:
36-
view.configureTheme(.Warning)
46+
view.configureTheme(.Warning, iconStyle: iconStyle)
3747
case 3:
38-
view.configureTheme(.Error)
48+
view.configureTheme(.Error, iconStyle: iconStyle)
3949
default:
4050
view.configureTheme(backgroundColor: UIColor.purpleColor(), foregroundColor: UIColor.whiteColor(), iconImage: nil, iconText: "🐸")
4151
view.button?.setImage(Icon.ErrorSubtle.image, forState: .Normal)
@@ -132,6 +142,7 @@ class ExploreViewController: UITableViewController, UITextFieldDelegate {
132142
@IBOutlet weak var interactiveHide: UISwitch!
133143
@IBOutlet weak var layout: UISegmentedControl!
134144
@IBOutlet weak var theme: UISegmentedControl!
145+
@IBOutlet weak var iconStyle: UISegmentedControl!
135146
@IBOutlet weak var dropShadow: UISwitch!
136147
@IBOutlet weak var titleText: UITextField!
137148
@IBOutlet weak var bodyText: UITextField!

‎Demo/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- SwiftMessages (1.0.0)
2+
- SwiftMessages (1.0.2)
33

44
DEPENDENCIES:
55
- SwiftMessages (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: ../
1010

1111
SPEC CHECKSUMS:
12-
SwiftMessages: c987edae29bba1d390bb2596e5f19a68598de7a6
12+
SwiftMessages: 443e1aef4889ba28c31d0d4dd53e63d3fe5ae119
1313

1414
PODFILE CHECKSUM: 6431c980c9207084d738b6ba87b2101dd9eb5097
1515

‎Demo/Pods/Local Podspecs/SwiftMessages.podspec.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Manifest.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Pods.xcodeproj/project.pbxproj

+63-63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Pods.xcodeproj/xcuserdata/wtmoose.xcuserdatad/xcschemes/Pods-Demo.xcscheme

+13-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Pods.xcodeproj/xcuserdata/wtmoose.xcuserdatad/xcschemes/xcschememanagement.plist

+1-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Target Support Files/SwiftMessages/Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Demo/Pods/Target Support Files/SwiftMessages/ResourceBundle-SwiftMessages-Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎SwiftMessages.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'SwiftMessages'
3-
spec.version = '1.0.1'
3+
spec.version = '1.0.2'
44
spec.license = { :type => 'MIT' }
55
spec.homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
66
spec.authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
77
spec.summary = 'A very flexible message bar for iOS written in Swift.'
8-
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => '1.0.1'}
8+
spec.source = {:git => 'https://github.com/SwiftKickMobile/SwiftMessages.git', :tag => '1.0.2'}
99
spec.platform = :ios, '8.0'
1010
spec.ios.deployment_target = '8.0'
1111
spec.source_files = 'SwiftMessages/**/*.swift'

‎SwiftMessages.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
86BBA9021D5E040600FE8F16 /* WindowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8644955C1D4FAF7C0056EB2A /* WindowViewController.swift */; };
2222
86BBA9031D5E040600FE8F16 /* UIViewController+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF81B1D551FE60031EE32 /* UIViewController+Utils.swift */; };
2323
86BBA9041D5E040600FE8F16 /* NSBundle+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 862C0CB01D5911C100D06168 /* NSBundle+Utils.swift */; };
24-
86BBA9051D5E040C00FE8F16 /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF82C1D580F410031EE32 /* Icon.swift */; };
24+
86BBA9051D5E040C00FE8F16 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF82C1D580F410031EE32 /* Theme.swift */; };
2525
86BBA9061D5E040C00FE8F16 /* Identifiable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864495551D4F7C390056EB2A /* Identifiable.swift */; };
2626
86BBA9071D5E040C00FE8F16 /* MarginAdjustable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF81D1D5549680031EE32 /* MarginAdjustable.swift */; };
2727
86BBA9081D5E040C00FE8F16 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86AAF82A1D580DD70031EE32 /* Error.swift */; };
@@ -56,7 +56,7 @@
5656
86AAF81B1D551FE60031EE32 /* UIViewController+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Utils.swift"; sourceTree = "<group>"; };
5757
86AAF81D1D5549680031EE32 /* MarginAdjustable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginAdjustable.swift; sourceTree = "<group>"; };
5858
86AAF82A1D580DD70031EE32 /* Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
59-
86AAF82C1D580F410031EE32 /* Icon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = "<group>"; };
59+
86AAF82C1D580F410031EE32 /* Theme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
6060
86B48AEC1D5A41C900063E2B /* SwiftMessages.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftMessages.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6161
86B48AEE1D5A41C900063E2B /* SwiftMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftMessages.h; sourceTree = "<group>"; };
6262
86B48AF01D5A41C900063E2B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -101,7 +101,7 @@
101101
isa = PBXGroup;
102102
children = (
103103
86589D461D64B6E40041676C /* BaseView.swift */,
104-
86AAF82C1D580F410031EE32 /* Icon.swift */,
104+
86AAF82C1D580F410031EE32 /* Theme.swift */,
105105
867BED201D622793005212E3 /* BackgroundViewable.swift */,
106106
864495551D4F7C390056EB2A /* Identifiable.swift */,
107107
86AAF81D1D5549680031EE32 /* MarginAdjustable.swift */,
@@ -292,7 +292,7 @@
292292
86BBA8FD1D5E03F800FE8F16 /* SwiftMessages.swift in Sources */,
293293
86BBA9021D5E040600FE8F16 /* WindowViewController.swift in Sources */,
294294
86BBA8FF1D5E040600FE8F16 /* Presenter.swift in Sources */,
295-
86BBA9051D5E040C00FE8F16 /* Icon.swift in Sources */,
295+
86BBA9051D5E040C00FE8F16 /* Theme.swift in Sources */,
296296
86BBA9081D5E040C00FE8F16 /* Error.swift in Sources */,
297297
86589D471D64B6E40041676C /* BaseView.swift in Sources */,
298298
86BBA9071D5E040C00FE8F16 /* MarginAdjustable.swift in Sources */,

‎SwiftMessages/Icon.swift

-31
This file was deleted.

‎SwiftMessages/MessageView.swift

+6-12
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,25 @@ public class MessageView: BaseView, Identifiable {
7575

7676
extension MessageView {
7777

78-
public enum Theme {
79-
case Info
80-
case Success
81-
case Warning
82-
case Error
83-
}
84-
85-
public func configureTheme(theme: Theme) {
78+
public func configureTheme(theme: Theme, iconStyle: IconStyle = .Default) {
79+
let iconImage = iconStyle.image(theme: theme)
8680
switch theme {
8781
case .Info:
8882
let backgroundColor = UIColor(red: 225.0/255.0, green: 225.0/255.0, blue: 225.0/255.0, alpha: 1.0)
8983
let foregroundColor = UIColor.darkTextColor()
90-
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: Icon.Info.image)
84+
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
9185
case .Success:
9286
let backgroundColor = UIColor(red: 97.0/255.0, green: 161.0/255.0, blue: 23.0/255.0, alpha: 1.0)
9387
let foregroundColor = UIColor.whiteColor()
94-
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: Icon.Success.image)
88+
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
9589
case .Warning:
9690
let backgroundColor = UIColor(red: 238.0/255.0, green: 189.0/255.0, blue: 34.0/255.0, alpha: 1.0)
9791
let foregroundColor = UIColor.whiteColor()
98-
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: Icon.Warning.image)
92+
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
9993
case .Error:
10094
let backgroundColor = UIColor(red: 249.0/255.0, green: 66.0/255.0, blue: 47.0/255.0, alpha: 1.0)
10195
let foregroundColor = UIColor.whiteColor()
102-
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: Icon.Error.image)
96+
configureTheme(backgroundColor: backgroundColor, foregroundColor: foregroundColor, iconImage: iconImage)
10397
}
10498
}
10599

‎SwiftMessages/Theme.swift

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// Theme.swift
3+
// SwiftMessages
4+
//
5+
// Created by Timothy Moose on 8/7/16.
6+
// Copyright © 2016 SwiftKick Mobile LLC.LLC. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
/// The theme enum specifies the built-in theme options
12+
public enum Theme {
13+
case Info
14+
case Success
15+
case Warning
16+
case Error
17+
}
18+
19+
/// The Icon enum provides type-safe access to the included icons.
20+
public enum Icon: String {
21+
22+
case Error = "errorIcon"
23+
case Warning = "warningIcon"
24+
case Success = "successIcon"
25+
case Info = "infoIcon"
26+
case ErrorLight = "errorIconLight"
27+
case WarningLight = "warningIconLight"
28+
case SuccessLight = "successIconLight"
29+
case InfoLight = "infoIconLight"
30+
case ErrorSubtle = "errorIconSubtle"
31+
case WarningSubtle = "warningIconSubtle"
32+
case SuccessSubtle = "successIconSubtle"
33+
case InfoSubtle = "infoIconSubtle"
34+
35+
/// Returns the associated image.
36+
public var image: UIImage {
37+
return UIImage(named: rawValue, inBundle: NSBundle.sm_frameworkBundle(), compatibleWithTraitCollection: nil)!
38+
}
39+
}
40+
41+
/// The IconStyle enum specifies the different variations of the included icons.
42+
public enum IconStyle {
43+
44+
case Default
45+
case Light
46+
case Subtle
47+
48+
/// Returns the image for the given theme
49+
public func image(theme theme: Theme) -> UIImage {
50+
switch (theme, self) {
51+
case (.Info, .Default): return Icon.Info.image
52+
case (.Info, .Light): return Icon.InfoLight.image
53+
case (.Info, .Subtle): return Icon.InfoSubtle.image
54+
case (.Success, .Default): return Icon.Success.image
55+
case (.Success, .Light): return Icon.SuccessLight.image
56+
case (.Success, .Subtle): return Icon.SuccessSubtle.image
57+
case (.Warning, .Default): return Icon.Warning.image
58+
case (.Warning, .Light): return Icon.WarningLight.image
59+
case (.Warning, .Subtle): return Icon.WarningSubtle.image
60+
case (.Error, .Default): return Icon.Error.image
61+
case (.Error, .Light): return Icon.ErrorLight.image
62+
case (.Error, .Subtle): return Icon.ErrorSubtle.image
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)
Please sign in to comment.