Skip to content

Commit

Permalink
Merge pull request #1674 from nextcloud/new-one-to-one-room-creation-…
Browse files Browse the repository at this point in the history
…flow

New one to one conversation creation flow
  • Loading branch information
Ivansss authored Jun 11, 2024
2 parents 9870ffb + 1b77836 commit dcf1bb3
Show file tree
Hide file tree
Showing 13 changed files with 433 additions and 54 deletions.
8 changes: 8 additions & 0 deletions NextcloudTalk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
2C1EF36B25505DCE007C9768 /* NCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1EF36A25505DCE007C9768 /* NCNavigationController.m */; };
2C1EF36D25505DCE007C9768 /* NCNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1EF36A25505DCE007C9768 /* NCNavigationController.m */; };
2C21446E2BB5B54D005A6537 /* BaseChatTableViewCell+Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C21446D2BB5B54D005A6537 /* BaseChatTableViewCell+Location.swift */; };
2C2145682BF6B8E900470C0C /* NewRoomTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2145672BF6B8E900470C0C /* NewRoomTableViewController.swift */; };
2C2A788E2359CC8800EEB797 /* NCAppBranding.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A788D2359CC8800EEB797 /* NCAppBranding.m */; };
2C2D7A172B8C9C0000642373 /* RoomCreationTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2D7A162B8C9C0000642373 /* RoomCreationTableViewController.swift */; };
2C2E64251F3462AF00D39CE8 /* NCSignalingMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C2E64241F3462AF00D39CE8 /* NCSignalingMessage.m */; };
Expand Down Expand Up @@ -530,6 +531,7 @@
2CC7158C20B8394A0045C789 /* PlaceholderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CC7158B20B8394A0045C789 /* PlaceholderView.m */; };
2CC7159420C54D080045C789 /* ChatTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CC7159320C54D080045C789 /* ChatTableViewCell.m */; };
2CCCD21D2835088F00F076CE /* OpenSSL in Frameworks */ = {isa = PBXBuildFile; productRef = 2CCCD21C2835088F00F076CE /* OpenSSL */; };
2CD4F6B72C11C80600ED594F /* ContactsSearchResultTableViewContoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD4F6B62C11C80600ED594F /* ContactsSearchResultTableViewContoller.swift */; };
2CD5F3242142781A006B71BF /* NCExternalSignalingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CD5F3232142781A006B71BF /* NCExternalSignalingController.m */; };
2CD80F482A4304AD00919057 /* OpenConversationsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CD80F472A4304AD00919057 /* OpenConversationsTableViewController.swift */; };
2CEDA88C26F492610044552B /* NSMutableAttributedString+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEDA88B26F492610044552B /* NSMutableAttributedString+Extensions.swift */; };
Expand Down Expand Up @@ -807,6 +809,7 @@
2C1EF36925505DCE007C9768 /* NCNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCNavigationController.h; sourceTree = "<group>"; };
2C1EF36A25505DCE007C9768 /* NCNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NCNavigationController.m; sourceTree = "<group>"; };
2C21446D2BB5B54D005A6537 /* BaseChatTableViewCell+Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseChatTableViewCell+Location.swift"; sourceTree = "<group>"; };
2C2145672BF6B8E900470C0C /* NewRoomTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewRoomTableViewController.swift; sourceTree = "<group>"; };
2C2A788C2359CC8800EEB797 /* NCAppBranding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCAppBranding.h; sourceTree = "<group>"; };
2C2A788D2359CC8800EEB797 /* NCAppBranding.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NCAppBranding.m; sourceTree = "<group>"; };
2C2D7A162B8C9C0000642373 /* RoomCreationTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomCreationTableViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1083,6 +1086,7 @@
2CC7158B20B8394A0045C789 /* PlaceholderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PlaceholderView.m; sourceTree = "<group>"; };
2CC7159220C54D080045C789 /* ChatTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChatTableViewCell.h; sourceTree = "<group>"; };
2CC7159320C54D080045C789 /* ChatTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChatTableViewCell.m; sourceTree = "<group>"; };
2CD4F6B62C11C80600ED594F /* ContactsSearchResultTableViewContoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsSearchResultTableViewContoller.swift; sourceTree = "<group>"; };
2CD5F3222142781A006B71BF /* NCExternalSignalingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCExternalSignalingController.h; sourceTree = "<group>"; };
2CD5F3232142781A006B71BF /* NCExternalSignalingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NCExternalSignalingController.m; sourceTree = "<group>"; };
2CD80F472A4304AD00919057 /* OpenConversationsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenConversationsTableViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1609,6 +1613,7 @@
1F3C41A029EDAC8800F58435 /* RoomAvatarInfoTableViewController.xib */,
2CD80F472A4304AD00919057 /* OpenConversationsTableViewController.swift */,
2C2D7A162B8C9C0000642373 /* RoomCreationTableViewController.swift */,
2C2145672BF6B8E900470C0C /* NewRoomTableViewController.swift */,
);
name = Rooms;
sourceTree = "<group>";
Expand All @@ -1634,6 +1639,7 @@
2C1ABDC5257A7CF000AEDFB6 /* NCContactsManager.m */,
2C1ABDE3257F883400AEDFB6 /* ABContact.h */,
2C1ABDE4257F883400AEDFB6 /* ABContact.m */,
2CD4F6B62C11C80600ED594F /* ContactsSearchResultTableViewContoller.swift */,
);
name = Contacts;
sourceTree = "<group>";
Expand Down Expand Up @@ -2714,6 +2720,7 @@
DA755811278EF3EF00A48A1B /* UserSettingsTableViewCell.swift in Sources */,
1FA38C9029A4B3C6008871B8 /* NCNotificationAction.swift in Sources */,
2C44B4D127FF05A000AD1C86 /* ReactionsSummaryView.swift in Sources */,
2CD4F6B72C11C80600ED594F /* ContactsSearchResultTableViewContoller.swift in Sources */,
1F35F8FB2AEEDBC600044BDA /* ChatViewControllerExtension.swift in Sources */,
2CC007B420D7AE990096D91F /* ResultMultiSelectionTableViewController.m in Sources */,
2CA1CCC31F166CC5002FE6A2 /* NCRoom.m in Sources */,
Expand Down Expand Up @@ -2757,6 +2764,7 @@
2C9B0B9C217F756B00A4752C /* NCNotification.m in Sources */,
2C2D7A172B8C9C0000642373 /* RoomCreationTableViewController.swift in Sources */,
1F8995B52973547700CABA33 /* WebRTCCommon.swift in Sources */,
2C2145682BF6B8E900470C0C /* NewRoomTableViewController.swift in Sources */,
1F1B503E2B8FB12100B0F2F4 /* BaseChatTableViewCell+Message.swift in Sources */,
DA66583127B6B24E00B46B11 /* UserProfileTableViewController+Utils.swift in Sources */,
1F1B0F422BE047CE003FD766 /* UIViewController+Transitions.swift in Sources */,
Expand Down
109 changes: 109 additions & 0 deletions NextcloudTalk/ContactsSearchResultTableViewContoller.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// Copyright (c) 2024 Ivan Sein <[email protected]>
//
// Author Ivan Sein <[email protected]>
//
// GNU GPL version 3 or any later version
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

