#import <React/RCTViewManager.h>
#import <MapKit/MapKit.h>
#import <math.h>
#import "YamapCircle.h"
#import "RNYamap.h"

#import "View/YamapCircleView.h"
#import "View/RNYMView.h"

#import "Converter/RCTConvert+Yamap.m"

#ifndef MAX
#import <NSObjCRuntime.h>
#endif

@implementation YamapCircle

RCT_EXPORT_MODULE()

- (NSArray<NSString*>*)supportedEvents {
    return @[@"onPress"];
}

- (instancetype)init {
    self = [super init];

    return self;
}

+ (BOOL)requiresMainQueueSetup {
    return YES;
}

- (UIView* _Nullable)view {
    return [[YamapCircleView alloc] init];
}

// PROPS
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)

RCT_CUSTOM_VIEW_PROPERTY (center, YMKPoint, YamapCircleView) {
   if (json != nil) {
       YMKPoint* point = [RCTConvert YMKPoint:json];
       [view setCircleCenter: point];
   }
}

RCT_CUSTOM_VIEW_PROPERTY (radius, NSNumber, YamapCircleView) {
   [view setRadius: [json floatValue]];
}

RCT_CUSTOM_VIEW_PROPERTY(fillColor, NSNumber, YamapCircleView) {
    [view setFillColor: [RCTConvert UIColor:json]];
}

RCT_CUSTOM_VIEW_PROPERTY(strokeColor, NSNumber, YamapCircleView) {
    [view setStrokeColor: [RCTConvert UIColor:json]];
}

RCT_CUSTOM_VIEW_PROPERTY(strokeWidth, NSNumber, YamapCircleView) {
    [view setStrokeWidth: json];
}

RCT_CUSTOM_VIEW_PROPERTY(zIndex, NSNumber, YamapCircleView) {
    [view setZIndex: json];
}

@end
