Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ final class CanvasScrollView: UIScrollView {
bouncesZoom = true
showsHorizontalScrollIndicator = false
showsVerticalScrollIndicator = false

imageView.isUserInteractionEnabled = true
}

func updateFrameImage(to image: UIImage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import DesignSystem
import PhotoGetherDomainInterface
import UIKit

final class StickerView: UIImageView {
private let nicknameLabel = UILabel()

private var sticker: StickerEntity


init(sticker: StickerEntity) {
self.sticker = sticker
super.init(frame: sticker.frame)
setupTapGesture()
addViews()
setupConstraints()
configureUI()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func addViews() {
addSubview(nicknameLabel)
}

private func setupConstraints() {
nicknameLabel.snp.makeConstraints {
$0.top.equalTo(snp.bottom)
$0.trailing.equalTo(snp.trailing)
}
}

private func configureUI() {
layer.borderColor = PTGColor.primaryGreen.color.cgColor
setImage(to: sticker.image)

sticker.owner != nil
? (layer.borderWidth = 1)
: (layer.borderWidth = 0)
}

private func setupTapGesture() {
isUserInteractionEnabled = true

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap))
addGestureRecognizer(tapGesture)
}

private func setImage(to urlString: String) {
guard let url = URL(string: urlString) else { return }

Task { [weak self] in
guard let (data, _) = try? await URLSession.shared.data(from: url)
else { return }

self?.image = UIImage(data: data)
}
}