Skip to content

Commit

Permalink
Merge pull request #144 from Imperiopolis/nt-tag-styling
Browse files Browse the repository at this point in the history
Add ability to add child BONChainables to style text between tags.
  • Loading branch information
ZevEisenberg committed May 20, 2016
2 parents e51b8a8 + d5d617f commit 5a7f599
Show file tree
Hide file tree
Showing 36 changed files with 2,558 additions and 583 deletions.
32 changes: 27 additions & 5 deletions Example/BonMot.xcodeproj/project.pbxproj
Expand Up @@ -21,8 +21,6 @@
730361E31C9B5CDD00987809 /* BONHumanReadableStringTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 730361E11C9B5CD300987809 /* BONHumanReadableStringTestCase.m */; };
CD64F15E1CA4DAC800042559 /* BONFigureTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD64F15D1CA4DAC800042559 /* BONFigureTestCase.m */; };
CD6DEFE11BF6ADF900676E2D /* BONBaseTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFD61BF6ADF900676E2D /* BONBaseTestCase.m */; };
CD6DEFE31BF6ADF900676E2D /* BONTextableTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFD71BF6ADF900676E2D /* BONTextableTestCase.m */; };
CD6DEFE51BF6ADF900676E2D /* BONChainEmptyTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFD81BF6ADF900676E2D /* BONChainEmptyTestCase.m */; };
CD6DEFE71BF6ADF900676E2D /* BONDebugStringTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFD91BF6ADF900676E2D /* BONDebugStringTestCase.m */; };
CD6DEFE91BF6ADF900676E2D /* BONDictionaryEqualityTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFDA1BF6ADF900676E2D /* BONDictionaryEqualityTestCase.m */; };
CD6DEFEB1BF6ADF900676E2D /* BONIndentSpacerTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DEFDB1BF6ADF900676E2D /* BONIndentSpacerTestCase.m */; };
Expand Down Expand Up @@ -66,7 +64,13 @@
CD6DF05A1BF6B98500676E2D /* NSDictionary+BONEquality.m in Sources */ = {isa = PBXBuildFile; fileRef = CD6DF04F1BF6B53100676E2D /* NSDictionary+BONEquality.m */; };
CD78701E1CA5F8EC00B2714F /* EBGaramond12-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = CD6DF03E1BF6AFAA00676E2D /* EBGaramond12-Regular.otf */; };
CDE658581C24ADD8009C7D09 /* BONUnderlineAndStrikethroughTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE658571C24ADD8009C7D09 /* BONUnderlineAndStrikethroughTestCase.m */; };
EC2F199E1CEA324900D9F1FE /* BONTagStylesTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = EC2F199C1CEA324300D9F1FE /* BONTagStylesTestCase.m */; };
EC2F19A11CEBBAF900D9F1FE /* BONTagTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = EC2F199F1CEBBA9E00D9F1FE /* BONTagTestCase.m */; };
EC433DB31C88B7D9001B3ABE /* BONTagMakeTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = EC433DB11C88B65B001B3ABE /* BONTagMakeTestCase.m */; };
EC433DB61C88BBDE001B3ABE /* BONUIKitUtilitiesTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = EC433DB41C88BBDB001B3ABE /* BONUIKitUtilitiesTestCase.m */; };
EC433DB91C88DE5F001B3ABE /* TagStylesCell.m in Sources */ = {isa = PBXBuildFile; fileRef = EC433DB81C88DE5F001B3ABE /* TagStylesCell.m */; };
EC433DBB1C88DEF7001B3ABE /* TagStylesCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = EC433DBA1C88DEF7001B3ABE /* TagStylesCell.xib */; };
ECD4DB6B1CE3EA2700079675 /* BONTagComplexMakeTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = ECD4DB691CE3EA1F00079675 /* BONTagComplexMakeTestCase.m */; };
F6E9CEC93164745FB8BEB8FC /* Pods_BonMot_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E8BB0552A748FFBA2BD0BE4 /* Pods_BonMot_Example.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -166,7 +170,14 @@
CDE658571C24ADD8009C7D09 /* BONUnderlineAndStrikethroughTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONUnderlineAndStrikethroughTestCase.m; sourceTree = "<group>"; };
CFD6D97A946F2FEF294F4BBB /* Pods_BonMot_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BonMot_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EBE7037465B0F6F184875C40 /* Pods-BonMot_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BonMot_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-BonMot_Example/Pods-BonMot_Example.release.xcconfig"; sourceTree = "<group>"; };
EC2F199C1CEA324300D9F1FE /* BONTagStylesTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONTagStylesTestCase.m; sourceTree = "<group>"; };
EC2F199F1CEBBA9E00D9F1FE /* BONTagTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONTagTestCase.m; sourceTree = "<group>"; };
EC433DB11C88B65B001B3ABE /* BONTagMakeTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONTagMakeTestCase.m; sourceTree = "<group>"; };
EC433DB41C88BBDB001B3ABE /* BONUIKitUtilitiesTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONUIKitUtilitiesTestCase.m; sourceTree = "<group>"; };
EC433DB71C88DE5F001B3ABE /* TagStylesCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagStylesCell.h; sourceTree = "<group>"; };
EC433DB81C88DE5F001B3ABE /* TagStylesCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagStylesCell.m; sourceTree = "<group>"; };
EC433DBA1C88DEF7001B3ABE /* TagStylesCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TagStylesCell.xib; sourceTree = "<group>"; };
ECD4DB691CE3EA1F00079675 /* BONTagComplexMakeTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BONTagComplexMakeTestCase.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -281,6 +292,10 @@
CD6DEFDA1BF6ADF900676E2D /* BONDictionaryEqualityTestCase.m */,
730361E11C9B5CD300987809 /* BONHumanReadableStringTestCase.m */,
CD6DEFDB1BF6ADF900676E2D /* BONIndentSpacerTestCase.m */,
EC2F199C1CEA324300D9F1FE /* BONTagStylesTestCase.m */,
EC433DB11C88B65B001B3ABE /* BONTagMakeTestCase.m */,
ECD4DB691CE3EA1F00079675 /* BONTagComplexMakeTestCase.m */,
EC2F199F1CEBBA9E00D9F1FE /* BONTagTestCase.m */,
CD6DEFDC1BF6ADF900676E2D /* BONPropertyClobberingTestCase.m */,
CD6DEFDD1BF6ADF900676E2D /* BONTextAlignmentConstraintTestCase.m */,
CD6DEFDE1BF6ADF900676E2D /* BONTextAlignmentTestCase.m */,
Expand Down Expand Up @@ -360,6 +375,9 @@
CD6DF01D1BF6AE8200676E2D /* SpecialCharactersCell.h */,
CD6DF01E1BF6AE8200676E2D /* SpecialCharactersCell.m */,
CD6DF01F1BF6AE8200676E2D /* SpecialCharactersCell.xib */,
EC433DB71C88DE5F001B3ABE /* TagStylesCell.h */,
EC433DB81C88DE5F001B3ABE /* TagStylesCell.m */,
EC433DBA1C88DEF7001B3ABE /* TagStylesCell.xib */,
CD6DF0201BF6AE8200676E2D /* TrackingCell.h */,
CD6DF0211BF6AE8200676E2D /* TrackingCell.m */,
CD6DF0221BF6AE8200676E2D /* TrackingCell.xib */,
Expand Down Expand Up @@ -428,7 +446,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = "";
LastSwiftUpdateCheck = 0710;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "Zev Eisenberg";
};
Expand Down Expand Up @@ -467,6 +485,7 @@
CD6DF0251BF6AE8200676E2D /* BaselineCapHeightCell.xib in Resources */,
CD6DF04D1BF6B50800676E2D /* Launch Screen.xib in Resources */,
CD6DF0311BF6AE8200676E2D /* InlineImagesCell.xib in Resources */,
EC433DBB1C88DEF7001B3ABE /* TagStylesCell.xib in Resources */,
CD6DF0351BF6AE8200676E2D /* ProgrammaticBaselineCapHeightCell.xib in Resources */,
CD6DF02F1BF6AE8200676E2D /* IndentationCell.xib in Resources */,
6003F598195388D20070C39A /* InfoPlist.strings in Resources */,
Expand Down Expand Up @@ -609,6 +628,7 @@
CD6DF02C1BF6AE8200676E2D /* FigureStyleCell.m in Sources */,
CD6DF04A1BF6B37E00676E2D /* DummyAssetClass.m in Sources */,
CD6DF0591BF6B7AF00676E2D /* DashedHairlineView.m in Sources */,
EC433DB91C88DE5F001B3ABE /* TagStylesCell.m in Sources */,
CD6DF0381BF6AE8200676E2D /* TrackingCell.m in Sources */,
CD6DF0231BF6AE8200676E2D /* AbstractCell.m in Sources */,
CD6DEFF61BF6AE4C00676E2D /* AppDelegate.m in Sources */,
Expand All @@ -624,15 +644,17 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EC2F199E1CEA324900D9F1FE /* BONTagStylesTestCase.m in Sources */,
EC433DB61C88BBDE001B3ABE /* BONUIKitUtilitiesTestCase.m in Sources */,
EC2F19A11CEBBAF900D9F1FE /* BONTagTestCase.m in Sources */,
CD6DF05A1BF6B98500676E2D /* NSDictionary+BONEquality.m in Sources */,
CD6DF04B1BF6B37E00676E2D /* DummyAssetClass.m in Sources */,
730361E31C9B5CDD00987809 /* BONHumanReadableStringTestCase.m in Sources */,
CD6DEFE51BF6ADF900676E2D /* BONChainEmptyTestCase.m in Sources */,
ECD4DB6B1CE3EA2700079675 /* BONTagComplexMakeTestCase.m in Sources */,
CD6DEFED1BF6ADF900676E2D /* BONPropertyClobberingTestCase.m in Sources */,
CD6DEFF11BF6ADF900676E2D /* BONTextAlignmentTestCase.m in Sources */,
CD6DEFE11BF6ADF900676E2D /* BONBaseTestCase.m in Sources */,
CD6DEFE31BF6ADF900676E2D /* BONTextableTestCase.m in Sources */,
EC433DB31C88B7D9001B3ABE /* BONTagMakeTestCase.m in Sources */,
CDE658581C24ADD8009C7D09 /* BONUnderlineAndStrikethroughTestCase.m in Sources */,
CD6DEFF31BF6ADF900676E2D /* BONTrackingTestCase.m in Sources */,
CD64F15E1CA4DAC800042559 /* BONFigureTestCase.m in Sources */,
Expand Down
Expand Up @@ -28,7 +28,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "83F933DF3E48175891E4EBFC2EDB74A2"
BlueprintIdentifier = "936C2599775DA43BC28A7798C3663474"
BuildableName = "BonMot.framework"
BlueprintName = "BonMot"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
Expand Down
13 changes: 13 additions & 0 deletions Example/BonMot/Cells/TagStylesCell.h
@@ -0,0 +1,13 @@
//
// TagStylesCell.h
// BonMot
//
// Created by Nora Trapp on 3/3/16.
// Copyright © 2016 Zev Eisenberg. All rights reserved.
//

