//
//  ShareInstance.m
//  ALand
//
//  Created by Z on 16/4/28.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "ShareInstance.h"
#import "CoverShadowView.h"
#import "ShareContentView.h"

#define kWindow [UIApplication sharedApplication].keyWindow
@interface ShareInstance ()
@property (nonatomic, strong) CoverShadowView *cover;
@property (nonatomic, strong) ShareContentView *shareContentView;
@end

@implementation ShareInstance
+ (ShareInstance *)shareInstace
{
    static ShareInstance *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[ShareInstance alloc] init];
        
    });
    return instance;
}

- (void)showWithTitle:(NSString *)title content:(NSString *)content url:(NSString *)url image:(UIImage *)image{
    
    [self.cover show];
    
    WS(weakSelf)
    self.cover.tapAction = ^{
        [UIView animateWithDuration:0.3 animations:^{
            CLog(@"animate");
            weakSelf.shareContentView.frame = CGRectMake(0, kHeight, kWidth, 140);
        }];
        
    };
    
    self.shareContentView.title = title;
    self.shareContentView.content = content;
    self.shareContentView.url = url;
    self.shareContentView.image = image;
    [MyTools animateFromBottomDuration:0.5 view:self.shareContentView viewHeight:140];

}

- (CoverShadowView *)cover {
    if (!_cover) {
        _cover = [[CoverShadowView alloc] initOnTopWithHeight:kHeight];
        [kWindow addSubview:_cover];
    }
    return _cover;
}

- (ShareContentView *)shareContentView {
    if (!_shareContentView) {
        _shareContentView = [ShareContentView viewWithNibName:@"ShareContentView"];
        _shareContentView.frame = CGRectMake(0, kHeight, kWidth, 140);
        [kWindow addSubview:_shareContentView];

    }
    return _shareContentView;
}
@end
