mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-05-01 07:18:08 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#ifndef AnimationTextProvider_hpp
|
|
#define AnimationTextProvider_hpp
|
|
|
|
#include <string>
|
|
#include <map>
|
|
|
|
namespace lottie {
|
|
|
|
/// Text provider is a protocol that is used to supply text to `AnimationView`.
|
|
class AnimationTextProvider {
|
|
public:
|
|
virtual std::string textFor(std::string const &keypathName, std::string const &sourceText) = 0;
|
|
};
|
|
|
|
/// Text provider that simply map values from dictionary
|
|
class DictionaryTextProvider: public AnimationTextProvider {
|
|
public:
|
|
DictionaryTextProvider(std::map<std::string, std::string> const &values) :
|
|
_values(values) {
|
|
}
|
|
|
|
virtual std::string textFor(std::string const &keypathName, std::string const &sourceText) override {
|
|
const auto it = _values.find(keypathName);
|
|
if (it != _values.end()) {
|
|
return it->second;
|
|
} else {
|
|
return sourceText;
|
|
}
|
|
}
|
|
|
|
private:
|
|
std::map<std::string, std::string> _values;
|
|
};
|
|
|
|
/// Default text provider. Uses text in the animation file
|
|
class DefaultTextProvider: public AnimationTextProvider {
|
|
public:
|
|
DefaultTextProvider() {
|
|
}
|
|
|
|
virtual ~DefaultTextProvider() = default;
|
|
|
|
virtual std::string textFor(std::string const &keypathName, std::string const &sourceText) override {
|
|
return sourceText;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* AnimationTextProvider_hpp */
|