diff --git a/Shared/Cells Xib/CellHomeExpertActionA.xib b/Shared/Cells Xib/CellHomeExpertAction.xib similarity index 99% rename from Shared/Cells Xib/CellHomeExpertActionA.xib rename to Shared/Cells Xib/CellHomeExpertAction.xib index 376ed8590..2b38880c3 100644 --- a/Shared/Cells Xib/CellHomeExpertActionA.xib +++ b/Shared/Cells Xib/CellHomeExpertAction.xib @@ -1,9 +1,9 @@ - + - + diff --git a/Shared/Cells Xib/CellHomeExpertActionB.xib b/Shared/Cells Xib/CellHomeExpertActionB.xib deleted file mode 100644 index d3dad5211..000000000 --- a/Shared/Cells Xib/CellHomeExpertActionB.xib +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Shared/Cells Xib/CellHomeExpertEventA.xib b/Shared/Cells Xib/CellHomeExpertEvent.xib similarity index 99% rename from Shared/Cells Xib/CellHomeExpertEventA.xib rename to Shared/Cells Xib/CellHomeExpertEvent.xib index 22039818a..90b213b59 100644 --- a/Shared/Cells Xib/CellHomeExpertEventA.xib +++ b/Shared/Cells Xib/CellHomeExpertEvent.xib @@ -1,9 +1,9 @@ - + - + diff --git a/Shared/Cells Xib/CellHomeExpertEventB.xib b/Shared/Cells Xib/CellHomeExpertEventB.xib deleted file mode 100644 index dfe69d0d0..000000000 --- a/Shared/Cells Xib/CellHomeExpertEventB.xib +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.h b/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.h index 8c7046312..da8918a20 100644 --- a/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.h +++ b/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.h @@ -24,4 +24,5 @@ @property(nonatomic) BOOL isPOI; @property(nonatomic) NSNumber *poiId; @property(nonatomic) CGFloat widthPicto; +@property(nonatomic) NSNumber *userMessageUID;//Used for the new version of detailMessageVC @end diff --git a/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.m b/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.m index 466a2d4ab..7625ecc79 100644 --- a/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.m +++ b/Shared/Classes/Controller/ActiveFeedItem/ChatCells/OTMessageReceivedCell.m @@ -51,6 +51,10 @@ - (void)configureWithTimelinePoint:(OTFeedItemTimelinePoint *)timelinePoint { self.ui_constraint_width_iv_link.constant = 0; } } + //Used for the new version of detailMessageVC + if ([timelinePoint isKindOfClass:[OTFeedItemMessage class]]) { + self.userMessageUID = ((OTFeedItemMessage*) timelinePoint).uID; + } } - (IBAction)showUserDetails:(id)sender { @@ -58,6 +62,9 @@ - (IBAction)showUserDetails:(id)sender { NSIndexPath *indexPath = [self.dataSource.tableView indexPathForCell:self]; OTFeedItemMessage *message = [self.dataSource.tableDataSource getItemAtIndexPath:indexPath]; [self.userProfile showProfile:message.uID]; + + //Used for the new version of detailMessageVC + [[NSNotificationCenter defaultCenter] postNotificationName:@"showUserProfile" object:nil userInfo:@{@"userUID":self.userMessageUID}]; } #pragma mark - private methods diff --git a/Shared/Classes/Controller/Home/OTHomeCollectionViewCells.swift b/Shared/Classes/Controller/Home/OTHomeCollectionViewCells.swift index 0f647074c..fa939f0a2 100644 --- a/Shared/Classes/Controller/Home/OTHomeCollectionViewCells.swift +++ b/Shared/Classes/Controller/Home/OTHomeCollectionViewCells.swift @@ -49,7 +49,7 @@ class OTHomeCollectionViewCell: UICollectionViewCell { else { ui_title_action.text = OTLocalisationService.getLocalizedValue(forKey: item.entourage_type) ui_info_show_more?.text = OTLocalisationService.getLocalizedValue(forKey: "show_more") - + if item.entourage_type == "contribution" { ui_title_action.textColor = UIColor.appBlue() ui_info_action_by?.text = OTLocalisationService.getLocalizedValue(forKey: "home_action_contrib_info_user") @@ -59,22 +59,22 @@ class OTHomeCollectionViewCell: UICollectionViewCell { ui_info_action_by?.text = OTLocalisationService.getLocalizedValue(forKey: "home_action_info_user") } } - + ui_title_description.text = item.title ui_title_profile.text = item.author.displayName - + //Picto if let pictoStr = OTAppAppearance.iconName(forEntourageItem: item, isAnnotation: false) { ui_picto_action.image = UIImage.init(named: pictoStr) } - + if item.isOnline.boolValue { ui_title_location.text = OTLocalisationService.getLocalizedValue(forKey: "info_feed_item_event_online") } else { let distance = HomeCellUtils.getDistance(item: item) var distanceStr = "" - + if distance < 1000000 { distanceStr = HomeCellUtils.formattedItemDistance(distance: distance) if distanceStr.count > 0 { @@ -86,11 +86,11 @@ class OTHomeCollectionViewCell: UICollectionViewCell { } ui_title_location.text = String.init(format: "%@%@", distanceStr,item.postalCode) } - + if OTAppConfiguration.shouldShowCreatorImagesForNewsFeedItems() { ui_button_profile.setupAsProfilePicture(fromUrl: item.author.avatarUrl) ui_button_profile.isHidden = false - + if item.author.partner == nil { ui_picto_check_profile.isHidden = true } @@ -103,7 +103,7 @@ class OTHomeCollectionViewCell: UICollectionViewCell { ui_button_profile.isHidden = true ui_picto_check_profile.isHidden = true } - + let nbPeople = item.noPeople.intValue if nbPeople == 1 { ui_title_nb_people?.text = "\(nbPeople) \(OTLocalisationService.getLocalizedValue(forKey: "participant")!)" @@ -296,7 +296,7 @@ class OTHomeImageCollectionViewCell: UICollectionViewCell { class OTHomeCellOther: UICollectionViewCell { @IBOutlet weak var ui_title: UILabel! @IBOutlet weak var ui_image: UIImageView? - @IBOutlet weak var ui_label_more: UILabel! + @IBOutlet weak var ui_label_more: UILabel? @IBOutlet weak var ui_image_bottom: UIImageView? var isShowZone = false @@ -307,18 +307,28 @@ class OTHomeCellOther: UICollectionViewCell { self.ui_image_bottom?.isHidden = true } - func populateCell(title:String,isShowZone:Bool) { + func populateCell(title:String,isShowZone:Bool, isAction:Bool) { ui_title.text = title self.isShowZone = isShowZone self.ui_image_bottom?.isHidden = true self.ui_image?.isHidden = false - self.contentView.backgroundColor = UIColor.appOrange() + + var labelMore = OTLocalisationService.getLocalizedValue(forKey: "cell_info_demand_empty_button") + if !isAction { + self.contentView.backgroundColor = UIColor.appOrange() + } + else { + self.contentView.backgroundColor = UIColor.init(red: 158 / 255.0, green: 158 / 255.0, blue: 158 / 255.0, alpha: 1.0) + labelMore = OTLocalisationService.getLocalizedValue(forKey: "cell_info_action_empty_button") + } + self.ui_label_more?.text = labelMore } + func populateCell(title:String,buttonMoreTxt:String) { ui_title.text = title self.isShowZone = false self.contentView.backgroundColor = UIColor.appOrange() - ui_label_more.text = buttonMoreTxt + ui_label_more?.text = buttonMoreTxt self.ui_image?.isHidden = true self.ui_image_bottom?.isHidden = false } diff --git a/Shared/Classes/Controller/Home/OTHomeExpertViewController.swift b/Shared/Classes/Controller/Home/OTHomeExpertViewController.swift index e06d6da55..08310fd9b 100644 --- a/Shared/Classes/Controller/Home/OTHomeExpertViewController.swift +++ b/Shared/Classes/Controller/Home/OTHomeExpertViewController.swift @@ -7,26 +7,14 @@ // import UIKit -import FirebaseRemoteConfig import AVFoundation -enum VariantCell { - case Original - case VariantA - case VariantB -} - class OTHomeExpertViewController: UIViewController { let CELL_HEADLINES_HEIGHT:CGFloat = 330 - let CELL_EVENTS_HEIGHT_ORIGINAL:CGFloat = 280 - let CELL_EVENTS_HEIGHT_VARIANT_A:CGFloat = 320 - let CELL_EVENTS_HEIGHT_VARIANT_B:CGFloat = 284 - - let CELL_ACTIONS_HEIGHT_ORIGINAL:CGFloat = 298 - let CELL_ACTIONS_HEIGHT_VARIANT_A:CGFloat = 286 - let CELL_ACTIONS_HEIGHT_VARIANT_B:CGFloat = 248 + let CELL_EVENTS_HEIGHT:CGFloat = 320 + let CELL_ACTIONS_HEIGHT:CGFloat = 286 @IBOutlet weak var ui_tableview: UITableView! @IBOutlet weak var ui_button_tour: UIButton! @@ -45,8 +33,6 @@ class OTHomeExpertViewController: UIViewController { var isFromProfile = false - var variantType:VariantCell = .Original - override func viewDidLoad() { super.viewDidLoad() @@ -75,42 +61,7 @@ class OTHomeExpertViewController: UIViewController { OTLogger.logEvent(View_Start_ExpertFeed) - let remoteValue = RemoteConfig.remoteConfig()["cell_home_expert_type"] - switch(remoteValue.numberValue) { - case 0: - self.variantType = .Original - case 1: - self.variantType = .VariantA - case 2 : - self.variantType = .VariantB - default: - break - } - - let defaultDuration:TimeInterval = 60 * 60 * 24 //TODO: -remettre les bonnes valuers après tests preprod- sinon 0 - RemoteConfig.remoteConfig().fetch(withExpirationDuration: defaultDuration) { Status, error in - if error == nil { - RemoteConfig.remoteConfig().activate { changed, error in - let remoteCell = RemoteConfig.remoteConfig()["cell_home_expert_type"] - - switch(remoteCell.numberValue) { - case 0: - self.variantType = .Original - case 1: - self.variantType = .VariantA - case 2 : - self.variantType = .VariantB - default: - break - } - - self.getFeed() - } - } - else { - self.getFeed() - } - } + self.getFeed() } override func viewWillAppear(_ animated: Bool) { @@ -137,6 +88,8 @@ class OTHomeExpertViewController: UIViewController { self.ui_tableview.scrollToRow(at: IndexPath(row: 0, section: 0), at: UITableView.ScrollPosition.top, animated: true) isFromProfile = false } + + loadUser() } @@ -268,6 +221,21 @@ class OTHomeExpertViewController: UIViewController { self.navigationController?.pushViewController(vc, animated: true) } + func loadUser() { + OTAuthService.init().getDetailsForUser(UserDefaults.standard.currentUser.uuid, success: { (user) in + if let _user = user { + UserDefaults.standard.currentUser = _user + DispatchQueue.main.async { + if let unreadCount = _user.unreadCount { + let notifDict = [kNotificationTotalUnreadCountKey:unreadCount] + let notif = Notification(name: NSNotification.Name.updateTotalUnreadCount, object: notifDict, userInfo: nil) + NotificationCenter.default.post(notif) + } + } + } + }) { (error) in } + } + //MARK: - Methods Tours - func createTourFromNav() { if (presentedViewController?.isKind(of: OTMapOptionsViewController.self)) != nil { @@ -317,31 +285,13 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource cell = tableView.dequeueReusableCell(withIdentifier: "CollectionCellAnnouncesEmpty", for: indexPath) as! OTHomeCellCollectionView } else if arrayFeedEmpty[indexPath.row].type == .Events { - var identifierVariant = "" - switch self.variantType { - case .Original: - identifierVariant = "collectionCellEventsEmpty" - case .VariantA: - identifierVariant = "collectionCellEventsEmptyA" - case .VariantB: - identifierVariant = "collectionCellEventsEmptyB" - } - cell = tableView.dequeueReusableCell(withIdentifier: identifierVariant, for: indexPath) as! OTHomeCellCollectionView + cell = tableView.dequeueReusableCell(withIdentifier: "collectionCellEventsEmptyA", for: indexPath) as! OTHomeCellCollectionView } else { - var identifierVariant = "" - switch self.variantType { - case .Original: - identifierVariant = "CollectionCellActionsEmpty" - case .VariantA: - identifierVariant = "CollectionCellActionsEmptyA" - case .VariantB: - identifierVariant = "CollectionCellActionsEmptyB" - } - cell = tableView.dequeueReusableCell(withIdentifier: identifierVariant, for: indexPath) as! OTHomeCellCollectionView + cell = tableView.dequeueReusableCell(withIdentifier: "CollectionCellActionsEmptyA", for: indexPath) as! OTHomeCellCollectionView } - cell.populateCell(card: arrayFeedEmpty[indexPath.row],clickDelegate: self, isLoading: isLoading,variantType:self.variantType) + cell.populateCell(card: arrayFeedEmpty[indexPath.row],clickDelegate: self, isLoading: isLoading) return cell } @@ -351,32 +301,13 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource cell = tableView.dequeueReusableCell(withIdentifier: "CollectionCellAnnounces", for: indexPath) as! OTHomeCellCollectionView } else if arrayFeed[indexPath.row].type == .Events { - var identifierVariant = "" - switch self.variantType { - case .Original: - identifierVariant = "collectionCellEvents" - case .VariantA: - identifierVariant = "collectionCellEventsA" - case .VariantB: - identifierVariant = "collectionCellEventsB" - } - - cell = tableView.dequeueReusableCell(withIdentifier: identifierVariant, for: indexPath) as! OTHomeCellCollectionView + cell = tableView.dequeueReusableCell(withIdentifier: "collectionCellEventsA", for: indexPath) as! OTHomeCellCollectionView } else { - var identifierVariant = "" - switch self.variantType { - case .Original: - identifierVariant = "CollectionCellActions" - case .VariantA: - identifierVariant = "CollectionCellActionsA" - case .VariantB: - identifierVariant = "CollectionCellActionsB" - } - cell = tableView.dequeueReusableCell(withIdentifier: identifierVariant, for: indexPath) as! OTHomeCellCollectionView + cell = tableView.dequeueReusableCell(withIdentifier: "CollectionCellActionsA", for: indexPath) as! OTHomeCellCollectionView } - cell.populateCell(card: arrayFeed[indexPath.row],clickDelegate: self, isLoading: isLoading,variantType:self.variantType) + cell.populateCell(card: arrayFeed[indexPath.row],clickDelegate: self, isLoading: isLoading) return cell } @@ -387,55 +318,18 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource return CELL_HEADLINES_HEIGHT } if arrayFeedEmpty[indexPath.row].type == .Events { - var cell_height:CGFloat - switch self.variantType { - case .Original: - cell_height = CELL_EVENTS_HEIGHT_ORIGINAL - case .VariantA: - cell_height = CELL_EVENTS_HEIGHT_VARIANT_A - case .VariantB: - cell_height = CELL_EVENTS_HEIGHT_VARIANT_B - } - return cell_height - } - var cell_height:CGFloat - switch self.variantType { - case .Original: - cell_height = CELL_ACTIONS_HEIGHT_ORIGINAL - case .VariantA: - cell_height = CELL_ACTIONS_HEIGHT_VARIANT_A - case .VariantB: - cell_height = CELL_ACTIONS_HEIGHT_VARIANT_B + return CELL_EVENTS_HEIGHT } - return cell_height + return CELL_ACTIONS_HEIGHT } if arrayFeed[indexPath.row].type == .Headlines { return CELL_HEADLINES_HEIGHT } if arrayFeed[indexPath.row].type == .Events { - var cell_height:CGFloat - switch self.variantType { - case .Original: - cell_height = CELL_EVENTS_HEIGHT_ORIGINAL - case .VariantA: - cell_height = CELL_EVENTS_HEIGHT_VARIANT_A - case .VariantB: - cell_height = CELL_EVENTS_HEIGHT_VARIANT_B - } - return cell_height - } - - var cell_height:CGFloat - switch self.variantType { - case .Original: - cell_height = CELL_ACTIONS_HEIGHT_ORIGINAL - case .VariantA: - cell_height = CELL_ACTIONS_HEIGHT_VARIANT_A - case .VariantB: - cell_height = CELL_ACTIONS_HEIGHT_VARIANT_B + return CELL_EVENTS_HEIGHT } - return cell_height + return CELL_ACTIONS_HEIGHT } //MARK: Delegate click Cells @@ -450,19 +344,7 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource func selectCollectionViewCell(item:Any,type:HomeCardType, position:Int) { let posStr = "\(position+1)" var logString = "" - - //MARK: Use for AB Testing precision variant Analytics - var tagAB = "" - switch self.variantType { - case .Original: - tagAB = "Action__ExpertFeed__Show_O" - case .VariantA: - tagAB = "Action__ExpertFeed__Show_A" - case .VariantB: - tagAB = "Action__ExpertFeed__Show_B" - } - - + if let _item = item as? OTEntourage { if _item.groupType == "outing" { if type == .Headlines { @@ -470,8 +352,6 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource } else { logString = "\(Action_expertFeed_Event)\(posStr)" - OTLogger.logEvent("Action__ExpertFeed__Show") //MARK: Use for AB Testing - OTLogger.logEvent(tagAB) //MARK: Use for AB Testing precision variant Analytics } let sb = UIStoryboard.init(name: "PublicFeedDetailNew", bundle: nil) let vc = sb.instantiateInitialViewController() as! OTDetailActionEventViewController @@ -485,8 +365,6 @@ extension OTHomeExpertViewController: UITableViewDelegate, UITableViewDataSource } else { logString = "\(Action_expertFeed_Action)\(posStr)" - OTLogger.logEvent("Action__ExpertFeed__Show") //MARK: Use for AB Testing - OTLogger.logEvent(tagAB) //MARK: Use for AB Testing precision variant Analytics } let sb = UIStoryboard.init(name: "PublicFeedDetailNew", bundle: nil) let vc = sb.instantiateInitialViewController() as! OTDetailActionEventViewController diff --git a/Shared/Classes/Controller/Home/OTHomeTableViewCells.swift b/Shared/Classes/Controller/Home/OTHomeTableViewCells.swift index 59d9bc1b8..70949fbb4 100644 --- a/Shared/Classes/Controller/Home/OTHomeTableViewCells.swift +++ b/Shared/Classes/Controller/Home/OTHomeTableViewCells.swift @@ -9,7 +9,7 @@ import UIKit //MARK: - Protocol Clic from Cells - -protocol CellClickDelegate: class { +protocol CellClickDelegate: AnyObject { func selectCollectionViewCell(item: Any,type:HomeCardType,position:Int) func showDetail(type:HomeCardType,isFromArrow:Bool,subtype:HomeCardType) func showDetailUser(userId:NSNumber) @@ -48,26 +48,11 @@ class OTHomeCellCollectionView: UITableViewCell,UICollectionViewDelegateFlowLayo weak var delegate:CellClickDelegate? = nil let cell_headline_size = CGSize(width: 200, height: 264) - - let cell_event_size_Original = CGSize(width: 292, height: 214) - let cell_event_size_VariantA = CGSize(width: 200, height: 260) - let cell_event_size_VariantB = CGSize(width: 200, height: 224) - - let cell_event_zone_size_Original = CGSize(width: 200, height: 214) - let cell_event_zone_size_VariantA = CGSize(width: 200, height: 260) - let cell_event_zone_size_VariantB = CGSize(width: 200, height: 224) - - let cell_empty_event_size_Original = CGSize(width: 140, height: 214) - let cell_empty_event_size_VariantA = CGSize(width: 140, height: 260) - let cell_empty_event_size_VariantB = CGSize(width: 140, height: 224) - - let cell_action_size_Original = CGSize(width: 200, height: 232) - let cell_action_size_VariantA = CGSize(width: 200, height: 218) - let cell_action_size_VariantB = CGSize(width: 200, height: 180) - - let cell_empty_action_size_Original = CGSize(width: 140, height: 232) - let cell_empty_action_size_VariantA = CGSize(width: 140, height: 218) - let cell_empty_action_size_VariantB = CGSize(width: 140, height: 180) + let cell_event_size = CGSize(width: 200, height: 260) + let cell_event_zone_size = CGSize(width: 200, height: 260) + let cell_empty_event_size = CGSize(width: 140, height: 260) + let cell_action_size = CGSize(width: 200, height: 218) + let cell_empty_action_size = CGSize(width: 140, height: 218) let cell_spacing:CGFloat = 15.0 let minimumItemsToShowMore = 2 @@ -80,8 +65,6 @@ class OTHomeCellCollectionView: UITableViewCell,UICollectionViewDelegateFlowLayo var isLoading = false - var variantType:VariantCell = .Original - override func awakeFromNib() { super.awakeFromNib() @@ -89,16 +72,11 @@ class OTHomeCellCollectionView: UITableViewCell,UICollectionViewDelegateFlowLayo self.ui_collectionview.dataSource = self self.ui_collectionview.delegate = self - //MARK: Use for AB Testing - let nibA = UINib(nibName: "CellHomeExpertEventA", bundle: nil) + let nibA = UINib(nibName: "CellHomeExpertEvent", bundle: nil) ui_collectionview.register(nibA, forCellWithReuseIdentifier: "cellCollEventA") - let nibB = UINib(nibName: "CellHomeExpertEventB", bundle: nil) - ui_collectionview.register(nibB, forCellWithReuseIdentifier: "cellCollEventB") - let nibActionA = UINib(nibName: "CellHomeExpertActionA", bundle: nil) + let nibActionA = UINib(nibName: "CellHomeExpertAction", bundle: nil) ui_collectionview.register(nibActionA, forCellWithReuseIdentifier: "cellCollActionA") - let nibActionB = UINib(nibName: "CellHomeExpertActionB", bundle: nil) - ui_collectionview.register(nibActionB, forCellWithReuseIdentifier: "cellCollActionB") } func changeFlowLayout() { @@ -108,28 +86,10 @@ class OTHomeCellCollectionView: UITableViewCell,UICollectionViewDelegateFlowLayo flowLayout.itemSize = cell_headline_size } else if cards.type == .Events { - var _size:CGSize - switch self.variantType { - case .Original: - _size = cell_event_size_Original - case .VariantA: - _size = cell_event_size_VariantA - case .VariantB: - _size = cell_event_size_VariantB - } - flowLayout.itemSize = _size + flowLayout.itemSize = cell_event_size } else { - var _size:CGSize - switch self.variantType { - case .Original: - _size = cell_action_size_Original - case .VariantA: - _size = cell_action_size_VariantA - case .VariantB: - _size = cell_action_size_VariantB - } - flowLayout.itemSize = _size + flowLayout.itemSize = cell_action_size } flowLayout.minimumLineSpacing = cell_spacing @@ -137,13 +97,11 @@ class OTHomeCellCollectionView: UITableViewCell,UICollectionViewDelegateFlowLayo self.ui_collectionview.collectionViewLayout = flowLayout } - func populateCell(card:HomeCard,clickDelegate:CellClickDelegate, isLoading:Bool, variantType:VariantCell) { + func populateCell(card:HomeCard,clickDelegate:CellClickDelegate, isLoading:Bool) { self.cards = card self.delegate = clickDelegate self.isLoading = isLoading - self.variantType = variantType - if card.type != .Headlines { self.isSpecialCells = cards.arrayCards.count <= minimalCellForSpecialCell } @@ -209,7 +167,7 @@ extension OTHomeCellCollectionView: UICollectionViewDataSource,UICollectionViewD if isSpecialCells && indexPath.row == cards.arrayCards.count { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellOther", for: indexPath) as! OTHomeCellOther - cell.populateCell(title: OTLocalisationService.getLocalizedValue(forKey: "home_button_modZone") , isShowZone: true) + cell.populateCell(title: OTLocalisationService.getLocalizedValue(forKey: "home_button_modZone") , isShowZone: true,isAction: false) return cell } @@ -219,16 +177,7 @@ extension OTHomeCellCollectionView: UICollectionViewDataSource,UICollectionViewD return cell } - var cellName = "" - switch self.variantType { - case .Original: - cellName = "cellCollEvent" - case .VariantA: - cellName = "cellCollEventA" - case .VariantB: - cellName = "cellCollEventB" - } - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellName, for: indexPath) as! OTHomeEventCollectionViewCell + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellCollEventA", for: indexPath) as! OTHomeEventCollectionViewCell let item = cards.arrayCards[indexPath.row] if let item = item as? OTEntourage { @@ -250,7 +199,7 @@ extension OTHomeCellCollectionView: UICollectionViewDataSource,UICollectionViewD return cell } let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellOther", for: indexPath) as! OTHomeCellOther - cell.populateCell(title: OTLocalisationService.getLocalizedValue(forKey: "home_button_helpEntourage"), isShowZone: true) + cell.populateCell(title: OTLocalisationService.getLocalizedValue(forKey: "home_button_helpEntourage"), isShowZone: true, isAction: true) return cell } @@ -269,25 +218,10 @@ extension OTHomeCellCollectionView: UICollectionViewDataSource,UICollectionViewD return cell } - var cellName = "" - switch self.variantType { - case .Original: - cellName = "cellCollAction" - case .VariantA: - cellName = "cellCollActionA" - case .VariantB: - cellName = "cellCollActionB" - } - - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellName, for: indexPath) as! OTHomeCollectionViewCell + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellCollActionA", for: indexPath) as! OTHomeCollectionViewCell if let _entourage = cards.arrayCards[indexPath.row] as? OTEntourage { - if self.variantType == .Original { - cell.updateCell(item: _entourage,delegate: delegate) - } - else { - cell.updateCellVariant(item: _entourage,delegate: delegate) - } + cell.updateCellVariant(item: _entourage,delegate: delegate) } return cell @@ -327,62 +261,26 @@ extension OTHomeCellCollectionView: UICollectionViewDataSource,UICollectionViewD return cell_headline_size } else if cards.type == .Events { - var specialSize:CGSize - var emptySize:CGSize - var normalSize:CGSize - switch self.variantType { - case .Original: - specialSize = cell_event_zone_size_Original - emptySize = cell_empty_event_size_Original - normalSize = cell_event_size_Original - case .VariantA: - specialSize = cell_event_zone_size_VariantA - emptySize = cell_empty_event_size_VariantA - normalSize = cell_event_size_VariantA - case .VariantB: - specialSize = cell_event_zone_size_VariantB - emptySize = cell_empty_event_size_VariantB - normalSize = cell_event_size_VariantB - } - if isSpecialCells && indexPath.row == cards.arrayCards.count { - return specialSize + return cell_event_zone_size } if indexPath.row == cards.arrayCards.count { - return emptySize + return cell_empty_event_size } - return normalSize + return cell_event_size } else { - var specialSize:CGSize - var emptySize:CGSize - var normalSize:CGSize - switch self.variantType { - case .Original: - specialSize = cell_action_size_Original - emptySize = cell_empty_action_size_Original - normalSize = cell_action_size_Original - case .VariantA: - specialSize = cell_action_size_VariantA - emptySize = cell_empty_action_size_VariantA - normalSize = cell_action_size_VariantA - case .VariantB: - specialSize = cell_action_size_VariantB - emptySize = cell_empty_action_size_VariantB - normalSize = cell_action_size_VariantB - } - if isSpecialCells && indexPath.row == cards.arrayCards.count { - return specialSize + return cell_action_size } if indexPath.row == cards.arrayCards.count { - return emptySize + return cell_empty_action_size } - return normalSize + return cell_action_size } } } diff --git a/Shared/Classes/Controller/MyEntourages/OTDetailMessageViewController.swift b/Shared/Classes/Controller/MyEntourages/OTDetailMessageViewController.swift new file mode 100644 index 000000000..3c7f80ad4 --- /dev/null +++ b/Shared/Classes/Controller/MyEntourages/OTDetailMessageViewController.swift @@ -0,0 +1,345 @@ +// +// OTDetailMessageViewController.swift +// entourage +// +// Created by Jerome on 06/01/2022. +// Copyright © 2022 Entourage. All rights reserved. +// + +import UIKit +import SVProgressHUD +import IQKeyboardManager +import SDWebImage + +class OTDetailMessageViewController: UIViewController { + + @IBOutlet weak var ui_view_report: UIView! + @IBOutlet weak var ui_tableview: UITableView! + + @IBOutlet weak var ui_constraint_view_report_top: NSLayoutConstraint! + @IBOutlet weak var ui_bt_sendMessage: UIButton! + @IBOutlet weak var ui_tv_chat: OTAutoGrowTextView! + + var feedItem:OTFeedItem = OTFeedItem() + var arrayItems = [OTFeedItemTimelinePoint]() + var entourageInfo:OTEntourage? + + @IBOutlet weak var ui_constraint_bottom_textview: NSLayoutConstraint! + let bottomConstraintTextview = 10 + + //MARK: - LifeCycle - + override func viewDidLoad() { + super.viewDidLoad() + + ui_tableview.rowHeight = UITableView.automaticDimension + ui_tableview.estimatedRowHeight = 100 + + ui_tableview.dataSource = self + ui_tableview.delegate = self + + updateUnread() + updateViewReport() + + IQKeyboardManager.shared().isEnabled = false + + NotificationCenter.default.addObserver(self, selector: #selector(showProfile(notification:)), name: NSNotification.Name("showUserProfile"), object: nil) + + NotificationCenter.default.addObserver(self, selector: #selector(showKeyboard(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(hideKeyboard(notification:)), name: UIResponder.keyboardDidHideNotification, object: nil) + + setupTopBar() + self.getEntourageInfo() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + reloadMessages() + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + + //MARK: - notif keyboard - + + @objc func showKeyboard(notification:Notification) { + let kbFrame = keyboardFrame(notification: notification) + if let _height = kbFrame?.size.height { + self.ui_constraint_bottom_textview.constant = CGFloat(self.bottomConstraintTextview) + _height + } + } + + @objc func hideKeyboard(notification:Notification) { + self.ui_constraint_bottom_textview.constant = CGFloat(self.bottomConstraintTextview) + } + + func keyboardFrame(notification:Notification) -> CGRect? { + if let userInfo = notification.userInfo { + return userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect + } + return nil + } + + //MARK: - Update views - + + func setupTopBar() { + let button = UIButton(type: .custom) + button.frame = CGRect(x: 0, y: 0, width: 30, height: 30) + button.setBackgroundImage(UIImage.init(named: "info_orange"), for: .normal) + button.addTarget(self, action: #selector(showInfo), for: .touchUpInside) + + let infoButton = UIBarButtonItem(customView: button) + self.navigationItem.setRightBarButton(infoButton, animated: true) + } + + func addButtonsToNavBar(iconView:UIImageView) { + var leftItems = [UIBarButtonItem]() + + let backImage = UIImage(named: "backItem")?.withRenderingMode(.alwaysTemplate) + let backItem = UIBarButtonItem(image: backImage, style: .done, target: self, action: #selector(backButton)) + backItem.tintColor = ApplicationTheme.shared().secondaryNavigationBarTintColor + let barItem = UIBarButtonItem(customView: iconView) + + leftItems.append(backItem) + leftItems.append(barItem) + self.navigationItem.leftBarButtonItems = leftItems + } + + func setupTitleUser() { + let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 60)) + titleLabel.text = entourageInfo?.title + titleLabel.textColor = ApplicationTheme.shared().secondaryNavigationBarTintColor + titleLabel.numberOfLines = 1 + titleLabel.isUserInteractionEnabled = true + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(showInfo)) + titleLabel.addGestureRecognizer(tapGesture) + self.navigationItem.titleView = titleLabel + + //Image + let iconSize:CGFloat = 36 + let tapGestureIcon = UITapGestureRecognizer(target: self, action: #selector(showInfo)) + let iconView = UIImageView(frame: CGRect(x: 0, y: 0, width: iconSize, height: iconSize)) + iconView.backgroundColor = .white + iconView.layer.cornerRadius = iconSize / 2 + iconView.isUserInteractionEnabled = true + iconView.clipsToBounds = true + iconView.contentMode = .scaleAspectFit + iconView.addGestureRecognizer(tapGestureIcon) + iconView.image = UIImage(named: "user")?.resize(to: iconView.frame.size) + + if let urlPath = entourageInfo?.author.avatarUrl, let url = URL(string: urlPath) { + let task = URLSession.shared.dataTask(with: url) { data, response, error in + guard let data = data, error == nil else { + self.addButtonsToNavBar(iconView: iconView) + return + } + + DispatchQueue.main.async { + if let image = UIImage(data: data) { + iconView.image = image.resize(to: iconView.frame.size) + } + self.addButtonsToNavBar(iconView: iconView) + } + } + task.resume() + } + else { + self.addButtonsToNavBar(iconView: iconView) + } + } + + func validateReport() { + self.feedItem.display_report_prompt = false + self.updateViewReport() + } + + func updateViewReport() { + if (self.feedItem.isConversation() && self.feedItem.isDisplay_report_prompt()) { + self.ui_constraint_view_report_top.constant = 0; + } + else { + self.ui_constraint_view_report_top.constant = -self.ui_view_report.frame.size.height; + } + } + + //MARK: - Actions - + + @objc func backButton() { + self.navigationController?.popViewController(animated: true) + } + + @objc func showInfo() { + if let _entourage = entourageInfo { + showUserProfile(userId: _entourage.author.uID) + } + } + + @objc func showProfile(notification:Notification) { + if let userUID = notification.userInfo?["userUID"] as? NSNumber { + showUserProfile(userId: userUID) + } + } + + func showUserProfile(userId:NSNumber) { + let sb = UIStoryboard.userProfile() + if let navVc = sb?.instantiateInitialViewController() as? UINavigationController, let vc = navVc.topViewController as? OTUserViewController { + let currentUser = UserDefaults.standard.currentUser + if currentUser?.sid.intValue == userId.intValue { + vc.user = currentUser + } + else { + vc.userId = userId + } + self.present(navVc, animated: true, completion: nil) + } + } + + //MARK: - Network - + + func getEntourageInfo() { + OTEntourageService().getEntourageWithStringId(feedItem.uuid) { entourage in + self.entourageInfo = entourage + self.setupTitleUser() + } failure: { error in } + } + + func reloadMessages() { + arrayItems.removeAll() + ui_tableview.reloadData() + if let _entourage = feedItem as? OTEntourage, let messaging = OTEntourageMessaging(entourage: _entourage) { + SVProgressHUD.show() + messaging.getMessagesWithSuccess { items in + SVProgressHUD.dismiss() + if let _items = items as? [OTFeedItemTimelinePoint], _items.count > 0 { + self.insertDates(items: _items) + self.updateViewReport() + } + } failure: { error in SVProgressHUD.dismiss() } + } + } + + //order messages + insert headers dates + func insertDates(items:[OTFeedItemTimelinePoint]) { + let sortedItems = items.sorted { a, b in + return a.date < b.date + } + + var result = [OTFeedItemTimelinePoint]() + var date = Date(timeIntervalSince1970: 0) + + for item in sortedItems { + if !Calendar.current.isDate(item.date, inSameDayAs: date) { + date = item.date + let chatPoint = OTFeedItemTimelinePoint() + chatPoint.date = date + result.append(chatPoint) + } + result.append(item) + } + arrayItems.removeAll() + arrayItems.append(contentsOf: result) + DispatchQueue.main.async { + self.ui_tableview.reloadData() + } + } + + func updateUnread() { + Logger.print("***$* start update read") + let _messageDelegate = OTFeedItemFactory.create(for: feedItem).getMessaging?() + _messageDelegate?.setMessagesAsRead({ [weak self] in + Logger.print("***$* end update read") + if let self = self { + OTUnreadMessagesService().setGroupAsRead(self.feedItem.uid, stringId: self.feedItem.uuid, refreshFeed: false) + } + }, orFailure: { error in }) + } + + //MARK: - IBActions - + + @IBAction func action_send_message(_ sender: Any) { + let message = ui_tv_chat.text.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) + if message.count == 0 { + return + } + + SVProgressHUD.show() + + if let _entourage = feedItem as? OTEntourage, let messaging = OTEntourageMessaging(entourage: _entourage) { + OTLogger.logEvent("AddContentToMessage") + messaging.send(message) { responseMessage in + SVProgressHUD.dismiss() + self.ui_tv_chat.text = "" + self.reloadMessages() + OTAppState.checkNotifications(completionHandler: nil) + } orFailure: { error in + SVProgressHUD.showError(withStatus: OTLocalisationService.getLocalizedValue(forKey: "generic_error")) + } + } + } + + @IBAction func action_close_report(_ sender: Any) { + validateReport() + } + + @IBAction func action_report(_ sender: Any) { + let txtColor = UIColor.appOrange() + let storyboard = UIStoryboard.init(name: "Popup", bundle: nil) + + let titleStr = "report_contribution_title".localized + let descriptionStr = "report_contribution_attributed_title".localized + + let popupVC = storyboard.instantiateInitialViewController() as! OTPopupViewController + + let firstString = NSMutableAttributedString(string: titleStr) + firstString.addAttribute(NSAttributedString.Key.foregroundColor, value: txtColor as Any, range: NSRange(location: 0, length: firstString.length)) + + let attributedString = NSMutableAttributedString(string: descriptionStr) + + attributedString.addAttribute(NSAttributedString.Key.font, value: UIFont(name: "SFUIText-Medium", size: 17) as Any, range: NSRange(location: 0, length: attributedString.length)) + + attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: txtColor as Any, range: NSRange(location: 0, length: attributedString.length)) + + firstString.append(attributedString) + + + popupVC.labelString = firstString + popupVC.textFieldPlaceholder = "report_entourage_placeholder".localized + popupVC.buttonTitle = "report_entourage_button".localized + popupVC.isEntourageReport = true + popupVC.entourageId = (self.feedItem as! OTEntourage).uid.stringValue + popupVC.detailMessagesVC = self + + self.present(popupVC, animated: true, completion: nil) + } + + @IBAction func action_report_cancel(_ sender: Any) { + OTEntourageService().deleteReportUserPrompt(forEntourage: self.feedItem.uuid) { + self.validateReport() + } failure: { error in } + } +} + +//MARK: - uitableview datasource / delegate - +extension OTDetailMessageViewController: UITableViewDataSource,UITableViewDelegate { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + Logger.print("***$* number of rows : \(arrayItems.count)") + return arrayItems.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let item = arrayItems[indexPath.row] + if let _item = item as? OTFeedItemMessage { + let currentUser = UserDefaults.standard.currentUser + let cellIdentifier = _item.uID == currentUser?.sid ? "MessageSentCell" : "MessageReceivedCell" + + let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! OTChatCellBase + cell.configure(with: _item) + return cell + } + else { + let cell = tableView.dequeueReusableCell(withIdentifier: "ChatDateCell", for: indexPath) as! OTChatCellBase + cell.configure(with: item) + return cell + } + } +} diff --git a/Shared/Classes/Controller/MyEntourages/OTEntourageMessageCell.swift b/Shared/Classes/Controller/MyEntourages/OTEntourageMessageCell.swift new file mode 100644 index 000000000..d5e6f3d26 --- /dev/null +++ b/Shared/Classes/Controller/MyEntourages/OTEntourageMessageCell.swift @@ -0,0 +1,105 @@ +// +// OTEntourageMessageCell.swift +// entourage +// +// Created by Jerome on 13/12/2021. +// Copyright © 2021 Entourage. All rights reserved. +// + +import UIKit + +class OTEntourageMessageCell: UITableViewCell { + + @IBOutlet weak var lblTitle:UILabel! + @IBOutlet weak var lblTimeDistance:UILabel! + @IBOutlet weak var lblLastMessage:UILabel! + @IBOutlet weak var imgCategory:UIImageView! + + var summaryProvider:OTSummaryProviderBehavior? = nil + + override func awakeFromNib() { + super.awakeFromNib() + summaryProvider = OTSummaryProviderBehavior() + } + + func configureWith(feedItem:OTFeedItem) { + let readFontLarge = UIFont(name: "SFUIText-Regular", size: 16) + let unReadFontLarge = UIFont(name: "SFUIText-Bold", size: 16) + let readFontSmall = UIFont(name: "SFUIText-Regular", size: 14) + let unReadFontSmall = UIFont(name: "SFUIText-Bold", size: 14) + + let readColor = UIColor(red: 51.0/255.0, green: 51.0/255.0, blue: 51.0/255.0, alpha: 1) + + let lightFont = UIFont(name:"SFUIText-Light", size:14) + + self.summaryProvider?.lblTitle = self.lblTitle + self.summaryProvider?.lblTimeDistance = self.lblTimeDistance + self.summaryProvider?.imgCategory = self.imgCategory + self.summaryProvider?.showRoundedBorder = true + self.summaryProvider?.showTimeAsUpdatedDate = true + self.summaryProvider?.imgCategorySize = CGSize(width: 25, height: 35) + + setupSubtitle(item: feedItem) + self.summaryProvider?.isFromMyEntourages = true + self.summaryProvider?.configure(with: feedItem) + self.summaryProvider?.clearConfiguration() + + if feedItem.unreadMessageCount.intValue > 0 { + self.lblTitle.font = unReadFontLarge + self.lblTitle.textColor = UIColor.black + + self.lblLastMessage.font = unReadFontSmall + self.lblLastMessage.textColor = UIColor.black + + self.lblTimeDistance.font = unReadFontSmall + self.lblTimeDistance.textColor = UIColor.black + } + else { + self.lblTitle.font = readFontLarge + self.lblTitle.textColor = readColor + + self.lblLastMessage.font = readFontSmall + self.lblLastMessage.textColor = UIColor.appGreyish() + + self.lblTimeDistance.font = lightFont + self.lblTimeDistance.textColor = readColor + } + setupSubtitle(item: feedItem) + } + + func setupSubtitle(item:OTFeedItem) { + let lastMessage = getAuthorText(lastMessage: item.lastMessage) + + if lastMessage.count > 0 { + summaryProvider?.lblDescription = self.lblLastMessage + self.lblLastMessage.text = lastMessage + } + else { + summaryProvider?.lblDescription = self.lblLastMessage + } + } + + func getAuthorText(lastMessage:OTMyFeedMessage?) -> String { + var messageStr = "" + let currentUSer = UserDefaults.standard.currentUser + let isMe = currentUSer?.sid == lastMessage?.authorId + + if isMe { + messageStr = "Vous" + } + else { + if let lastMsgName = lastMessage?.displayName, lastMsgName.count > 0 { + messageStr = lastMsgName + } + } + + if messageStr.count > 0 { + messageStr = messageStr + " : " + if let lastmsg = lastMessage?.text { + messageStr = messageStr + lastmsg + } + } + + return messageStr + } +} diff --git a/Shared/Classes/Controller/MyEntourages/OTMessagesService.swift b/Shared/Classes/Controller/MyEntourages/OTMessagesService.swift new file mode 100644 index 000000000..166e0f903 --- /dev/null +++ b/Shared/Classes/Controller/MyEntourages/OTMessagesService.swift @@ -0,0 +1,72 @@ +// +// OTMessagesService.swift +// entourage +// +// Created by Jerome on 16/12/2021. +// Copyright © 2021 Entourage. All rights reserved. +// + +import Foundation + +@objc class OTMessagesService: NSObject { + + static func getMessagesOne2One(withParams params:[String:Any]?,andCompletion completion: @escaping ([OTEntourage]?, Error?) -> Void) { + let token = UserDefaults.standard.currentUser.token + let urlStr = String.init(format: API_URL_MESSAGES_ONE2ONE, token!) + + OTHTTPRequestManager.sharedInstance()?.get(withUrl: urlStr, andParameters: params, andSuccess: { (responseObj) in + if let _resp = responseObj as? [String: Any] { + var arrayFeeds = [OTEntourage]() + if let arrayJson = _resp["entourages"] as? [[String: Any]] { + for item in arrayJson { + if let feeditem = OTEntourage.init(dictionary: item) { + arrayFeeds.append(feeditem) + } + } + } + DispatchQueue.main.async { + completion(arrayFeeds,nil) + } + } + else { + DispatchQueue.main.async { + completion(nil,nil) + } + } + }, andFailure: { (error) in + DispatchQueue.main.async { + completion(nil,error) + } + }) + } + + @objc static func getMessagesGroup(withParams params:[String:Any]?,andCompletion completion: @escaping ([OTEntourage]?, Error?) -> Void) { + let token = UserDefaults.standard.currentUser.token + let urlStr = String.init(format: API_URL_MESSAGES_GROUP, token!) + + OTHTTPRequestManager.sharedInstance()?.get(withUrl: urlStr, andParameters: params, andSuccess: { (responseObj) in + if let _resp = responseObj as? [String: Any] { + var arrayFeeds = [OTEntourage]() + if let arrayJson = _resp["entourages"] as? [[String: Any]] { + for item in arrayJson { + if let feeditem = OTEntourage.init(dictionary: item) { + arrayFeeds.append(feeditem) + } + } + } + DispatchQueue.main.async { + completion(arrayFeeds,nil) + } + } + else { + DispatchQueue.main.async { + completion(nil,nil) + } + } + }, andFailure: { (error) in + DispatchQueue.main.async { + completion(nil,error) + } + }) + } +} diff --git a/Shared/Classes/Controller/MyEntourages/OTMyEntourageMainViewController.swift b/Shared/Classes/Controller/MyEntourages/OTMyEntourageMainViewController.swift new file mode 100644 index 000000000..94a074e50 --- /dev/null +++ b/Shared/Classes/Controller/MyEntourages/OTMyEntourageMainViewController.swift @@ -0,0 +1,126 @@ +// +// OTMyEntourageMainViewController.swift +// entourage +// +// Created by Jerome on 10/12/2021. +// Copyright © 2021 Entourage. All rights reserved. +// + +import UIKit + +class OTMyEntourageMainViewController: UIViewController { + + @IBOutlet weak var ui_view_selector_group: UIView! + @IBOutlet weak var ui_view_selector_messages: UIView! + @IBOutlet weak var ui_label_bt_messages: UILabel! + @IBOutlet weak var ui_label_bt_group: UILabel! + @IBOutlet weak var ui_view_container: UIView! + + var groupsVC:UIViewController? = nil + var messagesVC:UIViewController? = nil + + var tabSelectedIndex = -1 + + var isAlreadyInitialized = false + override func viewDidLoad() { + super.viewDidLoad() + + setupVCs() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + if !isAlreadyInitialized { + changeButtons(newposition: 0) + isAlreadyInitialized = true + } + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + self.navigationController?.navigationBar.barTintColor = UIColor.white + self.navigationController?.setNavigationBarHidden(true, animated: animated) + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + self.navigationController?.setNavigationBarHidden(false, animated: animated) + } + + func setupVCs() { + groupsVC = UIStoryboard.myEntourages()?.instantiateViewController(withIdentifier: "MyEntourageMessages") as? OTMyEntourageMessagesViewController + + messagesVC = UIStoryboard.myEntourages()?.instantiateViewController(withIdentifier: "MyEntourageMessages") as? OTMyEntourageMessagesViewController + (messagesVC as? OTMyEntourageMessagesViewController)?.isMessagesGroup = false + } + + func changeVC() { + if tabSelectedIndex == 1 { + if let _ = groupsVC { + groupsVC?.willMove(toParent: nil) + groupsVC?.view.removeFromSuperview() + groupsVC?.removeFromParent() + } + + if let _ = messagesVC { + addChild(messagesVC!) + (messagesVC as? OTMyEntourageMessagesViewController)?.loadDatas() + messagesVC?.view.frame.size = self.ui_view_container.frame.size + ui_view_container.addSubview(messagesVC!.view) + messagesVC!.didMove(toParent: self) + } + } + else { + if let _ = messagesVC { + messagesVC?.willMove(toParent: nil) + messagesVC?.view.removeFromSuperview() + messagesVC?.removeFromParent() + } + + if let _ = groupsVC { + addChild(groupsVC!) + (groupsVC as? OTMyEntourageMessagesViewController)?.loadDatas() + groupsVC?.view.frame.size = self.ui_view_container.frame.size + ui_view_container.addSubview(groupsVC!.view) + groupsVC!.didMove(toParent: self) + } + } + } + + func changeButtons(newposition:Int) { + if newposition != tabSelectedIndex { + tabSelectedIndex = newposition + if newposition == 0 { + ui_label_bt_group.textColor = UIColor.appOrange() + ui_label_bt_messages.textColor = UIColor.appBlack30 + ui_view_selector_group.isHidden = false + ui_view_selector_messages.isHidden = true + } + else { + ui_label_bt_group.textColor = UIColor.appBlack30 + ui_label_bt_messages.textColor = UIColor.appOrange() + ui_view_selector_group.isHidden = true + ui_view_selector_messages.isHidden = false + } + changeVC() + } + } + + func setupVcsAfterTapTabbar() { + if tabSelectedIndex == 0 { + (groupsVC as? OTMyEntourageMessagesViewController)?.loadDatas() + } + else { + (messagesVC as? OTMyEntourageMessagesViewController)?.loadDatas() + } + } + + @IBAction func action_select_group(_ sender: Any) { + changeButtons(newposition: 0) + } + + @IBAction func action_select_messages(_ sender: Any) { + changeButtons(newposition: 1) + } +} diff --git a/Shared/Classes/Controller/MyEntourages/OTMyEntourageMessagesViewController.swift b/Shared/Classes/Controller/MyEntourages/OTMyEntourageMessagesViewController.swift new file mode 100644 index 000000000..ab52bf2db --- /dev/null +++ b/Shared/Classes/Controller/MyEntourages/OTMyEntourageMessagesViewController.swift @@ -0,0 +1,203 @@ +// +// OTMyEntourageMessagesViewController.swift +// entourage +// +// Created by Jerome on 10/12/2021. +// Copyright © 2021 Entourage. All rights reserved. +// + +import UIKit +import SVProgressHUD + +class OTMyEntourageMessagesViewController: UIViewController { + + let LOAD_MORE_DRAG_OFFSET:CGFloat = 50 + let LIMIT_PAGING = 10 + var currentPage = 1 + + var firstLoading = true + + var isMessagesGroup = true + + @IBOutlet weak var ui_view_no_data: UIView! + @IBOutlet weak var ui_tableView: UITableView? + + var arrayItems = [OTFeedItem]() + + let refreshControl = UIRefreshControl() + + override func viewDidLoad() { + super.viewDidLoad() + + refreshControl.addTarget(self, action: #selector(loadDatas), for: .valueChanged) + refreshControl.tintColor = UIColor.appOrange() + + if #available(iOS 10.0, *) { + ui_tableView?.refreshControl = refreshControl + } else { + ui_tableView?.addSubview(refreshControl) + } + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + if firstLoading { + firstLoading = false + loadDatas() + } + loadUserInfos() + } + + @objc func loadDatas() { + self.arrayItems.removeAll() + self.ui_tableView?.reloadData() + + self.currentPage = 1 + requestData { items, error in + if let _ = error { + self.arrayItems.removeAll() + DispatchQueue.main.async { + SVProgressHUD.dismiss() + self.refreshControl.endRefreshing() + self.ui_tableView?.reloadData() + self.showEmptyView() + } + } + else { + if let items = items as? [OTFeedItem] { + DispatchQueue.main.async { + self.arrayItems.removeAll() + self.ui_tableView?.reloadData() + } + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + SVProgressHUD.dismiss() + self.refreshControl.endRefreshing() + self.arrayItems.removeAll() + self.arrayItems.append(contentsOf: items) + self.ui_tableView?.reloadData() + self.showEmptyView() + } + } + } + } + } + + func showEmptyView() { + if arrayItems.count == 0 { + ui_view_no_data.isHidden = false + } + else { + ui_view_no_data.isHidden = true + } + } + + func requestData(completion: @escaping (Any?, Error?) -> Void) { + SVProgressHUD.show() + + let params:[String:Any] = ["per":LIMIT_PAGING,"page":currentPage] + + if isMessagesGroup { + OTMessagesService.getMessagesGroup(withParams: params) { items, error in + completion(items,error) + } + } + else { + OTMessagesService.getMessagesOne2One(withParams: params) { items, error in + completion(items,error) + } + } + } + + func loadNextPage() { + self.currentPage = self.currentPage + 1 + + requestData { items, error in + SVProgressHUD.dismiss() + if let _ = error { + self.currentPage = self.currentPage - 1 + } + else { + if let items = items as? [OTFeedItem] { + if items.count == 0 && self.currentPage > 1 { + self.currentPage = self.currentPage - 1 + } + else { + DispatchQueue.main.async { + self.arrayItems.append(contentsOf: items) + self.ui_tableView?.reloadData() + } + } + } + } + } + } + + func loadUserInfos() { + OTAuthService.init().getDetailsForUser(UserDefaults.standard.currentUser.uuid, success: { (user) in + SVProgressHUD.dismiss() + if let _user = user { + UserDefaults.standard.currentUser = _user + DispatchQueue.main.async { + if let unreadCount = _user.unreadCount { + let notifDict = [kNotificationTotalUnreadCountKey:unreadCount] + let notif = Notification(name: NSNotification.Name.updateTotalUnreadCount, object: notifDict, userInfo: nil) + NotificationCenter.default.post(notif) + } + } + } + }) { (error) in } + } +} + +//MARK: - uitableview Datsource / delegate - +extension OTMyEntourageMessagesViewController: UITableViewDelegate, UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return arrayItems.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let item = arrayItems[indexPath.row] + let cell = tableView.dequeueReusableCell(withIdentifier: "EntourageCell", for: indexPath) as! OTEntourageMessageCell + cell.configureWith(feedItem: item) + + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + arrayItems[indexPath.row].unreadMessageCount = 0 + let feedItem = arrayItems[indexPath.row] + + var vc:UIViewController + if isMessagesGroup { + let sb = UIStoryboard.init(name: "ActiveFeedItem", bundle: nil) + vc = sb.instantiateInitialViewController() as! OTActiveFeedItemViewController + (vc as! OTActiveFeedItemViewController).feedItem = feedItem + } + else { + let sb = UIStoryboard.init(name: "Messages", bundle: nil) + vc = sb.instantiateViewController(withIdentifier: "messageDetailVC") as! OTDetailMessageViewController + (vc as! OTDetailMessageViewController).feedItem = feedItem + } + + DispatchQueue.main.async { + self.navigationController?.pushViewController(vc, animated: true) + tableView.reloadRows(at: [indexPath], with: .none) + } + } + + func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + let offset = scrollView.contentOffset + let bounds = scrollView.bounds + let size = scrollView.contentSize + let inset = scrollView.contentInset + let y = offset.y + bounds.size.height - inset.bottom + let h = size.height + + if y > h + LOAD_MORE_DRAG_OFFSET { + loadNextPage() + } + } +} + + + diff --git a/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.h b/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.h index be14f3246..b5def70ad 100644 --- a/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.h +++ b/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.h @@ -12,5 +12,7 @@ @interface OTMyEntouragesViewController : UIViewController @property (nonatomic, weak) id optionsDelegate; - +- (void)showUnread; +@property(nonatomic) BOOL isMessagesOnly; +@property(nonatomic) BOOL isFirstLaunch; @end diff --git a/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.m b/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.m index 0f09c05b3..50190f774 100644 --- a/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.m +++ b/Shared/Classes/Controller/MyEntourages/OTMyEntouragesViewController.m @@ -51,7 +51,7 @@ @implementation OTMyEntouragesViewController - (void)viewDidLoad { [super viewDidLoad]; - + self.isFirstLaunch = YES; self.anonymousMode = IS_ANONYMOUS_USER; self.optionsButton.hidden = YES; @@ -90,10 +90,11 @@ - (void)dealloc { - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - if (!self.anonymousMode) { + ((OTMyEntouragesFilter*)self.entouragesDataSource.currentFilter).isUnread = self.isMessagesOnly; + if (!self.anonymousMode && self.isFirstLaunch) { [self loadInvitations]; [self.entouragesDataSource loadData]; + self.isFirstLaunch = NO; } [OTAppConfiguration updateAppearanceForMainTabBar]; } diff --git a/Shared/Classes/Controller/OTConfirmCloseViewController.m b/Shared/Classes/Controller/OTConfirmCloseViewController.m index e6c37cf77..20081c114 100644 --- a/Shared/Classes/Controller/OTConfirmCloseViewController.m +++ b/Shared/Classes/Controller/OTConfirmCloseViewController.m @@ -129,7 +129,7 @@ -(void) setupViews { self.ui_tv_send_comment.layer.borderColor = [[UIColor colorWithRed:216 / 255.0 green:216 / 255.0 blue:216 / 255.0 alpha:1.0]CGColor]; self.ui_tv_send_comment.layer.cornerRadius = 5; self.ui_label_send_comment_title.text = OTLocalizedString(@"pop_validate_action_add_comment_send_title"); - [self.ui_bt_send_comment setTitle:OTLocalizedString(@"pop_validate_action_add_comment_send_button") forState:UIControlStateNormal]; + [self.ui_bt_send_comment setTitle:OTLocalizedString(@"pop_validate_action_add_comment_send_button").uppercaseString forState:UIControlStateNormal]; self.ui_tv_send_comment.text = OTLocalizedString(@"pop_validate_action_add_comment_send_placeholder"); [self.ui_tv_send_comment setTextColor:[UIColor lightGrayColor]]; diff --git a/Shared/Classes/Controller/OTFeedsViewController.m b/Shared/Classes/Controller/OTFeedsViewController.m index 14cd253a0..cf3abd6e4 100644 --- a/Shared/Classes/Controller/OTFeedsViewController.m +++ b/Shared/Classes/Controller/OTFeedsViewController.m @@ -635,11 +635,6 @@ - (void)appWillEnterBackground:(NSNotification*)note { [self.newsFeedsSourceBehavior pause]; } -- (void)showEntourages { - [OTLogger logEvent:@"GoToMessages"]; - [self performSegueWithIdentifier:@"MyEntouragesSegue" sender:self]; -} - - (void)registerObserver { [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:NSLocalizedString(@"CURRENT_USER", @"") options:NSKeyValueObservingOptionNew context:nil]; } @@ -1227,10 +1222,6 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { controller.inviteBehaviorTriggered = self.inviteBehaviorTriggered; self.inviteBehaviorTriggered = NO; } - else if([segue.identifier isEqualToString:@"MyEntouragesSegue"]) { - OTMyEntouragesViewController *controller = (OTMyEntouragesViewController *)destinationViewController; - controller.optionsDelegate = self; - } } - (void)sendCloseMail: (NSNotification *)notification { diff --git a/Shared/Classes/Controller/OTMainGuideHubViewController.swift b/Shared/Classes/Controller/OTMainGuideHubViewController.swift index fee3f69b7..2019a943c 100644 --- a/Shared/Classes/Controller/OTMainGuideHubViewController.swift +++ b/Shared/Classes/Controller/OTMainGuideHubViewController.swift @@ -44,6 +44,8 @@ class OTMainGuideHubViewController: UIViewController { isNeedHelp = user?.isUserTypeAlone() ?? false ui_tableview?.reloadData() + + loadUser() } func showGds() { @@ -62,6 +64,21 @@ class OTMainGuideHubViewController: UIViewController { OTSafariService.launchInAppBrowser(withUrlString: url, viewController: self.navigationController) } } + + func loadUser() { + OTAuthService.init().getDetailsForUser(UserDefaults.standard.currentUser.uuid, success: { (user) in + if let _user = user { + UserDefaults.standard.currentUser = _user + DispatchQueue.main.async { + if let unreadCount = _user.unreadCount { + let notifDict = [kNotificationTotalUnreadCountKey:unreadCount] + let notif = Notification(name: NSNotification.Name.updateTotalUnreadCount, object: notifDict, userInfo: nil) + NotificationCenter.default.post(notif) + } + } + } + }) { (error) in } + } } extension OTMainGuideHubViewController: UITableViewDelegate,UITableViewDataSource { diff --git a/Shared/Classes/Controller/OTMainViewController.m b/Shared/Classes/Controller/OTMainViewController.m index 5ec78b1e9..30e5c2ebf 100644 --- a/Shared/Classes/Controller/OTMainViewController.m +++ b/Shared/Classes/Controller/OTMainViewController.m @@ -849,11 +849,6 @@ - (void)appWillEnterBackground:(NSNotification*)note { } } -- (void)showEntourages { - [OTLogger logEvent:@"GoToMessages"]; - [self performSegueWithIdentifier:@"MyEntouragesSegue" sender:self]; -} - - (void)createQuickEncounter { // EMA-2138 @@ -1652,10 +1647,6 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { controller.inviteBehaviorTriggered = self.inviteBehaviorTriggered; self.inviteBehaviorTriggered = NO; } - else if([segue.identifier isEqualToString:@"MyEntouragesSegue"]) { - OTMyEntouragesViewController *controller = (OTMyEntouragesViewController *)destinationViewController; - controller.optionsDelegate = self; - } else if ([segue.identifier isEqualToString:@"OTWebViewSegue"]) { [OTSafariService launchInAppBrowserWithUrlString:self.webview viewController:self.navigationController]; diff --git a/Shared/Classes/Controller/OTPopupViewController.swift b/Shared/Classes/Controller/OTPopupViewController.swift index a104f0709..7ee944121 100644 --- a/Shared/Classes/Controller/OTPopupViewController.swift +++ b/Shared/Classes/Controller/OTPopupViewController.swift @@ -31,6 +31,7 @@ import SVProgressHUD @objc var entourageId:String? = nil @objc var activeFeedVC:OTActiveFeedItemViewController? = nil + @objc var detailMessagesVC:OTDetailMessageViewController? = nil @objc init(labelString: NSMutableAttributedString, textFieldPlaceholder: String, buttonTitle: String) { super.init(nibName: nil, bundle: nil) @@ -98,11 +99,15 @@ import SVProgressHUD if let _ = activeFeedVC { SVProgressHUD.showSuccess(withStatus: OTLocalisationService.getLocalizedValue(forKey: "report_user")) } + else if let _ = detailMessagesVC { + SVProgressHUD.showSuccess(withStatus: OTLocalisationService.getLocalizedValue(forKey: "report_user")) + } else { SVProgressHUD.showSuccess(withStatus: OTLocalisationService.getLocalizedValue(forKey: "report_entourage")) } close(self) activeFeedVC?.validateReport() + detailMessagesVC?.validateReport() } private func showErrorMinTxt() { diff --git a/Shared/Classes/Controller/Settings/OTMenuProfileViewController.swift b/Shared/Classes/Controller/Settings/OTMenuProfileViewController.swift index 49f9caed9..e7dc432cf 100644 --- a/Shared/Classes/Controller/Settings/OTMenuProfileViewController.swift +++ b/Shared/Classes/Controller/Settings/OTMenuProfileViewController.swift @@ -72,6 +72,12 @@ class OTMenuProfileViewController: UIViewController { UserDefaults.standard.currentUser = _user DispatchQueue.main.async { self.ui_tableview?.reloadData() + + if let unreadCount = _user.unreadCount { + let notifDict = [kNotificationTotalUnreadCountKey:unreadCount] + let notif = Notification(name: NSNotification.Name.updateTotalUnreadCount, object: notifDict, userInfo: nil) + NotificationCenter.default.post(notif) + } } } }) { (error) in diff --git a/Shared/Classes/Model/OTFeedItem.m b/Shared/Classes/Model/OTFeedItem.m index cfabbeaa2..7808c8c30 100644 --- a/Shared/Classes/Model/OTFeedItem.m +++ b/Shared/Classes/Model/OTFeedItem.m @@ -81,6 +81,11 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary { self.type = [dictionary stringForKey:kWSKeyType]; self.updatedDate = [dictionary dateForKey:kWSUpdatedDate]; self.unreadMessageCount = [dictionary numberForKey:kWSNoUnreadMessages]; + + if (self.unreadMessageCount == nil) { + self.unreadMessageCount = @0; + } + self.shareUrl = [dictionary stringForKey:kWSKeyShareUrl]; NSDictionary *outcomeDictionary = [dictionary objectForKey:kWSKeyOutcome]; if (outcomeDictionary) { diff --git a/Shared/Classes/Settings/OTAPIConsts.h b/Shared/Classes/Settings/OTAPIConsts.h index 7c3251563..c8bfefeb0 100644 --- a/Shared/Classes/Settings/OTAPIConsts.h +++ b/Shared/Classes/Settings/OTAPIConsts.h @@ -112,4 +112,8 @@ #define API_URL_SEND_CHANGE_CODE @"users/request_phone_change" + +//Message 1 to 1 / groups +#define API_URL_MESSAGES_ONE2ONE @"conversations/private?token=%@" +#define API_URL_MESSAGES_GROUP @"conversations/group?token=%@" #endif /* OTAPIConsts_h */ diff --git a/Shared/Classes/Settings/OTAppConfiguration.m b/Shared/Classes/Settings/OTAppConfiguration.m index a8cf63f6d..16ed32802 100644 --- a/Shared/Classes/Settings/OTAppConfiguration.m +++ b/Shared/Classes/Settings/OTAppConfiguration.m @@ -216,27 +216,11 @@ - (void)configureFirebase if (!options) return; - [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelDebug]; + [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];//FIRLoggerLevelDebug [FIRApp configureWithOptions:options]; [FIRAnalytics setUserPropertyString:[OTAuthService currentUserAuthenticationLevel] forName:@"AuthenticationLevel"]; [FIRMessaging messaging].delegate = (id)[UIApplication sharedApplication].delegate; - - [self configureRemoteConfig]; -} - --(void) configureRemoteConfig { - [[FIRInstallations installations] authTokenForcingRefresh:true - completion:^(FIRInstallationsAuthTokenResult *result, NSError *error) { - if (error != nil) { - NSLog(@"Error fetching Installation token %@", error); - return; - } - [[NSUserDefaults standardUserDefaults]setObject:[result authToken] forKey:@"token_abtest"]; - }]; - - NSDictionary * defaultValues = @{@"cell_home_expert_type" : @0}; - [[FIRRemoteConfig remoteConfig] setDefaults:defaultValues]; } - (void)configureAnalyticsWithOptions:(NSDictionary *)launchOptions diff --git a/Shared/Classes/Utils/Behaviors/FeedItems/OTSummaryProviderBehavior.m b/Shared/Classes/Utils/Behaviors/FeedItems/OTSummaryProviderBehavior.m index 20efa9203..caa414275 100644 --- a/Shared/Classes/Utils/Behaviors/FeedItems/OTSummaryProviderBehavior.m +++ b/Shared/Classes/Utils/Behaviors/FeedItems/OTSummaryProviderBehavior.m @@ -112,35 +112,30 @@ - (void)configureWith:(OTFeedItem *)feedItem { self.lblLocation.text = @" "; } } - - if (feedItem.isOnline.boolValue) { - self.lblTimeDistance.text = [OTLocalisationService getLocalizedValueForKey:@"info_feed_item_event_online"]; - } - else { - if (self.lblTimeDistance) { - double distance = [uiDelegate distance]; - NSString *distanceStr = @""; - if (self.showTimeAsUpdatedDate) { - distanceStr = [self formattedMessageTimeForFeedItem:feedItem distance:distance]; - if (distanceStr.length > 0) { - distanceStr = [NSString stringWithFormat:@"%@ - ",distanceStr]; - } - } else if (distance < 1000000.f) { - distanceStr = [self formattedItemDistance:distance - creationDate:feedItem.creationDate]; - if (distanceStr.length > 0) { - distanceStr = [NSString stringWithFormat:@"%@ - ",distanceStr]; - } - } else { - distanceStr = @""; - } - if (self.isFromMyEntourages) { - distanceStr = [distanceStr stringByReplacingOccurrencesOfString:@" - " withString:@""]; - self.lblTimeDistance.text = distanceStr; + + if (self.lblTimeDistance) { + double distance = [uiDelegate distance]; + NSString *distanceStr = @""; + if (self.showTimeAsUpdatedDate) { + distanceStr = [self formattedMessageTimeForFeedItem:feedItem distance:distance]; + if (distanceStr.length > 0) { + distanceStr = [NSString stringWithFormat:@"%@ - ",distanceStr]; } - else { - self.lblTimeDistance.text = [NSString stringWithFormat:@"%@%@",distanceStr,feedItem.postalCode]; + } else if (distance < 1000000.f) { + distanceStr = [self formattedItemDistance:distance + creationDate:feedItem.creationDate]; + if (distanceStr.length > 0) { + distanceStr = [NSString stringWithFormat:@"%@ - ",distanceStr]; } + } else { + distanceStr = @""; + } + if (self.isFromMyEntourages) { + distanceStr = [distanceStr stringByReplacingOccurrencesOfString:@" - " withString:@""]; + self.lblTimeDistance.text = distanceStr; + } + else { + self.lblTimeDistance.text = [NSString stringWithFormat:@"%@%@",distanceStr,feedItem.postalCode]; } } diff --git a/Shared/Classes/Utils/Behaviors/UITableView/MyEntourages/OTMyEntouragesDataSource.m b/Shared/Classes/Utils/Behaviors/UITableView/MyEntourages/OTMyEntouragesDataSource.m index d3cf83eb9..3d738ee6f 100644 --- a/Shared/Classes/Utils/Behaviors/UITableView/MyEntourages/OTMyEntouragesDataSource.m +++ b/Shared/Classes/Utils/Behaviors/UITableView/MyEntourages/OTMyEntouragesDataSource.m @@ -97,18 +97,19 @@ - (void)filterChanged:(OTMyEntouragesFilter *)filter { - (void)requestDataWithSuccess:(void(^)(NSArray *items))success orFailure:(void(^)(void))failure { [SVProgressHUD show]; NSMutableDictionary *parameters = [self.currentFilter toDictionaryWithPageNumber:self.pageNumber andSize:DATA_PAGE_SIZE]; - [[OTFeedsService new] getMyFeedsWithParameters:parameters success:^(NSArray *items) { - [self.items addObjectsFromArray:items]; - - [self configureNoDataView]; - - [SVProgressHUD dismiss]; - success(items); - - } failure:^(NSError *error) { - [SVProgressHUD dismiss]; - if(failure) - failure(); + + [OTMessagesService getMessagesGroupWithParams:parameters andCompletion:^(NSArray *items, NSError *error) { + if (error == nil) { + [self.items addObjectsFromArray:items]; + [self configureNoDataView]; + [SVProgressHUD dismiss]; + success(items); + } + else { + [SVProgressHUD dismiss]; + if(failure) + failure(); + } }]; } diff --git a/Shared/Classes/Utils/Services/OTUnreadMessagesService.m b/Shared/Classes/Utils/Services/OTUnreadMessagesService.m index 5e214981e..674a91f62 100644 --- a/Shared/Classes/Utils/Services/OTUnreadMessagesService.m +++ b/Shared/Classes/Utils/Services/OTUnreadMessagesService.m @@ -30,7 +30,7 @@ + (OTUnreadMessagesService *)sharedInstance { - (void)setTotalUnreadCount:(NSNumber *)count { NSDictionary* notificationInfo = @{kNotificationTotalUnreadCountKey:count}; - [[NSNotificationCenter defaultCenter] postNotificationName:kUpdateTotalUnreadCountNotification object:notificationInfo]; + // [[NSNotificationCenter defaultCenter] postNotificationName:kUpdateTotalUnreadCountNotification object:notificationInfo]; } - (void)setGroupUnreadMessagesCount:(NSNumber *)feedId stringId:(NSString*)stringId count:(NSNumber *)count { diff --git a/Shared/OTMainTabbarViewController.swift b/Shared/OTMainTabbarViewController.swift index 1f7f5d455..2bc6622e1 100644 --- a/Shared/OTMainTabbarViewController.swift +++ b/Shared/OTMainTabbarViewController.swift @@ -116,7 +116,9 @@ class OTMainTabbarViewController: UITabBarController { plusVC.tabBarItem.image = UIImage.init(named: "ic_tab_plus_selected")?.withRenderingMode(.alwaysOriginal) plusVC.tabBarItem.selectedImage = UIImage.init(named: "ic_tab_plus_selected") - let _messagesVC = UIStoryboard.myEntourages()?.instantiateViewController(withIdentifier: "OTMyEntouragesViewController") as! OTMyEntouragesViewController +// let _messagesVC = UIStoryboard.myEntourages()?.instantiateViewController(withIdentifier: "OTMyEntouragesViewController") as! OTMyEntouragesViewController + let _messagesVC = UIStoryboard.myEntourages()?.instantiateViewController(withIdentifier: "MyEntourageMainVC") as! UIViewController + messagesVC = UINavigationController.init(rootViewController: _messagesVC) messagesVC.tabBarItem.title = OTLocalisationService.getLocalizedValue(forKey:"tabbar_message") messagesVC.tabBarItem.image = UIImage.init(named: "ic_tab_message")?.withRenderingMode(.alwaysOriginal) @@ -365,6 +367,12 @@ extension OTMainTabbarViewController: UITabBarControllerDelegate { oldItemSelected = currentItemSelected currentItemSelected = item.tag boldSelectedItem() + + if item.tag == 3 { + if let nav = messagesVC, let vc = nav.viewControllers[0] as? OTMyEntourageMainViewController { + vc.setupVcsAfterTapTabbar() + } + } } } diff --git a/Shared/Resources/Localizable.strings b/Shared/Resources/Localizable.strings index 71a7a276a..4fe9cfa45 100644 --- a/Shared/Resources/Localizable.strings +++ b/Shared/Resources/Localizable.strings @@ -1060,6 +1060,7 @@ "cell_info_demand_empty" = "C'est plutôt calme ici"; "cell_info_demand_empty_button" = "Rechercher\nplus loin"; +"cell_info_action_empty_button" = "Voir plus"; "info_asso_user" = "• S'abonner >"; "info_asso_user_joined" = "• Abonné"; "info_event_closed" = "événement complet"; diff --git a/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/Contents.json b/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/Contents.json new file mode 100644 index 000000000..e6cd9cc34 --- /dev/null +++ b/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "map-placeholder-bg_grey.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/map-placeholder-bg_grey.png b/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/map-placeholder-bg_grey.png new file mode 100644 index 000000000..a0f088487 Binary files /dev/null and b/Shared/Resources/SharedImages.xcassets/Common/map-placeholder-bg_grey.imageset/map-placeholder-bg_grey.png differ diff --git a/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/Contents.json b/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/Contents.json index 1dd5cd5d9..71a5a00cc 100644 --- a/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/Contents.json +++ b/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "bg_mod_zone.pdf", + "filename" : "bg_mod_zone.svg", "idiom" : "universal" } ], diff --git a/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.pdf b/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.pdf deleted file mode 100644 index f28c7a54e..000000000 Binary files a/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.pdf and /dev/null differ diff --git a/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.svg b/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.svg new file mode 100644 index 000000000..8891f2f35 --- /dev/null +++ b/Shared/Resources/SharedImages.xcassets/Home_tab_map/bg_mod_zone.imageset/bg_mod_zone.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Shared/Shared-Bridging-Header.h b/Shared/Shared-Bridging-Header.h index 11429f241..20f499236 100644 --- a/Shared/Shared-Bridging-Header.h +++ b/Shared/Shared-Bridging-Header.h @@ -38,7 +38,6 @@ #import "Analytics_keys.h" #import "UIViewController+menu.h" #import "UIImageView+entourage.h" -#import "OTMyEntouragesViewController.h" #import "OTMapOptionsViewController.h" #import "OTHTTPRequestManager.h" #import "OTOngoingTourService.h" @@ -93,3 +92,11 @@ #import "OTEntourageService.h" #import "OTNextStatusButtonBehavior.h" #import "OTConfirmCloseViewController.h" + +#import "OTEntouragesTableViewCell.h" +#import "OTSummaryProviderBehavior.h" + +#import "OTAutoGrowTextView.h" +#import "OTUnreadMessagesService.h" +#import "OTEntourageMessaging.h" +#import "OTChatCellBase.h" diff --git a/Shared/Storyboards/ActiveFeedItem.storyboard b/Shared/Storyboards/ActiveFeedItem.storyboard index 164f9f55c..6d837cfa6 100644 --- a/Shared/Storyboards/ActiveFeedItem.storyboard +++ b/Shared/Storyboards/ActiveFeedItem.storyboard @@ -1,9 +1,9 @@ - + - + @@ -597,7 +597,7 @@ - diff --git a/Shared/Storyboards/MyEntourages.storyboard b/Shared/Storyboards/MyEntourages.storyboard index 6990f07c8..da3c489b7 100644 --- a/Shared/Storyboards/MyEntourages.storyboard +++ b/Shared/Storyboards/MyEntourages.storyboard @@ -1,9 +1,9 @@ - - + + - + @@ -25,6 +25,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -34,18 +202,18 @@ - + - + @@ -155,35 +323,35 @@ L2 - + - + - + - + - + - + @@ -528,6 +696,161 @@ L2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -567,25 +890,25 @@ L2 - + - + - + - + - + - + - + - + @@ -639,10 +962,10 @@ L2 - + - + @@ -653,7 +976,7 @@ L2 - + - + @@ -692,7 +1015,7 @@ L2 - + - +