From d3ee2ef4e650cf92b5465444e8463b048c5b0bc5 Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Tue, 5 Nov 2019 15:10:58 +0300 Subject: [PATCH] [core][onboarding] tip data source is added --- map/CMakeLists.txt | 2 ++ map/onboarding.cpp | 35 +++++++++++++++++++++++++++++++++++ map/onboarding.hpp | 26 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 map/onboarding.cpp create mode 100644 map/onboarding.hpp diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index d97e691d28..699dac3d4d 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -91,6 +91,8 @@ set( notifications/notification_queue_serdes.hpp notifications/notification_queue_storage.cpp notifications/notification_queue_storage.hpp + onboarding.cpp + onboarding.hpp place_page_info.cpp place_page_info.hpp power_management/power_manager.cpp diff --git a/map/onboarding.cpp b/map/onboarding.cpp new file mode 100644 index 0000000000..00de8c369b --- /dev/null +++ b/map/onboarding.cpp @@ -0,0 +1,35 @@ +#include "map/onboarding.hpp" + +#include "platform/platform.hpp" + +#include "base/url_helpers.hpp" + +#include +#include +#include + +#include "private.h" + +namespace +{ +auto constexpr kTipsCount = static_cast(onboarding::Tip::Type::Count); + +std::string const kBaseUrl = "/guides_page?utm_source=maps.me&utm_medium=onboarding_button"; +std::array const kTipsLinks = { + kBaseUrl + "&url=%00&utm_campaign=catalog_discovery", + kBaseUrl + "&url=search%2F%3Ftag%3D181&utm_campaign=sample_discovery", + ""}; +} // namespace + +namespace onboarding +{ +Tip GetTip() +{ + auto const tipIndex = std::time(nullptr) % kTipsCount; + auto const url = kTipsLinks[tipIndex]; + + return {static_cast(tipIndex), url.empty() ? url : base::url::Join(DLINK_URL, url)}; +} + +bool CanShowTipButton() { return GetPlatform().IsConnected(); } +} // namespace onboarding diff --git a/map/onboarding.hpp b/map/onboarding.hpp new file mode 100644 index 0000000000..d1627e8b9e --- /dev/null +++ b/map/onboarding.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace onboarding +{ +struct Tip +{ + enum class Type + { + DiscoverCatalog, + DownloadSamples, + BuySubscription, + + Count + }; + + Tip(Type type, std::string const & url) : m_type(type), m_url(url) {} + + Type m_type; + std::string m_url; +}; + +Tip GetTip(); +bool CanShowTipButton(); +} // namespace onboarding