Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to integrate Gutenberg-Mobile into the WPiOS App #195

Merged
merged 47 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1d54536
RN App running inside iOS App
etoledom Oct 16, 2018
4dee77a
Merge branch 'master' into try/WPiOS-integration
etoledom Oct 16, 2018
cb372de
Update reference to WPiOS.
etoledom Oct 16, 2018
99a3bef
Updating react-native-aztec and WordPress-iOS submodule references
etoledom Oct 17, 2018
3f84337
Update submodules reference
etoledom Oct 18, 2018
815f8d6
Merge branch 'master' into try/WPiOS-integration
etoledom Oct 18, 2018
242a76d
Adding Done button to send a 'Done' message to native app.
etoledom Oct 19, 2018
5c66839
Removed WordPress-iOS from submodules
etoledom Oct 19, 2018
d45eb94
Recovering original ios example project
etoledom Oct 19, 2018
701f1d0
Changing folder name to react-native-aztec
etoledom Oct 23, 2018
7961460
Update react-native-aztec submodule reference
etoledom Oct 23, 2018
c8a004a
Merge branch 'master' into try/WPiOS-integration
etoledom Oct 23, 2018
bc30f4e
Added buttons to save and close at top.
etoledom Oct 23, 2018
6723e1d
Organizing dependencies to run example proyect.
etoledom Oct 24, 2018
cb198c9
Refactored MediaProvider to be easely implemented on different projects.
etoledom Oct 25, 2018
fa77088
Update RNAztec reference
etoledom Oct 25, 2018
e2ace68
Merge branch 'master' into try/WPiOS-integration
etoledom Oct 25, 2018
bc2049b
Update gutenberg reference
etoledom Oct 25, 2018
b43baf3
Fix lint issues
etoledom Oct 25, 2018
011f10d
Adding `block-serializer` helper to reuse code.
etoledom Oct 25, 2018
6e5f6d4
Removed React dependency from AppDelegate
etoledom Oct 25, 2018
0c0075c
Update RNAztec reference
etoledom Oct 25, 2018
c6c10b4
Fixing flow warning on `block-serializer`
etoledom Oct 25, 2018
27bbb33
GutenbergBridge: rootView is now a function to receive initial props.
etoledom Nov 1, 2018
99f6cb5
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 1, 2018
39bd7da
Updated Aztec and Gutenberg references
etoledom Nov 1, 2018
2b4abb7
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 1, 2018
69348e5
Implementing react-native-gutenberg-bridge on ios example app.
etoledom Nov 1, 2018
56cc4d0
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 2, 2018
67be16a
Clean up deprecated bridge communication.
etoledom Nov 2, 2018
3a05f6e
Solving pod warnings on RNReactNativeGutenbergBridge.podspec
etoledom Nov 2, 2018
73c147d
Bridge and aztec updates
etoledom Nov 2, 2018
17450f4
Reconnect Gutenberg Bridge to native Save action.
etoledom Nov 5, 2018
5929749
Modified iOS example project to test bridge methods easely.
etoledom Nov 5, 2018
78b66e4
Update Aztec reference.
etoledom Nov 5, 2018
16f1a4d
iOS Brdige: Remove extra delegate.
etoledom Nov 5, 2018
495c866
Update Aztec reference
etoledom Nov 6, 2018
05b394f
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 6, 2018
d5097ab
iOS Gutenberg.m: Refactoring `gutenbergBridgeModule` init.
etoledom Nov 7, 2018
c21e8cf
iOS Bridge: Refactor `Gutenberg` class init.
etoledom Nov 7, 2018
6c0ca2e
iOS Bridge: Fix retain cycle.
etoledom Nov 7, 2018
2ed47c4
html-text-input.js: Roll back `block-serializer` changes.
etoledom Nov 7, 2018
bc7a52e
iOS Bridge: Small syntax fixes.
etoledom Nov 7, 2018
23877bc
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 7, 2018
ab1a355
iOS Bridge: Removed unused protocol declaration.
etoledom Nov 7, 2018
292b31e
Updating Aztec reference to current master
etoledom Nov 8, 2018
2372f40
Merge branch 'master' into try/WPiOS-integration
etoledom Nov 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ios/gutenberg-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
//

#import <React/RCTBundleURLProvider.h>

