//
//  CommonUtil.h
//  JasonDevelop
//
//  Created by Jason Lee on 2/14/14.
//  Copyright (c) jasondevelop. All rights reserved.
//

typedef enum {
    AdjustFrameModeOriginY = 0,
    AdjustFrameModeHeight,
    AdjustFrameModeBoth
} AdjustFrameMode;

@class SortDictionary;

@interface CommonUtil : NSObject

#pragma mark - Device Util
/**
 앱 버전 리턴
 @return 앱 버전
 */
+ (NSString *)applicationVersion;

/**
 앱 표시 버전 리턴
 @return 앱 표시 버전
 */
+ (NSString *)applicationShortVersion;

+ (NSString *)bundleIdentifier;

/**
 시스템 OS 버전 리턴
 @return 시스템 OS 버전
 */
+ (CGFloat)deviceSystemVersion;

/**
 앱 고유아이디 리턴
 @return 앱 고유아이디
 */
+ (NSString *)uniqueIdentifier;
+ (NSString *)deviceName;
+ (void)showCurrentDevice;
+ (CGFloat)hardwareVersion;
+ (NSUInteger)hardware;

#pragma makr - Locale
+ (NSString *)countryCode;


#pragma mark - Network Util
+(BOOL)roamingCheck;
+ (BOOL)isOnPhoneCall;


#pragma mark - FileUtil
/**f
 Documents 내 절대 경로를 리턴
 @return 경로
 */
+(NSString*)getPath:(NSString *)lastPath;

/**
 해당 경로에 파일 존재 유무
 */
+(BOOL)isExistFile:(NSString*)filePath;

/**
 해당 경로에 파일 생성
 @return 생성결과
 */
+(BOOL) createFile:(NSString*)filePath;

/**
 해당 경로의 파일 삭제
 @return 삭제결과
 */
+ (BOOL)deleteFile:(NSString *)fileName;



/**
 iOS7인지 판단하여, 실제 윈도우 사이즈를 리턴
 @return 화면크기
 */
+ (CGRect)mainScreenBounds;

#pragma mark - UI Util

+ (id)instantiateViewControllerWithIdentifier:(NSString *)identifier storyboardName:(NSString *)storyboardName;
+ (UIViewController *)currentViewController;
+ (UIView *)topView;

/**
 컨테이너로부터의 센터위치를 리턴
 @param object 센터위치를 구할 대상 뷰
 @param container 컨테이너 뷰
 @param navigationBar 제공 여부
 @param TabBar 제공여부
 @return CGRect 센터위치
 */
+ (CGRect)getCenterPosition:(id)object fromContainer:(id)container hasNavigationBar:(BOOL)hasNavigationBar hasTabBar:(BOOL)hasTabBar;


+ (CGRect)centerRect:(id)object fromContainer:(id)container;
/**
 해당 뷰를 컨테이너뷰의 중앙으로 이동시킴
 @param object 센터위치를 구할 대상 뷰
 @param container 컨테이너 뷰
 @param navigationBar 제공 여부
 @param TabBar 제공여부
 */
+ (void)moveToCenter:(id)object withContainer:(id)container hasNavigationBar:(BOOL)hasNavigationBar hasTabBar:(BOOL)hasTabBar;

/**
 해당 뷰를 컨테이너뷰의 가로 중앙으로 이동시킴
 @param object 센터위치를 구할 대상 뷰
 @param container 컨테이너 뷰
 @param navigationBar 제공 여부
 @param TabBar 제공여부
 */
+ (void)moveToCenterHorizon:(id)object withContainer:(id)container;

/**
 해당 뷰를 컨테이너뷰의 세로 중앙으로 이동시킴
 @param object 센터위치를 구할 대상 뷰
 @param container 컨테이너 뷰
 @param navigationBar 제공 여부
 @param TabBar 제공여부
 */
+ (void)moveToCenterVertical:(id)object withContainer:(id)container;

+ (CGSize)sizeWithString:(NSString *)text font:(UIFont *)font constrainedToSize:(CGSize)constrainedToSize lineBreakMode:(NSLineBreakMode)lineBreakMode;
+ (float)sizeWithStringHeight:(NSString *)text font:(UIFont *)font constrainedToSize:(float)width lineBreakMode:(NSLineBreakMode)lineBreakMode;