#import "AbstractCell.h"

@interface TagStylesCell : AbstractCell

@end
41 changes: 41 additions & 0 deletions Example/BonMot/Cells/TagStylesCell.m
@@ -0,0 +1,41 @@
//
// TagStylesCell.m
// BonMot
//
// Created by Nora Trapp on 3/3/16.
// Copyright © 2016 Zev Eisenberg. All rights reserved.
//

#import "TagStylesCell.h"

@interface TagStylesCell ()

@property (weak, nonatomic) IBOutlet UILabel *label;

@end

@implementation TagStylesCell

+ (NSString *)title
{
return @"Tag Styles";
}

- (void)awakeFromNib
{
[super awakeFromNib];

BONChain *boldChain = BONChain.new.fontNameAndSize(@"Baskerville-Bold", 15);
BONChain *italicChain = BONChain.new.fontNameAndSize(@"Baskerville-Italic", 15);

BONChain *baseChain = BONChain.new.fontNameAndSize(@"Baskerville", 17)
.tagStyles(@{ @"bold" : boldChain,
@"italic" : italicChain })
.string(@"<bold>This text</bold> contains a \\<bold> tag.\n<italic>This text</italic> contains an \\<italic> tag.");

self.label.attributedText = baseChain.attributedString;

[self.label layoutIfNeeded]; // For auto-sizing cells
}