import UIKit

@objcMembers class ContactsSearchResultTableViewController: UITableViewController {

var indexes: [String] = []
var contacts: [String: [NCUser]] = [:]

let tableBackgroundView = PlaceholderView(for: .insetGrouped)!

override init(style: UITableView.Style) {
super.init(style: style)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()

self.tableView.register(UINib(nibName: kContactsTableCellNibName, bundle: nil), forCellReuseIdentifier: kContactCellIdentifier)

tableBackgroundView.setImage(UIImage(named: "contacts-placeholder"))
tableBackgroundView.placeholderTextView.text = NSLocalizedString("No results found", comment: "")
self.showSearchingUI()
self.tableView.backgroundView = tableBackgroundView

}

// MARK: - UI

func showSearchingUI() {
tableBackgroundView.placeholderView.isHidden = true
tableBackgroundView.loadingView.startAnimating()
tableBackgroundView.loadingView.isHidden = false
}

func hideSearchingUI() {
tableBackgroundView.loadingView.stopAnimating()
tableBackgroundView.loadingView.isHidden = true
}

func setContacts(_ contacts:[String: [NCUser]], indexes:[String]) {
self.contacts = contacts
self.indexes = indexes
self.tableView.reloadData()
}

func setSearchResultContacts(_ contacts:[String: [NCUser]], indexes:[String]) {
self.hideSearchingUI()
self.tableBackgroundView.placeholderView.isHidden = !contacts.isEmpty
self.setContacts(contacts, indexes: indexes)
}

// MARK: - TableView

override func numberOfSections(in tableView: UITableView) -> Int {
return indexes.count
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return indexes[section]
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let index = indexes[section]
return contacts[index]?.count ?? 0
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let index = indexes[indexPath.section]
let contactsForIndex = contacts[index]
guard let contact = contactsForIndex?[indexPath.row] else {
return UITableViewCell()
}

let contactCell = tableView.dequeueReusableCell(withIdentifier: kContactCellIdentifier) as? ContactsTableViewCell ??
ContactsTableViewCell(style: .default, reuseIdentifier: kContactCellIdentifier)

contactCell.labelTitle.text = contact.name

let contactType = contact.source as String
contactCell.contactImage.setActorAvatar(forId: contact.userId, withType: contactType, withDisplayName: contact.name, withRoomToken: nil)

return contactCell
}
}
2 changes: 1 addition & 1 deletion NextcloudTalk/NCAPIControllerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import Foundation
}
}

