Skip to content

Commit

Permalink
Moving WebView into UI Module (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddimax authored and gitoby committed Apr 4, 2019
1 parent e801f43 commit d5f1bed
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 105 deletions.
8 changes: 2 additions & 6 deletions examples/reddit/src/reddit.cpp
Expand Up @@ -2,7 +2,6 @@
#include <bdn/log.h>
#include <bdn/net.h>
#include <bdn/ui.h>
#include <bdn/webview-module.h>
#include <bdn/yogalayout.h>

#include <nlohmann/json.hpp>
Expand All @@ -21,11 +20,8 @@ class RedditPost
public:
RedditPost() = default;
RedditPost(const String &title_, const String &url_, const String &thumbnailUrl_)
{
title = title_;
url = url_;
thumbnailUrl = thumbnailUrl_;
}
: title(title_), url(url_), thumbnailUrl(thumbnailUrl_)
{}

Property<String> title;
Property<String> url;
Expand Down
1 change: 0 additions & 1 deletion framework/CMakeLists.txt
Expand Up @@ -53,7 +53,6 @@ add_subdirectory(net)
add_subdirectory(ui)
add_subdirectory(testing)
add_subdirectory(layout)
add_subdirectory(webview)

if(BDN_INCLUDE_LOTTIE)
add_subdirectory(lottieview)
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions framework/ui/platforms/CMakeLists.txt
@@ -1,10 +1,12 @@

if(BDN_PLATFORM_OSX)
add_subdirectory(mac)
target_link_libraries(ui INTERFACE ui_mac)
add_subdirectory(applecommon)
target_link_libraries(ui INTERFACE ui_mac ui_applecommon)
elseif(BDN_PLATFORM_IOS)
add_subdirectory(ios)
target_link_libraries(ui INTERFACE ui_ios)
add_subdirectory(applecommon)
target_link_libraries(ui INTERFACE ui_ios ui_applecommon)
elseif(BDN_PLATFORM_ANDROID)
add_subdirectory(android)
target_link_libraries(ui INTERFACE ui_android)
Expand Down
2 changes: 2 additions & 0 deletions framework/ui/platforms/applecommon/CMakeLists.txt
@@ -0,0 +1,2 @@
add_platform_library(NAME applecommon SOURCE_FOLDER ${CMAKE_CURRENT_LIST_DIR} COMPONENT_NAME IOS-MAC PARENT_LIBRARY ui DONT_LINK_PARENT_LIBRARY)
target_link_libraries(ui_applecommon PRIVATE ui)
@@ -0,0 +1,10 @@
#pragma once

#import <WebKit/WebKit.h>

#include "../../../include/bdn/WebView.h"

@interface WebViewNavigationController : NSObject <WKNavigationDelegate>
@property std::function<bool(bdn::WebView::RedirectRequest)> redirectHandler;
//- initWithCore:(std::shared_ptr<bdn::mac::WebViewCore>)core;
@end
@@ -0,0 +1,32 @@
#import <bdn/applecommon/WebViewNavigationController.hh>

#include <bdn/foundationkit/stringUtil.hh>
#include <bdn/log.h>

@implementation WebViewNavigationController

- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
bdn::logstream() << "Navigation failed: " << bdn::fk::nsStringToString(error.localizedDescription);
}

- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
bdn::logstream() << "Provisional navigation failed: " << bdn::fk::nsStringToString(error.localizedDescription);
}

- (void)webView:(WKWebView *)webView
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
bdn::WebView::RedirectRequest request;
request.url = bdn::fk::nsStringToString(navigationAction.request.URL.absoluteString);

if (!self.redirectHandler || self.redirectHandler(request)) {
decisionHandler(WKNavigationActionPolicyAllow);
} else {
decisionHandler(WKNavigationActionPolicyCancel);
}
}

@end
File renamed without changes.
41 changes: 0 additions & 41 deletions framework/webview/CMakeLists.txt

This file was deleted.

33 changes: 0 additions & 33 deletions framework/webview/install.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions framework/webview/platforms/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion framework/webview/platforms/android/CMakeLists.txt

This file was deleted.

2 changes: 0 additions & 2 deletions framework/webview/platforms/ios/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions framework/webview/platforms/mac/CMakeLists.txt

This file was deleted.

0 comments on commit d5f1bed

Please sign in to comment.