//
//  Extensions.swift
//  react-native-simple-grid
//
//  Created by Vittorio Cellucci on 2022-09-19.
//

import Foundation

extension UIView {
  func addBottomShadow() {
    layer.shadowRadius = 2
    layer.shadowOpacity = 0.25
    layer.shadowColor = UIColor.black.cgColor
    layer.shadowOffset = CGSize(width: 0, height: 1)
    layer.shadowPath = UIBezierPath(rect: CGRect(x: 0,
                                                 y: bounds.maxY - layer.shadowRadius,
                                                 width: bounds.width,
                                                 height: layer.shadowRadius)).cgPath
    self.clipsToBounds = false

  }
}

extension UIImage {
  func withColor(_ color: UIColor) -> UIImage? {
    let renderer = UIGraphicsImageRenderer(size: size)
    return renderer.image { context in
      color.setFill()
      self.draw(at: .zero)
      context.fill(CGRect(x: 0, y: 0, width: size.width, height: size.height), blendMode: .sourceAtop)
    }
  }
}

extension Notification.Name {
  static let onTappedSelection = Notification.Name("onTappedSelection")
  static let onTappedSelectionBand = Notification.Name("onTappedSelectionBand")
  static let onClearSelectionBand = Notification.Name("onClearSelectionBand")
  static let onSelectionDragged = Notification.Name("onSelectionDragged")
  static let onDragSelectDone = Notification.Name("onDragSelectDone")
}