public func createRoom(forAccount account: TalkAccount, withInvite invite: String?, ofType roomType: NCRoomType, andName roomName: String?, completionBlock: @escaping (_ rooms: NCRoom?, _ error: Error?) -> Void) {
public func createRoom(forAccount account: TalkAccount, withInvite invite: String?, ofType roomType: NCRoomType, andName roomName: String?, completionBlock: @escaping (_ room: NCRoom?, _ error: Error?) -> Void) {
guard let apiSessionManager = self.apiSessionManagers.object(forKey: account.accountId) as? NCAPISessionManager
else { return }

Expand Down
4 changes: 4 additions & 0 deletions NextcloudTalk/NCAppBranding.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ + (void)styleViewController:(UIViewController *)controller {
[controller.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[NCAppBranding themeTextColor]}];
controller.navigationController.navigationBar.barTintColor = [NCAppBranding themeColor];
controller.navigationController.navigationBar.tintColor = [NCAppBranding themeTextColor];
controller.navigationController.navigationBar.translucent = NO;
controller.tabBarController.tabBar.tintColor = [NCAppBranding themeColor];

UIColor *themeColor = [NCAppBranding themeColor];
Expand All @@ -239,6 +240,9 @@ + (void)styleViewController:(UIViewController *)controller {
controller.navigationItem.standardAppearance = appearance;
controller.navigationItem.compactAppearance = appearance;
controller.navigationItem.scrollEdgeAppearance = appearance;

// Fix uisearchcontroller animation
controller.extendedLayoutIncludesOpaqueBars = YES;
}

@end
4 changes: 3 additions & 1 deletion NextcloudTalk/NCContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#import <Foundation/Foundation.h>
#import <Realm/Realm.h>

@class NCUser;

@interface NCContact : RLMObject

@property (nonatomic, copy) NSString *internalId; // accountId@identifier
Expand All @@ -33,7 +35,7 @@

+ (instancetype)contactWithIdentifier:(NSString *)identifier cloudId:(NSString *)cloudId lastUpdate:(NSInteger)lastUpdate andAccountId:(NSString *)accountId;
+ (void)updateContact:(NCContact *)managedContact withContact:(NCContact *)contact;
+ (NSMutableArray *)contactsForAccountId:(NSString *)accountId contains:(NSString *)searchString;
+ (NSArray<NCUser *> *)contactsForAccountId:(NSString *)accountId contains:(NSString * _Nullable)searchString;
- (NSString *)userId;
- (NSString *)name;

Expand Down
2 changes: 1 addition & 1 deletion NextcloudTalk/NCContact.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ - (NSString *)name
return nil;
}

+ (NSMutableArray *)contactsForAccountId:(NSString *)accountId contains:(NSString *)searchString
+ (NSArray<NCUser *> *)contactsForAccountId:(NSString *)accountId contains:(NSString *)searchString
{
RLMResults *managedContacts = [NCContact objectsWhere:@"accountId = %@", accountId];
NSMutableArray *filteredContacts = nil;
Expand Down
4 changes: 2 additions & 2 deletions NextcloudTalk/NCUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ extern NSString * const kParticipantTypeFederated;
+ (instancetype)userWithDictionary:(NSDictionary *)userDict;
+ (instancetype)userFromNCContact:(NCContact *)contact;

+ (NSMutableDictionary *)indexedUsersFromUsersArray:(NSArray *)users;
+ (NSDictionary<NSString *, NSArray<NCUser *> *> *)indexedUsersFromUsersArray:(NSArray *)users;
// Duplicate users found in second array will be deleted
+ (NSMutableArray *)combineUsersArray:(NSArray *)firstArray withUsersArray:(NSArray *)secondArray;
+ (NSArray<NCUser *> *)combineUsersArray:(NSArray *)firstArray withUsersArray:(NSArray *)secondArray;

@end
4 changes: 2 additions & 2 deletions NextcloudTalk/NCUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ + (instancetype)userFromNCContact:(NCContact *)contact
return user;
}

+ (NSMutableDictionary *)indexedUsersFromUsersArray:(NSArray *)users
+ (NSDictionary<NSString *, NSArray<NCUser *> *> *)indexedUsersFromUsersArray:(NSArray *)users
{
NSMutableDictionary *indexedUsers = [[NSMutableDictionary alloc] init];
for (NCUser *user in users) {
Expand All @@ -100,7 +100,7 @@ + (NSMutableDictionary *)indexedUsersFromUsersArray:(NSArray *)users
return indexedUsers;
}

+ (NSMutableArray *)combineUsersArray:(NSArray *)firstArray withUsersArray:(NSArray *)secondArray
+ (NSArray<NCUser *> *)combineUsersArray:(NSArray *)firstArray withUsersArray:(NSArray *)secondArray
{
// Add first array of users
NSMutableArray *combinedUserArray = [[NSMutableArray alloc] initWithArray:firstArray];
Expand Down
Loading

0 comments on commit dcf1bb3

Please sign in to comment.