Skip to content

Commit

Permalink
History changes commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshtatekonda committed Nov 10, 2017
1 parent 551c46e commit 8c36735
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 52 deletions.
2 changes: 1 addition & 1 deletion ANAChat.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ANAChat'
s.version = '0.2.5'
s.version = '0.2.6'
s.summary = 'ANAChat iOS'

# This description is used to generate tags and improve search results.
Expand Down
12 changes: 10 additions & 2 deletions ANAChat/Classes/APIHelpers/APIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class APIManager: NSObject {
task.resume()
}

func get(params : Dictionary<String, String>?, apiPath : String? ,completionHandler:@escaping ([String: Any]) -> ()) {
func get(params : [String: Any]?, apiPath : String? ,completionHandler:@escaping ([String: Any]) -> ()) {

var finalApiPathString = String()

if let apiPath = apiPath{
Expand Down Expand Up @@ -174,6 +174,14 @@ class APIManager: NSObject {
}
}

//History API

func getHistoryFromServer(params : [String: Any], apiPath : String? , completionHandler:@escaping ([String: Any]) -> ()){
get(params: params, apiPath: apiPath) { (response) in
completionHandler(response)
}
}

// upload event
func uploadMedia(withMedia videoPath: URL,completionHandler:@escaping ([String: Any]) -> ()){
let url = NSURL(string: String(format:"%@files/", APIManager.sharedInstance.getAPIBaseUrl()))
Expand Down
9 changes: 9 additions & 0 deletions ANAChat/Classes/DBHelpers/CoreDataContentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public class CoreDataContentManager: NSObject {
}
}

class func fetchMessagesCount() -> Int{
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Message")
let count = try! CoreDataContentManager.backgroundObjectContext().count(for: fetchRequest)
return count
}

class func fetchRequest(withEntityName entity: String , predicate : NSPredicate , sortDescriptor : NSSortDescriptor) -> [Any]{
var request: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest()
request = NSFetchRequest(entityName: entity)
Expand Down Expand Up @@ -1540,6 +1546,9 @@ public class CoreDataContentManager: NSObject {
if let timeStamp = inputModel.messageTimeStamp{
messageObject.timestamp = timeStamp
}
if let dateStamp = inputModel.messageDateStamp{
messageObject.dateStamp = dateStamp
}
messageObject.syncedWithServer = NSNumber(value: true) as! Bool
CoreDataContentManager.saveBackgroundContextWith(successBlock: { (success) in
successCompletion(true)
Expand Down
2 changes: 1 addition & 1 deletion ANAChat/Classes/MockJson/allChatsMock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chats":[
"content":[
{"meta":{"id":"638d440e-b3f9-47ea-9d8a-3c3a5dcbb37c", "sender": {
"id": "business",
"medium": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//
// ChatCarouselCollectionCell.swift
// NowFloats-iOSSDK
//
// Created by Rakesh Tatekonda on 29/09/17.
// Copyright © 2017 NowFloats. All rights reserved.
//

import UIKit
Expand All @@ -20,6 +24,7 @@ class ChatCarouselCollectionCell: UICollectionViewCell {
@IBOutlet weak var cellContentView: UIView!
@IBOutlet weak var buttonsTableViewHeightConstraint: NSLayoutConstraint!

@IBOutlet weak var imageViewHeightConstraint: NSLayoutConstraint!
var item: CarouselItem?
var delegate: ChatCarouselCollectionCellDelegate?
var options: [Any]?
Expand All @@ -45,7 +50,7 @@ class ChatCarouselCollectionCell: UICollectionViewCell {
super.prepareForReuse()
self.imageView.image = nil
}

func configureCell(_ item:CarouselItem, showOptions : Bool){
self.playButton.isHidden = true
self.showOptions = showOptions
Expand All @@ -54,6 +59,11 @@ class ChatCarouselCollectionCell: UICollectionViewCell {
self.options = item.options?.sortedArray(using: [sortDescriptor])
self.titleLabel.text = item.title
self.descriptionLabel.text = item.desc
if item.title?.characters.count == 0, item.desc?.characters.count == 0{
self.imageViewHeightConstraint.constant = 210
}else{
self.imageViewHeightConstraint.constant = 130
}
if item.mediaType == 0{
self.playButton.isHidden = true
if let url = item.mediaUrl{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<outlet property="cellContentView" destination="aGS-r4-T10" id="hyg-dy-ucU"/>
<outlet property="descriptionLabel" destination="Ii7-zM-FUq" id="TFb-Pn-e81"/>
<outlet property="imageView" destination="xVk-nM-k90" id="xqP-mH-3dq"/>
<outlet property="imageViewHeightConstraint" destination="Nco-zZ-bJK" id="0s6-D5-mGR"/>
<outlet property="playButton" destination="Bmy-ix-yMZ" id="g0i-0D-Ffs"/>
<outlet property="titleLabel" destination="uD3-Bk-TfM" id="TeL-vx-kZ9"/>
</connections>
Expand Down
15 changes: 10 additions & 5 deletions ANAChat/Classes/UIComponents/Cells/ChatReceiveCarouselCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ class ChatReceiveCarouselCell: UITableViewCell ,ChatCarouselCollectionCellDelega
var delegate: InputCellProtocolDelegate?
var showOptions : Bool?

var previousMessageTimeStamp = NSDate()

override func awakeFromNib() {
super.awakeFromNib()
collectionview.delegate = self
collectionview.dataSource = self
collectionview.register(UINib.init(nibName: "ChatCarouselCollectionCell", bundle: CommonUtility.getFrameworkBundle()), forCellWithReuseIdentifier: "ChatCarouselCollectionCell")
}

override func prepareForReuse() {
super.prepareForReuse()
}

override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

Expand All @@ -34,11 +40,10 @@ class ChatReceiveCarouselCell: UITableViewCell ,ChatCarouselCollectionCellDelega
self.sortedItems = carousel.items?.sortedArray(using: [sortDescriptor])
self.collectionview.reloadData()
self.collectionview.scrollRectToVisible(CGRect.zero, animated: false)
/*
if (self.sortedItems?.count)! > 0{
self.collectionview.scrollToItem(at: IndexPath(item: 0, section: 0), at: .left, animated: false)
}
*/
}
if (self.sortedItems?.count)! > 0 , self.previousMessageTimeStamp != self.messageObject.timestamp{
self.previousMessageTimeStamp = self.messageObject.timestamp!
self.collectionview.scrollToItem(at: IndexPath(item: 0, section: 0), at: .left, animated: false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UIKit

@objc public class BaseViewController: UIViewController {

private var reachability:Reachability!
public var reachability:Reachability!

override public func viewDidLoad() {
super.viewDidLoad()
Expand Down
Loading

0 comments on commit 8c36735

Please sign in to comment.