Skip to content

Commit

Permalink
Add entry to share contact (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Aug 29, 2024
1 parent 17f7309 commit 527865c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
17 changes: 17 additions & 0 deletions deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class ContactDetailViewController: UITableViewController {
return cell
}()

private lazy var shareContactCell: ActionCell = {
let cell = ActionCell()
cell.actionTitle = String.localized("menu_share")
cell.actionColor = UIColor.systemBlue
return cell
}()

private lazy var ephemeralMessagesCell: UITableViewCell = {
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
cell.textLabel?.text = String.localized("ephemeral_messages")
Expand Down Expand Up @@ -199,6 +206,8 @@ class ContactDetailViewController: UITableViewController {
}
case .statusArea:
return statusCell
case .shareContact:
return shareContactCell
case .chatActions:
switch viewModel.chatActionFor(row: row) {
case .archiveChat:
Expand Down Expand Up @@ -229,12 +238,15 @@ class ContactDetailViewController: UITableViewController {
handleChatOption(indexPath: indexPath)
case .statusArea:
break
case .shareContact:
shareContact()
case .chatActions:
handleChatAction(indexPath: indexPath)
case .sharedChats:
let chatId = viewModel.getSharedChatIdAt(indexPath: indexPath)
showChat(chatId: chatId)
}
tableView.deselectRow(at: indexPath, animated: true)
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
Expand Down Expand Up @@ -329,6 +341,11 @@ class ContactDetailViewController: UITableViewController {
}

// MARK: - actions
@objc private func shareContact() {
// compare to `forward`.
// 1. select chat you want to forward this contact to.
// 2. stage this very contacts vcard
}

@objc private func showCopyToClipboard() {
UIMenuController.shared.menuItems = [
Expand Down
11 changes: 6 additions & 5 deletions deltachat-ios/ViewModel/ContactDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ContactDetailViewModel {
enum ProfileSections {
case chatOptions
case statusArea
case shareContact
case sharedChats
case chatActions
}
Expand Down Expand Up @@ -72,6 +73,8 @@ class ContactDetailViewModel {
sections.append(.statusArea)
}

sections.append(.shareContact)

if sharedChats.length > 0 && !isSavedMessages && !isDeviceTalk {
sections.append(.sharedChats)
}
Expand Down Expand Up @@ -142,7 +145,7 @@ class ContactDetailViewModel {
func numberOfRowsInSection(_ section: Int) -> Int {
switch sections[section] {
case .chatOptions: return chatOptions.count
case .statusArea: return 1
case .statusArea, .shareContact: return 1
case .sharedChats: return sharedChats.length
case .chatActions: return chatActions.count
}
Expand Down Expand Up @@ -177,7 +180,7 @@ class ContactDetailViewModel {

func titleFor(section: Int) -> String? {
switch sections[section] {
case .chatOptions: return nil
case .chatOptions, .shareContact: return nil
case .statusArea: return (isSavedMessages || isDeviceTalk) ? nil : String.localized("pref_default_status_label")
case .sharedChats: return String.localized("profile_shared_chats")
case .chatActions: return nil
Expand All @@ -195,9 +198,7 @@ class ContactDetailViewModel {
return String.localizedStringWithFormat(String.localized("last_seen_at"), DateUtils.getExtendedAbsTimeSpanString(timeStamp: Double(lastSeen)))
}

case .statusArea: return nil
case .sharedChats: return nil
case .chatActions: return nil
case .statusArea, .sharedChats, .chatActions, .shareContact: return nil
}
}

Expand Down

0 comments on commit 527865c

Please sign in to comment.