修改图标,修复个人中心数据加载问题
@@ -2,18 +2,18 @@
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "Home.png"
|
||||
"filename" : "Home Filled-32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "Home@2x.png"
|
||||
"filename" : "Home Filled-50.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "Home@3x.png"
|
||||
"filename" : "Home Filled-100.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 429 B |
|
After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 474 B |
|
Before Width: | Height: | Size: 973 B |
@@ -2,18 +2,18 @@
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "Home_Selected.png"
|
||||
"filename" : "Home Filled-32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "Home_Selected@2x.png"
|
||||
"filename" : "Home Filled-50.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "Home_Selected@3x.png"
|
||||
"filename" : "Home Filled-100.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 429 B |
|
After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 395 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 934 B |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -2,18 +2,18 @@
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "Lightning.png"
|
||||
"filename" : "Binoculars Filled-32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "Lightning@2x.png"
|
||||
"filename" : "Binoculars Filled-50.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "Lightning@3x.png"
|
||||
"filename" : "Binoculars Filled-100.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
Before Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 934 B |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -2,18 +2,18 @@
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "Lightning_Selected.png"
|
||||
"filename" : "Binoculars Filled-32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "Lightning_Selected@2x.png"
|
||||
"filename" : "Binoculars Filled-50.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "Lightning_Selected@3x.png"
|
||||
"filename" : "Binoculars Filled-100.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
Before Width: | Height: | Size: 556 B |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -2,18 +2,18 @@
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x",
|
||||
"filename" : "UserMale.png"
|
||||
"filename" : "User Male Filled-32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x",
|
||||
"filename" : "UserMale@2x.png"
|
||||
"filename" : "User Male Filled-50.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x",
|
||||
"filename" : "UserMale@3x.png"
|
||||
"filename" : "User Male Filled-100.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 507 B |
|
After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 431 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
@@ -44,9 +44,9 @@ struct LibrxService {
|
||||
case TimeLineHotest(page: Int)
|
||||
case Me
|
||||
case User(userId: Int)
|
||||
case UserPosts(userId: Int)
|
||||
case UserLikedPosts(userId: Int)
|
||||
case UserBookMarkPosts(userId: Int)
|
||||
case UserPosts(page: Int, userId: Int)
|
||||
case UserLikedPosts(page :Int, userId: Int)
|
||||
case UserBookMarkPosts(page :Int, userId: Int)
|
||||
case UserData(userId: Int)
|
||||
case Callback
|
||||
|
||||
@@ -73,9 +73,9 @@ struct LibrxService {
|
||||
case .Me: return "/api/v1/users/me"
|
||||
case .User(let userId): return "/api/v1/users/\(userId)"
|
||||
case .UserData(let userId): return "/api/v1/users/\(userId)/stats"
|
||||
case .UserPosts(let userId): return "/api/v1/users/\(userId)/posts"
|
||||
case .UserLikedPosts(let userId): return "/api/v1/users/\(userId)/posts/liked"
|
||||
case .UserBookMarkPosts(let userId): return "/api/v1/users/\(userId)/posts/bookmarked"
|
||||
case .UserPosts(let page, let userId): return "/api/v1/users/\(userId)/posts?page=\(page)"
|
||||
case .UserLikedPosts(let page, let userId): return "/api/v1/users/\(userId)/posts/liked?page=\(page)"
|
||||
case .UserBookMarkPosts(let page, let userId): return "/api/v1/users/\(userId)/posts/bookmarked?page=\(page)"
|
||||
case .Callback: return "/api/v1/users/auth/callback"
|
||||
default: return ""
|
||||
}
|
||||
@@ -129,26 +129,27 @@ struct LibrxService {
|
||||
|
||||
}
|
||||
|
||||
static func postsForUser(userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
static func postsForUser(page: Int, userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
|
||||
let urlString = baseURL + ResourcePath.UserPosts(userId: userId).description
|
||||
let urlString = baseURL + ResourcePath.UserPosts(page: page, userId: userId).description
|
||||
let headers: [String:String] = buildHttpRequestHeader()
|
||||
loadPostsByUrl(urlString, headers: headers, response: response)
|
||||
|
||||
}
|
||||
|
||||
static func postsForUserBookMark(userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
static func postsForUserBookMark(page: Int, userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
|
||||
let urlString = baseURL + ResourcePath.UserBookMarkPosts(userId: userId).description
|
||||
let urlString = baseURL + ResourcePath.UserBookMarkPosts(page: page, userId: userId).description
|
||||
let headers: [String:String] = buildHttpRequestHeader()
|
||||
|
||||
loadPostsByUrl(urlString, headers: headers, response: response)
|
||||
|
||||
}
|
||||
|
||||
static func postsForUserLiked(userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
static func postsForUserLiked(page: Int, userId: Int, response: ([Post], error: String?) -> ()) {
|
||||
|
||||
let urlString = baseURL + ResourcePath.UserLikedPosts(userId: userId).description
|
||||
let urlString = baseURL + ResourcePath.UserLikedPosts(page: page, userId: userId).description
|
||||
print(urlString)
|
||||
let headers: [String:String] = buildHttpRequestHeader()
|
||||
loadPostsByUrl(urlString, headers: headers, response: response)
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class PostsLoader {
|
||||
|
||||
func postsByUser(page: Int=1, userId: Int, completion: PostfixLoadCompetion) {
|
||||
|
||||
LibrxService.postsForUser(userId){ [weak self] (posts, error) in
|
||||
LibrxService.postsForUser(page, userId: userId){ [weak self] (posts, error) in
|
||||
if let storongSelf = self {
|
||||
storongSelf.isLoading = false
|
||||
completion(posts: posts, error: error)
|
||||
@@ -152,7 +152,7 @@ class PostsLoader {
|
||||
func postsByMeLiked(page: Int=1,completion: PostfixLoadCompetion) {
|
||||
|
||||
let userId = LocalStore.accessUserId()
|
||||
LibrxService.postsForUserLiked(userId!){ [weak self] (posts, error) in
|
||||
LibrxService.postsForUserLiked(page, userId: userId!){ [weak self] (posts, error) in
|
||||
if let storongSelf = self {
|
||||
storongSelf.isLoading = false
|
||||
completion(posts: posts, error: error)
|
||||
@@ -164,7 +164,7 @@ class PostsLoader {
|
||||
|
||||
func postsByUserLiked(page: Int=1, userId: Int, completion: PostfixLoadCompetion) {
|
||||
|
||||
LibrxService.postsForUserLiked(userId){ [weak self] (posts, error) in
|
||||
LibrxService.postsForUserLiked(page, userId: userId){ [weak self] (posts, error) in
|
||||
if let storongSelf = self {
|
||||
storongSelf.isLoading = false
|
||||
completion(posts: posts, error: error)
|
||||
@@ -177,7 +177,7 @@ class PostsLoader {
|
||||
func postsByMeBookMark(page: Int=1, completion: PostfixLoadCompetion) {
|
||||
|
||||
let userId = LocalStore.accessUserId()
|
||||
LibrxService.postsForUserBookMark(userId!){ [weak self] (posts, error) in
|
||||
LibrxService.postsForUserBookMark(page, userId: userId!){ [weak self] (posts, error) in
|
||||
if let storongSelf = self {
|
||||
storongSelf.isLoading = false
|
||||
completion(posts: posts, error: error)
|
||||
@@ -189,7 +189,7 @@ class PostsLoader {
|
||||
|
||||
func postsByUserBookMark(page: Int=1, userId: Int, completion: PostfixLoadCompetion) {
|
||||
|
||||
LibrxService.postsForUserBookMark(userId){ [weak self] (posts, error) in
|
||||
LibrxService.postsForUserBookMark(page, userId: userId){ [weak self] (posts, error) in
|
||||
if let storongSelf = self {
|
||||
storongSelf.isLoading = false
|
||||
completion(posts: posts, error: error)
|
||||
|
||||
@@ -23,6 +23,8 @@ class StorysTableViewController: UITableViewController {
|
||||
|
||||
private var posts:[Post] = []
|
||||
private var currentPage:Int = 1
|
||||
private var isFirstTime = true
|
||||
private var activityView: UIActivityIndicatorView?
|
||||
|
||||
|
||||
var postSection : PostsLoader.PostSection = .Default {
|
||||
@@ -51,13 +53,6 @@ class StorysTableViewController: UITableViewController {
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension
|
||||
self.tableView.backgroundColor = UIColor(white: 0.97, alpha: 1)
|
||||
|
||||
// reload data from cache
|
||||
self.posts = self.getLocalCachePosts()
|
||||
self.tableView.reloadData()
|
||||
// mark start refreshing
|
||||
self.refreshControl?.beginRefreshing()
|
||||
refresh()
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -83,8 +78,18 @@ class StorysTableViewController: UITableViewController {
|
||||
if self.refreshControl?.refreshing == false{
|
||||
self.refreshControl?.beginRefreshing()
|
||||
}
|
||||
// reload data when view did appear
|
||||
|
||||
// reload data from cache
|
||||
self.posts = self.getLocalCachePosts()
|
||||
self.tableView.reloadData()
|
||||
|
||||
if isFirstTime {
|
||||
// mark start refreshing
|
||||
self.refreshControl?.beginRefreshing()
|
||||
refresh()
|
||||
self.isFirstTime = false
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -184,13 +189,11 @@ class StorysTableViewController: UITableViewController {
|
||||
}
|
||||
|
||||
func loadMore() {
|
||||
print("load more data")
|
||||
postsLoader.load(currentPage+1, completion: { [weak self] (posts, error) in
|
||||
|
||||
if let selfView = self {
|
||||
|
||||
if posts.count == 0 {
|
||||
print("没有数据了")
|
||||
selfView.activityView?.stopAnimating()
|
||||
} else{
|
||||
selfView.posts += posts
|
||||
selfView.currentPage += 1
|
||||
@@ -205,12 +208,12 @@ class StorysTableViewController: UITableViewController {
|
||||
let cell = UITableViewCell.init(style: UITableViewCellStyle.Default, reuseIdentifier: "moretag")
|
||||
cell.backgroundColor = UIColor.clearColor()
|
||||
|
||||
let activityView = UIActivityIndicatorView.init(frame: CGRectMake(0, 10 ,self.view.frame.width,30.0))
|
||||
activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
|
||||
activityView.hidesWhenStopped = false
|
||||
activityView.startAnimating()
|
||||
self.activityView = UIActivityIndicatorView.init(frame: CGRectMake(0, 10 ,self.view.frame.width,30.0))
|
||||
self.activityView?.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
|
||||
self.activityView?.hidesWhenStopped = false
|
||||
self.activityView?.startAnimating()
|
||||
|
||||
cell.contentView.addSubview(activityView)
|
||||
cell.contentView.addSubview(activityView!)
|
||||
return cell
|
||||
|
||||
}
|
||||
|
||||