//
//  WebViewErrorView.m
//  Project
//
//  Created by Vae on 2018/10/26.
//

#import "WebViewErrorView.h"
#import "DrawUtils.h"
#import "SDK.h"
#import "CocoaUtils.h"
#import "Vars.h"
@interface WebViewErrorView()

@property (weak, nonatomic) IBOutlet UILabel *errorText;
@property (weak, nonatomic) IBOutlet UIImageView *imageVerror;
@end
@implementation WebViewErrorView

-(void)awakeFromNib{
	[super awakeFromNib];
	[DrawUtils addRoundedBorderToRect:self.refreshButton cornerRadius:5];
	NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:IMLocalizedString(@"Your Session has timed out due to inacitvity.") attributes:@{ NSForegroundColorAttributeName :[UIColor blackColor] ,NSFontAttributeName : [UIFont preferredFontForTextStyle:[Vars is_cn_website] ? UIFontTextStyleTitle2 :UIFontTextStyleTitle3] }];
	[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n\n"]];
	[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:IMLocalizedString(@"Please refresh the page.") attributes:@{ NSForegroundColorAttributeName : [UIColor lightGrayColor] ,NSFontAttributeName :[UIFont preferredFontForTextStyle:UIFontTextStyleBody]}]];
	if ([Vars is_tours_site]) {
		self.imageVerror.image = [UIImage imageNamed:@"tt_help_err"];
		self.errorText.attributedText =  attributedString;
	} else {
		self.imageVerror.image = [UIImage imageNamed:@"support_error"];
//		self.errorText.text  =  attributedString;
	}
	
	[self.refreshButton setTitle:IMLocalizedString(@"Reresh Page") forState:UIControlStateNormal];
	self.refreshButton.backgroundColor = [Vars defaultTintColor];
}
@end
