Skip to content

Commit

Permalink
feat: Добавили поддержку нового эмбедера для location_aurora и исправ…
Browse files Browse the repository at this point in the history
…или документацию

* location, changes for new flutter version
---------

Signed-off-by: deadbeef <[email protected]>
Co-authored-by: mozerrr <[email protected]>
  • Loading branch information
corvaxx and mozerrr authored Jul 25, 2024
1 parent 1d383dc commit 1071ff1
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 73 deletions.
4 changes: 4 additions & 0 deletions packages/location_aurora/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

* Добавлена поддержка эмбедера 3.16.2.-2

## 1.0.0

* Open Source release.
14 changes: 7 additions & 7 deletions packages/location_aurora/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ dependencies:
location: ^5.0.3
location_aurora:
hosted: https://pub-aurora.friflex.com
version: ^1.0.0
version: ^1.1.0
```
You need to add QT compatibility to main.cpp your app.
```main.cpp
#include <flutter/application.h>
#include <flutter/compatibility.h>
#include <flutter/flutter_aurora.h>
#include <flutter/flutter_compatibility_qt.h>
#include "generated_plugin_registrant.h"

int main(int argc, char *argv[]) {
Application::Initialize(argc, argv);
EnableQtCompatibility();
RegisterPlugins();
Application::Launch();
aurora::Initialize(argc, argv);
aurora::EnableQtCompatibility();
aurora::RegisterPlugins();
aurora::Launch();
return 0;
}
```
Expand Down
86 changes: 86 additions & 0 deletions packages/location_aurora/aurora/encodable_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* SPDX-FileCopyrightText: Copyright 2024 Open Mobile Platform LLC <[email protected]>
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef FLUTTER_PLUGIN_ENCODABLE_HELPER_H
#define FLUTTER_PLUGIN_ENCODABLE_HELPER_H

#include <flutter/encodable_value.h>

typedef flutter::EncodableValue EncodableValue;
typedef flutter::EncodableValue EncodableValue;
typedef flutter::EncodableMap EncodableMap;
typedef flutter::EncodableList EncodableList;

namespace Helper {

// ========== encodable_value ==========

template <typename T>
inline bool TypeIs(const EncodableValue & val) {
return std::holds_alternative<T>(val);
}

template <typename T>
inline const T GetValue(const EncodableValue & val) {
return std::get<T>(val);
}

inline EncodableMap GetMap(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
if (it != map.end() && TypeIs<EncodableMap>(it->second))
return GetValue<EncodableMap>(it->second);
return EncodableMap();
}

inline EncodableList GetList(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
if (it != map.end() && TypeIs<EncodableList>(it->second))
return GetValue<EncodableList>(it->second);
return EncodableList();
}

inline int GetInt(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
if (it != map.end() && TypeIs<int>(it->second))
return GetValue<int>(it->second);
return -1;
}

inline bool GetBool(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
if (it != map.end() && TypeIs<bool>(it->second))
return GetValue<bool>(it->second);
return false;
}

inline std::string GetString(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
if (it != map.end() && TypeIs<std::string>(it->second))
return GetValue<std::string>(it->second);
return std::string();
}

inline std::vector<int> GetVectorInt(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
std::vector<int> result{};
if (it != map.end() && TypeIs<std::vector<EncodableValue>>(it->second))
for (auto item : GetValue<std::vector<EncodableValue>>(it->second)) {
result.push_back(GetValue<int>(item));
}
return result;
}

inline std::vector<double> GetVectorDouble(const EncodableMap& map, const std::string& key) {
auto it = map.find(EncodableValue(key));
std::vector<double> result{};
if (it != map.end() && TypeIs<std::vector<EncodableValue>>(it->second))
for (auto item : GetValue<std::vector<EncodableValue>>(it->second)) {
result.push_back(GetValue<double>(item));
}
return result;
}

} // namespace Helper

#endif /* FLUTTER_PLUGIN_ENCODABLE_HELPER_H */
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@
#ifndef FLUTTER_PLUGIN_LOCATION_AURORA_PLUGIN_H
#define FLUTTER_PLUGIN_LOCATION_AURORA_PLUGIN_H

#include <flutter/plugin-interface.h>
#include <flutter/plugin_registrar.h>
#include <location_aurora/globals.h>

#include <memory>

//******************************************************************************
//******************************************************************************
class PLUGIN_EXPORT LocationAuroraPlugin final : public PluginInterface
class PLUGIN_EXPORT LocationAuroraPlugin final : public flutter::Plugin
{
public:
LocationAuroraPlugin();
LocationAuroraPlugin(flutter::PluginRegistrar * registrar);

public:
void RegisterWithRegistrar(PluginRegistrar &registrar) override;

private:
void onMethodCall(const MethodCall &call);
void unimplemented(const MethodCall &call);
static void RegisterWithRegistrar(flutter::PluginRegistrar * registrar);

private:
class impl;
Expand Down
Loading

0 comments on commit 1071ff1

Please sign in to comment.