Skip to content

Commit

Permalink
Merge tag 'Ent_TestFlight_8.9.2208'
Browse files Browse the repository at this point in the history
  • Loading branch information
FrPellissier committed Oct 4, 2023
2 parents d88d170 + 2f9086b commit 2ba0168
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 103 deletions.
3 changes: 3 additions & 0 deletions entourage.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion entourage/MainTabbarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MainTabbarViewController: UITabBarController {

@objc func showMyEvents() {
if let vc = eventsVC.topViewController as? EventMainHomeViewController {
vc.setMyFirst()
vc.setDiscoverFirst()
}
self.selectedIndex = 4
self.boldSelectedItem()
Expand Down
18 changes: 15 additions & 3 deletions entourage/Managers/DeeplinkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,21 @@ struct DeepLinkManager {
}

static func showContribListUniversalLink() {
if let vc = AppState.getTopViewController(){
if let _tabbar = vc.tabBarController as? MainTabbarViewController {
_tabbar.showActionsContrib()
if let vc = AppState.getTopViewController() {
// Verifier si le viewController est présenté comme modal
if vc.isModal {
// Fermer le modal avant de lancer la commande
vc.dismiss(animated: true) {
if let _vc = AppState.getTopViewController() {
if let _tabbar = _vc.tabBarController as? MainTabbarViewController {
_tabbar.showActionsContrib()
}
}
}
} else {
if let _tabbar = vc.tabBarController as? MainTabbarViewController {
_tabbar.showActionsContrib()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,15 @@ class NeighborhoodDetailMessagesViewController: UIViewController {
self.ui_textview_message.text = nil
ui_iv_bt_send.image = UIImage.init(named: "ic_send_comment_off")
NeighborhoodService.postCommentFor(neighborhoodId: neighborhoodId, parentPostId: parentCommentId, message: message) { error in

if error == nil {
if isRetry {
self.messagesForRetry.remove(at: positionForRetry)
// Ensure positionForRetry is in valid range before removing from array
if positionForRetry >= 0 && positionForRetry < self.messagesForRetry.count {
self.messagesForRetry.remove(at: positionForRetry)
} else {
print("Error: positionForRetry out of range. Value: \(positionForRetry), Array Count: \(self.messagesForRetry.count)")
}
}
self.getMessages()
return
Expand All @@ -181,13 +186,13 @@ class NeighborhoodDetailMessagesViewController: UIViewController {
postMsg.content = message
postMsg.user = UserLightNeighborhood()
postMsg.isRetryMsg = true

self.messagesForRetry.append(postMsg)

self.isStartEditing = false
self.ui_view_empty.isHidden = true
self.ui_tableview.reloadData()

if self.messages.count + self.messagesForRetry.count > 0 {
DispatchQueue.main.async {
let indexPath = IndexPath(row: self.messages.count + self.messagesForRetry.count - 1, section: 0)
Expand All @@ -197,6 +202,7 @@ class NeighborhoodDetailMessagesViewController: UIViewController {
}
}
}


func getDetailPost() {
NeighborhoodService.getDetailPostMessage(neighborhoodId: neighborhoodId, parentPostId: parentCommentId) { message, error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,80 +482,100 @@ extension NeighborhoodDetailViewController: UITableViewDataSource, UITableViewDe
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let neighborhood = self.neighborhood else {
return UITableViewCell()
}

if indexPath.section == 0 {
if indexPath.row == 0 {
if self.neighborhood!.isMember && !isAfterCreation {
let cell = tableView.dequeueReusableCell(withIdentifier: NeighborhoodDetailTopMemberCell.identifier, for: indexPath) as! NeighborhoodDetailTopMemberCell
cell.populateCell(neighborhood: self.neighborhood,isFollowingGroup: true, delegate: self)
return cell
}
else {
let cell = tableView.dequeueReusableCell(withIdentifier: NeighborhoodDetailTopCell.identifier, for: indexPath) as! NeighborhoodDetailTopCell
cell.populateCell(neighborhood: self.neighborhood, isFollowingGroup: false, delegate: self)
return cell
let isMember = neighborhood.isMember && !isAfterCreation
let identifier = isMember ? NeighborhoodDetailTopMemberCell.identifier : NeighborhoodDetailTopCell.identifier
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)
if isMember, let memberCell = cell as? NeighborhoodDetailTopMemberCell {
memberCell.populateCell(neighborhood: neighborhood, isFollowingGroup: true, delegate: self)
} else if let topCell = cell as? NeighborhoodDetailTopCell {
topCell.populateCell(neighborhood: neighborhood, isFollowingGroup: false, delegate: self)
}
}
else {
if neighborhood?.futureEvents?.count ?? 0 > 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: NeighborhoodEventsTableviewCell.identifier, for: indexPath) as! NeighborhoodEventsTableviewCell
cell.populateCell(events:neighborhood!.futureEvents!, delegate: self)
return cell
return cell
} else {
let events = neighborhood.futureEvents ?? []
let identifier = events.count > 0 ? NeighborhoodEventsTableviewCell.identifier : NeighborhoodEmptyEventCell.identifier
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)
if events.count > 0, let eventsCell = cell as? NeighborhoodEventsTableviewCell {
eventsCell.populateCell(events: events, delegate: self)
}
let cell = tableView.dequeueReusableCell(withIdentifier: NeighborhoodEmptyEventCell.identifier, for: indexPath)
return cell
}
}
if self.neighborhood?.messages?.count ?? 0 == 0 {

if neighborhood.messages?.count ?? 0 == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: NeighborhoodEmptyPostCell.identifier, for: indexPath)
return cell
}

if hasNewAndOldSections && indexPath.section == 2 {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: EventListSectionCell.identifier, for: indexPath) as! EventListSectionCell

cell.populateCell(title: "neighborhood_post_group_section_old_posts_title".localized, isTopHeader: false)
return cell
}

let postmessage:PostMessage = messagesOld[indexPath.row - 1]
var identifier = postmessage.isPostImage ? NeighborhoodPostImageCell.identifier : NeighborhoodPostTextCell.identifier
if postmessage.status == "deleted" {
identifier = NeighborhoodPostDeletedCell.identifier
if indexPath.row - 1 < messagesOld.count {
let postmessage = messagesOld[indexPath.row - 1]
var identifier = postmessage.isPostImage ? NeighborhoodPostImageCell.identifier : NeighborhoodPostTextCell.identifier
if postmessage.status == "deleted" {
identifier = NeighborhoodPostDeletedCell.identifier
}
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! NeighborhoodPostCell
cell.populateCell(message: postmessage,delegate: self,currentIndexPath: indexPath, userId: postmessage.user?.sid)
return cell
} else {
return UITableViewCell()
}
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! NeighborhoodPostCell
cell.populateCell(message: postmessage,delegate: self,currentIndexPath: indexPath, userId: postmessage.user?.sid)
return cell
}

if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: EventListSectionCell.neighborhoodHeaderIdentifier, for: indexPath) as! EventListSectionCell
cell.populateCell(title: "neighborhood_post_group_section_title".localized, isTopHeader: true)
return cell
}

//If not member we dont' show new/old post header

let countToAdd = countToAdd()
if countToAdd == 2 {
if indexPath.row == 1 {
let titleSection = hasNewAndOldSections || self.messagesOld.count == 0 ? "neighborhood_post_group_section_new_posts_title".localized : "neighborhood_post_group_section_old_posts_title".localized

let cell = tableView.dequeueReusableCell(withIdentifier: EventListSectionCell.identifier, for: indexPath) as! EventListSectionCell
cell.populateCell(title: titleSection , isTopHeader: false)
if countToAdd == 2 && indexPath.row == 1 {
let titleSection = hasNewAndOldSections || self.messagesOld.count == 0 ? "neighborhood_post_group_section_new_posts_title".localized : "neighborhood_post_group_section_old_posts_title".localized

let cell = tableView.dequeueReusableCell(withIdentifier: EventListSectionCell.identifier, for: indexPath) as! EventListSectionCell
cell.populateCell(title: titleSection , isTopHeader: false)
return cell
}

if hasNewAndOldSections {
if indexPath.row - countToAdd < self.messagesNew.count {
let postmessage = self.messagesNew[indexPath.row - countToAdd]
var identifier = postmessage.isPostImage ? NeighborhoodPostImageCell.identifier : NeighborhoodPostTextCell.identifier
if postmessage.status == "deleted" {
identifier = NeighborhoodPostDeletedCell.identifier
}
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! NeighborhoodPostCell
cell.populateCell(message: postmessage,delegate: self,currentIndexPath: indexPath, userId: postmessage.user?.sid)
return cell
} else {
return UITableViewCell()
}
}

let postmessage:PostMessage = hasNewAndOldSections ? self.messagesNew[indexPath.row - countToAdd] : self.neighborhood!.messages![indexPath.row - countToAdd]

var identifier = postmessage.isPostImage ? NeighborhoodPostImageCell.identifier : NeighborhoodPostTextCell.identifier
if postmessage.status == "deleted" {
identifier = NeighborhoodPostDeletedCell.identifier

if let messages = neighborhood.messages, indexPath.row - countToAdd < messages.count {
let postmessage = messages[indexPath.row - countToAdd]
var identifier = postmessage.isPostImage ? NeighborhoodPostImageCell.identifier : NeighborhoodPostTextCell.identifier
if postmessage.status == "deleted" {
identifier = NeighborhoodPostDeletedCell.identifier
}
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! NeighborhoodPostCell
cell.populateCell(message: postmessage,delegate: self,currentIndexPath: indexPath, userId: postmessage.user?.sid)
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath) as! NeighborhoodPostCell
cell.populateCell(message: postmessage,delegate: self,currentIndexPath: indexPath, userId: postmessage.user?.sid)
return cell

return UITableViewCell()
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,69 +558,76 @@ class NeighborhoodHomeViewController: UIViewController {
extension NeighborhoodHomeViewController: UITableViewDataSource, UITableViewDelegate {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (isGroupsSelected && myNeighborhoods.isEmpty && !isfirstLoadingMyGroup) || (isSearch && neighborhoodsSearch.isEmpty && isSendedSearch) || (!isGroupsSelected && neighborhoodsDiscovered.isEmpty) {
// showEmptyView()
}
else {
hideEmptyView()
if (isGroupsSelected && myNeighborhoods.isEmpty && !isfirstLoadingMyGroup) || (isSearch && neighborhoodsSearch.isEmpty && isSendedSearch) || (!isGroupsSelected && neighborhoodsDiscovered.isEmpty) {
// showEmptyView()
}
else {
hideEmptyView()
}

return isGroupsSelected ? myNeighborhoods.count : isSearch ? neighborhoodsSearch.count + 1 : neighborhoodsDiscovered.count + 1 //Search
}

return isGroupsSelected ? myNeighborhoods.count : isSearch ? neighborhoodsSearch.count + 1 : neighborhoodsDiscovered.count + 1 //Search
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if isGroupsSelected {
let neighborhood = myNeighborhoods[indexPath.row]

var cellName = "cellGroup"

if neighborhood.creator.uid == UserDefaults.currentUser?.sid {
cellName = "cellGroupMy"
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if isGroupsSelected {
guard let neighborhood = myNeighborhoods[safe: indexPath.row] else {
return UITableViewCell()
}

let cellName = (neighborhood.creator.uid == UserDefaults.currentUser?.sid) ? "cellGroupMy" : "cellGroup"

guard let cell = tableView.dequeueReusableCell(withIdentifier: cellName, for: indexPath) as? NeighborhoodHomeGroupCell else {
return UITableViewCell()
}

cell.populateCell(neighborhood: neighborhood)

return cell
}

let cell = tableView.dequeueReusableCell(withIdentifier: cellName, for: indexPath) as! NeighborhoodHomeGroupCell
if indexPath.row == 0 {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "cellSearch", for: indexPath) as? NeighborhoodHomeSearchCell else {
return UITableViewCell()
}

cell.populateCell(delegate: self, isSearch:isSearch,isCellUserSearch: false)

return cell
}

guard let cell = tableView.dequeueReusableCell(withIdentifier: "cellGroup", for: indexPath) as? NeighborhoodHomeGroupCell,
let neighborhood = isSearch ? neighborhoodsSearch[safe: indexPath.row - 1] : neighborhoodsDiscovered[safe: indexPath.row - 1] else {
return UITableViewCell()
}

cell.populateCell(neighborhood: neighborhood)

return cell
}

if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellSearch", for: indexPath) as! NeighborhoodHomeSearchCell

cell.populateCell(delegate: self, isSearch:isSearch,isCellUserSearch: false)

return cell
}

let cell = tableView.dequeueReusableCell(withIdentifier: "cellGroup", for: indexPath)as! NeighborhoodHomeGroupCell
let neighborhood = isSearch ? neighborhoodsSearch[indexPath.row - 1] : neighborhoodsDiscovered[indexPath.row - 1]
cell.populateCell(neighborhood: neighborhood)
return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var neighborhood:Neighborhood

if isGroupsSelected {
neighborhood = myNeighborhoods[indexPath.row]
AnalyticsLoggerManager.logEvent(name: Action_Group_MyGroup_Card)
}
else {
if indexPath.row == 0 { return }
neighborhood = isSearch ? neighborhoodsSearch[indexPath.row - 1] : neighborhoodsDiscovered[indexPath.row - 1]
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var neighborhood: Neighborhood?

if isSearch {
AnalyticsLoggerManager.logEvent(name: Action_Group_Search_SeeResult)
if isGroupsSelected {
neighborhood = myNeighborhoods[safe: indexPath.row]
AnalyticsLoggerManager.logEvent(name: Action_Group_MyGroup_Card)
}
else {
AnalyticsLoggerManager.logEvent(name: Action_Group_Discover_Card)
if indexPath.row == 0 { return }
neighborhood = isSearch ? neighborhoodsSearch[safe: indexPath.row - 1] : neighborhoodsDiscovered[safe: indexPath.row - 1]

if isSearch {
AnalyticsLoggerManager.logEvent(name: Action_Group_Search_SeeResult)
}
else {
AnalyticsLoggerManager.logEvent(name: Action_Group_Discover_Card)
}
}

guard let neighborhoodId = neighborhood?.uid else { return }

self.showNeighborhood(neighborhoodId: neighborhoodId, neighborhood: neighborhood)
}

self.showNeighborhood(neighborhoodId: neighborhood.uid,neighborhood:neighborhood)

}

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if isLoading { return }
Expand Down Expand Up @@ -706,3 +713,10 @@ extension NeighborhoodHomeViewController: NeighborhoodHomeSearchDelegate {
}
}
}


extension Array {
subscript(safe index: Int) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
21 changes: 21 additions & 0 deletions entourage/Tools/Extensions/Extensions_UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,24 @@ extension UIApplication {
return self.keyWindow?.rootViewController?.topFrontViewController
}
}


extension UIViewController {
var isModal: Bool {
if let navigationController = self.navigationController {
if navigationController.viewControllers.first != self {
return false
}
}
if self.presentingViewController != nil {
return true
}
if self.navigationController?.presentingViewController?.presentedViewController == self.navigationController {
return true
}
if self.tabBarController?.presentingViewController is UITabBarController {
return true
}
return false
}
}
Loading

0 comments on commit 2ba0168

Please sign in to comment.