Skip to content
Snippets Groups Projects
Commit a076b6fe authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Implemented inviting a friend sharing deeplink

parent 88a60d85
No related branches found
No related tags found
3 merge requests!71Releasing v1.1.5 (214),!67v1.1.5 b(203),!59Invite friends
...@@ -9,6 +9,7 @@ public enum MenuItem { ...@@ -9,6 +9,7 @@ public enum MenuItem {
case join case join
case scan case scan
case chats case chats
case share
case profile case profile
case contacts case contacts
case requests case requests
...@@ -171,6 +172,19 @@ public final class MenuController: UIViewController { ...@@ -171,6 +172,19 @@ public final class MenuController: UIViewController {
} }
}.store(in: &cancellables) }.store(in: &cancellables)
screenView.shareButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
dismiss(animated: true) { [weak self] in
guard let self = self, self.previousItem != .share else { return }
self.coordinator.toActivityController(
with: [Localized.Menu.shareContent(self.viewModel.referralDeeplink)],
from: self.previousController
)
}
}.store(in: &cancellables)
viewModel.requestCount viewModel.requestCount
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [weak screenView] in screenView?.requestsButton.updateNotification($0) } .sink { [weak screenView] in screenView?.requestsButton.updateNotification($0) }
......
...@@ -4,9 +4,11 @@ import Presentation ...@@ -4,9 +4,11 @@ import Presentation
public protocol MenuCoordinating { public protocol MenuCoordinating {
func toFlow(_ item: MenuItem, from: UIViewController) func toFlow(_ item: MenuItem, from: UIViewController)
func toDrawer(_: UIViewController, from: UIViewController) func toDrawer(_: UIViewController, from: UIViewController)
func toActivityController(with: [Any], from: UIViewController)
} }
public struct MenuCoordinator: MenuCoordinating { public struct MenuCoordinator: MenuCoordinating {
var modalPresenter: Presenting = ModalPresenter()
var bottomPresenter: Presenting = BottomPresenter() var bottomPresenter: Presenting = BottomPresenter()
var replacePresenter: Presenting = ReplacePresenter() var replacePresenter: Presenting = ReplacePresenter()
...@@ -16,6 +18,8 @@ public struct MenuCoordinator: MenuCoordinating { ...@@ -16,6 +18,8 @@ public struct MenuCoordinator: MenuCoordinating {
var settingsFactory: () -> UIViewController var settingsFactory: () -> UIViewController
var contactsFactory: () -> UIViewController var contactsFactory: () -> UIViewController
var requestsFactory: () -> UIViewController var requestsFactory: () -> UIViewController
var activityControllerFactory: ([Any]) -> UIViewController
= { UIActivityViewController(activityItems: $0, applicationActivities: nil) }
public init( public init(
scanFactory: @escaping () -> UIViewController, scanFactory: @escaping () -> UIViewController,
...@@ -61,4 +65,9 @@ public extension MenuCoordinator { ...@@ -61,4 +65,9 @@ public extension MenuCoordinator {
replacePresenter.present(controller, from: parent) replacePresenter.present(controller, from: parent)
} }
func toActivityController(with items: [Any], from parent: UIViewController) {
let screen = activityControllerFactory(items)
modalPresenter.present(screen, from: parent)
}
} }
...@@ -40,4 +40,8 @@ final class MenuViewModel { ...@@ -40,4 +40,8 @@ final class MenuViewModel {
var version: String { var version: String {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
} }
var referralDeeplink: String {
"xxmessenger://invitation-\(username)"
}
} }
...@@ -2,31 +2,33 @@ import UIKit ...@@ -2,31 +2,33 @@ import UIKit
import Shared import Shared
final class MenuView: UIView { final class MenuView: UIView {
let headerView = MenuHeaderView() let buildLabel = UILabel()
let versionLabel = UILabel()
let stackView = UIStackView() let stackView = UIStackView()
let xxdkVersionLabel = UILabel()
let infoStackView = UIStackView()
let headerView = MenuHeaderView()
let joinButton = MenuSectionButton()
let scanButton = MenuSectionButton() let scanButton = MenuSectionButton()
let shareButton = MenuSectionButton()
let chatsButton = MenuSectionButton() let chatsButton = MenuSectionButton()
let contactsButton = MenuSectionButton() let contactsButton = MenuSectionButton()
let requestsButton = MenuSectionButton() let requestsButton = MenuSectionButton()
let settingsButton = MenuSectionButton() let settingsButton = MenuSectionButton()
let dashboardButton = MenuSectionButton() let dashboardButton = MenuSectionButton()
let joinButton = MenuSectionButton()
let infoStackView = UIStackView()
let buildLabel = UILabel()
let versionLabel = UILabel()
let xxdkVersionLabel = UILabel()
init() { init() {
super.init(frame: .zero) super.init(frame: .zero)
backgroundColor = Asset.neutralDark.color backgroundColor = Asset.neutralDark.color
chatsButton.set(title: Localized.Menu.chats, image: Asset.menuChats.image)
scanButton.set(title: Localized.Menu.scan, image: Asset.menuScan.image) scanButton.set(title: Localized.Menu.scan, image: Asset.menuScan.image)
shareButton.set(title: Localized.Menu.share, image: Asset.menuShare.image)
chatsButton.set(title: Localized.Menu.chats, image: Asset.menuChats.image)
joinButton.set(title: Localized.Menu.join, image: Asset.permissionLogo.image)
requestsButton.set(title: Localized.Menu.requests, image: Asset.menuRequests.image) requestsButton.set(title: Localized.Menu.requests, image: Asset.menuRequests.image)
contactsButton.set(title: Localized.Menu.contacts, image: Asset.menuContacts.image) contactsButton.set(title: Localized.Menu.contacts, image: Asset.menuContacts.image)
settingsButton.set(title: Localized.Menu.settings, image: Asset.menuSettings.image) settingsButton.set(title: Localized.Menu.settings, image: Asset.menuSettings.image)
dashboardButton.set(title: Localized.Menu.dashboard, image: Asset.menuDashboard.image) dashboardButton.set(title: Localized.Menu.dashboard, image: Asset.menuDashboard.image)
joinButton.set(title: "Join xx network", image: Asset.permissionLogo.image)
stackView.addArrangedSubview(chatsButton) stackView.addArrangedSubview(chatsButton)
stackView.addArrangedSubview(contactsButton) stackView.addArrangedSubview(contactsButton)
...@@ -35,6 +37,7 @@ final class MenuView: UIView { ...@@ -35,6 +37,7 @@ final class MenuView: UIView {
stackView.addArrangedSubview(settingsButton) stackView.addArrangedSubview(settingsButton)
stackView.addArrangedSubview(dashboardButton) stackView.addArrangedSubview(dashboardButton)
stackView.addArrangedSubview(joinButton) stackView.addArrangedSubview(joinButton)
stackView.addArrangedSubview(shareButton)
infoStackView.spacing = 10 infoStackView.spacing = 10
infoStackView.axis = .vertical infoStackView.axis = .vertical
...@@ -59,17 +62,17 @@ final class MenuView: UIView { ...@@ -59,17 +62,17 @@ final class MenuView: UIView {
func select(item: MenuItem) { func select(item: MenuItem) {
switch item { switch item {
case .scan:
scanButton.set(color: Asset.brandPrimary.color)
case .chats: case .chats:
chatsButton.set(color: Asset.brandPrimary.color) chatsButton.set(color: Asset.brandPrimary.color)
case .contacts: case .contacts:
contactsButton.set(color: Asset.brandPrimary.color) contactsButton.set(color: Asset.brandPrimary.color)
case .requests: case .requests:
requestsButton.set(color: Asset.brandPrimary.color) requestsButton.set(color: Asset.brandPrimary.color)
case .scan:
scanButton.set(color: Asset.brandPrimary.color)
case .settings: case .settings:
settingsButton.set(color: Asset.brandPrimary.color) settingsButton.set(color: Asset.brandPrimary.color)
case .profile, .dashboard, .join: default:
break break
} }
} }
......
...@@ -70,6 +70,7 @@ public enum Asset { ...@@ -70,6 +70,7 @@ public enum Asset {
public static let menuRequests = ImageAsset(name: "menu_requests") public static let menuRequests = ImageAsset(name: "menu_requests")
public static let menuScan = ImageAsset(name: "menu_scan") public static let menuScan = ImageAsset(name: "menu_scan")
public static let menuSettings = ImageAsset(name: "menu_settings") public static let menuSettings = ImageAsset(name: "menu_settings")
public static let menuShare = ImageAsset(name: "menu_share")
public static let onboardingBackground = ImageAsset(name: "onboarding_background") public static let onboardingBackground = ImageAsset(name: "onboarding_background")
public static let onboardingBottomLogoStart = ImageAsset(name: "onboarding_bottom_logo_start") public static let onboardingBottomLogoStart = ImageAsset(name: "onboarding_bottom_logo_start")
public static let onboardingEmail = ImageAsset(name: "onboarding_email") public static let onboardingEmail = ImageAsset(name: "onboarding_email")
......
...@@ -633,6 +633,8 @@ public enum Localized { ...@@ -633,6 +633,8 @@ public enum Localized {
public static let contacts = Localized.tr("Localizable", "menu.contacts") public static let contacts = Localized.tr("Localizable", "menu.contacts")
/// Dashboard /// Dashboard
public static let dashboard = Localized.tr("Localizable", "menu.dashboard") public static let dashboard = Localized.tr("Localizable", "menu.dashboard")
/// Join xx network
public static let join = Localized.tr("Localizable", "menu.join")
/// Profile /// Profile
public static let profile = Localized.tr("Localizable", "menu.profile") public static let profile = Localized.tr("Localizable", "menu.profile")
/// Requests /// Requests
...@@ -641,6 +643,16 @@ public enum Localized { ...@@ -641,6 +643,16 @@ public enum Localized {
public static let scan = Localized.tr("Localizable", "menu.scan") public static let scan = Localized.tr("Localizable", "menu.scan")
/// Settings /// Settings
public static let settings = Localized.tr("Localizable", "menu.settings") public static let settings = Localized.tr("Localizable", "menu.settings")
/// Share my profile
public static let share = Localized.tr("Localizable", "menu.share")
/// Hi, I'm using xx messenger, you can download it here:
/// https://invite.xx.network
///
/// And you can add me using this link:
/// %@
public static func shareContent(_ p1: Any) -> String {
return Localized.tr("Localizable", "menu.shareContent", String(describing: p1))
}
/// Hello /// Hello
public static let title = Localized.tr("Localizable", "menu.title") public static let title = Localized.tr("Localizable", "menu.title")
/// Version %@ /// Version %@
......
{
"images" : [
{
"filename" : "Icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
File added
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
= "Connections"; = "Connections";
"menu.requests" "menu.requests"
= "Requests"; = "Requests";
"menu.join"
= "Join xx network";
"menu.share"
= "Share my profile";
"menu.viewProfile" "menu.viewProfile"
= "View Profile"; = "View Profile";
"menu.profile" "menu.profile"
...@@ -22,6 +26,8 @@ ...@@ -22,6 +26,8 @@
= "Build %@"; = "Build %@";
"menu.version" "menu.version"
= "Version %@"; = "Version %@";
"menu.shareContent"
= "Hi, I'm using xx messenger, you can download it here:\nhttps://invite.xx.network\n\nAnd you can add me using this link:\n%@";
// ChatListFeature // ChatListFeature
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment