Skip to content

Commit

Permalink
refactor some, update for Background color doesn't work #162.
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki_keishi committed Jan 5, 2017
1 parent f9ee3d6 commit 73be2a5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 40 deletions.
23 changes: 7 additions & 16 deletions SKPhotoBrowser/SKButtons.swift
Expand Up @@ -15,20 +15,19 @@ class SKButton: UIButton {
var showFrame: CGRect!
var hideFrame: CGRect!
var insets: UIEdgeInsets {


return UI_USER_INTERFACE_IDIOM() == .phone
? UIEdgeInsets(top: 15.25, left: 15.25, bottom: 15.25, right: 15.25) : UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
if UI_USER_INTERFACE_IDIOM() == .phone {
return UIEdgeInsets(top: 15.25, left: 15.25, bottom: 15.25, right: 15.25)
} else {
return UIEdgeInsets(top: 12, left: 12, bottom: 12, right: 12)
}
}
var size: CGSize = CGSize(width: 44, height: 44)
var margin: CGFloat = 5

var buttonTopOffset: CGFloat { return 5 }

func setup(_ imageName: String) {
backgroundColor = UIColor.clear
backgroundColor = .clear
imageEdgeInsets = insets
// clipsToBounds = true
translatesAutoresizingMaskIntoConstraints = true
autoresizingMask = [.flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin]

Expand All @@ -37,11 +36,9 @@ class SKButton: UIButton {
setImage(image, for: UIControlState())
}

func updateFrame() { }

func setFrameSize(_ size: CGSize) {
let newRect = CGRect(x: margin, y: buttonTopOffset, width: size.width, height: size.height)
self.frame = newRect
frame = newRect
showFrame = newRect
hideFrame = CGRect(x: margin, y: -20, width: size.width, height: size.height)
}
Expand All @@ -59,9 +56,6 @@ class SKCloseButton: SKButton {
showFrame = CGRect(x: margin, y: buttonTopOffset, width: size.width, height: size.height)
hideFrame = CGRect(x: margin, y: -20, width: size.width, height: size.height)
}

override func updateFrame() {
}
}

class SKDeleteButton: SKButton {
Expand All @@ -76,9 +70,6 @@ class SKDeleteButton: SKButton {
showFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: buttonTopOffset, width: size.width, height: size.height)
hideFrame = CGRect(x: SKMesurement.screenWidth - size.width, y: -20, width: size.width, height: size.height)
}

override func updateFrame() {
}

override func setFrameSize(_ size: CGSize) {
let newRect = CGRect(x: SKMesurement.screenWidth - size.width, y: buttonTopOffset, width: size.width, height: size.height)
Expand Down
6 changes: 3 additions & 3 deletions SKPhotoBrowser/SKCaptionView.swift
Expand Up @@ -80,14 +80,14 @@ private extension SKCaptionView {
photoLabel = UILabel(frame: CGRect(x: photoLabelPadding, y: 0, width: bounds.size.width - (photoLabelPadding * 2), height: bounds.size.height))
photoLabel.autoresizingMask = [.flexibleWidth, .flexibleHeight]
photoLabel.isOpaque = false
photoLabel.backgroundColor = UIColor.clear
photoLabel.textColor = UIColor.white
photoLabel.backgroundColor = .clear
photoLabel.textColor = SKCaptionOptions.textColor
photoLabel.textAlignment = SKCaptionOptions.textAlignment
photoLabel.lineBreakMode = SKCaptionOptions.lineBreakMode
photoLabel.numberOfLines = SKCaptionOptions.numberOfLine
photoLabel.font = SKCaptionOptions.font
photoLabel.shadowColor = UIColor(white: 0.0, alpha: 0.5)
photoLabel.shadowOffset = CGSize(width: 0.0, height: 1.0)
photoLabel.font = SKPhotoBrowserOptions.captionFont
photoLabel.text = photo?.caption
addSubview(photoLabel)
}
Expand Down
6 changes: 3 additions & 3 deletions SKPhotoBrowser/SKPhotoBrowser.swift
Expand Up @@ -495,7 +495,7 @@ internal extension SKPhotoBrowser {
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDuration(animationDuration)
UIView.setAnimationCurve(UIViewAnimationCurve.easeIn)
view.backgroundColor = UIColor.black
view.backgroundColor = .black
zoomingScrollView.center = CGPoint(x: finalX, y: finalY)
UIView.commitAnimations()
}
Expand Down Expand Up @@ -552,12 +552,12 @@ internal extension SKPhotoBrowser {
// MARK: - Private Function
private extension SKPhotoBrowser {
func configureAppearance() {
view.backgroundColor = UIColor.black
view.backgroundColor = .black
view.clipsToBounds = true
view.isOpaque = false

backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: SKMesurement.screenWidth, height: SKMesurement.screenHeight))
backgroundView.backgroundColor = UIColor.black
backgroundView.backgroundColor = .black
backgroundView.alpha = 0.0
applicationWindow.addSubview(backgroundView)

Expand Down
16 changes: 7 additions & 9 deletions SKPhotoBrowser/SKPhotoBrowserOptions.swift
Expand Up @@ -31,19 +31,17 @@ public struct SKPhotoBrowserOptions {
public static var enableSingleTapDismiss: Bool = false

public static var backgroundColor: UIColor = .black
public static var textAndIconColor: UIColor = .white
public static var toolbarTextShadowColor: UIColor = .darkText

public static var toolbarFont = UIFont(name: "Helvetica", size: 16.0)
public static var captionFont = UIFont.systemFont(ofSize: 17.0)

// FIXED: Scrolling performance slowed #145
// public static var imagePaddingX: CGFloat = 0
// public static var imagePaddingY: CGFloat = 0
}

public struct SKCaptionOptions {
public static var textColor: UIColor = .white
public static var textAlignment: NSTextAlignment = .center
public static var numberOfLine: Int = 3
public static var lineBreakMode: NSLineBreakMode = .byTruncatingTail
public static var font: UIFont = .systemFont(ofSize: 17.0)
}

public struct SKToolbarOptions {
public static var textColor: UIColor = .white
public static var font: UIFont = .systemFont(ofSize: 17.0)
}
12 changes: 6 additions & 6 deletions SKPhotoBrowser/SKToolbar.swift
Expand Up @@ -56,7 +56,7 @@ class SKToolbar: UIToolbar {

private extension SKToolbar {
func setupApperance() {
backgroundColor = UIColor.clear
backgroundColor = .clear
clipsToBounds = true
isTranslucent = true
setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
Expand Down Expand Up @@ -108,11 +108,11 @@ private extension SKToolbar {
func setupCounterLabel() {
toolCounterLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 95, height: 40))
toolCounterLabel.textAlignment = .center
toolCounterLabel.backgroundColor = UIColor.clear
toolCounterLabel.font = UIFont(name: "Helvetica", size: 16.0)
toolCounterLabel.textColor = UIColor.white
toolCounterLabel.shadowColor = UIColor.black
toolCounterLabel.backgroundColor = .clear
toolCounterLabel.shadowColor = .black
toolCounterLabel.shadowOffset = CGSize(width: 0.0, height: 1.0)
toolCounterLabel.font = SKToolbarOptions.font
toolCounterLabel.textColor = SKToolbarOptions.textColor
toolCounterButton = UIBarButtonItem(customView: toolCounterLabel)
}

Expand All @@ -127,7 +127,7 @@ class SKToolbarButton: UIButton {
let insets: UIEdgeInsets = UIEdgeInsets(top: 13.25, left: 17.25, bottom: 13.25, right: 17.25)

func setup(_ imageName: String) {
backgroundColor = UIColor.clear
backgroundColor = .clear
imageEdgeInsets = insets
translatesAutoresizingMaskIntoConstraints = true
autoresizingMask = [.flexibleBottomMargin, .flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin]
Expand Down
6 changes: 3 additions & 3 deletions SKPhotoBrowser/SKZoomingScrollView.swift
Expand Up @@ -48,23 +48,23 @@ open class SKZoomingScrollView: UIScrollView {
// tap
tapView = SKDetectingView(frame: bounds)
tapView.delegate = self
tapView.backgroundColor = UIColor.clear
tapView.backgroundColor = .clear
tapView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
addSubview(tapView)

// image
photoImageView = SKDetectingImageView(frame: frame)
photoImageView.delegate = self
photoImageView.contentMode = .bottom
photoImageView.backgroundColor = UIColor.clear
photoImageView.backgroundColor = .clear
addSubview(photoImageView)

// indicator
indicatorView = SKIndicatorView(frame: frame)
addSubview(indicatorView)

// self
backgroundColor = UIColor.clear
backgroundColor = .clear
delegate = self
showsHorizontalScrollIndicator = SKPhotoBrowserOptions.displayHorizontalScrollIndicator
showsVerticalScrollIndicator = SKPhotoBrowserOptions.displayVerticalScrollIndicator
Expand Down

0 comments on commit 73be2a5

Please sign in to comment.