Auto set ContainerViewWithShadow.childView's cornerRadius

pull/1024/head
Hwee-Boon Yar 6 years ago
parent 1064edc95a
commit bb6a74d9c1
  1. 7
      AlphaWallet/Browser/ViewControllers/EditMyDappViewController.swift
  2. 7
      AlphaWallet/Browser/Views/BrowserHistoryCell.swift
  3. 7
      AlphaWallet/Browser/Views/DappViewCell.swift
  4. 7
      AlphaWallet/Browser/Views/DiscoverDappCell.swift
  5. 7
      AlphaWallet/Browser/Views/MyDappCell.swift
  6. 8
      AlphaWallet/Tokens/ViewControllers/TokenViewController.swift
  7. 5
      AlphaWallet/UI/ContainerViewWithShadow.swift

@ -112,7 +112,7 @@ class EditMyDappViewController: UIViewController {
view.backgroundColor = viewModel.backgroundColor
imageHolder.configureShadow(color: viewModel.imageShadowColor, offset: viewModel.imageShadowOffset, opacity: viewModel.imageShadowOpacity, radius: viewModel.imageShadowRadius)
imageHolder.configureShadow(color: viewModel.imageShadowColor, offset: viewModel.imageShadowOffset, opacity: viewModel.imageShadowOpacity, radius: viewModel.imageShadowRadius, cornerRadius: imageHolder.frame.size.width / 2)
let iconImageView = imageHolder.childView
iconImageView.backgroundColor = viewModel.imageBackgroundColor
@ -161,11 +161,8 @@ class EditMyDappViewController: UIViewController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
imageHolder.childView.layer.cornerRadius = imageHolder.childView.frame.size.width / 2
imageHolder.layer.cornerRadius = imageHolder.frame.size.width / 2
if let viewModel = viewModel {
imageHolder.configureShadow(color: viewModel.imageShadowColor, offset: viewModel.imageShadowOffset, opacity: viewModel.imageShadowOpacity, radius: viewModel.imageShadowRadius)
imageHolder.configureShadow(color: viewModel.imageShadowColor, offset: viewModel.imageShadowOffset, opacity: viewModel.imageShadowOpacity, radius: viewModel.imageShadowRadius, cornerRadius: imageHolder.frame.size.width / 2)
}
}

@ -45,7 +45,7 @@ class BrowserHistoryCell: UITableViewCell {
backgroundColor = viewModel.backgroundColor
contentView.backgroundColor = viewModel.backgroundColor
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: iconImageViewHolder.frame.size.width / 2)
let iconImageView = iconImageViewHolder.childView
iconImageView.backgroundColor = viewModel.backgroundColor
@ -63,10 +63,7 @@ class BrowserHistoryCell: UITableViewCell {
//TODO ugly hack to get the image view's frame. Can't figure out a good point to retrieve the correct frame otherwise
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self.iconImageViewHolder.childView.layer.cornerRadius = self.iconImageViewHolder.childView.frame.size.width / 2
self.iconImageViewHolder.layer.cornerRadius = self.iconImageViewHolder.frame.size.width / 2
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: self.iconImageViewHolder.frame.size.width / 2)
}
}
}

@ -97,11 +97,8 @@ class DappViewCell: UICollectionViewCell {
override func layoutSubviews() {
super.layoutSubviews()
imageHolder.childView.layer.cornerRadius = imageHolder.childView.frame.size.width / 2
imageHolder.layer.cornerRadius = imageHolder.frame.size.width / 2
if let viewModel = viewModel {
imageHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
imageHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: imageHolder.frame.size.width / 2)
}
}
@ -113,7 +110,7 @@ class DappViewCell: UICollectionViewCell {
background.backgroundColor = viewModel.backgroundColor
background.clipsToBounds = true
imageHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
imageHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: imageHolder.frame.size.width / 2)
let imageView = imageHolder.childView
imageView.backgroundColor = viewModel.backgroundColor

