Color coded cell text

This commit is contained in:
Chris Li 2016-08-26 17:14:42 -04:00
parent 64f422945e
commit 11d442789e
4 changed files with 38 additions and 21 deletions

View File

@ -117,11 +117,28 @@ class CloudBooksController: UITableViewController, NSFetchedResultsControllerDel
guard let book = fetchedResultController.objectAtIndexPath(indexPath) as? Book else {return}
guard let cell = cell as? BasicBookCell else {return}
cell.titleLabel.text = book.title
let textColor: UIColor = {
switch book.spaceState {
case .Enough:
return UIColor.blackColor()
case .Caution:
return UIColor.orangeColor()
case .NotEnough:
return UIColor.grayColor()
}
}()
cell.hasPic = book.hasPic
cell.hasIndex = book.hasIndex
cell.favIcon.image = UIImage(data: book.favIcon ?? NSData())
cell.subtitleLabel.text = book.detailedDescription
cell.titleLabel.text = book.title
cell.subtitleLabel.text = [
book.dateDescription,
book.fileSizeDescription,
book.articleCountDescription
].flatMap({$0}).joinWithSeparator(" ")
cell.titleLabel.textColor = textColor
cell.subtitleLabel.textColor = textColor
}
// MARK: Other Data Source

View File

@ -49,7 +49,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.7.1361</string>
<string>1.7.1386</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View File

@ -134,10 +134,6 @@
<exclude reference="vCx-YB-CHS"/>
</mask>
<mask key="constraints">
<exclude reference="Ce5-0C-iQ7"/>
<exclude reference="ewd-yX-U7y"/>
<exclude reference="itt-a3-Qgu"/>
<exclude reference="y9U-EJ-3QB"/>
<exclude reference="0NT-oh-5ye"/>
<exclude reference="10b-5k-B8a"/>
<exclude reference="4DW-to-Vk5"/>
@ -169,6 +165,10 @@
<exclude reference="kf7-tp-XAe"/>
<exclude reference="ruI-Hr-sWV"/>
<exclude reference="sgb-S6-baI"/>
<exclude reference="Ce5-0C-iQ7"/>
<exclude reference="ewd-yX-U7y"/>
<exclude reference="itt-a3-Qgu"/>
<exclude reference="y9U-EJ-3QB"/>
</mask>
</variation>
<variation key="widthClass=regular">
@ -176,10 +176,6 @@
<include reference="vCx-YB-CHS"/>
</mask>
<mask key="constraints">
<include reference="Ce5-0C-iQ7"/>
<include reference="ewd-yX-U7y"/>
<include reference="itt-a3-Qgu"/>
<include reference="y9U-EJ-3QB"/>
<include reference="0NT-oh-5ye"/>
<exclude reference="10b-5k-B8a"/>
<exclude reference="3Hc-So-OgY"/>
@ -202,6 +198,10 @@
<exclude reference="i5e-7F-ctC"/>
<include reference="kf7-tp-XAe"/>
<exclude reference="sgb-S6-baI"/>
<include reference="Ce5-0C-iQ7"/>
<include reference="ewd-yX-U7y"/>
<include reference="itt-a3-Qgu"/>
<include reference="y9U-EJ-3QB"/>
</mask>
</variation>
<variation key="heightClass=regular-widthClass=regular">
@ -379,7 +379,7 @@
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="BZj-UA-kZf" id="QkJ-pZ-dqx">
<frame key="frameInset" width="600" height="43"/>
<frame key="frameInset" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" minimumFontSize="8" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GW1-dh-vyc">
@ -478,9 +478,9 @@
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="keh-40-lDf"/>
<exclude reference="b3j-jX-m2X"/>
<exclude reference="NdO-kZ-tsv"/>
<exclude reference="keh-40-lDf"/>
</mask>
</variation>
<connections>
@ -496,11 +496,11 @@
<rect key="frame" x="0.0" y="72" width="600" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="jhQ-Rz-z7y" id="0Qp-fj-4c4">
<frame key="frameInset" width="600" height="43"/>
<frame key="frameInset" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="jU7-ZQ-dsg">
<frame key="frameInset" minX="15" width="570" height="43"/>
<frame key="frameInset" minX="15" width="570" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -563,11 +563,11 @@
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="F3N-1z-GvO" id="btD-gq-ccE">
<frame key="frameInset" width="375" height="43"/>
<frame key="frameInset" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="cT9-LO-Cxy">
<frame key="frameInset" minX="15" width="345" height="43"/>
<frame key="frameInset" minX="15" width="345" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -607,7 +607,7 @@
<rect key="frame" x="0.0" y="28" width="600" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="z8v-Ld-3tX" id="PYl-F0-kUl">
<frame key="frameInset" width="600" height="43"/>
<frame key="frameInset" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="UgG-QR-OX4">
@ -661,7 +661,7 @@
<rect key="frame" x="0.0" y="72" width="600" height="87"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="wBv-ub-ny7" id="fk4-EM-rH7">
<frame key="frameInset" width="600" height="86"/>
<frame key="frameInset" width="600" height="86.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ien-Dp-MNO">
@ -907,7 +907,7 @@
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="bG3-jc-npj" customClass="LocalLangCell" customModule="Kiwix" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="102" height="42"/>
<rect key="frame" x="0.0" y="0.0" width="102" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="102" height="42"/>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.7.1635</string>
<string>1.7.1673</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>