diff --git a/Sources/MenuFeature/Controllers/MenuController.swift b/Sources/MenuFeature/Controllers/MenuController.swift index 682e23d450bde134916a2db8a00d13c2279c9321..93f1fcf4a328da1f73f077b8f0f8806ceee0c7f5 100644 --- a/Sources/MenuFeature/Controllers/MenuController.swift +++ b/Sources/MenuFeature/Controllers/MenuController.swift @@ -9,6 +9,7 @@ public enum MenuItem { case join case scan case chats + case share case profile case contacts case requests @@ -171,6 +172,19 @@ public final class MenuController: UIViewController { } }.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 .receive(on: DispatchQueue.main) .sink { [weak screenView] in screenView?.requestsButton.updateNotification($0) } diff --git a/Sources/MenuFeature/Coordinator/MenuCoordinator.swift b/Sources/MenuFeature/Coordinator/MenuCoordinator.swift index fba5c8ea4f8bfb1aa155dcf4ada8fba1a58c3f39..3e7d20cc85f6a4afa7e50e2f8133bdf041f5ace6 100644 --- a/Sources/MenuFeature/Coordinator/MenuCoordinator.swift +++ b/Sources/MenuFeature/Coordinator/MenuCoordinator.swift @@ -4,9 +4,11 @@ import Presentation public protocol MenuCoordinating { func toFlow(_ item: MenuItem, from: UIViewController) func toDrawer(_: UIViewController, from: UIViewController) + func toActivityController(with: [Any], from: UIViewController) } public struct MenuCoordinator: MenuCoordinating { + var modalPresenter: Presenting = ModalPresenter() var bottomPresenter: Presenting = BottomPresenter() var replacePresenter: Presenting = ReplacePresenter() @@ -16,6 +18,8 @@ public struct MenuCoordinator: MenuCoordinating { var settingsFactory: () -> UIViewController var contactsFactory: () -> UIViewController var requestsFactory: () -> UIViewController + var activityControllerFactory: ([Any]) -> UIViewController + = { UIActivityViewController(activityItems: $0, applicationActivities: nil) } public init( scanFactory: @escaping () -> UIViewController, @@ -61,4 +65,9 @@ public extension MenuCoordinator { replacePresenter.present(controller, from: parent) } + + func toActivityController(with items: [Any], from parent: UIViewController) { + let screen = activityControllerFactory(items) + modalPresenter.present(screen, from: parent) + } } diff --git a/Sources/MenuFeature/ViewModels/MenuViewModel.swift b/Sources/MenuFeature/ViewModels/MenuViewModel.swift index f3e4bcbd5260af8c2e62849c7eca05b4098cffe4..20f91ac91b8ab31d8c86b909529cb1a3cab2b487 100644 --- a/Sources/MenuFeature/ViewModels/MenuViewModel.swift +++ b/Sources/MenuFeature/ViewModels/MenuViewModel.swift @@ -40,4 +40,8 @@ final class MenuViewModel { var version: String { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" } + + var referralDeeplink: String { + "xxmessenger://invitation-\(username)" + } } diff --git a/Sources/MenuFeature/Views/MenuView.swift b/Sources/MenuFeature/Views/MenuView.swift index b19ec9d1d1367f5d910dfe97d40ee9198b7e3ec0..7342ced784547ec83d7f3252af4d0f8044b591ef 100644 --- a/Sources/MenuFeature/Views/MenuView.swift +++ b/Sources/MenuFeature/Views/MenuView.swift @@ -2,31 +2,33 @@ import UIKit import Shared final class MenuView: UIView { - let headerView = MenuHeaderView() + let buildLabel = UILabel() + let versionLabel = UILabel() let stackView = UIStackView() + let xxdkVersionLabel = UILabel() + let infoStackView = UIStackView() + let headerView = MenuHeaderView() + let joinButton = MenuSectionButton() let scanButton = MenuSectionButton() + let shareButton = MenuSectionButton() let chatsButton = MenuSectionButton() let contactsButton = MenuSectionButton() let requestsButton = MenuSectionButton() let settingsButton = MenuSectionButton() let dashboardButton = MenuSectionButton() - let joinButton = MenuSectionButton() - let infoStackView = UIStackView() - let buildLabel = UILabel() - let versionLabel = UILabel() - let xxdkVersionLabel = UILabel() init() { super.init(frame: .zero) backgroundColor = Asset.neutralDark.color - chatsButton.set(title: Localized.Menu.chats, image: Asset.menuChats.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) contactsButton.set(title: Localized.Menu.contacts, image: Asset.menuContacts.image) settingsButton.set(title: Localized.Menu.settings, image: Asset.menuSettings.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(contactsButton) @@ -35,6 +37,7 @@ final class MenuView: UIView { stackView.addArrangedSubview(settingsButton) stackView.addArrangedSubview(dashboardButton) stackView.addArrangedSubview(joinButton) + stackView.addArrangedSubview(shareButton) infoStackView.spacing = 10 infoStackView.axis = .vertical @@ -59,17 +62,17 @@ final class MenuView: UIView { func select(item: MenuItem) { switch item { + case .scan: + scanButton.set(color: Asset.brandPrimary.color) case .chats: chatsButton.set(color: Asset.brandPrimary.color) case .contacts: contactsButton.set(color: Asset.brandPrimary.color) case .requests: requestsButton.set(color: Asset.brandPrimary.color) - case .scan: - scanButton.set(color: Asset.brandPrimary.color) case .settings: settingsButton.set(color: Asset.brandPrimary.color) - case .profile, .dashboard, .join: + default: break } } diff --git a/Sources/Shared/AutoGenerated/Assets.swift b/Sources/Shared/AutoGenerated/Assets.swift index 6755de526a369e8245365d38a47984ea96a02e42..c55ff98183f5c8b9c3776a40a24bc8ddba91429b 100644 --- a/Sources/Shared/AutoGenerated/Assets.swift +++ b/Sources/Shared/AutoGenerated/Assets.swift @@ -70,6 +70,7 @@ public enum Asset { public static let menuRequests = ImageAsset(name: "menu_requests") public static let menuScan = ImageAsset(name: "menu_scan") 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 onboardingBottomLogoStart = ImageAsset(name: "onboarding_bottom_logo_start") public static let onboardingEmail = ImageAsset(name: "onboarding_email") diff --git a/Sources/Shared/AutoGenerated/Strings.swift b/Sources/Shared/AutoGenerated/Strings.swift index 315babf8e14569c98f9ea0f2513962566f9bfef8..1640774e563ec20094d2d9df9fc77dd118cc3f56 100644 --- a/Sources/Shared/AutoGenerated/Strings.swift +++ b/Sources/Shared/AutoGenerated/Strings.swift @@ -633,6 +633,8 @@ public enum Localized { public static let contacts = Localized.tr("Localizable", "menu.contacts") /// Dashboard public static let dashboard = Localized.tr("Localizable", "menu.dashboard") + /// Join xx network + public static let join = Localized.tr("Localizable", "menu.join") /// Profile public static let profile = Localized.tr("Localizable", "menu.profile") /// Requests @@ -641,6 +643,16 @@ public enum Localized { public static let scan = Localized.tr("Localizable", "menu.scan") /// 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 public static let title = Localized.tr("Localizable", "menu.title") /// Version %@ diff --git a/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Contents.json b/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..5c2f805eb3317d819659b5d73f14b6a1b249804f --- /dev/null +++ b/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "Icon.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Icon.pdf b/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Icon.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b09b053bb7c5bd064ae240eb8d69b92a81b85519 --- /dev/null +++ b/Sources/Shared/Resources/Assets.xcassets/AssetsMenu/menu_share.imageset/Icon.pdf @@ -0,0 +1,101 @@ +%PDF-1.7 + +1 0 obj + << >> +endobj + +2 0 obj + << /Length 3 0 R >> +stream +/DeviceRGB CS +/DeviceRGB cs +q +1.000000 0.000000 -0.000000 1.000000 5.000000 4.000000 cm +0.693500 0.711750 0.730000 scn +12.599999 1.800547 m +12.599999 4.501754 l +12.599999 4.999001 13.002944 5.402100 13.500000 5.402100 c +13.997056 5.402100 14.400000 4.999001 14.400000 4.501754 c +14.400000 1.800547 l +14.400000 0.807714 13.593665 0.000029 12.603939 0.000029 c +1.796060 0.000029 l +0.802609 0.000029 0.000000 0.804142 0.000000 1.800547 c +0.000000 4.501754 l +0.000000 4.999001 0.402944 5.402100 0.900000 5.402100 c +1.397056 5.402100 1.800000 4.999001 1.800000 4.501754 c +1.796060 1.800718 l +12.599999 1.800547 l +h +f +n +Q +q +-1.000000 -0.000000 0.000000 -1.000000 15.648438 20.002563 cm +0.693500 0.711750 0.730000 scn +1.539240 4.081299 m +2.545713 3.074440 l +2.545713 11.492543 l +2.545713 11.989956 2.945192 12.393188 3.445713 12.393188 c +3.942770 12.393188 4.345713 11.990088 4.345713 11.492543 c +4.345713 3.074440 l +5.352188 4.081299 l +5.705159 4.434405 6.273771 4.438073 6.627693 4.084015 c +6.979165 3.732409 6.977091 3.160265 6.624980 2.808019 c +4.084824 0.266890 l +3.906826 0.088822 3.676712 0.001439 3.446377 0.001585 c +3.215733 -0.000003 2.985826 0.087598 2.809317 0.264174 c +2.807509 0.265984 0.266448 2.808019 0.266448 2.808019 c +-0.086523 3.161125 -0.090189 3.729957 0.263733 4.084015 c +0.615205 4.435622 1.187128 4.433546 1.539240 4.081299 c +h +f +n +Q + +endstream +endobj + +3 0 obj + 1353 +endobj + +4 0 obj + << /Annots [] + /Type /Page + /MediaBox [ 0.000000 0.000000 24.000000 24.000000 ] + /Resources 1 0 R + /Contents 2 0 R + /Parent 5 0 R + >> +endobj + +5 0 obj + << /Kids [ 4 0 R ] + /Count 1 + /Type /Pages + >> +endobj + +6 0 obj + << /Pages 5 0 R + /Type /Catalog + >> +endobj + +xref +0 7 +0000000000 65535 f +0000000010 00000 n +0000000034 00000 n +0000001443 00000 n +0000001466 00000 n +0000001639 00000 n +0000001713 00000 n +trailer +<< /ID [ (some) (id) ] + /Root 6 0 R + /Size 7 +>> +startxref +1772 +%%EOF \ No newline at end of file diff --git a/Sources/Shared/Resources/en.lproj/Localizable.strings b/Sources/Shared/Resources/en.lproj/Localizable.strings index 2b7263918c46d1868d27b5fe82ff5d21137786e9..32235ed0528a1881c6c513f4edece96ca47ce4b3 100644 --- a/Sources/Shared/Resources/en.lproj/Localizable.strings +++ b/Sources/Shared/Resources/en.lproj/Localizable.strings @@ -8,6 +8,10 @@ = "Connections"; "menu.requests" = "Requests"; +"menu.join" += "Join xx network"; +"menu.share" += "Share my profile"; "menu.viewProfile" = "View Profile"; "menu.profile" @@ -22,6 +26,8 @@ = "Build %@"; "menu.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