Skip to content

Commit

Permalink
Merge pull request #27 from wordpress-mobile/issue/25-integrate-aztec…
Browse files Browse the repository at this point in the history
…-ios-2

Integrate Aztec into our Aztec RN wrapper.
  • Loading branch information
diegoreymendez authored Jul 10, 2018
2 parents 0504866 + 3c7cc33 commit 9d11c0f
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 49 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ This will build the Android library (via `gradle`) and example app, then launch

## iOS: Run the example app

Simply do:
Before being able to run the Example App, you'll need to install [Carthage](https://github.com/Carthage/Carthage) and the dependencies for this project:
```
cd ios
carthage bootstrap --platform iOS
```

Then go back to the root directory of the project and do:
```
$ cd example/
$ yarn clean:install
Expand Down
19 changes: 19 additions & 0 deletions example/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
F1663A4E20F49DB400DC4C03 /* Aztec.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1A879A820EE6E7300FABD31 /* Aztec.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F16E377220ED1D6900E81F5B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16E377120ED1D6900E81F5B /* AppDelegate.swift */; };
F17923DF20890AA0002FE09B /* libRNTAztecView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F17923DE20890A85002FE09B /* libRNTAztecView.a */; };
F1A879A920EE6E7300FABD31 /* Aztec.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1A879A820EE6E7300FABD31 /* Aztec.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -312,6 +314,19 @@
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
F1663A2820F49D8C00DC4C03 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
F1663A4E20F49DB400DC4C03 /* Aztec.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -340,6 +355,7 @@
F16E377020ED1D6900E81F5B /* example-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "example-Bridging-Header.h"; sourceTree = "<group>"; };
F16E377120ED1D6900E81F5B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = example/AppDelegate.swift; sourceTree = "<group>"; };
F17923D920890A85002FE09B /* RNTAztecView.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNTAztecView.xcodeproj; path = ../../ios/RNTAztecView.xcodeproj; sourceTree = "<group>"; };
F1A879A820EE6E7300FABD31 /* Aztec.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Aztec.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -355,6 +371,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F1A879A920EE6E7300FABD31 /* Aztec.framework in Frameworks */,
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */,
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
Expand Down Expand Up @@ -496,6 +513,7 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
F1A879A820EE6E7300FABD31 /* Aztec.framework */,
2D16E6891FA4F8E400B85C8A /* libReact.a */,
);
name = Frameworks;
Expand Down Expand Up @@ -617,6 +635,7 @@
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
F1663A2820F49D8C00DC4C03 /* CopyFiles */,
);
buildRules = (
);
Expand Down
113 changes: 101 additions & 12 deletions ios/RNTAztecView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,36 @@
objects = {

/* Begin PBXBuildFile section */
F121467D20ED2F81003DD17B /* RNTAztecView.m in Sources */ = {isa = PBXBuildFile; fileRef = F121467C20ED2F81003DD17B /* RNTAztecView.m */; };
F13BF4A020ECF5450047D3F9 /* RNTAztecView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F13BF49F20ECF5450047D3F9 /* RNTAztecView.swift */; };
F121467D20ED2F81003DD17B /* RCTAztecViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */; };
F13BF4A020ECF5450047D3F9 /* RCTAztecViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */; };
F166A38020EE6DF3008E7C9F /* Aztec.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F166A37B20EE6DD7008E7C9F /* Aztec.framework */; };
F1A879D020EE90C000FABD31 /* RCTAztecView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
F166A37A20EE6DD7008E7C9F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 5951CB8E1D8BC93600E1866F;
remoteInfo = Aztec;
};
F166A37C20EE6DD7008E7C9F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 5951CB971D8BC93600E1866F;
remoteInfo = AztecTests;
};
F166A37E20EE6DEE008E7C9F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 5951CB8D1D8BC93600E1866F;
remoteInfo = Aztec;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
F145CFC42087D16A006C159A /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
Expand All @@ -25,17 +51,20 @@

/* Begin PBXFileReference section */
F1017BCE20ED1B1A002B1024 /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };
F121467C20ED2F81003DD17B /* RNTAztecView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNTAztecView.m; sourceTree = "<group>"; };
F13BF49E20ECF5440047D3F9 /* RNTAztecView-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNTAztecView-Bridging-Header.h"; sourceTree = "<group>"; };
F13BF49F20ECF5450047D3F9 /* RNTAztecView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNTAztecView.swift; sourceTree = "<group>"; };
F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTAztecViewManager.m; sourceTree = "<group>"; };
F13BF49E20ECF5440047D3F9 /* RCTAztecView-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTAztecView-Bridging-Header.h"; sourceTree = "<group>"; };
F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RCTAztecViewManager.swift; sourceTree = "<group>"; };
F145CFC62087D16A006C159A /* libRNTAztecView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNTAztecView.a; sourceTree = BUILT_PRODUCTS_DIR; };
F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Aztec.xcodeproj; path = "Carthage/Checkouts/AztecEditor-iOS/Aztec.xcodeproj"; sourceTree = SOURCE_ROOT; };
F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RCTAztecView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
F145CFC32087D16A006C159A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F166A38020EE6DF3008E7C9F /* Aztec.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -46,6 +75,7 @@
isa = PBXGroup;
children = (
F145CFC82087D16A006C159A /* RNTAztecView */,
F166A37320EE6DC7008E7C9F /* Dependencies */,
F145CFF92087D497006C159A /* Frameworks */,
F145CFC72087D16A006C159A /* Products */,
);
Expand All @@ -62,9 +92,10 @@
F145CFC82087D16A006C159A /* RNTAztecView */ = {
isa = PBXGroup;
children = (
F13BF49E20ECF5440047D3F9 /* RNTAztecView-Bridging-Header.h */,
F121467C20ED2F81003DD17B /* RNTAztecView.m */,
F13BF49F20ECF5450047D3F9 /* RNTAztecView.swift */,
F13BF49E20ECF5440047D3F9 /* RCTAztecView-Bridging-Header.h */,
F121467C20ED2F81003DD17B /* RCTAztecViewManager.m */,
F13BF49F20ECF5450047D3F9 /* RCTAztecViewManager.swift */,
F1A879CF20EE90C000FABD31 /* RCTAztecView.swift */,
);
path = RNTAztecView;
sourceTree = "<group>";
Expand All @@ -77,6 +108,23 @@
path = Frameworks;
sourceTree = "<group>";
};
F166A37320EE6DC7008E7C9F /* Dependencies */ = {
isa = PBXGroup;
children = (
F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */,
);
path = Dependencies;
sourceTree = "<group>";
};
F166A37520EE6DD7008E7C9F /* Products */ = {
isa = PBXGroup;
children = (
F166A37B20EE6DD7008E7C9F /* Aztec.framework */,
F166A37D20EE6DD7008E7C9F /* AztecTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -91,6 +139,7 @@
buildRules = (
);
dependencies = (
F166A37F20EE6DEE008E7C9F /* PBXTargetDependency */,
);
name = RNTAztecView;
productName = RNTAztecView;
Expand Down Expand Up @@ -123,25 +172,57 @@
mainGroup = F145CFBD2087D169006C159A;
productRefGroup = F145CFC72087D16A006C159A /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = F166A37520EE6DD7008E7C9F /* Products */;
ProjectRef = F166A37420EE6DD7008E7C9F /* Aztec.xcodeproj */;
},
);
projectRoot = "";
targets = (
F145CFC52087D16A006C159A /* RNTAztecView */,
);
};
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
F166A37B20EE6DD7008E7C9F /* Aztec.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = Aztec.framework;
remoteRef = F166A37A20EE6DD7008E7C9F /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
F166A37D20EE6DD7008E7C9F /* AztecTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = AztecTests.xctest;
remoteRef = F166A37C20EE6DD7008E7C9F /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXSourcesBuildPhase section */
F145CFC22087D16A006C159A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F13BF4A020ECF5450047D3F9 /* RNTAztecView.swift in Sources */,
F121467D20ED2F81003DD17B /* RNTAztecView.m in Sources */,
F13BF4A020ECF5450047D3F9 /* RCTAztecViewManager.swift in Sources */,
F1A879D020EE90C000FABD31 /* RCTAztecView.swift in Sources */,
F121467D20ED2F81003DD17B /* RCTAztecViewManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
F166A37F20EE6DEE008E7C9F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = Aztec;
targetProxy = F166A37E20EE6DEE008E7C9F /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
F145CFCB2087D16A006C159A /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -263,6 +344,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = PZYM8XX95Q;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -271,7 +356,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RNTAztecView-Bridging-Header.h";
SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RCTAztecView-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -284,6 +369,10 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = PZYM8XX95Q;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -292,7 +381,7 @@
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RNTAztecView-Bridging-Header.h";
SWIFT_OBJC_BRIDGING_HEADER = "RNTAztecView/RCTAztecView-Bridging-Header.h";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import <React/RCTEventEmitter.h>
#import <React/RCTViewManager.h>

//@interface RCT_EXTERN_REMAP_MODULE(RCTAztecView, RCTAztecViewManager, RCTViewManager)
Expand Down
54 changes: 54 additions & 0 deletions ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import Aztec
import Foundation

class RCTAztecView: Aztec.TextView {
@objc var onContentSizeChange: RCTBubblingEventBlock? = nil

// MARK - View Height: Match to content height

override var contentSize: CGSize {
didSet {
contentSizeChanged()
}
}

func contentSizeChanged() {
let newSize = contentSize

updateHeightToMatch(newSize.height)

guard let onContentSizeChange = onContentSizeChange else {
return
}

let body = packForRN(newSize, withName: "contentSize")
onContentSizeChange(body)
}

func updateHeightToMatch(_ newHeight: CGFloat) {

frame = CGRect(origin: frame.origin,
size: CGSize(width: frame.width, height: newHeight))
}

// MARK: - Native-to-RN Value Packing Logic

func packForRN(_ size: CGSize, withName name: String) -> [AnyHashable: Any] {

let size = ["width": size.width,
"height": size.height]

return [name: size]
}

// MARK: - Set & get Contents

@objc func setContents(_ contents: NSString) {
super.setHTML(contents as String)
}

@objc func getContents() -> NSString {
return super.getHTML() as NSString
}
}

6 changes: 6 additions & 0 deletions ios/RNTAztecView/RCTAztecViewManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <React/RCTViewManager.h>

@interface RCT_EXTERN_REMAP_MODULE(RCTAztecView, RCTAztecViewManager, RCTViewManager)
//RCT_REMAP_VIEW_PROPERTY(text, contents, NSString)
RCT_EXPORT_VIEW_PROPERTY(onContentSizeChange, RCTBubblingEventBlock)
@end
17 changes: 17 additions & 0 deletions ios/RNTAztecView/RCTAztecViewManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation

@objc (RCTAztecViewManager)
class RCTAztecViewManager: RCTViewManager {

@objc override func view() -> UIView {
let view = RCTAztecView(
defaultFont: .systemFont(ofSize: 12),
defaultParagraphStyle: .default,
defaultMissingImage: UIImage())

view.backgroundColor = .cyan
view.text = "Hello world!"

return view
}
}
16 changes: 0 additions & 16 deletions ios/RNTAztecView/RNTAztecView.m

This file was deleted.

Loading

0 comments on commit 9d11c0f

Please sign in to comment.