//
//  UIImage+DDCategory.h
//  DDCategoryKit_Private
//  Created by DDIsFriend on 2022/7/29.

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

typedef NSString *DDWaterMarkInfoName NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString *DDWaterMarkLayoutName NS_TYPED_EXTENSIBLE_ENUM;

FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkInfoText;
FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkInfoAttributes;

FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkLayoutTop;
FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkLayoutLeft;
FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkLayoutBottom;
FOUNDATION_EXPORT DDWaterMarkInfoName const DDWaterMarkLayoutRight;

@interface UIImage (DDCategory)
/**
 * return a thumbnailImage  that cutted from the remote video.
 */
+ (UIImage *)dd_thumbnailImageForVideo:(NSURL *)videoURL;

/// @brief return a compressed image
/// @param maxLength bytes = 1024 *  (kb)
- (UIImage *)dd_compressWithQulitySize:(NSInteger)maxLength;

- (NSData *)dd_compressedToDataWithQulitySize:(NSInteger)maxLength;

/// @brief return a marked image
/// @param infoArr this array contain a list of dictionary,the dictionary is consists of  DDWaterMarkInfoName
- (UIImage *)dd_addWaterMarkWithInfoArray:(NSArray<NSDictionary<DDWaterMarkInfoName,id> *> *)infoArr;
@end

@interface UIImage (LoadWithTrait)
/// @briefthis function will return different image as the system interface mode changes.
/// @param lightImage return this image when appearance(UIUserInterfaceStyle) or system interface is Light.
/// @param darkImage return this image when appearance(UIUserInterfaceStyle) or system interface is Dark.
/// @warning Note the 'Appearance' property in info.plist.
+ (nullable UIImage *)dd_imageWithUserInerfaceStyleLightImage:(UIImage *)lightImage darkImage:(UIImage *)darkImage API_AVAILABLE(tvos(10.0)) API_AVAILABLE(ios(12.0)) API_UNAVAILABLE(watchos);
@end

@interface UIImage (LoadWithBundle)
/// @brief convenient function based on 'dd_imageNamed:(nonnull NSString *)name bundlePath:(nonnull NSString *)bundlePath'.
///
/// @param name resource name like this 'fileName/imageName'.
/// @param bundleName the name of the bundle where the resource located.
/// @param aClass The purpose of specifying the current type is to get the bundle location of the current library, it's related to the method '[NSBundle bundleForClass:aClass].resourcePath'.
+ (nullable UIImage *)dd_imageNamed:(nonnull NSString *)name bundleName:(nonnull NSString *)bundleName aClass:(nonnull Class)aClass;

/// @brief convenient function based on 'dd_imageForResource:(nullable NSString *)resource ofType:(nullable NSString *)type bundlePath:(nonnull NSString *)bundlePath'.
///
/// @param resource resource name like this 'fileName/imageName'.
/// @param type resource type.
/// @param bundleName the name of the bundle where the resource located.
/// @param aClass The purpose of specifying the current type is to get the bundle location of the current library, it's related to the method '[NSBundle bundleForClass:aClass].resourcePath'.
+ (nullable UIImage *)dd_imageForResource:(nullable NSString *)resource ofType:(nullable NSString *)type bundleName:(nonnull NSString *)bundleName aClass:(nonnull Class)aClass;

/// @brief return a image from a bundle.
/// @param name the image name.
/// @param bundlePath the bundle path like this 'Frameworks/DDCategoryKit_Private.framework/resources.bundle'.
/// @warning where the bundle is is important.
+ (nullable UIImage *)dd_imageNamed:(nonnull NSString *)name bundlePath:(nonnull NSString *)bundlePath;

/// @brief return a image from a bundle.
/// @param resource the format of resource is like this 'fileName/imageName'.
/// @param type image type.
/// @param bundlePath the bundle path like this 'Frameworks/DDCategoryKit_Private.framework/resources.bundle'.
+ (nullable UIImage *)dd_imageForResource:(nullable NSString *)resource ofType:(nullable NSString *)type bundlePath:(nonnull NSString *)bundlePath;

+ (nullable NSData *)dd_imageGifNamed:(nonnull NSString *)name bundleName:(nonnull NSString *)bundleName aClass:(nonnull Class)aClass;

+ (nullable NSData *)dd_imageForGifResource:(nullable NSString *)resource ofType:(nullable NSString *)type bundleName:(nonnull NSString *)bundleName aClass:(nonnull Class)aClass;

/// @brief return QRCode.
+ (instancetype)dd_generateQrcodeImageWithStr:(NSString *)QcodeStr size:(float)size;

@end

@interface UIImage (NullSafe)
- (instancetype)dd_nullSafe;
@end

NS_ASSUME_NONNULL_END
