mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-23 03:36:34 +10:00
Merge branch 'develop' of https://github.com/CatchChat/Yep into develop
This commit is contained in:
@@ -242,6 +242,8 @@
|
||||
50D4D0DB1AFA825B005AEB6F /* MediaControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */; };
|
||||
50DEE02C1BE209FF00015741 /* DeletedFeedConversationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DEE02A1BE209FF00015741 /* DeletedFeedConversationCell.swift */; };
|
||||
50DEE02D1BE209FF00015741 /* DeletedFeedConversationCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50DEE02B1BE209FF00015741 /* DeletedFeedConversationCell.xib */; };
|
||||
50DEE0311BE339B000015741 /* LoadMoreTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DEE02F1BE339B000015741 /* LoadMoreTableViewCell.swift */; };
|
||||
50DEE0321BE339B000015741 /* LoadMoreTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50DEE0301BE339B000015741 /* LoadMoreTableViewCell.xib */; };
|
||||
50E114F41ABBF9CC00F13000 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F31ABBF9CC00F13000 /* Models.swift */; };
|
||||
50E114F91ABC137A00F13000 /* YepServiceSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114F81ABC137A00F13000 /* YepServiceSync.swift */; };
|
||||
50E114FC1ABC549300F13000 /* ContactsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E114FA1ABC549300F13000 /* ContactsCell.swift */; };
|
||||
@@ -555,6 +557,8 @@
|
||||
50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaControlView.swift; path = Views/Media/MediaControlView.swift; sourceTree = "<group>"; };
|
||||
50DEE02A1BE209FF00015741 /* DeletedFeedConversationCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DeletedFeedConversationCell.swift; path = Views/Cells/DeletedFeedConversation/DeletedFeedConversationCell.swift; sourceTree = "<group>"; };
|
||||
50DEE02B1BE209FF00015741 /* DeletedFeedConversationCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = DeletedFeedConversationCell.xib; path = Views/Cells/DeletedFeedConversation/DeletedFeedConversationCell.xib; sourceTree = "<group>"; };
|
||||
50DEE02F1BE339B000015741 /* LoadMoreTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoadMoreTableViewCell.swift; path = Views/Cells/LoadMore/LoadMoreTableViewCell.swift; sourceTree = "<group>"; };
|
||||
50DEE0301BE339B000015741 /* LoadMoreTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LoadMoreTableViewCell.xib; path = Views/Cells/LoadMore/LoadMoreTableViewCell.xib; sourceTree = "<group>"; };
|
||||
50E114F31ABBF9CC00F13000 /* Models.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Models.swift; path = Realm/Models.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
@@ -1078,6 +1082,7 @@
|
||||
502B60611BD112EA00D9C17E /* QuickPickPhotos */,
|
||||
502B60661BD1209300D9C17E /* Camera */,
|
||||
50E1CE901BE0BFF70025B933 /* MediaView */,
|
||||
50DEE0331BE339B600015741 /* LoadMore */,
|
||||
);
|
||||
name = Cells;
|
||||
sourceTree = "<group>";
|
||||
@@ -1848,6 +1853,15 @@
|
||||
name = DeletedFeedConversation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
50DEE0331BE339B600015741 /* LoadMore */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50DEE02F1BE339B000015741 /* LoadMoreTableViewCell.swift */,
|
||||
50DEE0301BE339B000015741 /* LoadMoreTableViewCell.xib */,
|
||||
);
|
||||
name = LoadMore;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
50E114F51ABBF9D100F13000 /* Realm */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -2255,6 +2269,7 @@
|
||||
5053AD5B1AF83B4200B3CBFA /* ChatLeftLocationCell.xib in Resources */,
|
||||
0A8F54B81AB67D11004AD60E /* Images.xcassets in Resources */,
|
||||
50EB8CC51AE89F12001AC1EE /* ChatRightVideoCell.xib in Resources */,
|
||||
50DEE0321BE339B000015741 /* LoadMoreTableViewCell.xib in Resources */,
|
||||
502AE5191AB70D72005BD199 /* Intro.storyboard in Resources */,
|
||||
502B60601BD112E500D9C17E /* QuickPickPhotosCell.xib in Resources */,
|
||||
504BDC151B4528A500DBD35D /* Badges.xcassets in Resources */,
|
||||
@@ -2481,6 +2496,7 @@
|
||||
848806B61B7B4F53000C5424 /* ShowViewController.swift in Sources */,
|
||||
5099B9C71AB99F7B002F940B /* RegisterPickAvatarViewController.swift in Sources */,
|
||||
50E1CE8E1BE0BFF00025B933 /* MediaViewCell.swift in Sources */,
|
||||
50DEE0311BE339B000015741 /* LoadMoreTableViewCell.swift in Sources */,
|
||||
504F41251ACE2D1D00FBB19A /* SampleView.swift in Sources */,
|
||||
50A640EC1B6F4E420050E4A3 /* DoNotDisturbPeriodViewController.swift in Sources */,
|
||||
502AE5291AB81076005BD199 /* YepService.swift in Sources */,
|
||||
|
||||
@@ -71,6 +71,7 @@ class FeedsViewController: UIViewController {
|
||||
|
||||
let feedSkillUsersCellID = "FeedSkillUsersCell"
|
||||
let feedCellID = "FeedCell"
|
||||
let loadMoreTableViewCellID = "LoadMoreTableViewCell"
|
||||
|
||||
lazy var noFeedsFooterView: InfoView = InfoView(NSLocalizedString("No Feeds.", comment: ""))
|
||||
|
||||
@@ -127,19 +128,15 @@ class FeedsViewController: UIViewController {
|
||||
|
||||
var feedSortStyle: FeedSortStyle = .Default {
|
||||
didSet {
|
||||
|
||||
feeds = [DiscoveredFeed]()
|
||||
|
||||
feeds = []
|
||||
feedsTableView.reloadData()
|
||||
|
||||
activityIndicator.startAnimating()
|
||||
|
||||
|
||||
filterBarItem?.title = feedSortStyle.nameWithArrow
|
||||
|
||||
updateFeeds()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var navigationControllerDelegate: ConversationMessagePreviewNavigationControllerDelegate?
|
||||
var originalNavigationControllerDelegate: UINavigationControllerDelegate?
|
||||
|
||||
@@ -177,6 +174,7 @@ class FeedsViewController: UIViewController {
|
||||
|
||||
feedsTableView.registerNib(UINib(nibName: feedSkillUsersCellID, bundle: nil), forCellReuseIdentifier: feedSkillUsersCellID)
|
||||
feedsTableView.registerNib(UINib(nibName: feedCellID, bundle: nil), forCellReuseIdentifier: feedCellID)
|
||||
feedsTableView.registerNib(UINib(nibName: loadMoreTableViewCellID, bundle: nil), forCellReuseIdentifier: loadMoreTableViewCellID)
|
||||
|
||||
feedSortStyle = .Time
|
||||
}
|
||||
@@ -218,18 +216,34 @@ class FeedsViewController: UIViewController {
|
||||
filterView.showInView(window)
|
||||
}
|
||||
}
|
||||
|
||||
func updateFeeds(finish: (() -> Void)? = nil) {
|
||||
|
||||
if let filterBarItem = filterBarItem {
|
||||
filterBarItem.title = feedSortStyle.nameWithArrow
|
||||
|
||||
var currentPageIndex = 1
|
||||
var isFetchingFeeds = false
|
||||
func updateFeeds(isLoadMore isLoadMore: Bool = false, finish: (() -> Void)? = nil) {
|
||||
|
||||
if isFetchingFeeds {
|
||||
return
|
||||
}
|
||||
|
||||
activityIndicator.startAnimating()
|
||||
isFetchingFeeds = true
|
||||
|
||||
discoverFeedsWithSortStyle(feedSortStyle, skill: skill, pageIndex: 1, perPage: 50, failureHandler: { reason, errorMessage in
|
||||
if !isLoadMore {
|
||||
activityIndicator.startAnimating()
|
||||
}
|
||||
|
||||
if isLoadMore {
|
||||
currentPageIndex++
|
||||
|
||||
} else {
|
||||
currentPageIndex = 1
|
||||
}
|
||||
|
||||
discoverFeedsWithSortStyle(feedSortStyle, skill: skill, pageIndex: currentPageIndex, perPage: 50, failureHandler: { reason, errorMessage in
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) { [weak self] in
|
||||
|
||||
self?.isFetchingFeeds = false
|
||||
|
||||
self?.activityIndicator.stopAnimating()
|
||||
|
||||
finish?()
|
||||
@@ -240,6 +254,9 @@ class FeedsViewController: UIViewController {
|
||||
}, completion: { [weak self] feeds in
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) { [weak self] in
|
||||
|
||||
self?.isFetchingFeeds = false
|
||||
|
||||
self?.activityIndicator.stopAnimating()
|
||||
|
||||
finish?()
|
||||
@@ -259,8 +276,17 @@ class FeedsViewController: UIViewController {
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
|
||||
strongSelf.feeds = feeds
|
||||
strongSelf.feedsTableView.reloadData() // 服务端有新的排序算法,以及避免刷新后消息数字更新不及时的问题
|
||||
if isLoadMore {
|
||||
strongSelf.feeds += feeds
|
||||
|
||||
} else {
|
||||
strongSelf.feeds = feeds
|
||||
}
|
||||
|
||||
// 确保有新的才 reload
|
||||
if !feeds.isEmpty {
|
||||
strongSelf.feedsTableView.reloadData() // 服务端有新的排序算法,以及避免刷新后消息数字更新不及时的问题
|
||||
}
|
||||
|
||||
// if newIndexPaths.count == allNewFeedSet.count {
|
||||
// strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(newIndexPaths)
|
||||
@@ -462,11 +488,12 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
enum Section: Int {
|
||||
case SkillUsers
|
||||
case Feed
|
||||
case LoadMore
|
||||
}
|
||||
|
||||
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
|
||||
return 2
|
||||
return 3
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
@@ -476,6 +503,8 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
return (skill == nil) ? 0 : 1
|
||||
case Section.Feed.rawValue:
|
||||
return feeds.count
|
||||
case Section.LoadMore.rawValue:
|
||||
return feeds.isEmpty ? 0 : 1
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
@@ -548,11 +577,34 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
|
||||
return cell
|
||||
|
||||
case Section.LoadMore.rawValue:
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier(loadMoreTableViewCellID) as! LoadMoreTableViewCell
|
||||
return cell
|
||||
|
||||
default:
|
||||
return UITableViewCell()
|
||||
}
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
|
||||
|
||||
if indexPath.section == Section.LoadMore.rawValue {
|
||||
|
||||
if let cell = cell as? LoadMoreTableViewCell {
|
||||
|
||||
println("load more feeds")
|
||||
|
||||
if !cell.loadingActivityIndicator.isAnimating() {
|
||||
cell.loadingActivityIndicator.startAnimating()
|
||||
}
|
||||
|
||||
updateFeeds(isLoadMore: true, finish: { [weak cell] in
|
||||
cell?.loadingActivityIndicator.stopAnimating()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
|
||||
switch indexPath.section {
|
||||
@@ -564,6 +616,9 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate {
|
||||
let feed = feeds[indexPath.item]
|
||||
return heightOfFeed(feed)
|
||||
|
||||
case Section.LoadMore.rawValue:
|
||||
return 60
|
||||
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// LoadMoreTableViewCell.swift
|
||||
// Yep
|
||||
//
|
||||
// Created by nixzhu on 15/10/30.
|
||||
// Copyright © 2015年 Catch Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class LoadMoreTableViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet weak var loadingActivityIndicator: UIActivityIndicatorView!
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
separatorInset = UIEdgeInsets(top: 0, left: UIScreen.mainScreen().bounds.width, bottom: 0, right: 0)
|
||||
}
|
||||
|
||||
override func setSelected(selected: Bool, animated: Bool) {
|
||||
super.setSelected(selected, animated: animated)
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="LoadMoreTableViewCell" id="KGk-i7-Jjw" customClass="LoadMoreTableViewCell" customModule="Yep" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="gray" translatesAutoresizingMaskIntoConstraints="NO" id="IuQ-2F-VCW">
|
||||
<rect key="frame" x="150" y="12" width="20" height="20"/>
|
||||
</activityIndicatorView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="IuQ-2F-VCW" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="E1W-p1-rmy"/>
|
||||
<constraint firstItem="IuQ-2F-VCW" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="zSG-Ui-wTC"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="loadingActivityIndicator" destination="IuQ-2F-VCW" id="lwh-BP-t10"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
Reference in New Issue
Block a user