//
//  PopoerViewManager.m
//  Project
//
//  Created by Vae on 2018/10/30.
//

#import "PopoverViewManager.h"
#import "Utility.h"
#import <AMPopTip/AMPopTip.h>

@interface PopoverViewManager ()
@property(nonatomic, strong) AMPopTip *popTip;

@end

@implementation PopoverViewManager

+ (instancetype)sharedInstance {
	static dispatch_once_t onceToken;
	static PopoverViewManager *instance = nil;
	dispatch_once(&onceToken,^{
		instance = [[super allocWithZone:NULL] init];
	});
	return instance;
}

+ (id)allocWithZone:(struct _NSZone *)zone{
	return [self sharedInstance];
}

- (void)showPopoVerInView:(UIView *)view withAttributeString:(NSAttributedString *)attributeString fromFrame:(CGRect)frame{
	[self.popTip showAttributedText:attributeString direction:AMPopTipDirectionUp maxWidth:200 inView:view fromFrame:frame duration:5];
	self.popTip.popoverColor = [Utility popoverViewBackGroundColor];
	
}

-(void)hiddenPopoverView{
	[self.popTip hide];
}

-(AMPopTip *)popTip{
	if (!_popTip) {
		_popTip = [[AMPopTip alloc] init];
		UITapGestureRecognizer *tapGesture = [_popTip valueForKey:@"tapRemoveGesture"];
		tapGesture.enabled = NO;
		_popTip.arrowSize = CGSizeMake(8, 6);
	}
	return _popTip;
}

@end
