Skip to content

Commit

Permalink
Merge branch 'main' into doc_asyncstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Nov 3, 2023
2 parents fd3d64d + a28fb76 commit 6e353a5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
4 changes: 0 additions & 4 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,9 @@ LayoutResult DomNode::GetLayoutInfoFromRoot() {
void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode>>& changed_nodes) {
auto not_equal = std::not_equal_to<>();
bool changed = layout_node_->IsDirty() || layout_node_->HasNewLayout();
#ifdef __ANDROID__
bool trigger_layout_event = true;
#else
bool trigger_layout_event =
not_equal(layout_.left, layout_node_->GetLeft()) || not_equal(layout_.top, layout_node_->GetTop()) ||
not_equal(layout_.width, layout_node_->GetWidth()) || not_equal(layout_.height, layout_node_->GetHeight());
#endif

layout_.left = layout_node_->GetLeft();
layout_.top = layout_node_->GetTop();
Expand Down
6 changes: 6 additions & 0 deletions driver/js/src/modules/animation_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ std::shared_ptr<ParseAnimationResult> ParseAnimation(const std::shared_ptr<Ctx>&
const std::shared_ptr<CtxValue> arguments[],
std::shared_ptr<CtxValue>& exception) {
if (argument_count != kAnimationUpdateArgc) {
exception = context->CreateException("animation argument count error");
return nullptr;
}

Expand Down Expand Up @@ -306,11 +307,13 @@ RegisterAnimation(const std::weak_ptr<Scope>& weak_scope) {
auto weak_dom_manager = scope->GetDomManager();
auto dom_manager = weak_dom_manager.lock();
if (!dom_manager) {
exception = scope->GetContext()->CreateException("dom_manager null error");
return nullptr;
}
auto weak_root_node = scope->GetRootNode();
auto root_node = weak_root_node.lock();
if (!root_node) {
exception = scope->GetContext()->CreateException("root_node null error");
return nullptr;
}
auto result = ParseAnimation(scope->GetContext(), argument_count, arguments, exception);
Expand Down Expand Up @@ -619,15 +622,18 @@ RegisterAnimationSet(const std::weak_ptr<Scope>& weak_scope) {
auto weak_dom_manager = scope->GetDomManager();
auto dom_manager = weak_dom_manager.lock();
if (!dom_manager) {
exception = scope->GetContext()->CreateException("dom_manager null error");
return nullptr;
}
auto weak_root_node = scope->GetRootNode();
auto root_node = weak_root_node.lock();
if (!root_node) {
exception = scope->GetContext()->CreateException("root_node null error");
return nullptr;
}
auto animation_manager = root_node->GetAnimationManager();
if (!animation_manager) {
exception = scope->GetContext()->CreateException("animation_manager null error");
return nullptr;
}
auto set = ParseAnimationSet(scope->GetContext(), argument_count, arguments, exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ - (void)setHorizontal:(BOOL)horizontal {
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
layout.scrollDirection = horizontal ? UICollectionViewScrollDirectionHorizontal : UICollectionViewScrollDirectionVertical;
[self.collectionView.collectionViewLayout invalidateLayout];
if (horizontal) {
[self.collectionView setAlwaysBounceHorizontal:YES];
[self.collectionView setAlwaysBounceVertical:NO];
} else {
[self.collectionView setAlwaysBounceVertical:YES];
[self.collectionView setAlwaysBounceHorizontal:NO];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ - (void)initCollectionView {
collectionView.dataSource = self;
collectionView.delegate = self;
collectionView.layoutDelegate = self;
collectionView.alwaysBounceVertical = YES;
collectionView.backgroundColor = [UIColor clearColor];
_collectionView = collectionView;
[self registerCells];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
NS_ASSUME_NONNULL_BEGIN

@interface NativeRenderSimpleWebView : WKWebView <WKUIDelegate, WKNavigationDelegate>
@property (nonatomic, strong) NSString *userAgent;
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong) NSDictionary *source;
@property (nonatomic, copy) HippyDirectEventBlock onLoadStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,35 @@ - (void)setSource:(NSDictionary *)source {
_source = source;
if (source && [source[@"uri"] isKindOfClass:[NSString class]]) {
NSString *urlString = source[@"uri"];
[self loadUrl:urlString];
NSString *method = source[@"method"];

// Wait for other properties to be updated
dispatch_async(dispatch_get_main_queue(), ^{
[self loadUrl:urlString withMethod:method];
});
}
}

- (void)loadUrl:(NSString *)urlString {
- (void)loadUrl:(NSString *)urlString withMethod:(NSString*)method {
_url = urlString;
NSURL *url = HippyURLWithString(urlString, NULL);
if (!url) {
return;
}
NSURLRequest *request = [NSURLRequest requestWithURL:url];

NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
method = [method uppercaseString];
if([method isEqualToString:@"GET"]){
request.HTTPMethod = @"GET";
}else if ([method isEqualToString:@"POST"]){
request.HTTPMethod = @"POST";
}else{
// System default is 'GET' no need to be specified explicitly
}
NSString* ua = self.userAgent;
if(ua){
self.customUserAgent = ua;
}
[self loadRequest:request];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ @implementation NativeRenderSimpleWebViewManager

HIPPY_EXPORT_MODULE(WebView)

HIPPY_EXPORT_VIEW_PROPERTY(userAgent, NSString)
HIPPY_EXPORT_VIEW_PROPERTY(source, NSDictionary)
HIPPY_EXPORT_VIEW_PROPERTY(onLoadStart, HippyDirectEventBlock)
HIPPY_EXPORT_VIEW_PROPERTY(onLoadEnd, HippyDirectEventBlock)
Expand Down

0 comments on commit 6e353a5

Please sign in to comment.