+ (CGFloat)getLabelRealWidth:(UILabel *)label fixedWidth:(CGFloat)fixedWidth;
+ (CGFloat)getLabelRealHeight:(UILabel *)label;
+ (CGSize)getLabelRealSize:(UILabel *)label fixedWdith:(CGFloat)fixedWidth;
+ (CGSize)getSizeFromString:(NSString *)string font:(UIFont *)font width:(CGFloat)fixedWidth;
+ (CGSize)getSizeFromAttributeString:(NSAttributedString *)string width:(CGFloat)fixedWidth;

+ (NSArray *)nibViews:(NSString *)nibName;


#pragma mark - Date Util
+ (NSCalendar *)calendar;
+ (NSCalendar *)calendar2;
+ (NSDateFormatter *)dateFormatter;
+ (NSString *)currentDate;
+ (NSString *)currentDate2;
+ (NSString *)currentDate3;
+ (NSString *)currentYear;
+ (NSString *)currentMonth;
+ (NSString *)currentDay;
+ (NSString *)stringFromDate:(NSDate *)date;
+ (NSString *)stringFromDateTime:(NSDate *)date;
+ (NSString *)stringFromDate2:(NSDate *)date;
+ (NSString *)birthStringFromDate:(NSDate *)date;

+ (NSString *)connectDataFromStr:(NSString *)dateString;

+ (NSString *)stringFromString:(NSString *)dateString;
+ (NSString *)stringFromDateComponents:(NSDateComponents *)components;
+ (NSString *)stringFromDateComponents2:(NSDateComponents *)components;
+ (NSString *)stringYearMonthFromDateComponents:(NSDateComponents *)components;

+ (NSDateComponents *)dateComponents:(NSDate *)date;
+ (NSDateComponents *)dateComponents:(NSDate *)date timezone:(NSTimeZone *)timezone;
+ (NSDateComponents *)dateComponentsFromString:(NSString *)dateString;
+ (NSDateComponents *)dateComponentsFromUTCString:(NSString *)utcString;
+ (NSDate *)dateFromDateString:(NSString *)dateString;
+ (NSString *)paramMonthFromDateString:(NSString *)dateString;

+ (NSDate *)dateFrom:(NSDate *)date adjustDay:(NSInteger)day;

+ (NSString *)UTCDateStringFromLocal:(NSString *)locDateString;
+ (NSString *)localDateFromUTC:(NSString *)utcDateString;
+ (NSString *)localDateFromUTC2:(NSString *)utcDateString;

+ (NSString *)formattedDate:(NSString *)dateString;
+ (NSString *)formattedDate2:(NSString *)dateString;
+ (NSString *)formattedDate3:(NSString *)datetime;
+ (NSString *)formattedDate4:(NSString *)datetime;
+ (NSString *)formattedDate5:(NSString *)dateString;
+ (NSString *)formattedMonthDate:(NSString *)dateString;

#pragma mark - String Util
+ (NSNumberFormatter *)numberFormatter;
+ (NSString *)numberString:(NSInteger)number;
+ (NSString *)currencyString:(NSInteger)number;
+ (NSString *)currencyString2:(NSInteger)number;

+ (NSString *)svcNoString:(NSString *)svcNo;
+ (NSString *)telNoString:(NSString *)telNo;
+ (NSString *)cutSaName:(NSString *)saName;
+ (NSInteger)getIntegerFromCurrency:(NSString *)currency;

+ (NSString *)formattedPhoneNumber:(NSString *)phoneNumber;
+ (NSString *)formattedIAId:(NSString *)iaId;

+ (NSInteger)countForOccurrencesOfString:(NSString *)occurString;



#pragma mark - TimeUtil
+ (NSString *)formattedTime:(NSString *)timeString;
+ (NSString *)formattedTime2:(NSString *)timeString;

+ (NSDateComponents *)timeComponentsFromString:(NSString *)timeString;
+ (NSString *)stringFromTime:(NSDate *)date;
+ (BOOL)stringContainsEmoji:(NSString *)string;

#pragma mark - URL Encode
+(NSString *)URLEncoding:(NSString *)sender;
+(NSString *)URLDecoding:(NSString *)sender;

+(UIImage*)resizableImageWithCapInsets:(UIEdgeInsets)make resizingMode:(UIImageResizingMode)resizingMode img:(UIImage *)img;

+(NSString *)switchPostUrl:(NSString *)getUrl;
+(NSString *)getUrl:(NSString *)getUrl;

#pragma mark - timezone
+ (SortDictionary *)timeZoneDict;

#pragma mark - Color
+(UIColor *)convertFromRGBToUIColor:(NSString *)hexRGB;


+(NSString *)getImageNameFormUrlString:(NSString*)urlString;


@end