@ -74,7 +74,7 @@ class DiscoverDappCell: UITableViewCell {
removeButton.borderWidth = viewModel.addRemoveButtonBorderWidth
removeButton.cornerRadius = viewModel.addRemoveButtonBorderCornerRadius
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: iconImageViewHolder.frame.size.width / 2)
let iconImageView = iconImageViewHolder.childView
iconImageView.backgroundColor = viewModel.backgroundColor
@ -92,10 +92,7 @@ class DiscoverDappCell: UITableViewCell {
//TODO ugly hack to get the image view's frame. Can't figure out a good point to retrieve the correct frame otherwise
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self.iconImageViewHolder.childView.layer.cornerRadius = self.iconImageViewHolder.childView.frame.size.width / 2
self.iconImageViewHolder.layer.cornerRadius = self.iconImageViewHolder.frame.size.width / 2
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: self.iconImageViewHolder.frame.size.width / 2)
}
}

@ -50,7 +50,7 @@ class MyDappCell: UITableViewCell {
urlLabel.textColor = viewModel.domainNameColor
urlLabel.text = viewModel.domainName
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: iconImageViewHolder.frame.size.width / 2)
let iconImageView = iconImageViewHolder.childView
iconImageView.backgroundColor = viewModel.backgroundColor
@ -60,10 +60,7 @@ class MyDappCell: UITableViewCell {
//TODO ugly hack to get the image view's frame. Can't figure out a good point to retrieve the correct frame otherwise
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
self.iconImageViewHolder.childView.layer.cornerRadius = self.iconImageViewHolder.childView.frame.size.width / 2
self.iconImageViewHolder.layer.cornerRadius = self.iconImageViewHolder.frame.size.width / 2
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius)
self.iconImageViewHolder.configureShadow(color: viewModel.imageViewShadowColor, offset: viewModel.imageViewShadowOffset, opacity: viewModel.imageViewShadowOpacity, radius: viewModel.imageViewShadowRadius, cornerRadius: self.iconImageViewHolder.frame.size.width / 2)
}
}
}

@ -88,25 +88,21 @@ class TokenViewController: UIViewController {
header.frame.size.height = 220
tableView.tableHeaderView = header
sendButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius)
sendButtonContainer.layer.cornerRadius = viewModel.sendReceiveButtonCornerRadius
sendButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.sendReceiveButtonCornerRadius)
receiveButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius)
receiveButtonContainer.layer.cornerRadius = viewModel.sendReceiveButtonCornerRadius
receiveButtonContainer.configureShadow(color: viewModel.actionButtonShadowColor, offset: viewModel.actionButtonShadowOffset, opacity: viewModel.actionButtonShadowOpacity, radius: viewModel.actionButtonShadowRadius, cornerRadius: viewModel.sendReceiveButtonCornerRadius)
let sendButton = sendButtonContainer.childView
sendButton.setTitle(viewModel.sendButtonTitle, for: .normal)
sendButton.addTarget(self, action: #selector(send), for: .touchUpInside)
sendButton.setBackgroundColor(viewModel.sendReceiveButtonBackgroundColor, forState: .normal)
sendButton.setTitleColor(viewModel.sendReceiveButtonTitleColor, for: .normal)
sendButton.cornerRadius = viewModel.sendReceiveButtonCornerRadius
let receiveButton = receiveButtonContainer.childView
receiveButton.setTitle(viewModel.receiveButtonTitle, for: .normal)
receiveButton.addTarget(self, action: #selector(receive), for: .touchUpInside)
receiveButton.setBackgroundColor(viewModel.sendReceiveButtonBackgroundColor, forState: .normal)
receiveButton.setTitleColor(viewModel.sendReceiveButtonTitleColor, for: .normal)
receiveButton.cornerRadius = viewModel.sendReceiveButtonCornerRadius
tableView.reloadData()
}

@ -35,7 +35,10 @@ class ContainerViewWithShadow<T: UIView>: UIView {
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius).cgPath
}
func configureShadow(color: UIColor, offset: CGSize, opacity: Float, radius: CGFloat) {
func configureShadow(color: UIColor, offset: CGSize, opacity: Float, radius: CGFloat, cornerRadius: CGFloat) {
layer.cornerRadius = cornerRadius
childView.cornerRadius = cornerRadius
layer.shadowColor = color.cgColor
layer.shadowOffset = offset
layer.shadowOpacity = opacity

Loading…
Cancel
Save