mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-13 14:56:03 +10:00
refactor SayHiView to BottomButtonView
This commit is contained in:
@@ -207,7 +207,7 @@
|
||||
50E114F91ABC137A00F13000 /* YepServiceSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F81ABC137A00F13000 /* YepServiceSync.swift */; };
|
||||
50E114FC1ABC549300F13000 /* ContactsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114FA1ABC549300F13000 /* ContactsCell.swift */; };
|
||||
50E114FD1ABC549300F13000 /* ContactsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50E114FB1ABC549300F13000 /* ContactsCell.xib */; };
|
||||
50E18BB71B180F7D0076C3C6 /* SayHiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E18BB61B180F7D0076C3C6 /* SayHiView.swift */; };
|
||||
50E18BB71B180F7D0076C3C6 /* BottomButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E18BB61B180F7D0076C3C6 /* BottomButtonView.swift */; };
|
||||
50E61CEB1AF1F69D00908A9D /* ConversationTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E61CEA1AF1F69D00908A9D /* ConversationTitleView.swift */; };
|
||||
50EB8C5E1AE78AB9001AC1EE /* YepAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EB8C5D1AE78AB9001AC1EE /* YepAsset.swift */; };
|
||||
50EB8CBF1AE89ED8001AC1EE /* ChatLeftVideoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50EB8CBD1AE89ED8001AC1EE /* ChatLeftVideoCell.swift */; };
|
||||
@@ -444,7 +444,7 @@
|
||||
50E114F81ABC137A00F13000 /* YepServiceSync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepServiceSync.swift; path = Services/YepServiceSync.swift; sourceTree = "<group>"; };
|
||||
50E114FA1ABC549300F13000 /* ContactsCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ContactsCell.swift; path = Views/Cells/Contacts/ContactsCell.swift; sourceTree = "<group>"; };
|
||||
50E114FB1ABC549300F13000 /* ContactsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ContactsCell.xib; path = Views/Cells/Contacts/ContactsCell.xib; sourceTree = "<group>"; };
|
||||
50E18BB61B180F7D0076C3C6 /* SayHiView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SayHiView.swift; path = Views/SayHi/SayHiView.swift; sourceTree = "<group>"; };
|
||||
50E18BB61B180F7D0076C3C6 /* BottomButtonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BottomButtonView.swift; path = Views/SayHi/BottomButtonView.swift; sourceTree = "<group>"; };
|
||||
50E61CEA1AF1F69D00908A9D /* ConversationTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConversationTitleView.swift; path = Views/ConversationTitle/ConversationTitleView.swift; sourceTree = "<group>"; };
|
||||
50EB8C5D1AE78AB9001AC1EE /* YepAsset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepAsset.swift; path = Helpers/YepAsset.swift; sourceTree = "<group>"; };
|
||||
50EB8CBD1AE89ED8001AC1EE /* ChatLeftVideoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftVideoCell.swift; path = Views/Cells/ChatLeftVideo/ChatLeftVideoCell.swift; sourceTree = "<group>"; };
|
||||
@@ -1469,7 +1469,7 @@
|
||||
50E18BB81B180F8E0076C3C6 /* SayHi */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50E18BB61B180F7D0076C3C6 /* SayHiView.swift */,
|
||||
50E18BB61B180F7D0076C3C6 /* BottomButtonView.swift */,
|
||||
);
|
||||
name = SayHi;
|
||||
sourceTree = "<group>";
|
||||
@@ -1929,7 +1929,7 @@
|
||||
505498621B12FB0E0037E3BD /* ConversationMessagePreviewNavigationControllerDelegate.swift in Sources */,
|
||||
0A944C251AC8BB2F00037A06 /* YepStorageService.swift in Sources */,
|
||||
505EC8171ADF8151001D27E0 /* SkillCategoryCell.swift in Sources */,
|
||||
50E18BB71B180F7D0076C3C6 /* SayHiView.swift in Sources */,
|
||||
50E18BB71B180F7D0076C3C6 /* BottomButtonView.swift in Sources */,
|
||||
0A90187E1B01152800AE4B7F /* ProfileSocialAccountCell.swift in Sources */,
|
||||
50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */,
|
||||
5053AD5A1AF83B4200B3CBFA /* ChatLeftLocationCell.swift in Sources */,
|
||||
|
||||
@@ -485,7 +485,7 @@
|
||||
<outlet property="delegate" destination="AyC-pt-NR2" id="j2k-7a-66r"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sfC-fv-gcr" userLabel="Say Hi View" customClass="SayHiView" customModule="Yep" customModuleProvider="target">
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sfC-fv-gcr" userLabel="Say Hi View" customClass="BottomButtonView" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="550" width="600" height="50"/>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
|
||||
@@ -155,7 +155,7 @@ class ProfileViewController: UIViewController {
|
||||
sayHiView.hidden = true
|
||||
|
||||
} else {
|
||||
sayHiView.sayHiAction = {
|
||||
sayHiView.tapAction = {
|
||||
self.sayHi()
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class ProfileViewController: UIViewController {
|
||||
@IBOutlet weak var topShadowImageView: UIImageView!
|
||||
@IBOutlet weak var profileCollectionView: UICollectionView!
|
||||
|
||||
@IBOutlet weak var sayHiView: SayHiView!
|
||||
@IBOutlet weak var sayHiView: BottomButtonView!
|
||||
|
||||
var customNavigationBar: UINavigationBar!
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// SayHiView.swift
|
||||
// Yep
|
||||
//
|
||||
// Created by NIX on 15/5/29.
|
||||
// Copyright (c) 2015年 Catch Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
class BottomButtonView: UIView {
|
||||
|
||||
@IBInspectable var topLineColor: UIColor = UIColor.lightGrayColor()
|
||||
@IBInspectable var topLineWidth: CGFloat = 1 / UIScreen.mainScreen().scale
|
||||
@IBInspectable var title: String = NSLocalizedString("Say Hi", comment: "")
|
||||
|
||||
lazy var actionButton: UIButton = {
|
||||
let button = UIButton()
|
||||
button.titleLabel?.font = UIFont(name: "Helvetica-Regular", size: 14)
|
||||
button.setTitle(self.title, forState: .Normal)
|
||||
button.backgroundColor = UIColor.yepTintColor()
|
||||
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
|
||||
button.layer.cornerRadius = 5
|
||||
button.addTarget(self, action: "tryTap", forControlEvents: UIControlEvents.TouchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
var tapAction: (() -> Void)?
|
||||
|
||||
override func didMoveToSuperview() {
|
||||
super.didMoveToSuperview()
|
||||
|
||||
backgroundColor = UIColor.whiteColor()
|
||||
|
||||
// Add actionButton
|
||||
|
||||
self.addSubview(actionButton)
|
||||
actionButton.setTranslatesAutoresizingMaskIntoConstraints(false)
|
||||
|
||||
let actionButtonCenterXConstraint = NSLayoutConstraint(item: actionButton, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1.0, constant: 0)
|
||||
|
||||
let actionButtonCenterYConstraint = NSLayoutConstraint(item: actionButton, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1.0, constant: 0)
|
||||
|
||||
let actionButtonWidthConstraint = NSLayoutConstraint(item: actionButton, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 185)
|
||||
|
||||
let actionButtonHeightConstraint = NSLayoutConstraint(item: actionButton, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 30)
|
||||
|
||||
NSLayoutConstraint.activateConstraints([
|
||||
actionButtonCenterXConstraint,
|
||||
actionButtonCenterYConstraint,
|
||||
actionButtonWidthConstraint,
|
||||
actionButtonHeightConstraint,
|
||||
])
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
func tryTap() {
|
||||
tapAction?()
|
||||
}
|
||||
|
||||
// MARK: Draw
|
||||
|
||||
override func drawRect(rect: CGRect) {
|
||||
super.drawRect(rect)
|
||||
|
||||
topLineColor.setStroke()
|
||||
|
||||
let context = UIGraphicsGetCurrentContext()
|
||||
|
||||
CGContextSetLineWidth(context, topLineWidth)
|
||||
CGContextMoveToPoint(context, 0, 0)
|
||||
CGContextAddLineToPoint(context, CGRectGetWidth(rect), 0)
|
||||
CGContextStrokePath(context)
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
//
|
||||
// SayHiView.swift
|
||||
// Yep
|
||||
//
|
||||
// Created by NIX on 15/5/29.
|
||||
// Copyright (c) 2015年 Catch Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
class SayHiView: UIView {
|
||||
|
||||
@IBInspectable var topLineColor: UIColor = UIColor.lightGrayColor()
|
||||
@IBInspectable var topLineWidth: CGFloat = 1 / UIScreen.mainScreen().scale
|
||||
|
||||
lazy var sayHiButton: UIButton = {
|
||||
let button = UIButton()
|
||||
button.titleLabel?.font = UIFont(name: "Helvetica-Regular", size: 14)
|
||||
button.setTitle(NSLocalizedString("Say Hi", comment: ""), forState: .Normal)
|
||||
button.backgroundColor = UIColor.yepTintColor()
|
||||
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
|
||||
button.layer.cornerRadius = 5
|
||||
button.addTarget(self, action: "trySayHi", forControlEvents: UIControlEvents.TouchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
var sayHiAction: (() -> Void)?
|
||||
|
||||
override func didMoveToSuperview() {
|
||||
super.didMoveToSuperview()
|
||||
|
||||
backgroundColor = UIColor.whiteColor()
|
||||
|
||||
// Add sayHiButton
|
||||
|
||||
self.addSubview(sayHiButton)
|
||||
sayHiButton.setTranslatesAutoresizingMaskIntoConstraints(false)
|
||||
|
||||
let sayHiButtonCenterXConstraint = NSLayoutConstraint(item: sayHiButton, attribute: .CenterX, relatedBy: .Equal, toItem: self, attribute: .CenterX, multiplier: 1.0, constant: 0)
|
||||
|
||||
let sayHiButtonCenterYConstraint = NSLayoutConstraint(item: sayHiButton, attribute: .CenterY, relatedBy: .Equal, toItem: self, attribute: .CenterY, multiplier: 1.0, constant: 0)
|
||||
|
||||
let sayHiButtonWidthConstraint = NSLayoutConstraint(item: sayHiButton, attribute: .Width, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 185)
|
||||
|
||||
let sayHiButtonHeightConstraint = NSLayoutConstraint(item: sayHiButton, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 30)
|
||||
|
||||
NSLayoutConstraint.activateConstraints([
|
||||
sayHiButtonCenterXConstraint,
|
||||
sayHiButtonCenterYConstraint,
|
||||
sayHiButtonWidthConstraint,
|
||||
sayHiButtonHeightConstraint,
|
||||
])
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
func trySayHi() {
|
||||
sayHiAction?()
|
||||
}
|
||||
|
||||
// MARK: Draw
|
||||
|
||||
override func drawRect(rect: CGRect) {
|
||||
super.drawRect(rect)
|
||||
|
||||
topLineColor.setStroke()
|
||||
|
||||
let context = UIGraphicsGetCurrentContext()
|
||||
|
||||
CGContextSetLineWidth(context, topLineWidth)
|
||||
CGContextMoveToPoint(context, 0, 0)
|
||||
CGContextAddLineToPoint(context, CGRectGetWidth(rect), 0)
|
||||
CGContextStrokePath(context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user