Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ability to tag friend #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 00f851ab2cafeab39b5ffb648f84b8cbdc34cb13

COCOAPODS: 1.2.0
COCOAPODS: 1.3.1
50 changes: 49 additions & 1 deletion TSWeChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -848,13 +848,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-TSWeChat-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
A4299EA1E4F2C96BC7D82600 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -863,9 +866,54 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-TSWeChat/Pods-TSWeChat-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
"${BUILT_PRODUCTS_DIR}/BSGridCollectionViewLayout/BSGridCollectionViewLayout.framework",
"${BUILT_PRODUCTS_DIR}/BSImagePicker/BSImagePicker.framework",
"${BUILT_PRODUCTS_DIR}/Cent/Cent.framework",
"${BUILT_PRODUCTS_DIR}/Dollar/Dollar.framework",
"${BUILT_PRODUCTS_DIR}/INTULocationManager/INTULocationManager.framework",
"${BUILT_PRODUCTS_DIR}/KeychainAccess/KeychainAccess.framework",
"${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework",
"${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework",
"${BUILT_PRODUCTS_DIR}/RxBlocking/RxBlocking.framework",
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
"${BUILT_PRODUCTS_DIR}/SVProgressHUD/SVProgressHUD.framework",
"${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
"${BUILT_PRODUCTS_DIR}/TSVoiceConverter/TSVoiceConverter.framework",
"${BUILT_PRODUCTS_DIR}/TimedSilver/TimedSilver.framework",
"${BUILT_PRODUCTS_DIR}/UIColor_Hex_Swift/UIColor_Hex_Swift.framework",
"${BUILT_PRODUCTS_DIR}/UIImageViewModeScaleAspect/UIImageViewModeScaleAspect.framework",
"${BUILT_PRODUCTS_DIR}/XCGLogger/XCGLogger.framework",
"${BUILT_PRODUCTS_DIR}/XLActionController/XLActionController.framework",
"${BUILT_PRODUCTS_DIR}/YYText/YYText.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSGridCollectionViewLayout.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BSImagePicker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cent.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Dollar.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/INTULocationManager.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/KeychainAccess.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Kingfisher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxBlocking.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVProgressHUD.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TSVoiceConverter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TimedSilver.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/UIColor_Hex_Swift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/UIImageViewModeScaleAspect.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/XCGLogger.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/XLActionController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYText.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
27 changes: 27 additions & 0 deletions TSWeChat/Classes/Chat/TSChatViewController+Interaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import MobileCoreServices
// 分享更多里面的 Button 交互
extension TSChatViewController: ChatShareMoreViewDelegate {

//提朋友
func tagFriend() {
let viewController = TSContactsViewController.ts_initFromNib() as! TSContactsViewController
viewController.delegate = self
self.ts_presentViewController(viewController, completion: nil)
}

//选择打开相册
func chatShareMoreViewPhotoTaped() {
self.ts_presentImagePickerController(
Expand Down Expand Up @@ -224,6 +231,9 @@ extension TSChatViewController: ChatEmotionInputViewDelegate {
// MARK: - @protocol UITextViewDelegate
extension TSChatViewController: UITextViewDelegate {
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
if text == "@" {
tagFriend()
}
if text == "\n" {
//点击发送文字,包含表情
self.chatSendText()
Expand Down Expand Up @@ -316,6 +326,23 @@ extension TSChatViewController: TSChatCellDelegate {
}
}

protocol TagContactDelegate {
func didTag(_ contact: String)
}

extension TSChatViewController: TagContactDelegate {
func didTag(_ contact: String) {
self.dismiss(animated: true, completion: nil)
self.chatActionBarView.inputTextView.becomeFirstResponder()
let pinedContact = "@" + contact + " "
if let text = self.chatActionBarView.inputTextView.text {
self.chatActionBarView.inputTextView.text = text + " " + pinedContact
} else {
self.chatActionBarView.inputTextView.text = pinedContact
}
}
}




37 changes: 33 additions & 4 deletions TSWeChat/Classes/Contacts/TSContactsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class TSContactsViewController: UIViewController {
fileprivate var sortedkeys = [String]() //UITableView 右侧索引栏的 value
fileprivate var dataDict: Dictionary<String, NSMutableArray>?

var delegate: TagContactDelegate?

override func viewDidLoad() {
super.viewDidLoad()
self.title = "通讯录"
Expand All @@ -31,7 +33,8 @@ class TSContactsViewController: UIViewController {
self.listTableView.estimatedRowHeight = 54
self.listTableView.sectionIndexColor = UIColor.darkGray
self.listTableView.tableFooterView = self.footerView


self.setUpNavBar()
self.fetchContactList()
}

Expand Down Expand Up @@ -94,6 +97,31 @@ class TSContactsViewController: UIViewController {
self.listTableView.reloadData()
}
}

func handleCancel() {
self.dismiss(animated: true, completion: nil)
}

func setUpNavBar() {
var isModal: Bool {
if presentingViewController != nil {
return true
}
if navigationController?.presentingViewController?.presentedViewController === navigationController {
return true
}
if let presentingVC = tabBarController?.presentingViewController, presentingVC is UITabBarController {
return true
}
return false
}

if isModal {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(handleCancel))
} else {
self.navigationItem.rightBarButtonItem = nil
}
}

deinit {
log.verbose("deinit")
Expand Down Expand Up @@ -124,8 +152,9 @@ extension TSContactsViewController: UITableViewDelegate {
tableView.deselectRow(at: indexPath, animated: true)
let section = indexPath.section
let row = indexPath.row
// let key = self.sortedkeys[indexPath.section]
// let dataArray: NSMutableArray = self.dataDict![key]!
let key = self.sortedkeys[indexPath.section]
let dataArray: NSMutableArray = self.dataDict![key]!
let model = dataArray[indexPath.row] as! ContactModel

if section == 0 {
let type = ContactModelEnum(rawValue: row)!
Expand All @@ -140,7 +169,7 @@ extension TSContactsViewController: UITableViewDelegate {
break
}
} else {

delegate?.didTag(model.chineseName!)
}
}
}
Expand Down