#import "OneNativeLazyHStackComponentView.h"
#import <React/RCTView.h>
#import "One-Swift.h"
#import <react/renderer/components/OneNativeSpec/ComponentDescriptors.h>
#import <React/RCTConversions.h>

using namespace facebook::react;

@implementation OneNativeLazyHStackComponentView {
  OneNativeLazyHStackView *_stackView;
}

+ (ComponentDescriptorProvider)componentDescriptorProvider {
  return concreteComponentDescriptorProvider<OneNativeLazyHStackComponentDescriptor>();
}

- (instancetype)initWithFrame:(CGRect)frame {
  if (self = [super initWithFrame:frame]) {
    _props = std::make_shared<const OneNativeLazyHStackProps>();
    _stackView = [OneNativeLazyHStackView new];
    self.container = _stackView;
    self.contentView = _stackView;
  }
  return self;
}

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
  const auto &next = *std::static_pointer_cast<const OneNativeLazyHStackProps>(props);
  [_stackView configureWithAlignment:RCTNSStringFromString(next.alignment)
                                          spacing:next.spacing];
  [super updateProps:props oldProps:oldProps];
}

@end
