Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:alibaba/weex into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sospartan committed Dec 22, 2016
2 parents 8162124 + 956be54 commit c76e60b
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/component/input-demo.we
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
}
}
};
</script>
</script>
1 change: 0 additions & 1 deletion examples/component/web-demo.we
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
module.exports = {
methods: {
goback: function() {
var $webview = require('@weex-module/webview');
var webElement = this.$el('webview');
$webview.goBack(webElement.ref);
},
Expand Down
3 changes: 2 additions & 1 deletion examples/module/stream-demo.we
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
stream.fetch({
method: 'POST',
url: POST_URL,
type:'json'
type:'json',
body:JSON.stringify({username:'weex'})//or you can just use JSON Object {username:'weex'}
}, function(ret) {
if(!ret.ok){
me.postResult = "request failed";
Expand Down
22 changes: 12 additions & 10 deletions ios/sdk/WeexSDK/Sources/Component/WXEmbedComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,18 @@ - (void)_renderWithURL:(NSURL *)sourceURL
};

_embedInstance.onFailed = ^(NSError *error) {
if (weakSelf.errorView) {
return ;
}

WXErrorView *errorView = [[WXErrorView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 135.0f, 130.0f)];
errorView.center = CGPointMake(weakSelf.view.bounds.size.width / 2.0f, weakSelf.view.bounds.size.height / 2.0f);
errorView.delegate = weakSelf;
[weakSelf.view addSubview:errorView];

weakSelf.errorView = errorView;
dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.errorView) {
return ;
}

WXErrorView *errorView = [[WXErrorView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 135.0f, 130.0f)];
errorView.center = CGPointMake(weakSelf.view.bounds.size.width / 2.0f, weakSelf.view.bounds.size.height / 2.0f);
errorView.delegate = weakSelf;
[weakSelf.view addSubview:errorView];

weakSelf.errorView = errorView;
});
};

_embedInstance.renderFinish = ^(UIView *view) {
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void)updateAttributes:(NSDictionary *)attributes
_imageSrc = [[WXConvert NSString:attributes[@"src"]] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[self updateImage];
}

[self configPlaceHolder:attributes];

if (attributes[@"resize"]) {
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ - (void)adjustSticky
}
CGFloat scrollOffsetY = ((UIScrollView *)self.view).contentOffset.y;
for(WXComponent *component in self.stickyArray) {
if (CGPointEqualToPoint(component->_absolutePosition, CGPointZero)) {
if (isnan(component->_absolutePosition.x) && isnan(component->_absolutePosition.y)) {
component->_absolutePosition = [component.supercomponent.view convertPoint:component.view.frame.origin toView:self.view];
}
CGPoint relativePosition = component->_absolutePosition;
Expand Down
37 changes: 36 additions & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXSliderNeighborComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,23 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gesture shouldReceiveTouch:(UIT
return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
//if the view which the otherGestureRecognizer works on is a scrollview and also it is scrollEnabled vertically ,at this time,we should not block the guesture from being recognized by the otherGestureRecognize
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) {
UIScrollView* scrollview = (UIScrollView *)otherGestureRecognizer.view;
if (scrollview.scrollEnabled) {
UIPanGestureRecognizer* panRcgn= (UIPanGestureRecognizer *)gestureRecognizer;
//check offset for confirming vertival movement
if (fabs([panRcgn translationInView:panRcgn.view].y) > fabs([panRcgn translationInView:panRcgn.view].x)*16) {
return YES;
}
}
}
}
return NO;
}


- (void)didPan:(UIPanGestureRecognizer *)panGesture
{
Expand All @@ -526,11 +543,12 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture
_scrolling = NO;
_decelerating = NO;
_previousTranslation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x;

[_delegate sliderNeighborWillBeginDragging:self];
break;
}
case UIGestureRecognizerStateEnded:

case UIGestureRecognizerStateCancelled:
case UIGestureRecognizerStateFailed:
{
Expand Down Expand Up @@ -566,6 +584,7 @@ - (void)didPan:(UIPanGestureRecognizer *)panGesture
}
case UIGestureRecognizerStateChanged:
{

CGFloat translation = _vertical? [panGesture translationInView:self].y: [panGesture translationInView:self].x;
CGFloat velocity = _vertical? [panGesture velocityInView:self].y: [panGesture velocityInView:self].x;

Expand Down Expand Up @@ -1425,6 +1444,22 @@ - (UIView *)loadView
return _sliderView;
}

- (void)dealloc
{
_sliderView.delegate = nil;
_sliderView.dataSource = nil;
if (_autoPlay) {
[self _stopAutoPlayTimer];
}
_sliderView = nil;
[self.items removeAllObjects];
}

- (void)viewDidUnload
{
[self.items removeAllObjects];
}

- (void)viewDidLoad
{
_sliderView = (WXSliderNeighborView *)self.view;
Expand Down
3 changes: 1 addition & 2 deletions ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ - (void)removeEvent:(NSString *)removeEventName

- (void)_initEvents:(NSArray *)events
{
NSArray *eventsCopy = [events copy];
for (NSString *addEventName in eventsCopy) {
for (NSString *addEventName in events) {
[self _addEventOnMainThread:addEventName];
}
}
Expand Down
1 change: 0 additions & 1 deletion ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ - (void)createFinish
WX_MONITOR_SUCCESS(WXMTNativeRender);

if(instance.renderFinish){
[instance creatFinish];
instance.renderFinish(rootView);
}
}];
Expand Down
3 changes: 2 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ - (instancetype)initWithRef:(NSString *)ref
_styles = styles ? [NSMutableDictionary dictionaryWithDictionary:styles] : [NSMutableDictionary dictionary];
_attributes = attributes ? [NSMutableDictionary dictionaryWithDictionary:attributes] : [NSMutableDictionary dictionary];
_events = events ? [NSMutableArray arrayWithArray:events] : [NSMutableArray array];

_subcomponents = [NSMutableArray array];

_absolutePosition = CGPointMake(NAN, NAN);

_isNeedJoinLayoutSystem = YES;
_isLayoutDirty = YES;
_isViewFrameSyncWithCalculated = YES;
Expand Down
7 changes: 6 additions & 1 deletion ios/sdk/WeexSDK/Sources/Module/WXGlobalEventModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)removeEventListener:(NSString *)event
{
if (_eventCallback[event]) {
[_eventCallback removeObjectForKey:event];
[[NSNotificationCenter defaultCenter] removeObserver:self name:event object:weexInstance];
[[NSNotificationCenter defaultCenter] removeObserver:self name:event object:nil];
} else {
WXLogWarning(@"eventName \"%@\" doesn't exist", event);
}
Expand All @@ -70,4 +70,9 @@ - (void)fireGlobalEvent:(NSNotification *)notification
}
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
22 changes: 20 additions & 2 deletions ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ - (void)fetch:(NSDictionary *)options callback:(WXModuleCallback)callback progre
}
urlStr = newUrlStr;
NSDictionary *headers = [options objectForKey:@"headers"];
NSString *body = [options objectForKey:@"body"];
NSString *type = [options objectForKey:@"type"];
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
Expand All @@ -95,8 +94,27 @@ - (void)fetch:(NSDictionary *)options callback:(WXModuleCallback)callback progre
NSString *value = [headers objectForKey:header];
[request setValue:value forHTTPHeaderField:header];
}
[request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];

if ([options objectForKey:@"body"]) {
NSData * body = nil;
if ([[options objectForKey:@"body"] isKindOfClass:[NSString class]]) {
// compatible with the string body
body = [[options objectForKey:@"body"] dataUsingEncoding:NSUTF8StringEncoding];
}
if ([[options objectForKey:@"body"] isKindOfClass:[NSDictionary class]]) {
body = [[WXUtility JSONString:[options objectForKey:@"body"]] dataUsingEncoding:NSUTF8StringEncoding];
}
if (!body) {
[callbackRsp setObject:@(-1) forKey:@"status"];
[callbackRsp setObject:@false forKey:@"ok"];
callback(callbackRsp);

return;
}

[request setHTTPBody:body];
}

[callbackRsp setObject:@{ @"OPENED": @1 } forKey:@"readyState"];

progressCallback(callbackRsp, TRUE);
Expand Down
1 change: 0 additions & 1 deletion ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @discussion callback data to js, the id of callback function will be removed to save memory.
*/
typedef void (^WXModuleCallback)(id result);
typedef void (^WXModuleKeepAliveCallback)(id result, BOOL keepAlive);

/**
* @abstract the module callback , result can be string or dictionary.
Expand Down

0 comments on commit c76e60b

Please sign in to comment.