Skip to content

Commit

Permalink
Merge pull request #5 from ArcBlock/change-motif-alpha
Browse files Browse the repository at this point in the history
fix: motif rerender animted fix
  • Loading branch information
karthuszY authored Dec 9, 2022
2 parents dc6b7c9 + 043edd2 commit 8fd7ae5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ class ViewController: UIViewController {
}

private func renderWithSpecificShape() {
motifView1.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .square)
motifView1.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .square, animated: false)
didLabel1.text = "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3"

motifView2.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .circle)
motifView2.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .circle, animated: false)
didLabel2.text = "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3"

motifView3.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .rectangle)
motifView3.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .rectangle, animated: false)
didLabel3.text = "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3"

motifView4.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .hexagon)
motifView4.renderWith(address: "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3", shape: .hexagon, animated: false)
didLabel4.text = "zNKb2kbCvDHo9APDhD1trbAV1EVoYF6PcSJ3"
}

Expand Down
32 changes: 23 additions & 9 deletions Sources/did-motif-ios/DIDMotifView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ public class DIDMotifView: UIView {
// MARK: - UI Functions
extension DIDMotifView {
private func commonInit() {
layer.addSublayer(shapeLayer)
for _ in 0...7 {
let subLayer = CAShapeLayer()
subLayer.isHidden = true
subLayer.fillColor = UIColor(white: 1, alpha: 0.5).cgColor
shapeLayer.addSublayer(subLayer)
hexagonLayers.append(subLayer)
}
addSubLayers()
}

private func setupUI() {
Expand Down Expand Up @@ -132,6 +125,25 @@ extension DIDMotifView {
anim.initialVelocity = 4
return anim
}

private func addSubLayers() {
layer.addSublayer(shapeLayer)
for _ in 0...7 {
let subLayer = CAShapeLayer()
subLayer.isHidden = true
subLayer.fillColor = UIColor(white: 1, alpha: 0.5).cgColor
shapeLayer.addSublayer(subLayer)
hexagonLayers.append(subLayer)
}
}

private func clearSubLayers() {
shapeLayer.removeFromSuperlayer()
hexagonLayers.forEach { subLayer in
subLayer.removeFromSuperlayer()
}
hexagonLayers.removeAll()
}
}
// MARK: - Action Functions
extension DIDMotifView {
Expand All @@ -153,7 +165,9 @@ extension DIDMotifView {
self.address = address
self.shape = shape
self.animated = animated


clearSubLayers()
addSubLayers()
decodeAddress()
}
}

0 comments on commit 8fd7ae5

Please sign in to comment.