@end
46 changes: 46 additions & 0 deletions Example/BonMot/Cells/TagStylesCell.xib
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="83" id="d6g-Gc-orO" userLabel="Tag Styles Cell" customClass="TagStylesCell">
<rect key="frame" x="0.0" y="0.0" width="398" height="83"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="d6g-Gc-orO" id="8H7-Bg-FVy">
<rect key="frame" x="0.0" y="0.0" width="398" height="82.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="88h-1O-j4A">
<rect key="frame" x="15" y="8" width="368" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="88h-1O-j4A" firstAttribute="leading" secondItem="8H7-Bg-FVy" secondAttribute="leadingMargin" constant="7" id="5bp-md-I9T"/>
<constraint firstItem="88h-1O-j4A" firstAttribute="top" secondItem="8H7-Bg-FVy" secondAttribute="top" constant="8" id="92L-uh-jKB"/>
<constraint firstAttribute="trailing" secondItem="88h-1O-j4A" secondAttribute="trailing" constant="15" id="L6f-ru-EoT"/>
<constraint firstAttribute="trailingMargin" secondItem="88h-1O-j4A" secondAttribute="trailing" constant="7" id="SPg-E0-3vK"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="88h-1O-j4A" secondAttribute="bottom" constant="8" id="a9a-dS-3fY"/>
<constraint firstItem="88h-1O-j4A" firstAttribute="leading" secondItem="8H7-Bg-FVy" secondAttribute="leading" constant="15" id="yRF-YX-Lbu"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="L6f-ru-EoT"/>
<exclude reference="yRF-YX-Lbu"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="label" destination="88h-1O-j4A" id="Aen-of-Ac3"/>
</connections>
<point key="canvasLocation" x="352" y="424.5"/>
</tableViewCell>
</objects>
</document>
2 changes: 2 additions & 0 deletions Example/BonMot/RootViewController.m
Expand Up @@ -20,6 +20,7 @@
#import "SpecialCharactersCell.h"
#import "BaselineOffsetCell.h"
#import "ConcatenationCell.h"
#import "TagStylesCell.h"

@interface RootViewController ()

Expand Down Expand Up @@ -48,6 +49,7 @@ - (void)viewDidLoad
[SpecialCharactersCell class],
[BaselineOffsetCell class],
[ConcatenationCell class],
[TagStylesCell class]
];

for (Class CellClass in self.cellClasses) {
Expand Down
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Expand Up @@ -11,7 +11,7 @@ DEPENDENCIES:

EXTERNAL SOURCES:
BonMot:
:path: "../"
:path: ../

SPEC CHECKSUMS:
BonMot: e8d7b8920dc9363291c308e853ccb5784d5de4bd
Expand Down
1 change: 1 addition & 0 deletions Example/Pods/Headers/Private/BonMot/BONTag.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Example/Pods/Headers/Private/BonMot/BONTag_Private.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a7f599

Please sign in to comment.