#import <React/RCTEventEmitter.h>
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>
#import "Gutenberg.h"
42 changes: 22 additions & 20 deletions ios/gutenberg.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
2DCD954D1E0B4F2C00145EB5 /* gutenbergTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* gutenbergTests.m */; };
2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
7E4C21212187419000EC7F49 /* libRNReactNativeGutenbergBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */; };
7E45CC5B218B42E000C0B2AB /* libRNReactNativeGutenbergBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */; };
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
8C666FF0C9224FB88C2C0447 /* libRNSVG-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BFAFEB337654221B2F14D03 /* libRNSVG-tvOS.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
CF45443564B845C8BDCFBAB6 /* libRNTAztecView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ADEFEC092CF4D00BEF1019E /* libRNTAztecView.a */; };
DD2AE937473A49B2B5A0E7B6 /* libRNSVG.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EB766FE2F6D446A80AC6E6A /* libRNSVG.a */; };
F1289ECB2100E4320091E81D /* Aztec.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1289ECA2100E4320091E81D /* Aztec.framework */; };
F151983B2100DC3D000F6E97 /* BridgeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15198382100DC3C000F6E97 /* BridgeDelegate.swift */; };
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15198392100DC3D000F6E97 /* AppDelegate.swift */; };
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F151983A2100DC3D000F6E97 /* MediaProvider.swift */; };
F19CFDA821021EB100EAB240 /* Aztec.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1289ECA2100E4320091E81D /* Aztec.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -305,9 +305,9 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTLinking;
};
7E4C211C2187417100EC7F49 /* PBXContainerItemProxy */ = {
7E45CC59218B42C000C0B2AB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */;
containerPortal = 7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNReactNativeGutenbergBridge;
Expand Down Expand Up @@ -386,16 +386,16 @@
3ADEFEC092CF4D00BEF1019E /* libRNTAztecView.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNTAztecView.a; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNReactNativeGutenbergBridge.xcodeproj; path = "../react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.xcodeproj"; sourceTree = "<group>"; };
7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNReactNativeGutenbergBridge.xcodeproj; path = "../react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.xcodeproj"; sourceTree = "<group>"; };
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = GutenbergViewController.swift; path = gutenberg/GutenbergViewController.swift; sourceTree = "<group>"; tabWidth = 1; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
9B18D59B9364468890D0E546 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSVG.xcodeproj; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = "<group>"; };
9BFAFEB337654221B2F14D03 /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNSVG-tvOS.a"; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
F1289ECA2100E4320091E81D /* Aztec.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Aztec.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "gutenberg-Bridging-Header.h"; sourceTree = "<group>"; };
F15198382100DC3C000F6E97 /* BridgeDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BridgeDelegate.swift; path = gutenberg/BridgeDelegate.swift; sourceTree = "<group>"; };
F15198392100DC3D000F6E97 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = gutenberg/AppDelegate.swift; sourceTree = "<group>"; };
F151983A2100DC3D000F6E97 /* MediaProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaProvider.swift; path = gutenberg/MediaProvider.swift; sourceTree = "<group>"; };
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = "gutenberg-Bridging-Header.h"; sourceTree = "<group>"; tabWidth = 1; };
F15198392100DC3D000F6E97 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = gutenberg/AppDelegate.swift; sourceTree = "<group>"; tabWidth = 1; };
F151983A2100DC3D000F6E97 /* MediaProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = MediaProvider.swift; path = gutenberg/MediaProvider.swift; sourceTree = "<group>"; tabWidth = 1; usesTabs = 0; };
F619623252704B46A619C33C /* RNTAztecView.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNTAztecView.xcodeproj; path = "../react-native-aztec/ios/RNTAztecView.xcodeproj"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -413,7 +413,7 @@
buildActionMask = 2147483647;
files = (
F1289ECB2100E4320091E81D /* Aztec.framework in Frameworks */,
7E4C21212187419000EC7F49 /* libRNReactNativeGutenbergBridge.a in Frameworks */,
7E45CC5B218B42E000C0B2AB /* libRNReactNativeGutenbergBridge.a in Frameworks */,
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */,
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
Expand Down Expand Up @@ -544,7 +544,7 @@
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */,
F15198392100DC3D000F6E97 /* AppDelegate.swift */,
F15198382100DC3C000F6E97 /* BridgeDelegate.swift */,
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */,
F151983A2100DC3D000F6E97 /* MediaProvider.swift */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
Expand Down Expand Up @@ -603,18 +603,18 @@
name = Products;
sourceTree = "<group>";
};
7E4C20F42187417100EC7F49 /* Products */ = {
7E45CC56218B42C000C0B2AB /* Products */ = {
isa = PBXGroup;
children = (
7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */,
7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */,
);
name = Products;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */,
7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */,
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
Expand Down Expand Up @@ -869,8 +869,8 @@
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = 7E4C20F42187417100EC7F49 /* Products */;
ProjectRef = 7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */;
ProductGroup = 7E45CC56218B42C000C0B2AB /* Products */;
ProjectRef = 7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */;
},
{
ProductGroup = FFEDF6EF21241BDF007FCC6D /* Products */;
Expand Down Expand Up @@ -1137,11 +1137,11 @@
remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */ = {
7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNReactNativeGutenbergBridge.a;
remoteRef = 7E4C211C2187417100EC7F49 /* PBXContainerItemProxy */;
remoteRef = 7E45CC59218B42C000C0B2AB /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
832341B51AAA6A8300B99B32 /* libRCTText.a */ = {
Expand Down Expand Up @@ -1228,7 +1228,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1260,8 +1260,8 @@
buildActionMask = 2147483647;
files = (
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */,
F151983B2100DC3D000F6E97 /* BridgeDelegate.swift in Sources */,
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */,
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1382,6 +1382,7 @@
"$(SRCROOT)/../react-native-aztec/example/iOS/example",
/usr/include/libxml2,
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
"$(SRCROOT)/../react-native-gutenberg-bridge/ios/**",
);
INFOPLIST_FILE = gutenberg/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down Expand Up @@ -1410,6 +1411,7 @@
"$(SRCROOT)/../react-native-aztec/example/iOS/example",
/usr/include/libxml2,
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
"$(SRCROOT)/../react-native-gutenberg-bridge/ios/**",
);
INFOPLIST_FILE = gutenberg/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
52 changes: 8 additions & 44 deletions ios/gutenberg/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,18 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let mediaProvider = MediaProvider()

lazy var bridgeDelegate: BridgeDelegate = {
let sourceURL = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)!

return BridgeDelegate(sourceURL: sourceURL, mediaProvider: self.mediaProvider)
}()


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

let bridge = RCTBridge(delegate: bridgeDelegate, launchOptions: launchOptions)
let rootView = RCTRootView(bridge: bridge, moduleName: "gutenberg", initialProperties: nil)

rootView?.backgroundColor = .white


window = UIWindow(frame: UIScreen.main.bounds)

let rootViewController = UIViewController()

rootViewController.view = rootView
window?.rootViewController = rootViewController

let rootViewController = GutenbergViewController()

window?.rootViewController = UINavigationController(rootViewController: rootViewController)
window?.makeKeyAndVisible()

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
30 changes: 0 additions & 30 deletions ios/gutenberg/BridgeDelegate.swift

This file was deleted.

31 changes: 31 additions & 0 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import UIKit

class GutenbergViewController: UIViewController {
Copy link
Contributor

@diegoreymendez diegoreymendez Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going the route of providing a VC in Gutenberg is a double edged sword, and one that I'd really try to avoid, if possible.

I realize I may not see the full picture so my initial question is: was this choice because of advantages? requirements?

To explain a bit more why I think this is a bigger deal that can be apparent at first... this is all coming from my experience working in Aztec:

  • This couples the UI surrounding the editor, to gutenberg-mobile. If the UI needs to be customized we'll need to add extra code to support any such customization (that'd be otherwise for free). Think of the app needing to show different colors... change the whole layout... move buttons around. Or even worse, us wanting to use this library in two different Apps.
  • This potentially couples other things too, such as service calls, business logic (that may already exist WPiOS). We may also need to add native dependencies to gutenberg-mobile (things like WordPressShared... the media provider... services... UI components that exist in WPiOS... etc).
  • It would reduce our ability to reuse Gutenberg elsewhere. I don't have a clear picture of where Gutenberg may end up showing up, but the advantage in working the editor as a view component is that you can place it anywhere.

Overall, while it may seem simpler, it may end up adding a ton of extra work to access things that we'd get for free if we just provided a view component.

Copy link
Contributor Author

@etoledom etoledom Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments @diegoreymendez !

I believe there's a misunderstanding. Probably I haven't explained this implementation properly.
This GutenbergViewController only exists in the Example app and is meant to be a testing platform for the native modules (the communication between RN and Native).

The plan (as I see it so far) would be to provide just the Gutenberg.h interface to the gutenberg-mobile users (i.e: WPiOS). Gutenberg.h currently lives inside react-native-gutenberg-bridge but ideally we would provide it as the public header in a Pod framework. It provide access to the Gutenberg RootView (plain UIView), and it doesn't have any React / ReactNative public dependencies (all the React dependencies are managed internally). It also has methods to send messages to the RN side and a delegate to receive messages from RN.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could rename it GutenbergExampleController, or plane ExampleController to be more explicit about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my confusion stems from the fact there's no mention of Example in the file path or name... it's not a big deal to be honest. If this is an Example App VC we should be good.

lazy var gutenberg = Gutenberg()

override func loadView() {
view = gutenberg.rootView
}

override func viewDidLoad() {
super.viewDidLoad()
addSaveButton()
gutenberg.delegate = self
navigationController?.navigationBar.isTranslucent = false
}

func addSaveButton() {
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(saveButtonPressed(sender:)))
}

@objc func saveButtonPressed(sender: UIBarButtonItem) {
gutenberg.requestHTML()
}
}

extension GutenbergViewController: GutenbergBridgeDelegate {
func gutenbergDidProvideHTML(_ html: String) {
print("Did receive HTML: \(html)")
}
}
Loading