diff --git a/.gitignore b/.gitignore index 85e7c1d..f2c8c65 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.idea/ +/.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 57a2afc..21cf8df 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,6 @@ { "files.associations": { - "optional": "cpp", - "system_error": "cpp", - "string": "cpp", + "qsettings": "cpp", "array": "cpp", "atomic": "cpp", "bit": "cpp", @@ -23,6 +21,9 @@ "cwchar": "cpp", "cwctype": "cpp", "deque": "cpp", + "list": "cpp", + "map": "cpp", + "string": "cpp", "unordered_map": "cpp", "vector": "cpp", "exception": "cpp", @@ -32,9 +33,11 @@ "memory": "cpp", "memory_resource": "cpp", "numeric": "cpp", + "optional": "cpp", "random": "cpp", "ratio": "cpp", "string_view": "cpp", + "system_error": "cpp", "tuple": "cpp", "type_traits": "cpp", "utility": "cpp", @@ -42,6 +45,7 @@ "initializer_list": "cpp", "iomanip": "cpp", "iosfwd": "cpp", + "iostream": "cpp", "istream": "cpp", "limits": "cpp", "mutex": "cpp", @@ -54,6 +58,9 @@ "stop_token": "cpp", "streambuf": "cpp", "thread": "cpp", - "typeinfo": "cpp" + "typeinfo": "cpp", + "variant": "cpp", + "qstring": "cpp", + "qvariant": "cpp" } } \ No newline at end of file diff --git a/packages/shared_preferences/shared_preferences_aurora/aurora/CMakeLists.txt b/packages/shared_preferences/shared_preferences_aurora/aurora/CMakeLists.txt index 336e7b6..5871417 100644 --- a/packages/shared_preferences/shared_preferences_aurora/aurora/CMakeLists.txt +++ b/packages/shared_preferences/shared_preferences_aurora/aurora/CMakeLists.txt @@ -19,7 +19,7 @@ add_library(${PLUGIN_NAME} SHARED shared_preferences_aurora_plugin.cpp) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::Qt5Core) +target_link_libraries(${PLUGIN_NAME} PUBLIC PkgConfig::Qt5Core) target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) diff --git a/packages/shared_preferences/shared_preferences_aurora/aurora/include/shared_preferences_aurora/shared_preferences_aurora_plugin.h b/packages/shared_preferences/shared_preferences_aurora/aurora/include/shared_preferences_aurora/shared_preferences_aurora_plugin.h index f8d4cc3..c4a5afc 100644 --- a/packages/shared_preferences/shared_preferences_aurora/aurora/include/shared_preferences_aurora/shared_preferences_aurora_plugin.h +++ b/packages/shared_preferences/shared_preferences_aurora/aurora/include/shared_preferences_aurora/shared_preferences_aurora_plugin.h @@ -2,6 +2,9 @@ #define FLUTTER_PLUGIN_SHARED_PREFERENCES_AURORA_PLUGIN_H #include +#include +#include +#include #ifdef PLUGIN_IMPL #define PLUGIN_EXPORT __attribute__((visibility("default"))) @@ -12,13 +15,46 @@ class PLUGIN_EXPORT SharedPreferencesAuroraPlugin final : public PluginInterface { public: + SharedPreferencesAuroraPlugin(); void RegisterWithRegistrar(PluginRegistrar ®istrar) override; + struct ARGS + { + QString key; + Encodable value; + }; + + enum Methods + { + getInt, + setInt, + getBool, + setBool, + getDouble, + setDouble, + getString, + setString, + getStringList, + setStringList, + }; + private: void onMethodCall(const MethodCall &call); + void unimplemented(const MethodCall &call); + ARGS getArguments(const MethodCall &call); void onGetInt(const MethodCall &call); void onSetInt(const MethodCall &call); - void unimplemented(const MethodCall &call); + void onGetBool(const MethodCall &call); + void onSetBool(const MethodCall &call); + void onGetDouble(const MethodCall &call); + void onSetDouble(const MethodCall &call); + void onGetString(const MethodCall &call); + void onSetString(const MethodCall &call); + void onGetStringList(const MethodCall &call); + void onSetStringList(const MethodCall &call); + + QSettings settings; + std::map mapping; }; #endif /* FLUTTER_PLUGIN_SHARED_PREFERENCES_AURORA_PLUGIN_H */ diff --git a/packages/shared_preferences/shared_preferences_aurora/aurora/shared_preferences_aurora_plugin.cpp b/packages/shared_preferences/shared_preferences_aurora/aurora/shared_preferences_aurora_plugin.cpp index 206d0e6..295bf65 100644 --- a/packages/shared_preferences/shared_preferences_aurora/aurora/shared_preferences_aurora_plugin.cpp +++ b/packages/shared_preferences/shared_preferences_aurora/aurora/shared_preferences_aurora_plugin.cpp @@ -2,7 +2,25 @@ #include #include #include -#include + +SharedPreferencesAuroraPlugin::SharedPreferencesAuroraPlugin(): settings( + QString::fromStdString(Application::GetID().orgname), + QString::fromStdString(Application::GetID().appname) +) { + // map methods + this->mapping = std::map ({ + {"getInt", Methods::getInt}, + {"setInt", Methods::setInt}, + {"getBool", Methods::getBool}, + {"setBool", Methods::setBool}, + {"getDouble", Methods::getDouble}, + {"setDouble", Methods::setDouble}, + {"getString", Methods::getString}, + {"setString", Methods::setString}, + {"getStringList", Methods::getStringList}, + {"setStringList", Methods::setStringList}, + }); +} void SharedPreferencesAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) { @@ -11,17 +29,29 @@ void SharedPreferencesAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®is [this](const MethodCall &call) { this->onMethodCall(call); }); } +SharedPreferencesAuroraPlugin::ARGS SharedPreferencesAuroraPlugin::getArguments(const MethodCall &call) +{ + ARGS args; + args.key = QString::fromStdString(call.GetArguments()["key"].GetString()); + args.value = call.GetArguments()["value"]; + return args; +} + void SharedPreferencesAuroraPlugin::onMethodCall(const MethodCall &call) { const auto &method = call.GetMethod(); - if (method == "getInt") { - onGetInt(call); - return; - } - else if (method == "setInt") { - onSetInt(call); - return; + switch (this->mapping[method]) { + case Methods::getInt: onGetInt(call); return; + case Methods::setInt: onSetInt(call); return; + case Methods::getBool: onGetBool(call); return; + case Methods::setBool: onSetBool(call); return; + case Methods::getDouble: onGetDouble(call); return; + case Methods::setDouble: onSetDouble(call); return; + case Methods::getString: onGetString(call); return; + case Methods::setString: onSetString(call); return; + case Methods::getStringList: onGetStringList(call); return; + case Methods::setStringList: onSetStringList(call); return; } unimplemented(call); @@ -29,27 +59,96 @@ void SharedPreferencesAuroraPlugin::onMethodCall(const MethodCall &call) void SharedPreferencesAuroraPlugin::onGetInt(const MethodCall &call) { - // get arguments - std::string key = call.GetArguments()["key"].GetString(); - int value = call.GetArguments()["value"].GetInt(); - // init settings - const auto [orgname, appname] = Application::GetID(); - QSettings settings(QString::fromStdString(orgname), QString::fromStdString(appname)); - // send response - call.SendSuccessResponse(settings.value(QString::fromStdString(key), value).toInt()); + const auto [key, value] = this->getArguments(call); + call.SendSuccessResponse(settings.value(key, value.GetInt()).toInt()); } void SharedPreferencesAuroraPlugin::onSetInt(const MethodCall &call) { - // get arguments - std::string key = call.GetArguments()["key"].GetString(); - int value = call.GetArguments()["value"].GetInt(); - // init settings - const auto [orgname, appname] = Application::GetID(); - QSettings settings(QString::fromStdString(orgname), QString::fromStdString(appname)); - // save - settings.setValue(QString::fromStdString(key), value); - // send response + const auto [key, value] = this->getArguments(call); + settings.setValue(key, value.GetInt()); + call.SendSuccessResponse(true); +} + +void SharedPreferencesAuroraPlugin::onGetBool(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + call.SendSuccessResponse(settings.value(key, value.GetBoolean()).toBool()); +} + +void SharedPreferencesAuroraPlugin::onSetBool(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + settings.setValue(key, value.GetBoolean()); + call.SendSuccessResponse(true); +} + +void SharedPreferencesAuroraPlugin::onGetDouble(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + call.SendSuccessResponse(settings.value(key, value.GetFloat()).toDouble()); +} + +void SharedPreferencesAuroraPlugin::onSetDouble(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + settings.setValue(key, value.GetFloat()); + call.SendSuccessResponse(true); +} + +void SharedPreferencesAuroraPlugin::onGetString(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + call.SendSuccessResponse(settings.value( + key, + QString::fromStdString(value.GetString())).toString().toStdString() + ); +} + +void SharedPreferencesAuroraPlugin::onSetString(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + settings.setValue(key, QString::fromStdString(value.GetString())); + call.SendSuccessResponse(true); +} + +void SharedPreferencesAuroraPlugin::onGetStringList(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + + std::vector vec; + QStringList list = settings.value(key, "") + .toString() + .split(","); + + for (const auto& item : list) + { + vec.push_back(Encodable(item.toStdString())); + } + + if (vec.size() > 0) { + call.SendSuccessResponse(vec); + } else { + call.SendSuccessResponse(value.GetList()); + } +} + +void SharedPreferencesAuroraPlugin::onSetStringList(const MethodCall &call) +{ + const auto [key, value] = this->getArguments(call); + const auto vec = value.GetList(); + std::stringstream ss; + + for (const auto& item : vec) + { + if (ss.rdbuf()->in_avail() != 0) + { + ss << ","; + } + ss << item; + } + + settings.setValue(key, QString::fromStdString(ss.str())); call.SendSuccessResponse(true); } diff --git a/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart b/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart index 03446a8..0a18ab3 100644 --- a/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart +++ b/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart @@ -16,8 +16,15 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - int _platformVersion = -1; - final _sharedPreferencesAuroraPlugin = SharedPreferencesAurora(); + int _valueInt = -1; + bool _valueBool = false; + double _valueDouble = 0.0; + String _valueString = ""; + List _valueStringList = []; + + String? _error; + + final _sharedPreferences = SharedPreferencesAurora(); @override void initState() { @@ -25,37 +32,184 @@ class _MyAppState extends State { initPlatformState(); } - // Platform messages are asynchronous, so we initialize in an async method. Future initPlatformState() async { - int platformVersion; - // Platform messages may fail, so we use a try/catch PlatformException. - // We also handle the message potentially returning null. + int valueInt = -1; + bool valueBool = false; + double valueDouble = 0.0; + String valueString = ""; + List valueStringList = []; + String error = ""; + try { - await _sharedPreferencesAuroraPlugin.setInt('key', 222); - platformVersion = await _sharedPreferencesAuroraPlugin.getInt('key', -99); + await _sharedPreferences.setInt('_valueInt', 77); + await _sharedPreferences.setBool('_valueBool', true); + await _sharedPreferences.setDouble('_valueDouble', 0.77); + await _sharedPreferences.setString('_valueString', "String"); + await _sharedPreferences.setStringList('_valueStringList', [ + "Item 1", + "Item 2", + ]); + + valueInt = await _sharedPreferences.getInt( + '_valueInt', + _valueInt, + ); + valueBool = await _sharedPreferences.getBool( + '_valueBool', + _valueBool, + ); + valueDouble = await _sharedPreferences.getDouble( + '_valueDouble', + _valueDouble, + ); + valueString = await _sharedPreferences.getString( + '_valueString', + _valueString, + ); + valueStringList = await _sharedPreferences.getStringList( + '_valueStringList', + _valueStringList, + ); } on PlatformException { - platformVersion = -2; + error = 'Platform exception'; } - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. if (!mounted) return; setState(() { - _platformVersion = platformVersion; + if (error.isEmpty) { + _valueInt = valueInt; + _valueBool = valueBool; + _valueDouble = valueDouble; + _valueString = valueString; + _valueStringList = valueStringList; + } else { + _error = error; + } }); } @override Widget build(BuildContext context) { + const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); + const textStyleTitle = TextStyle(fontSize: 20, color: Colors.black); + const textStylePath = TextStyle(fontSize: 18, color: Colors.black54); + + const spaceMedium = SizedBox(height: 20); + const spaceSmall = SizedBox(height: 10); + return MaterialApp( home: Scaffold( appBar: AppBar( - title: const Text('Plugin example app'), + title: const Text('Example shared_preferences'), ), - body: Center( - child: Text('Running on: $_platformVersion\n'), + body: Stack( + children: [ + // Error message + Visibility( + visible: _error != null, + child: Center( + child: Padding( + padding: const EdgeInsets.all(16), + child: Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.redAccent, + borderRadius: BorderRadius.all(Radius.circular(10.0)), + ), + child: Text( + _error ?? '', + style: textStyleWhite, + ), + ), + ), + ), + ), + // List directories path + Visibility( + visible: _error == null, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Center( + child: Column( + children: [ + // Info + Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.green, + borderRadius: + BorderRadius.all(Radius.circular(10.0)), + ), + child: const Text( + 'Demo application demonstration implementation of shared_preferences', + style: textStyleWhite, + textAlign: TextAlign.center, + ), + ), + const SizedBox(height: 30), + + const Text( + 'setInt/getInt', + style: textStyleTitle, + ), + spaceSmall, + Text( + _valueInt.toString(), + style: textStylePath, + ), + + spaceMedium, + const Text( + 'setBool/getBool', + style: textStyleTitle, + ), + spaceSmall, + Text( + _valueBool.toString(), + style: textStylePath, + ), + + spaceMedium, + const Text( + 'setDouble/getDouble', + style: textStyleTitle, + ), + spaceSmall, + Text( + _valueDouble.toString(), + style: textStylePath, + ), + + spaceMedium, + const Text( + 'setString/getString', + style: textStyleTitle, + ), + spaceSmall, + Text( + _valueString, + style: textStylePath, + ), + + spaceMedium, + const Text( + 'setStringList/getStringList', + style: textStyleTitle, + ), + spaceSmall, + Text( + _valueStringList.toString(), + style: textStylePath, + ), + ], + ), + ), + ), + ), + ), + ], ), ), ); diff --git a/packages/shared_preferences/shared_preferences_aurora/example/pubspec.lock b/packages/shared_preferences/shared_preferences_aurora/example/pubspec.lock index b3d3936..c782233 100644 --- a/packages/shared_preferences/shared_preferences_aurora/example/pubspec.lock +++ b/packages/shared_preferences/shared_preferences_aurora/example/pubspec.lock @@ -116,6 +116,13 @@ packages: relative: true source: path version: "0.0.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" sky_engine: dependency: transitive description: flutter @@ -172,4 +179,4 @@ packages: version: "2.1.2" sdks: dart: ">=2.18.6 <3.0.0" - flutter: ">=2.5.0" + flutter: ">=3.0.0" diff --git a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora.dart b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora.dart index b91e61d..62c2652 100644 --- a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora.dart +++ b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora.dart @@ -1,6 +1,8 @@ import 'shared_preferences_aurora_platform_interface.dart'; class SharedPreferencesAurora { + static void registerWith() {} + Future getInt(String key, int value) { return SharedPreferencesAuroraPlatform.instance.getInt(key, value); } @@ -8,4 +10,36 @@ class SharedPreferencesAurora { Future setInt(String key, int value) { return SharedPreferencesAuroraPlatform.instance.setInt(key, value); } + + Future getBool(String key, bool value) { + return SharedPreferencesAuroraPlatform.instance.getBool(key, value); + } + + Future setBool(String key, bool value) { + return SharedPreferencesAuroraPlatform.instance.setBool(key, value); + } + + Future getDouble(String key, double value) { + return SharedPreferencesAuroraPlatform.instance.getDouble(key, value); + } + + Future setDouble(String key, double value) { + return SharedPreferencesAuroraPlatform.instance.setDouble(key, value); + } + + Future getString(String key, String value) { + return SharedPreferencesAuroraPlatform.instance.getString(key, value); + } + + Future setString(String key, String value) { + return SharedPreferencesAuroraPlatform.instance.setString(key, value); + } + + Future> getStringList(String key, List value) { + return SharedPreferencesAuroraPlatform.instance.getStringList(key, value); + } + + Future setStringList(String key, List value) { + return SharedPreferencesAuroraPlatform.instance.setStringList(key, value); + } } diff --git a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_method_channel.dart b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_method_channel.dart index d2d25fe..f88abf5 100644 --- a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_method_channel.dart +++ b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_method_channel.dart @@ -27,4 +27,79 @@ class MethodChannelSharedPreferencesAurora }) ?? false; } + + @override + Future getBool(String key, bool value) async { + final result = await methodChannel.invokeMethod('getBool', { + 'key': key, + 'value': value, + }); + return result ?? value; + } + + @override + Future setBool(String key, bool value) async { + return await methodChannel.invokeMethod('setBool', { + 'key': key, + 'value': value, + }) ?? + false; + } + + @override + Future getDouble(String key, double value) async { + final result = await methodChannel.invokeMethod('getDouble', { + 'key': key, + 'value': value, + }); + return result ?? value; + } + + @override + Future setDouble(String key, double value) async { + return await methodChannel.invokeMethod('setDouble', { + 'key': key, + 'value': value, + }) ?? + false; + } + + @override + Future getString(String key, String value) async { + final result = await methodChannel.invokeMethod('getString', { + 'key': key, + 'value': value, + }); + return result ?? value; + } + + @override + Future setString(String key, String value) async { + return await methodChannel.invokeMethod('setString', { + 'key': key, + 'value': value, + }) ?? + false; + } + + @override + Future> getStringList(String key, List value) async { + final result = await methodChannel.invokeMethod?>( + 'getStringList', + { + 'key': key, + 'value': value, + }, + ); + return result?.map((e) => e as String).toList() ?? value; + } + + @override + Future setStringList(String key, List value) async { + return await methodChannel.invokeMethod('setStringList', { + 'key': key, + 'value': value, + }) ?? + false; + } } diff --git a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_platform_interface.dart b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_platform_interface.dart index d0e0450..8574ec7 100644 --- a/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_platform_interface.dart +++ b/packages/shared_preferences/shared_preferences_aurora/lib/shared_preferences_aurora_platform_interface.dart @@ -31,4 +31,36 @@ abstract class SharedPreferencesAuroraPlatform extends PlatformInterface { Future setInt(String key, int value) { throw UnimplementedError('setInt() has not been implemented.'); } + + Future getBool(String key, bool value) { + throw UnimplementedError('getBool() has not been implemented.'); + } + + Future setBool(String key, bool value) { + throw UnimplementedError('setBool() has not been implemented.'); + } + + Future getDouble(String key, double value) { + throw UnimplementedError('getDouble() has not been implemented.'); + } + + Future setDouble(String key, double value) { + throw UnimplementedError('setDouble() has not been implemented.'); + } + + Future getString(String key, String value) { + throw UnimplementedError('getString() has not been implemented.'); + } + + Future setString(String key, String value) { + throw UnimplementedError('setString() has not been implemented.'); + } + + Future> getStringList(String key, List value) { + throw UnimplementedError('getStringList() has not been implemented.'); + } + + Future setStringList(String key, List value) { + throw UnimplementedError('setStringList() has not been implemented.'); + } } diff --git a/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml b/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml index af18dbb..3fea4a7 100644 --- a/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml @@ -1,5 +1,5 @@ name: shared_preferences_aurora -description: A new Flutter plugin project. +description: The Aurora OS implementation of shared_preferences. version: 0.0.1 homepage: @@ -11,59 +11,16 @@ dependencies: flutter: sdk: flutter plugin_platform_interface: ^2.0.2 + shared_preferences_platform_interface: ^2.2.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) - # which should be registered in the plugin registry. This is required for - # using method channels. - # The Android 'package' specifies package in which the registered class is. - # This is required for using method channels on Android. - # The 'ffiPlugin' specifies that native code should be built and bundled. - # This is required for using `dart:ffi`. - # All these are used by the tooling to maintain consistency when - # adding or updating assets for this project. plugin: platforms: aurora: pluginClass: SharedPreferencesAuroraPlugin - - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + dartPluginClass: SharedPreferencesAurora \ No newline at end of file diff --git a/script/vscode_properties.sh b/script/vscode_properties.sh new file mode 100755 index 0000000..b126a9e --- /dev/null +++ b/script/vscode_properties.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +## Script create c_cpp_properties.json with dependencies for flutter aurora + +## Usage +## +## chmod +x ./vscode_properties.sh +## ./vscode_properties.sh + +## https://developer.auroraos.ru/doc/software_development/psdk/setup +## Install Platform SDK path +## You may not have set the PSDK_DIR environment variable. +## export PSDK_DIR=$HOME/AuroraPlatformSDK/sdks/aurora_psdk + +cd ../ + +## check file +[ -f .vscode/c_cpp_properties.json ] && { echo "File c_cpp_properties.json already exist!"; exit; } + +## find target +TARGET=$($PSDK_DIR/sdk-chroot sdk-assistant list | grep armv | grep default | sed 's/^.*A/A/g' | sed 's/\s.*//g') + +## mkdir .vscode if not exist +[ -d .vscode ] || mkdir .vscode + +## find targets path +TARGETS_PATH=$(cd "$PSDK_DIR/../../" && pwd)/targets + +## save file +tee -a .vscode/c_cpp_properties.json << END +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "\${workspaceFolder}/**", + "$TARGETS_PATH/$TARGET/usr/include", + "$TARGETS_PATH/$TARGET/usr/include/dconf", + "$TARGETS_PATH/$TARGET/usr/include/flutter-embedder", + "$TARGETS_PATH/$TARGET/usr/include/maliit", + "$TARGETS_PATH/$TARGET/usr/include/appmanifest-cpp", + "$TARGETS_PATH/$TARGET/usr/include/glib-2.0", + "$TARGETS_PATH/$TARGET/usr/lib/glib-2.0/include", + "$TARGETS_PATH/$TARGET/usr/include/sailfishapp", + "$TARGETS_PATH/$TARGET/usr/include/qt5", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtConcurrent", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtCore", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtDBus", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtGui", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtMultimedia", + "$TARGETS_PATH/$TARGET/usr/include/qt5/QtQuick" + ], + "defines": [ + "__ARM_PCS_VFP" + ], + "compilerPath": "/usr/bin/g++", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} +END \ No newline at end of file