[core][onboarding] tip data source is added

This commit is contained in:
Arsentiy Milchakov 2019-11-05 15:10:58 +03:00 committed by Aleksandr Zatsepin
parent 5df4d4eba4
commit d3ee2ef4e6
3 changed files with 63 additions and 0 deletions

View file

@ -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

35
map/onboarding.cpp Normal file
View file

@ -0,0 +1,35 @@
#include "map/onboarding.hpp"
#include "platform/platform.hpp"
#include "base/url_helpers.hpp"
#include <array>
#include <cstdint>
#include <ctime>
#include "private.h"
namespace
{
auto constexpr kTipsCount = static_cast<uint8_t>(onboarding::Tip::Type::Count);
std::string const kBaseUrl = "/guides_page?utm_source=maps.me&utm_medium=onboarding_button";
std::array<std::string, kTipsCount> 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<Tip::Type>(tipIndex), url.empty() ? url : base::url::Join(DLINK_URL, url)};
}
bool CanShowTipButton() { return GetPlatform().IsConnected(); }
} // namespace onboarding

26
map/onboarding.hpp Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include <string>
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