From f77b7df77b7a17e3fbae00657cfdc4ea13069285 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 1 Dec 2015 14:17:35 +0800 Subject: [PATCH] subscribeAction --- .../ConversationViewController.swift | 9 ++++++++ Yep/Views/Subscribe/SubscribeView.swift | 22 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index a630740a..af360189 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -813,6 +813,15 @@ class ConversationViewController: BaseViewController { } delay(1) { [weak self] in + + self?.subscribeView.subscribeAction = { [weak self] in + if let groupID = self?.conversation.withGroup?.groupID { + joinGroup(groupID: groupID, failureHandler: nil, completion: { + println("subscribe OK") + }) + } + } + self?.subscribeView.show() } } diff --git a/Yep/Views/Subscribe/SubscribeView.swift b/Yep/Views/Subscribe/SubscribeView.swift index 8dbffa22..3f83188d 100644 --- a/Yep/Views/Subscribe/SubscribeView.swift +++ b/Yep/Views/Subscribe/SubscribeView.swift @@ -34,15 +34,23 @@ class SubscribeView: UIView { button.setTitle(NSLocalizedString("Subscribe", comment: ""), forState: .Normal) button.setTitleColor(UIColor.yepTintColor(), forState: .Normal) button.contentEdgeInsets = UIEdgeInsets(top: 8, left: 15, bottom: 8, right: 15) + + button.addTarget(self, action: "subscribe:", forControlEvents: .TouchUpInside) + return button }() lazy var dismissButton: UIButton = { let button = UIButton() button.setImage(UIImage(named: "icon_subscribe_close"), forState: .Normal) + + button.addTarget(self, action: "dismiss:", forControlEvents: .TouchUpInside) + return button }() + var subscribeAction: (() -> Void)? + override func didMoveToSuperview() { makeUI() @@ -110,9 +118,21 @@ class SubscribeView: UIView { func hide() { UIView.animateWithDuration(0.25, delay: 0.0, options: .CurveEaseInOut, animations: { [weak self] in - self?.bottomConstraint?.constant = -SubscribeView.height + self?.bottomConstraint?.constant = SubscribeView.height self?.superview?.layoutIfNeeded() }, completion: { _ in }) } + + func subscribe(sender: BorderButton) { + + subscribeAction?() + + hide() + } + + func dismiss(sender: UIButton) { + + hide() + } }