diff --git a/README.md b/README.md index 43e2ae5..5a0c194 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,42 @@ It contains the source code for Aurora Flutter's packages (i.e., packages develo ## Package done -Packages made or for review +Package verified -| Package | Version | OS Version | State | Comment | -|-------------------------------------------------------------------------------------|----------|------------|---------|---------------------------------------------------------------------| -| [battery_plus](https://pub.dev/packages/battery_plus) | 4.0.1 | 4.0.2 | Review | - | -| [device_info_plus](https://pub.dev/packages/device_info_plus) | 9.0.2 | 4.0.2 | Review | - | -| [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) | 14.1.1 | 4.0.2 | Done | - | -| [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) | 8.0.0 | 4.0.2 | Review | Ключь нужно генерировать сейчас самому, например через пин от юзера | -| [package_info_plus](https://pub.dev/packages/package_info_plus) | 4.0.2 | 4.0.2 | Done | Достать `version` & `build_number` не удалось | -| [path_provider](https://pub.dev/packages/path_provider) | 2.0.15 | 4.0.2 | Review | - | -| [shared_preferences](https://pub.dev/packages/shared_preferences) | 2.1.2 | 4.0.2 | Review | - | -| [sqflite](https://pub.dev/packages/sqflite) | 2.2.6 | 4.0.2 | Review | - | -| [wakelock](https://pub.dev/packages/wakelock) | 0.6.2 | 4.0.2 | Review | - | -| xdga_directories | - | 4.0.2 | Review | Аналог [xdg_directories](https://pub.dev/packages/xdg_directories) | - -## Package verified - -Verified packages on Aurora OS - -| Package | Version | OS Version | State | Comment | -|-------------------------------------------------------------------------|----------|-------------|--------|------------------------------------| -| [flutter_cache_manager](https://pub.dev/packages/flutter_cache_manager) | 3.3.0 | 4.0.2 | Done | Depends on `path_provider` | -| [cached_network_image](https://pub.dev/packages/cached_network_image) | 3.2.3 | 4.0.2 | Done | Depends on `flutter_cache_manager` | +| Package | Version | OS Version | Comment | +|-------------------------------------------------------------------------------------|-----------|------------|---------------------------------------------------------------------| +| [flutter_keyboard_visibility](https://pub.dev/packages/flutter_keyboard_visibility) | 5.4.1 | 4.0.2 | Дополнительная фича с получением высоты клавиатуры | +| [battery_plus](https://pub.dev/packages/battery_plus) | 4.0.1 | 4.0.2 | - | +| [device_info_plus](https://pub.dev/packages/device_info_plus) | 8.2.2 | 4.0.2 | - | +| [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) | 14.1.1 | 4.0.2 | - | +| [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) | 8.0.0 | 4.0.2 | Ключь нужно генерировать сейчас самому, например через пин от юзера | +| [package_info_plus](https://pub.dev/packages/package_info_plus) | 3.1.2 | 4.0.2 | Достать `version` & `build_number` не удалось | +| [path_provider](https://pub.dev/packages/path_provider) | 2.0.15 | 4.0.2 | - | +| [shared_preferences](https://pub.dev/packages/shared_preferences) | 2.1.2 | 4.0.2 | - | +| [sqflite](https://pub.dev/packages/sqflite) | 2.2.6 | 4.0.2 | - | +| [wakelock](https://pub.dev/packages/wakelock) | 0.6.2 | 4.0.2 | - | +| xdga_directories | 0.0.1 | 4.0.2 | Аналог [xdg_directories](https://pub.dev/packages/xdg_directories) | +| [flutter_cache_manager](https://pub.dev/packages/flutter_cache_manager) | 3.3.0 | 4.0.2 | Depends on `path_provider` | +| [cached_network_image](https://pub.dev/packages/cached_network_image) | 3.2.3 | 4.0.2 | Depends on `flutter_cache_manager` | +| [crypto](https://pub.dev/packages/crypto) | 3.0.2 | 4.0.2 | - | +| [cupertino_icons](https://pub.dev/packages/cupertino_icons) | 1.0.5 | 4.0.2 | - | +| [get_it](https://pub.dev/packages/get_it) | 7.6.0 | 4.0.2 | - | +| [google_fonts](https://pub.dev/packages/google_fonts) | 4.0.4 | 4.0.2 | - | +| [intl](https://pub.dev/packages/intl) | 0.17.0 | 4.0.2 | - | +| [photo_view](https://pub.dev/packages/photo_view) | 0.14.0 | 4.0.2 | - | +| [scoped_model](https://pub.dev/packages/scoped_model) | 2.0.0 | 4.0.2 | - | +| [dartz](https://pub.dev/packages/dartz) | 0.10.1 | 4.0.2 | - | +| [freezed](https://pub.dev/packages/freezed) | 2.3.3 | 4.0.2 | - | +| [equatable](https://pub.dev/packages/equatable) | 2.0.5 | 4.0.2 | - | +| [flutter_markdown](https://pub.dev/packages/flutter_markdown) | 0.6.15 | 4.0.2 | - | +| [build_runner](https://pub.dev/packages/build_runner) | 2.3.3 | 4.0.2 | - | +| [freezed_annotation](https://pub.dev/packages/freezed_annotation) | 2.2.0 | 4.0.2 | - | +| [json_annotation](https://pub.dev/packages/json_annotation) | 4.8.0 | 4.0.2 | - | +| [json_serializable](https://pub.dev/packages/json_serializable) | 6.6.1 | 4.0.2 | - | +| [provider](https://pub.dev/packages/provider) | 6.0.5 | 4.0.2 | - | +| [qr_flutter](https://pub.dev/packages/qr_flutter) | 4.0.0 | 4.0.2 | - | +| [rxdart](https://pub.dev/packages/rxdart) | 0.27.7 | 4.0.2 | - | +| [translator](https://pub.dev/packages/translator) | 0.1.7 | 4.0.2 | - | ## Package in progress @@ -39,7 +52,6 @@ Started development and its status | [url_launcher](https://pub.dev/packages/url_launcher) | 6.1.11 | 5.0.0 | Waiting | [OpenURI](https://confluence.omprussia.ru/pages/viewpage.action?pageId=163055648) | | [sensors_plus](https://pub.dev/packages/sensors_plus) | 3.0.2 | 4.0.2 | Blocked | Нет интерфейса для использования Sensors API без Qt | - ## Package waiting Packets waiting in line diff --git a/packages/device_info_plus/device_info_plus_aurora/example/.gitignore b/example/.gitignore similarity index 94% rename from packages/device_info_plus/device_info_plus_aurora/example/.gitignore rename to example/.gitignore index 3db3823..bf6a5bc 100644 --- a/packages/device_info_plus/device_info_plus_aurora/example/.gitignore +++ b/example/.gitignore @@ -45,3 +45,7 @@ app.*.map.json # Aurora generated /aurora/flutter + +# Dart generated +*.g.dart +*.freezed.dart diff --git a/example/.metadata b/example/.metadata new file mode 100644 index 0000000..8a5abeb --- /dev/null +++ b/example/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 135454af32477f815a7525073027a3ff9eff1bfd + channel: aurora + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + - platform: aurora + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..09bcd04 --- /dev/null +++ b/example/README.md @@ -0,0 +1,19 @@ +# Flutter example packages + +Demonstrating the operation of Flutter plugins on the Aurora OS. + +## Getting Started + +```shell +# Add an alias if it doesn't already exist +alias flutter-aurora=$HOME/.local/opt/flutter/bin/flutter + +# Get dependencies +flutter-aurora pub get + +# Generate internationalizing +flutter-aurora pub run build_runner build + +# Run build +flutter-aurora build aurora --release # [--release|--debug|--profile] +``` diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle new file mode 100644 index 0000000..2162396 --- /dev/null +++ b/example/android/app/build.gradle @@ -0,0 +1,66 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion getProperty('flutter.compileSdkVersion').toInteger() + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + applicationId "ru.auroraos.flutter_example_packages" + minSdkVersion getProperty('flutter.minSdkVersion').toInteger() + targetSdkVersion getProperty('flutter.targetSdkVersion').toInteger() + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..22f758d --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5be26d7 --- /dev/null +++ b/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/example/android/app/src/main/kotlin/ru/auroraos/flutter_example_packages/MainActivity.kt b/example/android/app/src/main/kotlin/ru/auroraos/flutter_example_packages/MainActivity.kt new file mode 100644 index 0000000..619a0b7 --- /dev/null +++ b/example/android/app/src/main/kotlin/ru/auroraos/flutter_example_packages/MainActivity.kt @@ -0,0 +1,6 @@ +package ru.auroraos.flutter_example_packages + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable/icon_splash.png b/example/android/app/src/main/res/drawable/icon_splash.png new file mode 100644 index 0000000..ad245a5 Binary files /dev/null and b/example/android/app/src/main/res/drawable/icon_splash.png differ diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable/splash.xml b/example/android/app/src/main/res/drawable/splash.xml new file mode 100644 index 0000000..7be22f0 --- /dev/null +++ b/example/android/app/src/main/res/drawable/splash.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cc636aa Binary files /dev/null and b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dc8a840 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..d32963c Binary files /dev/null and b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..334a373 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..dc2e2a1 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c6a675c Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..ddbe6c1 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..fe0d529 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..6f0c8ab Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..efa2172 Binary files /dev/null and b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/example/android/app/src/main/res/values-night/colors.xml b/example/android/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..b610850 --- /dev/null +++ b/example/android/app/src/main/res/values-night/colors.xml @@ -0,0 +1,4 @@ + + + #000000 + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..b81264e --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/colors.xml b/example/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..5a0d831 --- /dev/null +++ b/example/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #ffffff + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..7039d5b --- /dev/null +++ b/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..22f758d --- /dev/null +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle new file mode 100644 index 0000000..cf4feca --- /dev/null +++ b/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.8.22' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:7.1.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example/android/gradle.properties b/example/android/gradle.properties new file mode 100644 index 0000000..7c1c752 --- /dev/null +++ b/example/android/gradle.properties @@ -0,0 +1,6 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true +flutter.minSdkVersion=19 +flutter.targetSdkVersion=33 +flutter.compileSdkVersion=33 \ No newline at end of file diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..cb24abd --- /dev/null +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/assets/images/large_image.jpg b/example/assets/images/large_image.jpg new file mode 100644 index 0000000..f49af2f Binary files /dev/null and b/example/assets/images/large_image.jpg differ diff --git a/example/assets/images/leading.png b/example/assets/images/leading.png new file mode 100644 index 0000000..654a57a Binary files /dev/null and b/example/assets/images/leading.png differ diff --git a/example/assets/images/logo-head.png b/example/assets/images/logo-head.png new file mode 100644 index 0000000..93bed9f Binary files /dev/null and b/example/assets/images/logo-head.png differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/.gitignore b/example/aurora/.gitignore similarity index 100% rename from packages/battery_plus/battery_plus_aurora/example/aurora/.gitignore rename to example/aurora/.gitignore diff --git a/packages/wakelock/wakelock_aurora/example/aurora/CMakeLists.txt b/example/aurora/CMakeLists.txt similarity index 97% rename from packages/wakelock/wakelock_aurora/example/aurora/CMakeLists.txt rename to example/aurora/CMakeLists.txt index 4029b94..be3adf9 100644 --- a/packages/wakelock/wakelock_aurora/example/aurora/CMakeLists.txt +++ b/example/aurora/CMakeLists.txt @@ -2,7 +2,7 @@ # License: Proprietary. cmake_minimum_required(VERSION 3.10) -project(com.example.wakelock_aurora_example LANGUAGES CXX) +project(ru.auroraos.flutter_example_packages LANGUAGES CXX) include(GNUInstallDirs) diff --git a/example/aurora/desktop/ru.auroraos.flutter_example_packages.desktop b/example/aurora/desktop/ru.auroraos.flutter_example_packages.desktop new file mode 100644 index 0000000..385dfe0 --- /dev/null +++ b/example/aurora/desktop/ru.auroraos.flutter_example_packages.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Name=Flutter example packages +Comment=Examples of the flutter plugins for Aurora OS. +Icon=ru.auroraos.flutter_example_packages +Exec=/usr/bin/ru.auroraos.flutter_example_packages +X-Nemo-Application-Type=silica-qt5 + +[X-Application] +Permissions=DeviceInfo,UserDirs +OrganizationName=ru.auroraos +ApplicationName=flutter_example_packages diff --git a/example/aurora/icons/108x108.png b/example/aurora/icons/108x108.png new file mode 100644 index 0000000..a0b871d Binary files /dev/null and b/example/aurora/icons/108x108.png differ diff --git a/example/aurora/icons/128x128.png b/example/aurora/icons/128x128.png new file mode 100644 index 0000000..5a4abc7 Binary files /dev/null and b/example/aurora/icons/128x128.png differ diff --git a/example/aurora/icons/172x172.png b/example/aurora/icons/172x172.png new file mode 100644 index 0000000..2979270 Binary files /dev/null and b/example/aurora/icons/172x172.png differ diff --git a/example/aurora/icons/86x86.png b/example/aurora/icons/86x86.png new file mode 100644 index 0000000..b4e9f1f Binary files /dev/null and b/example/aurora/icons/86x86.png differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/main.cpp b/example/aurora/main.cpp similarity index 100% rename from packages/battery_plus/battery_plus_aurora/example/aurora/main.cpp rename to example/aurora/main.cpp diff --git a/packages/sqflite/sqflite_aurora/example/aurora/rpm/com.example.sqflite_aurora_example.spec b/example/aurora/rpm/ru.auroraos.flutter_example_packages.spec similarity index 86% rename from packages/sqflite/sqflite_aurora/example/aurora/rpm/com.example.sqflite_aurora_example.spec rename to example/aurora/rpm/ru.auroraos.flutter_example_packages.spec index 5c0b8ae..2c965f8 100644 --- a/packages/sqflite/sqflite_aurora/example/aurora/rpm/com.example.sqflite_aurora_example.spec +++ b/example/aurora/rpm/ru.auroraos.flutter_example_packages.spec @@ -1,8 +1,8 @@ %global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ %global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ -Name: com.example.sqflite_aurora_example -Summary: Demonstrates how to use the sqflite_aurora plugin. +Name: ru.auroraos.flutter_example_packages +Summary: Examples of the flutter plugins for Aurora OS. Version: 0.1.0 Release: 1 License: Proprietary diff --git a/example/data/raw/flutter.svg b/example/data/raw/flutter.svg new file mode 100644 index 0000000..30c3a1e --- /dev/null +++ b/example/data/raw/flutter.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/data/raw/gingerbread-man-christmas-treat-candy-cartoon.svg b/example/data/raw/gingerbread-man-christmas-treat-candy-cartoon.svg new file mode 100644 index 0000000..a14f383 --- /dev/null +++ b/example/data/raw/gingerbread-man-christmas-treat-candy-cartoon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/data/raw/icon.png b/example/data/raw/icon.png new file mode 100644 index 0000000..cefa8bf Binary files /dev/null and b/example/data/raw/icon.png differ diff --git a/example/data/raw/icon.xcf b/example/data/raw/icon.xcf new file mode 100644 index 0000000..4151ebe Binary files /dev/null and b/example/data/raw/icon.xcf differ diff --git a/example/data/raw/icon2.png b/example/data/raw/icon2.png new file mode 100644 index 0000000..0282c35 Binary files /dev/null and b/example/data/raw/icon2.png differ diff --git a/example/data/raw/links b/example/data/raw/links new file mode 100644 index 0000000..6c111aa --- /dev/null +++ b/example/data/raw/links @@ -0,0 +1,3 @@ +https://iconduck.com/icons/94312/flutter +https://iconduck.com/icons/54169/package +https://iconduck.com/illustrations/108225/gingerbread-man-christmas-treat-candy-cartoon diff --git a/example/data/raw/logo-head.svg b/example/data/raw/logo-head.svg new file mode 100644 index 0000000..ee98409 --- /dev/null +++ b/example/data/raw/logo-head.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/data/raw/package.svg b/example/data/raw/package.svg new file mode 100644 index 0000000..3626988 --- /dev/null +++ b/example/data/raw/package.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/example/l10n.yaml b/example/l10n.yaml new file mode 100644 index 0000000..15338f2 --- /dev/null +++ b/example/l10n.yaml @@ -0,0 +1,3 @@ +arb-dir: lib/l10n +template-arb-file: app_en.arb +output-localization-file: app_localizations.dart diff --git a/example/lib/app.dart b/example/lib/app.dart new file mode 100644 index 0000000..180e1bb --- /dev/null +++ b/example/lib/app.dart @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/packages.dart'; +import 'package:flutter_example_packages/pages/home/page.dart'; +import 'package:flutter_example_packages/theme/theme.dart'; +import 'package:flutter_example_packages/widgets/layouts/page_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +/// Main app class +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + final routes = { + '/': (context) => const HomePage(), + }; + for (var item in packages) { + if (item is PackagePage) { + routes['/${item.key}'] = (context) => PageLayout( + child: item.page.call(), + ); + } + } + + return MaterialApp( + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + debugShowCheckedModeBanner: false, + theme: appTheme, + initialRoute: '/', + routes: routes, + ); + } +} diff --git a/example/lib/base/build/build.config.dart b/example/lib/base/build/build.config.dart new file mode 100644 index 0000000..7a72998 --- /dev/null +++ b/example/lib/base/build/build.config.dart @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +abstract class BuildConfig { + bool get isDebug; +} diff --git a/example/lib/base/build/build.debug.dart b/example/lib/base/build/build.debug.dart new file mode 100644 index 0000000..0efafcf --- /dev/null +++ b/example/lib/base/build/build.debug.dart @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'build.config.dart'; + +class BuildDebugConfig implements BuildConfig { + @override + bool get isDebug => true; +} diff --git a/example/lib/base/build/build.release.dart b/example/lib/base/build/build.release.dart new file mode 100644 index 0000000..c5cd3aa --- /dev/null +++ b/example/lib/base/build/build.release.dart @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'build.config.dart'; + +class BuildReleaseConfig implements BuildConfig { + @override + bool get isDebug => false; +} diff --git a/example/lib/base/di/app_di.dart b/example/lib/base/di/app_di.dart new file mode 100644 index 0000000..eacc605 --- /dev/null +++ b/example/lib/base/di/app_di.dart @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/build/build.config.dart'; +import 'package:flutter_example_packages/pages/home/model.dart'; +import 'package:get_it/get_it.dart'; + +final getIt = GetIt.instance; + +/// Initialization application DI +void setupDI(BuildConfig config) { + getIt + ..registerSingleton(config) + ..registerFactory(() => HomeModel()); +} diff --git a/example/lib/base/package/package.dart b/example/lib/base/package/package.dart new file mode 100644 index 0000000..0908cdd --- /dev/null +++ b/example/lib/base/package/package.dart @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:universal_io/io.dart'; + +class Package { + Package({ + required this.key, + required this.descEN, + required this.descRU, + required this.version, + required this.isPlatformDependent, + }); + + /// Get brief description of the package + String get desc => (Platform.localeName == 'ru_RU' ? descRU : descEN) + .replaceAll("\n", " ") + .replaceAll(RegExp(' +'), ' ') + .trim(); + + /// Key package (https://pub.dev/packages/) + final String key; + + /// Brief description of the package (EN) + final String descEN; + + /// Brief description of the package (RU) + final String descRU; + + /// Version package check + final String version; + + /// Is the package platform dependent? + final bool isPlatformDependent; +} diff --git a/example/lib/base/package/package_dialog.dart b/example/lib/base/package/package_dialog.dart new file mode 100644 index 0000000..3d6b6e6 --- /dev/null +++ b/example/lib/base/package/package_dialog.dart @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:universal_io/io.dart'; + +class PackageDialog extends Package { + PackageDialog({ + required super.key, + required super.descEN, + required super.descRU, + required super.version, + required super.isPlatformDependent, + required this.messageEN, + required this.messageRU, + }); + + /// Get brief description of the package + String get message => (Platform.localeName == 'ru_RU' ? messageRU : messageEN) + .replaceAll("\n", " ") + .replaceAll(RegExp(' +'), ' ') + .trim(); + + /// Message show in dialog (EN) + final String messageEN; + + /// Message show in dialog (RU) + final String messageRU; +} diff --git a/example/lib/base/package/package_page.dart b/example/lib/base/package/package_page.dart new file mode 100644 index 0000000..d0a1c3c --- /dev/null +++ b/example/lib/base/package/package_page.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; + +class PackagePage extends Package { + PackagePage({ + required super.key, + required super.descEN, + required super.descRU, + required super.version, + required super.isPlatformDependent, + required this.page, + required this.init, + }) { + init.call(); + } + + /// Package preview page + final Widget Function() page; + + /// Init callback + final void Function() init; +} diff --git a/example/lib/extensions/keys_ext.dart b/example/lib/extensions/keys_ext.dart new file mode 100644 index 0000000..ead4c20 --- /dev/null +++ b/example/lib/extensions/keys_ext.dart @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +/// Extensions for [GlobalKey] +extension ExtGlobalKey on GlobalKey { + /// Get height by key + double? getHeight() { + if (currentContext == null) { + return null; + } + try { + final renderBoxRed = currentContext!.findRenderObject() as RenderBox; + final sizeRed = renderBoxRed.size; + return sizeRed.height; + } catch (e) { + return 0; + } + } +} diff --git a/example/lib/l10n/app_en.arb b/example/lib/l10n/app_en.arb new file mode 100644 index 0000000..2647a5f --- /dev/null +++ b/example/lib/l10n/app_en.arb @@ -0,0 +1,226 @@ +{ + "@_PROVIDER": {}, + "providerTitle": "Provider", + "providerSubtitle": "Simple example use provider package", + + "@_RXDART": {}, + "rxdartTitle": "Rxdart", + "rxdartSubtitle": "Simple example using Rx for Dart", + + "@_TRANSLATOR": {}, + "translatorTitle": "Translate", + "translatorSubtitle": "Translate en -> ru 'Hello!'", + "translatorText": "Hello!", + + "@_EQUATABLE": {}, + "equatableTitleDefault": "It's default class, 46 of lines", + "equatableTitleFreezed": "It's equatable class, 26 of lines", + "equatableSubtitle": "Methods: toString, operator ==, hashCode.", + + "@_FREEZED": {}, + "freezedTitleDefault": "It's default class, 74 of lines", + "freezedTitleFreezed": "It's freezed class, 21 of lines", + "freezedSubtitle": "Methods: fromJson, copyWith, toJson, toString, operator ==, hashCode.", + + "@_DARTZ": {}, + "dartzTitle": "Convert size", + "dartzDesc": "Convert the size grid of Russia to the size grid of Europe.", + "dartzErrorReq": "Required field", + "dartzErrorInt": "Please enter RUS size (42 - 62)", + "dartzErrorFound": "Size not found (42 - 62)", + "dartzDefaultValue": "Specify the size and click 'Submit'", + "dartzLabel": "Size in RUS", + "dartzSubmit": "Submit", + + "@_SQFLITE": {}, + "sqfliteTitleState": "Database state", + "sqfliteTitleInsert": "Database insert", + "sqfliteTitleUpdate": "Database update by ID", + "sqfliteTitleDelete": "Database delete by ID", + "sqfliteTitleError": "ID not found", + "sqfliteTitleBtnClear": "Clear", + "sqfliteTitleBtnSubmit": "Submit", + "sqfliteTitleFieldID": "ID", + "sqfliteTitleFieldName": "Name (TEXT)", + "sqfliteTitleFieldValue": "Value (INTEGER)", + "sqfliteTitleFieldNum": "Num (REAL)", + "sqfliteTitleValidateRequired": "Required field", + "sqfliteTitleValidateType": "Please enter {type} value", + "@sqfliteTitleValidateType": { + "placeholders": { + "type": { + "type": "String", + "example": "int" + } + } + }, + + "@_BATTERY_PLUS": {}, + "batteryPlusTitleBatteryLevel": "Battery Level", + "batteryPlusDescBatteryLevel": "Battery level in percent 0 - 100.", + "batteryPlusTitleBatteryState": "Battery State", + "batteryPlusDescBatteryState": "Battery state: full, charging, discharging, unknown.", + "batteryPlusTitleBatterySaveMode": "Save Mode", + "batteryPlusDescBatterySaveMode": "Check is enable 'Save Mode'.", + "batteryPlusTitleBatteryStateLive": "Battery State 'Live'", + "batteryPlusDescBatteryStateLive": "Battery change state stream.", + + "@_FLUTTER_KEYBOARD_VISIBILITY": {}, + "flutterKeyboardVisibilityTitle": "Keyboard", + "flutterKeyboardVisibilityDesc": "Stream state keyboard open/close", + "flutterKeyboardVisibilityTitleHeight": "Keyboard height", + "flutterKeyboardVisibilityDescHeight": "Stream state keyboard height", + "flutterKeyboardVisibilityField": "Click for focus", + "flutterKeyboardVisibilityButton": "Clear focus", + + "@_DEVICE_INFO_PLUS": {}, + "deviceInfoPlusTitleID": "ID", + "deviceInfoPlusDescID": "Device ID.", + "deviceInfoPlusTitleName": "Name", + "deviceInfoPlusDescName": "Device name.", + "deviceInfoPlusTitleVersion": "Version OS", + "deviceInfoPlusDescVersion": "Short OS version.", + "deviceInfoPlusTitlePrettyName": "Full Name", + "deviceInfoPlusDescPrettyName": "Pretty name OS.", + "deviceInfoPlusTitleGNSS": "GNSS", + "deviceInfoPlusDescGNSS": "Check is has GNSS.", + "deviceInfoPlusTitleNFC": "NFC", + "deviceInfoPlusDescNFC": "Check is has NFC.", + "deviceInfoPlusTitleBluetooth": "Bluetooth", + "deviceInfoPlusDescBluetooth": "Check is has bluetooth.", + "deviceInfoPlusTitleWlan": "WLAN", + "deviceInfoPlusDescWlan": "Check is has Wireless LAN.", + "deviceInfoPlusTitleMaxCpuClockSpeed": "CPU speed", + "deviceInfoPlusDescMaxCpuClockSpeed": "Max CPU clock speed.", + "deviceInfoPlusTitleNumberCpuCores": "CPU cores", + "deviceInfoPlusDescNumberCpuCores": "Number CPU cores.", + "deviceInfoPlusTitleBatteryCharge": "Battery charge", + "deviceInfoPlusDescBatteryCharge": "Battery level in percent 0-100.", + "deviceInfoPlusTitleMainCameraResolution": "Main camera", + "deviceInfoPlusDescMainCameraResolution": "Main camera resolution.", + "deviceInfoPlusTitleFrontalCameraResolution": "Frontal camera", + "deviceInfoPlusDescFrontalCameraResolution": "Frontal camera resolution.", + "deviceInfoPlusTitleRamTotalSize": "RAM total", + "deviceInfoPlusDescRamTotalSize": "RAM total size.", + "deviceInfoPlusTitleRamFreeSize": "RAM free", + "deviceInfoPlusDescRamFreeSize": "RAM free size.", + "deviceInfoPlusTitleScreenResolution": "Screen", + "deviceInfoPlusDescScreenResolution": "Screen resolution.", + "deviceInfoPlusTitleOsVersion": "Version OS", + "deviceInfoPlusDescOsVersion": "Full OS version.", + "deviceInfoPlusTitleDeviceModel": "Device", + "deviceInfoPlusDescDeviceModel": "Device name model.", + + "@_FLUTTER_LOCAL_NOTIFICATIONS": {}, + "flutterLocalNotificationsHintTitle": "Notification title", + "flutterLocalNotificationsHintBody": "Notification body", + "flutterLocalNotificationsBtn": "Send", + + "@_FLUTTER_SECURE_STORAGE": {}, + "flutterSecureStorageSuccess": "Data saved successfully", + "flutterSecureStorageTitleSave": "Save value", + "flutterSecureStorageTitleGet": "Get value", + "flutterSecureStorageFieldPass": "Password", + "flutterSecureStorageFieldKey": "Key", + "flutterSecureStorageFieldValue": "Value", + "flutterSecureStorageBtnSave": "Save value", + "flutterSecureStorageBtnGet": "Get value", + + "@_PACKAGE_INFO_PLUS": {}, + "packageInfoPlusTitlePackageName": "Package", + "packageInfoPlusDescPackageName": "Package name.", + "packageInfoPlusTitleApplicationName": "Name", + "packageInfoPlusDescApplicationName": "Application name.", + + "@_PATH_PROVIDER": {}, + "pathProviderTitleApplicationSupport": "Application Support", + "pathProviderDescApplicationSupport": "Directory where the application may place application support files.", + "pathProviderTitleTemporary": "Temporary", + "pathProviderDescTemporary": "Directory location where user-specific non-essential (cached) data should be written.", + "pathProviderTitleApplicationDocuments": "Documents", + "pathProviderDescApplicationDocuments": "Directory containing user document files.", + "pathProviderTitleDownloads": "Download", + "pathProviderDescDownloads": "Directory for user's downloaded files.", + "pathProviderTitlePictures": "Pictures", + "pathProviderDescPictures": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.pictures directory.", + "pathProviderTitleMusic": "Music", + "pathProviderDescMusic": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.music directory.", + "pathProviderTitleMovies": "Movies", + "pathProviderDescMovies": "There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.movies directory.", + + "@_SHARED_PREFERENCES": {}, + "sharedPreferencesTitleState": "State", + "sharedPreferencesTitleUpdate": "Update", + "sharedPreferencesFieldInt": "Int", + "sharedPreferencesFieldBool": "Bool", + "sharedPreferencesFieldDouble": "Double", + "sharedPreferencesFieldString": "String", + "sharedPreferencesFieldList": "List", + "sharedPreferencesFieldBtnClean": "Clean", + "sharedPreferencesFieldBtn": "Save", + "sharedPreferencesFieldError": "Please enter {value} value", + "@sharedPreferencesFieldError": { + "placeholders": { + "value": { + "type": "String", + "example": "int" + } + } + }, + + "@_WAKELOCK": {}, + "wakelockTitle": "Wakelock", + "wakelockDesc": "The plugin allows you to enable and toggle the screen wakelock, which prevents the screen from turning off automatically.", + + "@_XDGA_DIRECTORIES": {}, + "xdgaDirectoriesTitleCacheLocation": "App Data Location", + "xdgaDirectoriesDescCacheLocation": "Directory location where persistent application data can be stored.", + "xdgaDirectoriesTitleAppDataLocation": "Cache Location", + "xdgaDirectoriesDescAppDataLocation": "Directory location where user-specific non-essential (cached) data should be written.", + "xdgaDirectoriesTitleDocumentsLocation": "Documents Location", + "xdgaDirectoriesDescDocumentsLocation": "Directory containing user document files.", + "xdgaDirectoriesTitleDownloadLocation": "Download Location", + "xdgaDirectoriesDescDownloadLocation": "Directory for user's downloaded files.", + "xdgaDirectoriesTitleMusicLocation": "Music Location", + "xdgaDirectoriesDescMusicLocation": "Directory containing the user's music or other audio files.", + "xdgaDirectoriesTitlePicturesLocation": "Pictures Location", + "xdgaDirectoriesDescPicturesLocation": "Directory containing the user's pictures or photos.", + "xdgaDirectoriesTitleGenericDataLocation": "Generic Data Location", + "xdgaDirectoriesDescGenericDataLocation": "Directory location where persistent data shared across applications can be stored.", + "xdgaDirectoriesTitleMoviesLocation": "Movies Location", + "xdgaDirectoriesDescMoviesLocation": "Directory containing the user's movies and videos.", + + "@_COMMON": {}, + "commonClose": "Close", + "commonEmptyValue": "Empty", + "commonLoading": "Loading...", + + "@_HOME_SCREEN": {}, + "homePageTitle": "Flutter Aurora OS", + "homeWelcomeTitle": "Welcome!", + "homeWelcomeText": "In this application you can find {count} Flutter plugins supporting Aurora OS. If it happens that something is missing for you, you can write to us or add it yourself.", + "@homeWelcomeText": { + "placeholders": { + "count": { + "type": "int", + "example": "0" + } + } + }, + "homeListStateDependent": "platform dependent", + "homeListStateIndependent": "platform independent", + "homeListVersion": "Version: {version}", + "@homeListVersion": { + "placeholders": { + "version": { + "type": "String", + "example": "1.0.0" + } + } + }, + "homeSearchTitle": "Search...", + "homeSearch": "Search packages", + "homeFilter": "Filter", + "homeNotFoundTitle": "Not found", + "homeNotFoundSubtitle": "What you were looking for is not in the list of verified plugins, but this does not mean that it will not work, check it out and you may want to add it to this list of verified plugins." +} diff --git a/example/lib/l10n/app_ru.arb b/example/lib/l10n/app_ru.arb new file mode 100644 index 0000000..b8bd5e4 --- /dev/null +++ b/example/lib/l10n/app_ru.arb @@ -0,0 +1,218 @@ +{ + "@_PROVIDER": {}, + "providerTitle": "Provider", + "providerSubtitle": "Простой пример использования пакета provider", + + "@_RXDART": {}, + "rxdartTitle": "Rxdart", + "rxdartSubtitle": "Простой пример использования Rx для Dart", + + "@_TRANSLATOR": {}, + "translatorTitle": "Переводчик", + "translatorSubtitle": "Перевод en -> ru 'Hello!'", + "translatorText": "Hello!", + + "@_EQUATABLE": {}, + "equatableTitleDefault": "Класс по умолчанию, 46 строки", + "equatableTitleFreezed": "Класс c freezed, 26 строк", + "equatableSubtitle": "Методы: toString, operator ==, hashCode.", + + "@_FREEZED": {}, + "freezedTitleDefault": "Класс по умолчанию, 74 строки", + "freezedTitleFreezed": "Класс c freezed, 21 строка", + "freezedSubtitle": "Методы: fromJson, copyWith, toJson, toString, operator ==, hashCode.", + + "@_DARTZ": {}, + "dartzTitle": "Преобразовать размер", + "dartzDesc": "Преобразовать размерную сетку России в размерную сетку Европы.", + "dartzErrorReq": "Обязательное поле", + "dartzErrorInt": "Введите размер RUS (42–62)", + "dartzErrorFound": "Размер не найден (42–62)", + "dartzDefaultValue": "Укажите размер и нажмите 'Отправить'", + "dartzLabel": "Размер в RUS", + "dartzSubmit": "Отправить", + + "@_SQFLITE": {}, + "sqfliteTitleState": "Состояние базы данных", + "sqfliteTitleInsert": "Вставка в базу данных", + "sqfliteTitleUpdate": "Обновление базы данных по ID", + "sqfliteTitleDelete": "Удаление базы данных по ID", + "sqfliteTitleError": "ID не найден", + "sqfliteTitleBtnClear": "Очистить", + "sqfliteTitleBtnSubmit": "Отправить", + "sqfliteTitleFieldID": "Идентификатор", + "sqfliteTitleFieldName": "Имя (TEXT)", + "sqfliteTitleFieldValue": "Значение (INTEGER)", + "sqfliteTitleFieldNum": "Число (REAL)", + "sqfliteTitleValidateRequired": "Обязательное поле", + "sqfliteTitleValidateType": "Введите значение {type}", + "@sqfliteTitleValidateType": { + "placeholders": { + "type": { + "type": "String", + "example": "int" + } + } + }, + + "@_BATTERY_PLUS": {}, + "batteryPlusTitleBatteryLevel": "Уровень заряда батареи", + "batteryPlusDescBatteryLevel": "Уровень заряда батареи в процентах от 0 до 100.", + "batteryPlusTitleBatteryState": "Состояние батареи", + "batteryPlusDescBatteryState": "Состояния: full, charging, discharging, unknown.", + "batteryPlusTitleBatterySaveMode": "Save Mode", + "batteryPlusDescBatterySaveMode": "Проверка включен ли режим 'Save Mode'.", + "batteryPlusTitleBatteryStateLive": "Состояние батареи 'Live'", + "batteryPlusDescBatteryStateLive": "Изменение состояния батареи.", + + "@_FLUTTER_KEYBOARD_VISIBILITY": {}, + "flutterKeyboardVisibilityTitle": "Клавиатура", + "flutterKeyboardVisibilityDesc": "Сигнал при изменении состояния клавиатуры открыта/закрыта", + "flutterKeyboardVisibilityTitleHeight": "Высота клавиатуры", + "flutterKeyboardVisibilityDescHeight": "Сигнал при изменении высоты клавиатуры", + "flutterKeyboardVisibilityField": "Нажмите, чтобы сфокусироваться", + "flutterKeyboardVisibilityButton": "Снять фокус", + + "@_DEVICE_INFO_PLUS": {}, + "deviceInfoPlusTitleID": "ID", + "deviceInfoPlusDescID": "Идентификатор устройства.", + "deviceInfoPlusTitleName": "Имя", + "deviceInfoPlusDescName": "Имя устройства.", + "deviceInfoPlusTitleVersion": "Версия ОС", + "deviceInfoPlusDescVersion": "Короткое название версии ОС.", + "deviceInfoPlusTitlePrettyName": "Полное имя", + "deviceInfoPlusDescPrettyName": "Красивое имя ОС.", + "deviceInfoPlusTitleGNSS": "GNSS", + "deviceInfoPlusDescGNSS": "Проверить наличие GNSS.", + "deviceInfoPlusTitleNFC": "NFC", + "deviceInfoPlusDescNFC": "Проверить, есть ли NFC.", + "deviceInfoPlusTitleBluetooth": "Bluetooth", + "deviceInfoPlusDescBluetooth": "Проверьте, есть ли Bluetooth.", + "deviceInfoPlusTitleWlan": "WLAN", + "deviceInfoPlusDescWlan": "Проверьте, есть ли Wireless LAN.", + "deviceInfoPlusTitleMaxCpuClockSpeed": "Частота процессора", + "deviceInfoPlusDescMaxCpuClockSpeed": "Максимальная тактовая частота процессора.", + "deviceInfoPlusTitleNumberCpuCores": "Ядра ЦП", + "deviceInfoPlusDescNumberCpuCores": "Количество ядер ЦП.", + "deviceInfoPlusTitleBatteryCharge": "Заряд батареи", + "deviceInfoPlusDescBatteryCharge": "Уровень заряда батареи в процентах от 0 до 100.", + "deviceInfoPlusTitleMainCameraResolution": "Основная камера", + "deviceInfoPlusDescMainCameraResolution": "Разрешение основной камеры.", + "deviceInfoPlusTitleFrontalCameraResolution": "Фронтальная камера", + "deviceInfoPlusDescFrontalCameraResolution": "Разрешение фронтальной камеры.", + "deviceInfoPlusTitleRamTotalSize": "Всего ОЗУ", + "deviceInfoPlusDescRamTotalSize": "Общий размер ОЗУ.", + "deviceInfoPlusTitleRamFreeSize": "Свободно ОЗУ", + "deviceInfoPlusDescRamFreeSize": "Свободный размер ОЗУ.", + "deviceInfoPlusTitleScreenResolution": "Экран", + "deviceInfoPlusDescScreenResolution": "Разрешение экрана.", + "deviceInfoPlusTitleOsVersion": "Версия ОС", + "deviceInfoPlusDescOsVersion": "Полное название версия ОС.", + "deviceInfoPlusTitleDeviceModel": "Устройство", + "deviceInfoPlusDescDeviceModel": "Имя модели устройства.", + + "@_FLUTTER_LOCAL_NOTIFICATIONS": {}, + "flutterLocalNotificationsHintTitle": "Заголовок уведомления", + "flutterLocalNotificationsHintBody": "Текст уведомления", + "flutterLocalNotificationsBtn": "Отправить", + + "@_FLUTTER_SECURE_STORAGE": {}, + "flutterSecureStorageSuccess": "Данные успешно сохранены", + "flutterSecureStorageTitleSave": "Сохранить значение", + "flutterSecureStorageTitleGet": "Получить значение", + "flutterSecureStorageFieldPass": "Пароль", + "flutterSecureStorageFieldKey": "Ключ", + "flutterSecureStorageFieldValue": "Значение", + "flutterSecureStorageBtnSave": "Сохранить значение", + "flutterSecureStorageBtnGet": "Получить значение", + + "@_PACKAGE_INFO_PLUS": {}, + "packageInfoPlusTitlePackageName": "Пакет", + "packageInfoPlusDescPackageName": "Имя пакета.", + "packageInfoPlusTitleApplicationName": "Имя", + "packageInfoPlusDescApplicationName": "Имя приложения.", + + "@_PATH_PROVIDER": {}, + "pathProviderTitleApplicationSupport": "Поддержка приложений", + "pathProviderDescApplicationSupport": "Каталог, в котором приложение может размещать файлы поддержки приложений.", + "pathProviderTitleTemporary": "Временный", + "pathProviderDescTemporary": "Расположение каталога, куда должны быть записаны второстепенные (кешированные) данные пользователя.", + "pathProviderTitleApplicationDocuments": "Документы", + "pathProviderDescApplicationDocuments": "Каталог, содержащий файлы пользовательских документов.", + "pathProviderTitleDownloads": "Скачать", + "pathProviderDescDownloads": "Каталог для загруженных пользователем файлов.", + "pathProviderTitlePictures": "Изображения", + "pathProviderDescPictures": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.pictures.", + "pathProviderTitleMusic": "Музыка", + "pathProviderDescMusic": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.music.", + "pathProviderTitleMovies": "Фильмы", + "pathProviderDescMovies": "В Aurora OS нет концепции External, но этот интерфейс позволяет получить каталог StorageDirectory.movies.", + + "@_SHARED_PREFERENCES": {}, + "sharedPreferencesTitleState": "Состояние", + "sharedPreferencesTitleUpdate": "Обновить", + "sharedPreferencesFieldInt": "Int", + "sharedPreferencesFieldBool": "Bool", + "sharedPreferencesFieldDouble": "Double", + "sharedPreferencesFieldString": "String", + "sharedPreferencesFieldList": "Список", + "sharedPreferencesFieldBtnClean": "Очистить", + "sharedPreferencesFieldBtn": "Сохранить", + "sharedPreferencesFieldError": "Пожалуйста, введите {value} значение", + + "@_WAKELOCK": {}, + "wakelockTitle": "Wakelock", + "wakelockDesc": "Плагин позволяет включать и переключать блокировку экрана, которая предотвращает автоматическое выключение экрана.", + + "@_XDGA_DIRECTORIES": {}, + "xdgaDirectoriesTitleCacheLocation": "App Data Location", + "xdgaDirectoriesDescCacheLocation": "Расположение каталога, в котором могут храниться постоянные данные приложения.", + "xdgaDirectoriesTitleAppDataLocation": "Cache Location", + "xdgaDirectoriesDescAppDataLocation": "Расположение каталога, в котором должны быть записаны второстепенные (кэшированные) данные пользователя.", + "xdgaDirectoriesTitleDocumentsLocation": "Documents Location", + "xdgaDirectoriesDescDocumentsLocation": "Каталог, содержащий файлы документов пользователя.", + "xdgaDirectoriesTitleDownloadLocation": "Download Location", + "xdgaDirectoriesDescDownloadLocation": "Каталог для загруженных пользователем файлов.", + "xdgaDirectoriesTitleMusicLocation": "Music Location", + "xdgaDirectoriesDescMusicLocation": "Каталог, содержащий музыку пользователя или другие аудиофайлы.", + "xdgaDirectoriesTitlePicturesLocation": "Pictures Location", + "xdgaDirectoriesDescPicturesLocation": "Каталог, содержащий изображения или фотографии пользователя.", + "xdgaDirectoriesTitleGenericDataLocation": "Generic Data Location", + "xdgaDirectoriesDescGenericDataLocation": "Расположение каталога, в котором могут храниться постоянные данные, совместно используемые приложениями.", + "xdgaDirectoriesTitleMoviesLocation": "Movies Location", + "xdgaDirectoriesDescMoviesLocation": "Каталог, содержащий фильмы и видео пользователя.", + + "@_COMMON": {}, + "commonClose": "Закрыть", + "commonEmptyValue": "Пусто", + "commonLoading": "Загрузка...", + + "@_HOME_SCREEN": {}, + "homePageTitle": "Flutter ОС Аврора", + "homeWelcomeTitle": "Приветствую!", + "homeWelcomeText": "В этом приложении вы можете найти {count} плагинов Flutter, поддерживающих ОС Aurora. Если вдруг вам чего-то не хватает, вы можете написать нам или добавить самостоятельно.", + "@homeWelcomeText": { + "placeholders": { + "count": { + "type": "int", + "example": "0" + } + } + }, + "homeListStateDependent": "платформо-зависимый", + "homeListStateIndependent": "платформонезависимый", + "homeListVersion": "Версия: {version}", + "@homeListVersion": { + "placeholders": { + "version": { + "type": "String", + "example": "1.0.0" + } + } + }, + "homeSearchTitle": "Поиск...", + "homeSearch": "Поиск пакетов", + "homeNotFoundTitle": "Не найдено", + "homeNotFoundSubtitle": "То что вы искали нет в списке провереных плагинов, но это не означает что он работать не будет, проверьте его и возможно вы захотите добавить его в этот список проверенных плагинов.", + "homeFilter": "Фильтр" +} diff --git a/example/lib/main.dart b/example/lib/main.dart new file mode 100644 index 0000000..41f13e7 --- /dev/null +++ b/example/lib/main.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/app.dart'; +import 'package:flutter_example_packages/base/build/build.release.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; + +void main() { + setupDI(BuildReleaseConfig()); + runApp(const MyApp()); +} diff --git a/example/lib/main.release.dart b/example/lib/main.release.dart new file mode 100644 index 0000000..cf01643 --- /dev/null +++ b/example/lib/main.release.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/app.dart'; +import 'package:flutter_example_packages/base/build/build.debug.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; + +void main() { + setupDI(BuildDebugConfig()); + runApp(const MyApp()); +} diff --git a/example/lib/packages/battery_plus/model.dart b/example/lib/packages/battery_plus/model.dart new file mode 100644 index 0000000..5817ee6 --- /dev/null +++ b/example/lib/packages/battery_plus/model.dart @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:battery_plus/battery_plus.dart'; + +/// Model for [BatteryPlusPage] +class BatteryPlusModel extends Model { + /// Get [ScopedModel] + static BatteryPlusModel of(BuildContext context) => + ScopedModel.of(context); + + final _battery = Battery(); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Get battery level in percent 0-100 + Future getBatteryLevel() async { + try { + return await _battery.batteryLevel; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get status + Future getBatteryState() async { + try { + return await _battery.batteryState; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Check is enable save mode + Future isInBatterySaveMode() async { + try { + return await _battery.isInBatterySaveMode; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Stream change state + Stream onBatteryStateChanged() async* { + try { + yield await _battery.batteryState; + await for (final state in _battery.onBatteryStateChanged) { + yield state; + } + } catch (e) { + _error = e.toString(); + notifyListeners(); + } + } +} diff --git a/example/lib/packages/battery_plus/package.dart b/example/lib/packages/battery_plus/package.dart new file mode 100644 index 0000000..7b3c9e1 --- /dev/null +++ b/example/lib/packages/battery_plus/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/battery_plus/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageBatteryPlus = PackagePage( + key: 'battery_plus', + descEN: ''' + A Flutter plugin to access various information about the + battery of the device the app is running on. + ''', + descRU: ''' + Плагин Flutter для доступа к различной информации о + аккумулятор устройства, на котором запущено приложение. + ''', + version: '4.0.1', + isPlatformDependent: true, + page: () => BatteryPlusPage(), + init: () { + GetIt.instance.registerFactory(() => BatteryPlusModel()); + }, +); diff --git a/example/lib/packages/battery_plus/page.dart b/example/lib/packages/battery_plus/page.dart new file mode 100644 index 0000000..bcf08c4 --- /dev/null +++ b/example/lib/packages/battery_plus/page.dart @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/battery_plus/model.dart'; +import 'package:flutter_example_packages/packages/battery_plus/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class BatteryPlusPage extends AppStatefulWidget { + BatteryPlusPage({ + super.key, + }); + + final Package package = packageBatteryPlus; + + @override + State createState() => _BatteryPlusPageState(); +} + +class _BatteryPlusPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.batteryPlusTitleBatteryLevel, + desc: l10n.batteryPlusDescBatteryLevel, + future: model.getBatteryLevel(), + builder: (value) => '$value%', + ), + BlockItem( + title: l10n.batteryPlusTitleBatteryState, + desc: l10n.batteryPlusDescBatteryState, + future: model.getBatteryState(), + builder: (value) => + value.toString().split('.').last.toUpperCase(), + ), + BlockItem( + title: l10n.batteryPlusTitleBatterySaveMode, + desc: l10n.batteryPlusDescBatterySaveMode, + future: model.isInBatterySaveMode(), + ), + BlockItem( + title: l10n.batteryPlusTitleBatteryStateLive, + desc: l10n.batteryPlusDescBatteryStateLive, + stream: model.onBatteryStateChanged(), + builder: (value) => + value.toString().split('.').last.toUpperCase(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/build_runner/package.dart b/example/lib/packages/build_runner/package.dart new file mode 100644 index 0000000..942b083 --- /dev/null +++ b/example/lib/packages/build_runner/package.dart @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageBuildRunner = PackageDialog( + key: 'build_runner', + descEN: ''' + The build_runner package provides a concrete way of generating files using + Dart code. Files are always generated directly on disk, and rebuilds + are incremental - inspired by tools such as Bazel. + ''', + descRU: ''' + Пакет build_runner предоставляет конкретный способ создания файлов с + использованием кода Dart. Файлы всегда генерируются непосредственно на + диске и перестраиваются являются инкрементными — вдохновлены такими + инструментами, как Bazel. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '2.3.3', + isPlatformDependent: false, +); diff --git a/example/lib/packages/cached_network_image/model.dart b/example/lib/packages/cached_network_image/model.dart new file mode 100644 index 0000000..1ee4487 --- /dev/null +++ b/example/lib/packages/cached_network_image/model.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [CachedNetworkImagePage] +class CachedNetworkImageModel extends Model { + /// Get [ScopedModel] + static CachedNetworkImageModel of(BuildContext context) => + ScopedModel.of(context); +} diff --git a/example/lib/packages/cached_network_image/package.dart b/example/lib/packages/cached_network_image/package.dart new file mode 100644 index 0000000..cba869c --- /dev/null +++ b/example/lib/packages/cached_network_image/package.dart @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/cached_network_image/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageCachedNetworkImage = PackagePage( + key: 'cached_network_image', + descEN: ''' + A flutter library to show images from the internet + and keep them in the cache directory. + ''', + descRU: ''' + Библиотека флаттера для отображения изображений из + Интернета и хранения их в каталоге кеша. + ''', + version: '3.2.3', + isPlatformDependent: true, + page: () => CachedNetworkImagePage(), + init: () { + GetIt.instance.registerFactory( + () => CachedNetworkImageModel()); + }, +); diff --git a/example/lib/packages/cached_network_image/page.dart b/example/lib/packages/cached_network_image/page.dart new file mode 100644 index 0000000..0788492 --- /dev/null +++ b/example/lib/packages/cached_network_image/page.dart @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/cached_network_image/model.dart'; +import 'package:flutter_example_packages/packages/cached_network_image/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class CachedNetworkImagePage extends AppStatefulWidget { + CachedNetworkImagePage({ + super.key, + }); + + final Package package = packageCachedNetworkImage; + + @override + State createState() => _CachedNetworkImagePageState(); +} + +class _CachedNetworkImagePageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + SizedBox( + width: double.infinity, + height: 150, + child: Center( + child: CachedNetworkImage( + imageUrl: "https://via.placeholder.com/350x150", + placeholder: (context, url) => + const CircularProgressIndicator(), + errorWidget: (context, url, error) => + const Icon(Icons.error), + ), + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/crypto/package.dart b/example/lib/packages/crypto/package.dart new file mode 100644 index 0000000..fa019cb --- /dev/null +++ b/example/lib/packages/crypto/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageCrypto = PackageDialog( + key: 'crypto', + descEN: ''' + A set of cryptographic hashing functions for Dart. + ''', + descRU: ''' + Набор криптографических функций хеширования для Dart. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '3.0.2', + isPlatformDependent: false, +); diff --git a/example/lib/packages/cupertino_icons/package.dart b/example/lib/packages/cupertino_icons/package.dart new file mode 100644 index 0000000..b154ccc --- /dev/null +++ b/example/lib/packages/cupertino_icons/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageCupertinoIcons = PackageDialog( + key: 'cupertino_icons', + descEN: ''' + This is an asset repo containing the default set of icon assets + used by Flutter's Cupertino widgets. + ''', + descRU: ''' + Это репозиторий ресурсов, содержащий набор ресурсов значков по умолчанию + используется виджетами Flutter Cupertino. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '1.0.5', + isPlatformDependent: false, +); diff --git a/example/lib/packages/dartz/model.dart b/example/lib/packages/dartz/model.dart new file mode 100644 index 0000000..0174b47 --- /dev/null +++ b/example/lib/packages/dartz/model.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:dartz/dartz.dart'; +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [DartzPage] +class DartzModel extends Model { + /// Get [ScopedModel] + static DartzModel of(BuildContext context) => + ScopedModel.of(context); + + /// Example using Option from package dartz + Option getEURManSize(int size) { + if (size < 42) return none(); + if (size < 44) return some('XS'); + if (size < 46) return some('S'); + if (size < 48) return some('M'); + if (size < 50) return some('L'); + if (size < 54) return some('XL'); + if (size < 56) return some('XXL'); + if (size < 58) return some('XXXL'); + if (size <= 62) return some('XXXXL'); + return none(); + } +} diff --git a/example/lib/packages/dartz/package.dart b/example/lib/packages/dartz/package.dart new file mode 100644 index 0000000..214a2d9 --- /dev/null +++ b/example/lib/packages/dartz/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageDartz = PackagePage( + key: 'dartz', + descEN: ''' + Functional programming in Dart. + ''', + descRU: ''' + Функциональное программирование в Dart. + ''', + version: '0.10.1', + isPlatformDependent: false, + page: () => DartzPage(), + init: () { + GetIt.instance.registerFactory(() => DartzModel()); + }, +); diff --git a/example/lib/packages/dartz/page.dart b/example/lib/packages/dartz/page.dart new file mode 100644 index 0000000..7fe4870 --- /dev/null +++ b/example/lib/packages/dartz/page.dart @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:async'; + +import 'package:flutter/foundation.dart' show kIsAurora; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; + +import 'model.dart'; +import 'package.dart'; + +class DartzPage extends AppStatefulWidget { + DartzPage({ + super.key, + }); + + final Package package = packageDartz; + + @override + State createState() => _DartzPageState(); +} + +class _DartzPageState extends AppState { + final TextEditingController _textController = TextEditingController(); + final _formKey = GlobalKey(); + String? _sizeEUR; + bool _isError = false; + + double _keyboardHeight = 0; + StreamSubscription? _streamSub; + final _controllerAurora = FlutterKeyboardVisibilityAurora(); + + @override + void initState() { + super.initState(); + if (kIsAurora) { + _streamSub = _controllerAurora.onChangeHeight.listen((event) { + setState(() { + _keyboardHeight = event; + }); + }); + } + } + + @override + void dispose() { + super.dispose(); + _streamSub?.cancel(); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + padding: EdgeInsets.only(bottom: _keyboardHeight), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.dartzTitle, + desc: l10n.dartzDesc, + value: _sizeEUR ?? l10n.dartzDefaultValue, + ), + TextFormField( + controller: _textController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.dartzLabel, + errorText: _isError ? l10n.dartzErrorFound : null, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.dartzErrorReq; + } + if (int.tryParse(value) == null) { + return l10n.dartzErrorInt; + } + return null; + }, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () async { + if (_formKey.currentState?.validate() == true) { + final sizeRU = int.parse(_textController.text); + model + .getEURManSize(sizeRU) + .map( + (classification) => setState(() { + _isError = false; + _sizeEUR = classification; + }), + ) + .getOrElse( + () => setState(() { + _sizeEUR = null; + _isError = true; + }), + ); + } + }, + child: TextBodyLarge( + l10n.dartzSubmit, + color: Colors.white, + ), + ), + ), + ], + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/device_info_plus/model.dart b/example/lib/packages/device_info_plus/model.dart new file mode 100644 index 0000000..3b7c11e --- /dev/null +++ b/example/lib/packages/device_info_plus/model.dart @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:device_info_plus/device_info_plus.dart'; +import 'package:device_info_plus_aurora/aurora_device_info.dart'; +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [DeviceInfoPlusPage] +class DeviceInfoPlusModel extends Model { + /// Get [ScopedModel] + static DeviceInfoPlusModel of(BuildContext context) => + ScopedModel.of(context); + + final _deviceInfoPlugin = DeviceInfoPlugin(); + + /// Get Aurora info + Future get _deviceInfo async => + await _deviceInfoPlugin.linuxInfo as AuroraDeviceInfo; + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Get ID name device + Future getID() async { + try { + return (await _deviceInfo).id; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Device name + Future getName() async { + try { + return (await _deviceInfo).name; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Version + Future getVersion() async { + try { + return (await _deviceInfo).version; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Device full name + Future getPrettyName() async { + try { + return (await _deviceInfo).prettyName; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Check has GNSS + Future hasGNSS() async { + try { + return (await _deviceInfo).hasGNSS; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Check has NFC + Future hasNFC() async { + try { + return (await _deviceInfo).hasNFC; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Check has Bluetooth + Future hasBluetooth() async { + try { + return (await _deviceInfo).hasBluetooth; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Check has Wlan + Future hasWlan() async { + try { + return (await _deviceInfo).hasWlan; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Max CPU clock speed + Future getMaxCpuClockSpeed() async { + try { + return (await _deviceInfo).maxCpuClockSpeed; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Number CPU cores + Future getNumberCpuCores() async { + try { + return (await _deviceInfo).numberCpuCores; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get battery level in percent 0-100 + Future getBatteryChargePercentage() async { + try { + return (await _deviceInfo).batteryChargePercentage; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Camera resolution + Future getMainCameraResolution() async { + try { + return (await _deviceInfo).mainCameraResolution; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Frontal camera resolution + Future getFrontalCameraResolution() async { + try { + return (await _deviceInfo).frontalCameraResolution; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// RAM total size + Future getRamTotalSize() async { + try { + return (await _deviceInfo).ramTotalSize; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// RAM free size + Future getRamFreeSize() async { + try { + return (await _deviceInfo).ramFreeSize; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Screen resolution + Future getScreenResolution() async { + try { + return (await _deviceInfo).screenResolution; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Version @todo + Future getOsVersion() async { + try { + return (await _deviceInfo).osVersion; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Device model + Future getDeviceModel() async { + try { + return (await _deviceInfo).deviceModel; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get map with info about external storage + Future?> getExternalStorage() async { + try { + return (await _deviceInfo).externalStorage; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get map with info about internal storage + Future?> getInternalStorage() async { + try { + return (await _deviceInfo).internalStorage; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get map with info about SIM cards + Future>?> getSimCards() async { + try { + return (await _deviceInfo).simCards; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } +} diff --git a/example/lib/packages/device_info_plus/package.dart b/example/lib/packages/device_info_plus/package.dart new file mode 100644 index 0000000..d8cc105 --- /dev/null +++ b/example/lib/packages/device_info_plus/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/device_info_plus/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageDeviceInfoPlus = PackagePage( + key: 'device_info_plus', + descEN: ''' + Get current device information from within the Flutter application. + ''', + descRU: ''' + Получите текущую информацию об устройстве из приложения Flutter. + ''', + version: '8.2.2', + isPlatformDependent: true, + page: () => DeviceInfoPlusPage(), + init: () { + GetIt.instance + .registerFactory(() => DeviceInfoPlusModel()); + }, +); diff --git a/example/lib/packages/device_info_plus/page.dart b/example/lib/packages/device_info_plus/page.dart new file mode 100644 index 0000000..903e399 --- /dev/null +++ b/example/lib/packages/device_info_plus/page.dart @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/device_info_plus/model.dart'; +import 'package:flutter_example_packages/packages/device_info_plus/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class DeviceInfoPlusPage extends AppStatefulWidget { + DeviceInfoPlusPage({ + super.key, + }); + + final Package package = packageDeviceInfoPlus; + + @override + State createState() => _DeviceInfoPlusPageState(); +} + +class _DeviceInfoPlusPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.deviceInfoPlusTitleID, + desc: l10n.deviceInfoPlusDescID, + future: model.getID(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleName, + desc: l10n.deviceInfoPlusDescName, + future: model.getName(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleVersion, + desc: l10n.deviceInfoPlusDescVersion, + future: model.getVersion(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitlePrettyName, + desc: l10n.deviceInfoPlusDescName, + future: model.getPrettyName(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleGNSS, + desc: l10n.deviceInfoPlusDescGNSS, + future: model.hasGNSS(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleNFC, + desc: l10n.deviceInfoPlusDescNFC, + future: model.hasNFC(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleBluetooth, + desc: l10n.deviceInfoPlusDescBluetooth, + future: model.hasBluetooth(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleWlan, + desc: l10n.deviceInfoPlusDescWlan, + future: model.hasWlan(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleMaxCpuClockSpeed, + desc: l10n.deviceInfoPlusDescMaxCpuClockSpeed, + future: model.getMaxCpuClockSpeed(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleNumberCpuCores, + desc: l10n.deviceInfoPlusDescNumberCpuCores, + future: model.getNumberCpuCores(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleBatteryCharge, + desc: l10n.deviceInfoPlusDescBatteryCharge, + future: model.getBatteryChargePercentage(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleMainCameraResolution, + desc: l10n.deviceInfoPlusDescMainCameraResolution, + future: model.getMainCameraResolution(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleFrontalCameraResolution, + desc: l10n.deviceInfoPlusDescFrontalCameraResolution, + future: model.getFrontalCameraResolution(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleRamTotalSize, + desc: l10n.deviceInfoPlusDescRamTotalSize, + future: model.getRamTotalSize(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleRamFreeSize, + desc: l10n.deviceInfoPlusDescRamFreeSize, + future: model.getRamFreeSize(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleScreenResolution, + desc: l10n.deviceInfoPlusDescScreenResolution, + future: model.getScreenResolution(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleOsVersion, + desc: l10n.deviceInfoPlusDescOsVersion, + future: model.getOsVersion(), + ), + BlockItem( + title: l10n.deviceInfoPlusTitleDeviceModel, + desc: l10n.deviceInfoPlusDescDeviceModel, + future: model.getDeviceModel(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/equatable/model.dart b/example/lib/packages/equatable/model.dart new file mode 100644 index 0000000..0814b38 --- /dev/null +++ b/example/lib/packages/equatable/model.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:flutter_example_packages/packages/equatable/user_entity.dart'; +import 'package:flutter_example_packages/packages/equatable/user_entity_equatable.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [EquatablePage] +class EquatableModel extends Model { + /// Get [ScopedModel] + static EquatableModel of(BuildContext context) => + ScopedModel.of(context); + + UserEntity userEntity = const UserEntity( + name: 'Default', + email: 'default@yandex.ru', + age: 12, + ); + + UserEntityEquatable userEntityEquatable = const UserEntityEquatable( + name: 'Equatable', + email: 'default@yandex.ru', + age: 12, + ); +} diff --git a/example/lib/packages/equatable/package.dart b/example/lib/packages/equatable/package.dart new file mode 100644 index 0000000..bb5d85d --- /dev/null +++ b/example/lib/packages/equatable/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageEquatable = PackagePage( + key: 'equatable', + descEN: ''' + Being able to compare objects in Dart often involves having to override + the == operator as well as hashCode. + ''', + descRU: ''' + Возможность сравнивать объекты в Dart часто требует переопределения + оператора ==, а также hashCode. + ''', + version: '2.0.5', + isPlatformDependent: false, + page: () => EquatablePage(), + init: () { + GetIt.instance.registerFactory(() => EquatableModel()); + }, +); diff --git a/example/lib/packages/equatable/page.dart b/example/lib/packages/equatable/page.dart new file mode 100644 index 0000000..1df6614 --- /dev/null +++ b/example/lib/packages/equatable/page.dart @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import 'model.dart'; +import 'package.dart'; + +class EquatablePage extends AppStatefulWidget { + EquatablePage({ + super.key, + }); + + final Package package = packageEquatable; + + @override + State createState() => _EquatablePageState(); +} + +class _EquatablePageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + TextTitleLarge(l10n.equatableTitleDefault), + const SizedBox(height: 8), + TextBodyMedium(l10n.equatableSubtitle), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium(model.userEntity.toString()), + ), + ), + const SizedBox(height: 20), + TextTitleLarge(l10n.equatableTitleFreezed), + const SizedBox(height: 8), + TextBodyMedium(l10n.equatableSubtitle), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium(model.userEntityEquatable.toString()), + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/equatable/user_entity.dart b/example/lib/packages/equatable/user_entity.dart new file mode 100644 index 0000000..28877f3 --- /dev/null +++ b/example/lib/packages/equatable/user_entity.dart @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/foundation.dart'; + +@immutable +class UserEntity { + const UserEntity({ + required this.name, + required this.email, + required this.age, + }); + + final String name; + final String email; + final int age; + + @override + String toString() { + return 'UserEntity(' + '$name,' + '$email,' + '$age' + ')'; + } + + @override + bool operator ==(dynamic other) { + return other is UserEntity && + other.name == name && + other.email == email && + other.age == age; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + email, + age, + ); + } +} diff --git a/example/lib/packages/equatable/user_entity_equatable.dart b/example/lib/packages/equatable/user_entity_equatable.dart new file mode 100644 index 0000000..950203c --- /dev/null +++ b/example/lib/packages/equatable/user_entity_equatable.dart @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart'; + +@immutable +class UserEntityEquatable extends Equatable { + const UserEntityEquatable({ + required this.name, + required this.email, + required this.age, + }); + + final String name; + final String email; + final int age; + + @override + List get props => [name, email, age]; + + @override + bool get stringify => true; +} diff --git a/example/lib/packages/flutter_cache_manager/package.dart b/example/lib/packages/flutter_cache_manager/package.dart new file mode 100644 index 0000000..6cdede0 --- /dev/null +++ b/example/lib/packages/flutter_cache_manager/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageFlutterCacheManager = PackageDialog( + key: 'flutter_cache_manager', + descEN: ''' + CacheManager v2 introduced some breaking changes when configuring + a custom CacheManager. + ''', + descRU: ''' + В CacheManager v2 были внесены некоторые критические изменения при + настройке пользовательского CacheManager. + ''', + messageEN: ''' + This is a platform dependent plugin, used in a plugin + cached_network_image should work for you too. + ''', + messageRU: ''' + Это плагин зависимый от платформы, используется в плагине + cached_network_image, должен работать и у вас. + ''', + version: '3.3.0', + isPlatformDependent: true, +); diff --git a/example/lib/packages/flutter_keyboard_visibility/model.dart b/example/lib/packages/flutter_keyboard_visibility/model.dart new file mode 100644 index 0000000..a6ea279 --- /dev/null +++ b/example/lib/packages/flutter_keyboard_visibility/model.dart @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; +import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:flutter/foundation.dart' show kIsAurora; + +/// Model for [FlutterKeyboardVisibilityPage] +class FlutterKeyboardVisibilityModel extends Model { + /// Get [ScopedModel] + static FlutterKeyboardVisibilityModel of(BuildContext context) => + ScopedModel.of(context); + + final _controller = KeyboardVisibilityController(); + final _controllerAurora = FlutterKeyboardVisibilityAurora(); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Stream change visibility + Stream onChangeKeyboard() async* { + try { + yield _controller.isVisible; + await for (final state in _controller.onChange) { + yield state; + } + } catch (e) { + _error = e.toString(); + notifyListeners(); + } + } + + /// Stream change height + Stream onChangeKeyboardHeight() async* { + if (kIsAurora) { + try { + yield await _controllerAurora.height; + await for (final state in _controllerAurora.onChangeHeight) { + yield state; + } + } catch (e) { + _error = e.toString(); + notifyListeners(); + } + } else { + yield 0; + } + } +} diff --git a/example/lib/packages/flutter_keyboard_visibility/package.dart b/example/lib/packages/flutter_keyboard_visibility/package.dart new file mode 100644 index 0000000..289c603 --- /dev/null +++ b/example/lib/packages/flutter_keyboard_visibility/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'page.dart'; +import 'model.dart'; + +/// Package values +final packageFlutterKeyboardVisibility = PackagePage( + key: 'flutter_keyboard_visibility', + descEN: ''' + React to keyboard visibility changes. + ''', + descRU: ''' + Реагировать на изменения видимости клавиатуры. + ''', + version: '5.4.1', + isPlatformDependent: true, + page: () => FlutterKeyboardVisibilityPage(), + init: () { + GetIt.instance.registerFactory( + () => FlutterKeyboardVisibilityModel()); + }, +); diff --git a/example/lib/packages/flutter_keyboard_visibility/page.dart b/example/lib/packages/flutter_keyboard_visibility/page.dart new file mode 100644 index 0000000..501bf9c --- /dev/null +++ b/example/lib/packages/flutter_keyboard_visibility/page.dart @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:async'; + +import 'package:flutter/foundation.dart' show kIsAurora; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import 'model.dart'; +import 'package.dart'; + +class FlutterKeyboardVisibilityPage extends AppStatefulWidget { + FlutterKeyboardVisibilityPage({ + super.key, + }); + + final Package package = packageFlutterKeyboardVisibility; + + @override + State createState() => + _FlutterKeyboardVisibilityPageState(); +} + +class _FlutterKeyboardVisibilityPageState + extends AppState { + double _keyboardHeight = 0; + StreamSubscription? _streamSub; + final model = getIt(); + + @override + void initState() { + super.initState(); + if (kIsAurora) { + _streamSub = model.onChangeKeyboardHeight().listen((height) { + setState(() { + _keyboardHeight = height; + }); + }); + } + } + + @override + void dispose() { + super.dispose(); + _streamSub?.cancel(); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: model, + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + padding: EdgeInsets.only(bottom: _keyboardHeight), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + decoration: InputDecoration( + hintText: l10n.flutterKeyboardVisibilityField, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: 140, + child: ElevatedButton( + onPressed: () => FocusScope.of(context).unfocus(), + child: TextBodyLarge( + l10n.flutterKeyboardVisibilityButton, + color: Colors.white, + ), + ), + ), + const SizedBox(height: 20), + Visibility( + visible: kIsAurora, + child: BlockItem( + title: l10n.flutterKeyboardVisibilityTitleHeight, + desc: l10n.flutterKeyboardVisibilityDescHeight, + value: _keyboardHeight, + builder: (value) => value.toInt().toString(), + ), + ), + const SizedBox(height: 20), + BlockItem( + title: l10n.flutterKeyboardVisibilityTitle, + desc: l10n.flutterKeyboardVisibilityDesc, + stream: model.onChangeKeyboard(), + builder: (value) => value.toString().toUpperCase(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/flutter_local_notifications/model.dart b/example/lib/packages/flutter_local_notifications/model.dart new file mode 100644 index 0000000..31cf1d2 --- /dev/null +++ b/example/lib/packages/flutter_local_notifications/model.dart @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [FlutterLocalNotificationsPage] +class FlutterLocalNotificationsModel extends Model { + /// Get [ScopedModel] + static FlutterLocalNotificationsModel of(BuildContext context) => + ScopedModel.of(context); + + final FlutterLocalNotificationsPlugin notification = + FlutterLocalNotificationsPlugin(); + + final notificationID = 1; + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Show local notification + Future showNotification({ + required String title, + required String body, + }) async { + try { + // Cansel if already run + await notification.cancel(notificationID); + // Show notification + await notification.show( + notificationID, + title, + body, + null, + ); + } catch (e) { + _error = e.toString(); + notifyListeners(); + } + } +} diff --git a/example/lib/packages/flutter_local_notifications/package.dart b/example/lib/packages/flutter_local_notifications/package.dart new file mode 100644 index 0000000..ff8556d --- /dev/null +++ b/example/lib/packages/flutter_local_notifications/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/flutter_local_notifications/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageFlutterLocalNotifications = PackagePage( + key: 'flutter_local_notifications', + descEN: ''' + A cross platform plugin for displaying local notifications. + ''', + descRU: ''' + Кроссплатформенный плагин для отображения локальных уведомлений. + ''', + version: '14.1.1', + isPlatformDependent: true, + page: () => FlutterLocalNotificationsPage(), + init: () { + GetIt.instance.registerFactory( + () => FlutterLocalNotificationsModel()); + }, +); diff --git a/example/lib/packages/flutter_local_notifications/page.dart b/example/lib/packages/flutter_local_notifications/page.dart new file mode 100644 index 0000000..b9833d5 --- /dev/null +++ b/example/lib/packages/flutter_local_notifications/page.dart @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/flutter_local_notifications/model.dart'; +import 'package:flutter_example_packages/packages/flutter_local_notifications/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class FlutterLocalNotificationsPage extends AppStatefulWidget { + FlutterLocalNotificationsPage({ + super.key, + }); + + final Package package = packageFlutterLocalNotifications; + + @override + State createState() => + _FlutterLocalNotificationsPageState(); +} + +class _FlutterLocalNotificationsPageState + extends AppState { + final TextEditingController _titleController = TextEditingController(); + final TextEditingController _bodyController = TextEditingController(); + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: _titleController, + decoration: InputDecoration( + hintText: l10n.flutterLocalNotificationsHintTitle, + ), + ), + const SizedBox(height: 16), + TextField( + controller: _bodyController, + decoration: InputDecoration( + hintText: l10n.flutterLocalNotificationsHintBody, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => model.showNotification( + title: _titleController.text.isEmpty + ? l10n.flutterLocalNotificationsHintTitle + : _titleController.text, + body: _bodyController.text.isEmpty + ? l10n.flutterLocalNotificationsHintBody + : _bodyController.text, + ), + child: TextBodyLarge( + l10n.flutterLocalNotificationsBtn, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/flutter_markdown/model.dart b/example/lib/packages/flutter_markdown/model.dart new file mode 100644 index 0000000..bd5b831 --- /dev/null +++ b/example/lib/packages/flutter_markdown/model.dart @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [FlutterMarkdownPage] +class FlutterMarkdownModel extends Model { + /// Get [ScopedModel] + static FlutterMarkdownModel of(BuildContext context) => + ScopedModel.of(context); + + final String data = ''' +An h1 header +============ + +Paragraphs are separated by a blank line. + +2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists +look like: + + * this one + * that one + * the other one + +Note that --- not considering the asterisk --- the actual text +content starts at 4-columns in. + +> Block quotes are +> written like so. +> +> They can span multiple paragraphs, +> if you like. + +Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all +in chapters 12--14"). Three dots ... will be converted to an ellipsis. +Unicode is supported. ☺ + +## Image + +![Minion](https://github.com/keygenqt/awesome-aurora/blob/master/docs/assets/images/common/aurora.png?raw=true) + '''; +} diff --git a/example/lib/packages/flutter_markdown/package.dart b/example/lib/packages/flutter_markdown/package.dart new file mode 100644 index 0000000..2caac89 --- /dev/null +++ b/example/lib/packages/flutter_markdown/package.dart @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageFlutterMarkdown = PackagePage( + key: 'flutter_markdown', + descEN: ''' + A markdown renderer for Flutter. It supports the original format, + but no inline HTML. + ''', + descRU: ''' + Рендерер уценки для Flutter. Он поддерживает исходный формат, + но не поддерживает встроенный HTML. + ''', + version: '0.6.15', + isPlatformDependent: false, + page: () => FlutterMarkdownPage(), + init: () { + GetIt.instance + .registerFactory(() => FlutterMarkdownModel()); + }, +); diff --git a/example/lib/packages/flutter_markdown/page.dart b/example/lib/packages/flutter_markdown/page.dart new file mode 100644 index 0000000..3c0ed59 --- /dev/null +++ b/example/lib/packages/flutter_markdown/page.dart @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; + +import 'model.dart'; +import 'package.dart'; + +class FlutterMarkdownPage extends AppStatefulWidget { + FlutterMarkdownPage({ + super.key, + }); + + final Package package = packageFlutterMarkdown; + + @override + State createState() => _FlutterMarkdownPageState(); +} + +class _FlutterMarkdownPageState extends AppState { + final ScrollController _scrollController = ScrollController(); + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return Column( + children: [ + Flexible( + flex: 0, + child: Padding( + padding: const EdgeInsets.only( + top: 20, + left: 20, + right: 20, + ), + child: BlockInfoPackage(widget.package), + ), + ), + Flexible( + flex: 1, + child: Markdown( + controller: _scrollController, + padding: const EdgeInsets.all(20.0), + data: model.data, + ), + ), + ], + ); + }, + ); + } +} diff --git a/example/lib/packages/flutter_secure_storage/model.dart b/example/lib/packages/flutter_secure_storage/model.dart new file mode 100644 index 0000000..c7f49f0 --- /dev/null +++ b/example/lib/packages/flutter_secure_storage/model.dart @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:convert'; + +import 'package:crypto/crypto.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:flutter_secure_storage_aurora/flutter_secure_storage_aurora.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [FlutterSecureStoragePage] +class FlutterSecureStorageModel extends Model { + /// Get [ScopedModel] + static FlutterSecureStorageModel of(BuildContext context) => + ScopedModel.of(context); + + final _secureStorage = const FlutterSecureStorage(); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Save success + bool _isSuccess = false; + + /// Public success + bool get isSuccess => _isSuccess; + + /// Value for read form secure storage + String _readValue = ""; + + /// Public read value + String get readValue => _readValue; + + // Get data from secure storage + Future read({ + required String key, + required String password, + }) async { + try { + // Update secret key + _updateByPassword(password); + // Read data + _readValue = await _secureStorage.read(key: key) ?? "Not found"; + } catch (e) { + _readValue = "Error password"; + } + notifyListeners(); + } + + // Write new data in secure storage + Future write({ + required String key, + required String value, + required String password, + }) async { + try { + // Update secret key + _updateByPassword(password); + // Clear old data + await _secureStorage.deleteAll(); + // Save new data + await _secureStorage.write(key: key, value: value); + // Show success + _isSuccess = true; + // Close success + Future.delayed(const Duration(milliseconds: 1500), () { + _isSuccess = false; + notifyListeners(); + }); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Update password + void _updateByPassword( + String password, + ) { + // https://pub.dev/packages/encrypt + // Encrypter(AES(key)) + // secure-random --length 16 --base 16 + // You can generate a secret key based on user data, as an example of a hash pin-code + FlutterSecureStorageAurora.setSecret( + _getPasswordFromString(password), + ); + } + + /// Generate secure key 32 length from string password + String _getPasswordFromString( + String password, + ) { + return md5.convert(utf8.encode(password)).toString(); + } + + /// Clear value if change values + void clearReadValue() { + _readValue = ""; + notifyListeners(); + } +} diff --git a/example/lib/packages/flutter_secure_storage/package.dart b/example/lib/packages/flutter_secure_storage/package.dart new file mode 100644 index 0000000..e3d7e0a --- /dev/null +++ b/example/lib/packages/flutter_secure_storage/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/flutter_secure_storage/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageFlutterSecureStorage = PackagePage( + key: 'flutter_secure_storage', + descEN: ''' + Flutter Secure Storage provides API to store data in secure storage. + ''', + descRU: ''' + Flutter Secure Storage предоставляет API для хранения данных в безопасном хранилище. + ''', + version: '8.0.0', + isPlatformDependent: true, + page: () => FlutterSecureStoragePage(), + init: () { + GetIt.instance.registerFactory( + () => FlutterSecureStorageModel()); + }, +); diff --git a/example/lib/packages/flutter_secure_storage/page.dart b/example/lib/packages/flutter_secure_storage/page.dart new file mode 100644 index 0000000..5187814 --- /dev/null +++ b/example/lib/packages/flutter_secure_storage/page.dart @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:async'; + +import 'package:flutter/foundation.dart' show kIsAurora; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/flutter_secure_storage/model.dart'; +import 'package:flutter_example_packages/packages/flutter_secure_storage/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; + +class FlutterSecureStoragePage extends AppStatefulWidget { + FlutterSecureStoragePage({ + super.key, + }); + + final Package package = packageFlutterSecureStorage; + + @override + State createState() => + _FlutterSecureStoragePageState(); +} + +class _FlutterSecureStoragePageState + extends AppState { + double _keyboardHeight = 0; + StreamSubscription? _streamSub; + final _controllerAurora = FlutterKeyboardVisibilityAurora(); + + bool _isValidSave = false; + final TextEditingController _passSaveController = TextEditingController(); + final TextEditingController _keySaveController = TextEditingController(); + final TextEditingController _valueSaveController = TextEditingController(); + + bool _isValidGet = false; + final TextEditingController _passGetController = TextEditingController(); + final TextEditingController _keyGetController = TextEditingController(); + final TextEditingController _valueGetController = TextEditingController(); + + void _validateSave() { + setState(() { + _isValidSave = _passSaveController.text.isNotEmpty && + _keySaveController.text.isNotEmpty && + _valueSaveController.text.isNotEmpty; + }); + } + + void _validateGet() { + setState(() { + _isValidGet = _passGetController.text.isNotEmpty && + _keyGetController.text.isNotEmpty; + }); + } + + @override + void initState() { + super.initState(); + if (kIsAurora) { + _streamSub = _controllerAurora.onChangeHeight.listen((event) { + setState(() { + _keyboardHeight = event; + }); + }); + } + } + + @override + void dispose() { + super.dispose(); + _streamSub?.cancel(); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + // update read only value + _valueGetController.text = model.readValue; + // return widget + return SingleChildScrollView( + padding: EdgeInsets.only(bottom: _keyboardHeight), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(l10n.flutterSecureStorageTitleSave), + const SizedBox(height: 14), + if (model.isSuccess) + BlockAlert( + l10n.flutterSecureStorageSuccess, + color: Colors.lightGreen, + ), + const SizedBox(height: 6), + TextField( + controller: _passSaveController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldPass, + ), + onChanged: (_) => _validateSave(), + ), + const SizedBox(height: 16), + TextField( + controller: _keySaveController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldKey, + ), + onChanged: (_) => _validateSave(), + ), + const SizedBox(height: 16), + TextField( + controller: _valueSaveController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldValue, + ), + onChanged: (_) => _validateSave(), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _isValidSave + ? () => model.write( + key: _keySaveController.text, + value: _valueSaveController.text, + password: _passSaveController.text, + ) + : null, + child: TextBodyLarge( + l10n.flutterSecureStorageBtnSave, + color: Colors.white, + ), + ), + ), + const SizedBox(height: 30), + TextTitleLarge(l10n.flutterSecureStorageTitleGet), + const SizedBox(height: 16), + TextField( + controller: _passGetController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldPass, + ), + onChanged: (_) { + _validateGet(); + model.clearReadValue(); + }, + ), + const SizedBox(height: 16), + TextField( + controller: _keyGetController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldKey, + ), + onChanged: (_) { + _validateGet(); + model.clearReadValue(); + }), + const SizedBox(height: 16), + TextField( + enabled: false, + readOnly: true, + controller: _valueGetController, + decoration: InputDecoration( + labelText: l10n.flutterSecureStorageFieldValue, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _isValidGet + ? () => model.read( + key: _keyGetController.text, + password: _passGetController.text, + ) + : null, + child: TextBodyLarge( + l10n.flutterSecureStorageBtnGet, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/freezed/model.dart b/example/lib/packages/freezed/model.dart new file mode 100644 index 0000000..c431b93 --- /dev/null +++ b/example/lib/packages/freezed/model.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:flutter_example_packages/packages/freezed/user_entity.dart'; +import 'package:flutter_example_packages/packages/freezed/user_entity_freezed.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [FreezedPage] +class FreezedModel extends Model { + /// Get [ScopedModel] + static FreezedModel of(BuildContext context) => + ScopedModel.of(context); + + UserEntity userEntity = UserEntity.fromJson(const { + 'name': 'Default', + 'email': 'default@yandex.ru', + 'age': 12, + }); + + UserEntityFreezed userEntityFreezed = UserEntityFreezed.fromJson(const { + 'name': 'Default', + 'email': 'default@yandex.ru', + 'age': 12, + }); +} diff --git a/example/lib/packages/freezed/package.dart b/example/lib/packages/freezed/package.dart new file mode 100644 index 0000000..b94bc2d --- /dev/null +++ b/example/lib/packages/freezed/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageFreezed = PackagePage( + key: 'freezed', + descEN: ''' + Code generator for data-classes/unions/pattern-matching/cloning. + ''', + descRU: ''' + Генератор кода для классов данных/объединений/сопоставления + с образцом/клонирования. + ''', + version: '2.3.3', + isPlatformDependent: false, + page: () => FreezedPage(), + init: () { + GetIt.instance.registerFactory(() => FreezedModel()); + }, +); diff --git a/example/lib/packages/freezed/page.dart b/example/lib/packages/freezed/page.dart new file mode 100644 index 0000000..3177f78 --- /dev/null +++ b/example/lib/packages/freezed/page.dart @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import 'model.dart'; +import 'package.dart'; + +class FreezedPage extends AppStatefulWidget { + FreezedPage({ + super.key, + }); + + final Package package = packageFreezed; + + @override + State createState() => _FreezedPageState(); +} + +class _FreezedPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + TextTitleLarge(l10n.freezedTitleDefault), + const SizedBox(height: 8), + TextBodyMedium(l10n.freezedSubtitle), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium( + const JsonEncoder.withIndent(' ').convert( + model.userEntity.copyWith(name: 'My name').toJson()), + ), + ), + ), + const SizedBox(height: 20), + TextTitleLarge(l10n.freezedTitleFreezed), + const SizedBox(height: 8), + TextBodyMedium(l10n.freezedSubtitle), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium( + const JsonEncoder.withIndent(' ').convert(model + .userEntityFreezed + .copyWith(name: 'My name') + .toJson()), + ), + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/freezed/user_entity.dart b/example/lib/packages/freezed/user_entity.dart new file mode 100644 index 0000000..d852223 --- /dev/null +++ b/example/lib/packages/freezed/user_entity.dart @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/foundation.dart'; + +@immutable +class UserEntity { + const UserEntity({ + required this.name, + required this.email, + required this.age, + }); + + factory UserEntity.fromJson(Map json) { + return UserEntity( + name: json['name'] as String, + email: json['email'] as String, + age: json['age'] as int, + ); + } + + final String name; + final String email; + final int age; + + UserEntity copyWith({ + String? name, + String? email, + int? age, + }) { + return UserEntity( + name: name ?? this.name, + email: email ?? this.email, + age: age ?? this.age, + ); + } + + Map toJson() { + return { + 'name': name, + 'email': email, + 'age': age, + }; + } + + @override + String toString() { + return 'UserEntity(' + 'name: $name' + 'email: $email' + 'age: $age' + ')'; + } + + @override + bool operator ==(dynamic other) { + return other is UserEntity && + other.name == name && + other.email == email && + other.age == age; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + email, + age, + ); + } +} diff --git a/example/lib/packages/freezed/user_entity_freezed.dart b/example/lib/packages/freezed/user_entity_freezed.dart new file mode 100644 index 0000000..7dd2917 --- /dev/null +++ b/example/lib/packages/freezed/user_entity_freezed.dart @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'user_entity_freezed.freezed.dart'; +part 'user_entity_freezed.g.dart'; + +@freezed +class UserEntityFreezed with _$UserEntityFreezed { + const factory UserEntityFreezed({ + required String name, + required String email, + required int age, + }) = _UserEntityFreezed; + + factory UserEntityFreezed.fromJson(Map json) => + _$UserEntityFreezedFromJson(json); +} diff --git a/example/lib/packages/freezed_annotation/package.dart b/example/lib/packages/freezed_annotation/package.dart new file mode 100644 index 0000000..7fbc8cd --- /dev/null +++ b/example/lib/packages/freezed_annotation/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageFreezedAnnotation = PackageDialog( + key: 'freezed_annotation', + descEN: ''' + Annotations for freezed. This package does nothing without freezed. + ''', + descRU: ''' + Аннотации для freezed. Этот пакет ничего не делает без freezed. + ''', + messageEN: ''' + This is a platform independent plugin used in this application in the demo + of the freezed plugin. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении в + демострации работы плагина freezed. + ''', + version: '2.2.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/get_it/package.dart b/example/lib/packages/get_it/package.dart new file mode 100644 index 0000000..3a148ac --- /dev/null +++ b/example/lib/packages/get_it/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageGetIt = PackageDialog( + key: 'get_it', + descEN: ''' + This is a simple Service Locator for Dart and Flutter projects with some + additional goodies highly inspired by Splat. + ''', + descRU: ''' + Это простой сервис-локатор для проектов Dart и Flutter с некоторыми + дополнительные вкусности, вдохновленные Splat. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '7.6.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/google_fonts/package.dart b/example/lib/packages/google_fonts/package.dart new file mode 100644 index 0000000..e3529da --- /dev/null +++ b/example/lib/packages/google_fonts/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageGoogleFonts = PackageDialog( + key: 'google_fonts', + descEN: ''' + A Flutter package to use fonts from fonts.google.com. + ''', + descRU: ''' + Пакет Flutter для использования шрифтов с fonts.google.com. + ''', + messageEN: ''' + This is a platform dependent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин зависимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '4.0.4', + isPlatformDependent: true, +); diff --git a/example/lib/packages/intl/package.dart b/example/lib/packages/intl/package.dart new file mode 100644 index 0000000..92e801a --- /dev/null +++ b/example/lib/packages/intl/package.dart @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageIntl = PackageDialog( + key: 'intl', + descEN: ''' + Provides internationalization and localization facilities, + including message translation, plurals and genders, + date/number formatting and parsing, and bidirectional text. + ''', + descRU: ''' + Предоставляет средства интернационализации и локализации, + включая перевод сообщений, множественное число и пол, + форматирование и разбор даты/числа, а также двунаправленный текст. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '0.17.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/json_annotation/package.dart b/example/lib/packages/json_annotation/package.dart new file mode 100644 index 0000000..28eeecc --- /dev/null +++ b/example/lib/packages/json_annotation/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageJsonAnnotation = PackageDialog( + key: 'json_annotation', + descEN: ''' + Defines the annotations used by json_serializable to create code for + JSON serialization and deserialization. + ''', + descRU: ''' + Определяет аннотации, используемые json_serializable для создания кода для + JSON Serialization и Deserialization. + ''', + messageEN: ''' + This is a platform independent plugin used in this application in the demo + of the freezed plugin. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении в + демострации работы плагина freezed. + ''', + version: '4.8.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/json_serializable/package.dart b/example/lib/packages/json_serializable/package.dart new file mode 100644 index 0000000..bbd0ab5 --- /dev/null +++ b/example/lib/packages/json_serializable/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageJsonSerializable = PackageDialog( + key: 'json_serializable', + descEN: ''' + Provides Dart Build System builders for handling JSON. + ''', + descRU: ''' + Предоставляет Dart Build System System для обработки JSON. + ''', + messageEN: ''' + This is a platform independent plugin used in this application in the demo + of the freezed plugin. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении в + демострации работы плагина freezed. + ''', + version: '6.6.1', + isPlatformDependent: false, +); diff --git a/example/lib/packages/package_info_plus/model.dart b/example/lib/packages/package_info_plus/model.dart new file mode 100644 index 0000000..c779d25 --- /dev/null +++ b/example/lib/packages/package_info_plus/model.dart @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +/// Model for [PackageInfoPlusPage] +class PackageInfoPlusModel extends Model { + /// Get [ScopedModel] + static PackageInfoPlusModel of(BuildContext context) => + ScopedModel.of(context); + + /// Get [PackageInfo] + Future get _packageInfo async => + await PackageInfo.fromPlatform(); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Get package + Future getPackageName() async { + try { + return (await _packageInfo).packageName; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Get application name + Future getApplicationName() async { + try { + return (await _packageInfo).appName; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } +} diff --git a/example/lib/packages/package_info_plus/package.dart b/example/lib/packages/package_info_plus/package.dart new file mode 100644 index 0000000..bab909d --- /dev/null +++ b/example/lib/packages/package_info_plus/package.dart @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/package_info_plus/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packagePackageInfoPlus = PackagePage( + key: 'package_info_plus', + descEN: ''' + This Flutter plugin provides an API for querying information about + an application package. + ''', + descRU: ''' + Этот плагин Flutter предоставляет API для запроса информации о + пакете приложения. + ''', + version: '3.1.2', + isPlatformDependent: true, + page: () => PackageInfoPlusPage(), + init: () { + GetIt.instance + .registerFactory(() => PackageInfoPlusModel()); + }, +); diff --git a/example/lib/packages/package_info_plus/page.dart b/example/lib/packages/package_info_plus/page.dart new file mode 100644 index 0000000..1dfa78c --- /dev/null +++ b/example/lib/packages/package_info_plus/page.dart @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/package_info_plus/model.dart'; +import 'package:flutter_example_packages/packages/package_info_plus/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class PackageInfoPlusPage extends AppStatefulWidget { + PackageInfoPlusPage({ + super.key, + }); + + final Package package = packagePackageInfoPlus; + + @override + State createState() => _PackageInfoPlusPageState(); +} + +class _PackageInfoPlusPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.packageInfoPlusTitlePackageName, + desc: l10n.packageInfoPlusDescPackageName, + future: model.getPackageName(), + ), + BlockItem( + title: l10n.packageInfoPlusTitleApplicationName, + desc: l10n.packageInfoPlusDescApplicationName, + future: model.getApplicationName(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/packages.dart b/example/lib/packages/packages.dart new file mode 100644 index 0000000..580cd7a --- /dev/null +++ b/example/lib/packages/packages.dart @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/battery_plus/package.dart'; +import 'package:flutter_example_packages/packages/build_runner/package.dart'; +import 'package:flutter_example_packages/packages/cached_network_image/package.dart'; +import 'package:flutter_example_packages/packages/crypto/package.dart'; +import 'package:flutter_example_packages/packages/cupertino_icons/package.dart'; +import 'package:flutter_example_packages/packages/dartz/package.dart'; +import 'package:flutter_example_packages/packages/device_info_plus/package.dart'; +import 'package:flutter_example_packages/packages/equatable/package.dart'; +import 'package:flutter_example_packages/packages/flutter_cache_manager/package.dart'; +import 'package:flutter_example_packages/packages/flutter_keyboard_visibility/package.dart'; +import 'package:flutter_example_packages/packages/flutter_local_notifications/package.dart'; +import 'package:flutter_example_packages/packages/flutter_markdown/package.dart'; +import 'package:flutter_example_packages/packages/flutter_secure_storage/package.dart'; +import 'package:flutter_example_packages/packages/freezed/package.dart'; +import 'package:flutter_example_packages/packages/freezed_annotation/package.dart'; +import 'package:flutter_example_packages/packages/get_it/package.dart'; +import 'package:flutter_example_packages/packages/google_fonts/package.dart'; +import 'package:flutter_example_packages/packages/intl/package.dart'; +import 'package:flutter_example_packages/packages/json_annotation/package.dart'; +import 'package:flutter_example_packages/packages/json_serializable/package.dart'; +import 'package:flutter_example_packages/packages/package_info_plus/package.dart'; +import 'package:flutter_example_packages/packages/path/package.dart'; +import 'package:flutter_example_packages/packages/path_provider/package.dart'; +import 'package:flutter_example_packages/packages/photo_view/package.dart'; +import 'package:flutter_example_packages/packages/provider/package.dart'; +import 'package:flutter_example_packages/packages/qr_flutter/package.dart'; +import 'package:flutter_example_packages/packages/rxdart/package.dart'; +import 'package:flutter_example_packages/packages/scoped_model/package.dart'; +import 'package:flutter_example_packages/packages/shared_preferences/package.dart'; +import 'package:flutter_example_packages/packages/sqflite/package.dart'; +import 'package:flutter_example_packages/packages/translator/package.dart'; +import 'package:flutter_example_packages/packages/universal_io/package.dart'; +import 'package:flutter_example_packages/packages/wakelock/package.dart'; +import 'package:flutter_example_packages/packages/xdga_directories/package.dart'; + +/// List app packages +final packages = [ + packageBatteryPlus, + packageBuildRunner, + packageCachedNetworkImage, + packageCrypto, + packageCupertinoIcons, + packageDartz, + packageDeviceInfoPlus, + packageEquatable, + packageFlutterCacheManager, + packageFlutterKeyboardVisibility, + packageFlutterLocalNotifications, + packageFlutterMarkdown, + packageFlutterSecureStorage, + packageFreezed, + packageFreezedAnnotation, + packageGetIt, + packageGoogleFonts, + packageIntl, + packageJsonAnnotation, + packageJsonSerializable, + packagePackageInfoPlus, + packagePath, + packagePathProvider, + packagePhotoView, + packageProvider, + packageQrFlutter, + packageRxdart, + packageScopedModel, + packageSharedPreferences, + packageSqflite, + packageTranslator, + packageUniversalIO, + packageWakelock, + packageXdgaDirectories, +]; diff --git a/example/lib/packages/path/package.dart b/example/lib/packages/path/package.dart new file mode 100644 index 0000000..6b94749 --- /dev/null +++ b/example/lib/packages/path/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packagePath = PackageDialog( + key: 'path', + descEN: ''' + A comprehensive, cross-platform path manipulation library for Dart. + ''', + descRU: ''' + Комплексная кроссплатформенная библиотека управления путями для Dart. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '1.8.2', + isPlatformDependent: false, +); diff --git a/example/lib/packages/path_provider/model.dart b/example/lib/packages/path_provider/model.dart new file mode 100644 index 0000000..a59a663 --- /dev/null +++ b/example/lib/packages/path_provider/model.dart @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:path_provider/path_provider.dart' as provider; +import 'package:scoped_model/scoped_model.dart'; +import 'package:universal_io/io.dart'; + +/// Model for [PathProviderPage] +class PathProviderModel extends Model { + /// Get [ScopedModel] + static PathProviderModel of(BuildContext context) => + ScopedModel.of(context); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Directory where the application may place application support files. + Future getApplicationSupportDirectory() async { + try { + return await provider.getApplicationSupportDirectory(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Directory location where user-specific non-essential (cached) data should be written. + Future getTemporaryDirectory() async { + try { + return await provider.getTemporaryDirectory(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Directory containing user document files. + Future getApplicationDocumentsDirectory() async { + try { + return await provider.getApplicationDocumentsDirectory(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Directory for user's downloaded files. + Future getDownloadsDirectory() async { + try { + return await provider.getDownloadsDirectory(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.pictures directory. + Future?> getExternalStorageDirectoriesPictures() async { + try { + return await provider.getExternalStorageDirectories( + type: StorageDirectory.pictures, + ); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.music directory. + Future?> getExternalStorageDirectoriesMusic() async { + try { + return await provider.getExternalStorageDirectories( + type: StorageDirectory.music, + ); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// There is no concept of External in Aurora OS, but this interface allows you to get the StorageDirectory.movies directory. + Future?> getExternalStorageDirectoriesMovies() async { + try { + return await provider.getExternalStorageDirectories( + type: StorageDirectory.movies, + ); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } +} diff --git a/example/lib/packages/path_provider/package.dart b/example/lib/packages/path_provider/package.dart new file mode 100644 index 0000000..237661e --- /dev/null +++ b/example/lib/packages/path_provider/package.dart @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/path_provider/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packagePathProvider = PackagePage( + key: 'path_provider', + descEN: ''' + A Flutter plugin for finding commonly used locations on the filesystem. + Supports Android, iOS, Linux, macOS, Windows and Aurora OS. + Not all methods are supported on all platforms. + ''', + descRU: ''' + Плагин Flutter для поиска часто используемых мест в файловой системе. + Поддерживает Android, iOS, Linux, macOS, Windows и ОС Aurora. + Не все методы поддерживаются на всех платформах. + ''', + version: '2.0.15', + isPlatformDependent: true, + page: () => PathProviderPage(), + init: () { + GetIt.instance + .registerFactory(() => PathProviderModel()); + }, +); diff --git a/example/lib/packages/path_provider/page.dart b/example/lib/packages/path_provider/page.dart new file mode 100644 index 0000000..2606b15 --- /dev/null +++ b/example/lib/packages/path_provider/page.dart @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/path_provider/model.dart'; +import 'package:flutter_example_packages/packages/path_provider/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class PathProviderPage extends AppStatefulWidget { + PathProviderPage({super.key}); + + final Package package = packagePathProvider; + + @override + State createState() => _PathProviderPageState(); +} + +class _PathProviderPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.pathProviderTitleApplicationSupport, + desc: l10n.pathProviderDescApplicationSupport, + future: model.getApplicationSupportDirectory(), + ), + BlockItem( + title: l10n.pathProviderTitleTemporary, + desc: l10n.pathProviderDescTemporary, + future: model.getTemporaryDirectory(), + ), + BlockItem( + title: l10n.pathProviderTitleApplicationDocuments, + desc: l10n.pathProviderDescApplicationDocuments, + future: model.getApplicationDocumentsDirectory(), + ), + BlockItem( + title: l10n.pathProviderTitleDownloads, + desc: l10n.pathProviderDescDownloads, + future: model.getDownloadsDirectory(), + ), + BlockItem( + title: l10n.pathProviderTitlePictures, + desc: l10n.pathProviderDescPictures, + future: model.getExternalStorageDirectoriesPictures(), + ), + BlockItem( + title: l10n.pathProviderTitleMusic, + desc: l10n.pathProviderDescMusic, + future: model.getExternalStorageDirectoriesMusic(), + ), + BlockItem( + title: l10n.pathProviderTitleMovies, + desc: l10n.pathProviderDescMovies, + future: model.getExternalStorageDirectoriesMovies(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/photo_view/model.dart b/example/lib/packages/photo_view/model.dart new file mode 100644 index 0000000..b0c4c6e --- /dev/null +++ b/example/lib/packages/photo_view/model.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [PhotoViewPage] +class PhotoViewModel extends Model { + /// Get [ScopedModel] + static PhotoViewModel of(BuildContext context) => + ScopedModel.of(context); +} diff --git a/example/lib/packages/photo_view/package.dart b/example/lib/packages/photo_view/package.dart new file mode 100644 index 0000000..b3b698e --- /dev/null +++ b/example/lib/packages/photo_view/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/photo_view/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packagePhotoView = PackagePage( + key: 'photo_view', + descEN: ''' + A simple zoomable image/content widget for Flutter. + ''', + descRU: ''' + Простой масштабируемый виджет изображения/контента для Flutter. + ''', + version: '0.14.0', + isPlatformDependent: false, + page: () => PhotoViewPage(), + init: () { + GetIt.instance.registerFactory(() => PhotoViewModel()); + }, +); diff --git a/example/lib/packages/photo_view/page.dart b/example/lib/packages/photo_view/page.dart new file mode 100644 index 0000000..e5c3aed --- /dev/null +++ b/example/lib/packages/photo_view/page.dart @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/photo_view/model.dart'; +import 'package:flutter_example_packages/packages/photo_view/package.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:photo_view/photo_view.dart'; + +class PhotoViewPage extends AppStatefulWidget { + PhotoViewPage({ + super.key, + }); + + final Package package = packagePhotoView; + + @override + State createState() => _PhotoViewPageState(); +} + +class _PhotoViewPageState extends AppState { + double _heightPhotoView = 1; + final _keyPhotoView = GlobalKey(); + + @override + void onDidChangeMetrics() { + setState(() { + _heightPhotoView = _getHeightPhotoView(); + }); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + ClipRRect( + borderRadius: AppRadius.small, + child: SizedBox( + key: _keyPhotoView, + width: double.infinity, + height: _heightPhotoView, + child: PhotoView( + imageProvider: + const AssetImage("assets/images/large_image.jpg"), + ), + ), + ), + ], + ), + ), + ); + }, + ); + } + + double _getHeightPhotoView() { + if (_keyPhotoView.currentContext != null) { + RenderBox? box = + _keyPhotoView.currentContext?.findRenderObject() as RenderBox; + Offset position = + box.localToGlobal(Offset.zero); //this is global position + return MediaQuery.of(context).size.height - position.dy - 20; + } + return 1; + } +} diff --git a/example/lib/packages/provider/model.dart b/example/lib/packages/provider/model.dart new file mode 100644 index 0000000..adbbfe9 --- /dev/null +++ b/example/lib/packages/provider/model.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [ProviderPage] +class ProviderModel extends Model { + /// Get [ScopedModel] + static ProviderModel of(BuildContext context) => + ScopedModel.of(context); +} diff --git a/example/lib/packages/provider/package.dart b/example/lib/packages/provider/package.dart new file mode 100644 index 0000000..845f16e --- /dev/null +++ b/example/lib/packages/provider/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageProvider = PackagePage( + key: 'provider', + descEN: ''' + A wrapper around InheritedWidget to make them easier to use and more + reusable. + ''', + descRU: ''' + Оболочка вокруг InheritedWidget, чтобы сделать их более простыми в + использовании и более удобными для повторного использования. + ''', + version: '6.0.5', + isPlatformDependent: false, + page: () => ProviderPage(), + init: () { + GetIt.instance.registerFactory(() => ProviderModel()); + }, +); diff --git a/example/lib/packages/provider/page.dart b/example/lib/packages/provider/page.dart new file mode 100644 index 0000000..ebae7fa --- /dev/null +++ b/example/lib/packages/provider/page.dart @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:provider/provider.dart'; + +import 'model.dart'; +import 'package.dart'; + +class ProviderPage extends AppStatefulWidget { + ProviderPage({ + super.key, + }); + + final Package package = packageProvider; + + @override + State createState() => _ProviderPageState(); +} + +class _ProviderPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return FutureProvider( + initialData: 0, + create: (context) => Future.value(12345), // Set value + child: BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockItem( + title: l10n.providerTitle, + desc: l10n.providerSubtitle, + value: context.watch(), // Get value + ), + ], + ), + ), + ); + }, + ), + ); + } +} diff --git a/example/lib/packages/qr_flutter/model.dart b/example/lib/packages/qr_flutter/model.dart new file mode 100644 index 0000000..7c4b38f --- /dev/null +++ b/example/lib/packages/qr_flutter/model.dart @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [QrFlutterPage] +class QrFlutterModel extends Model { + /// Get [ScopedModel] + static QrFlutterModel of(BuildContext context) => + ScopedModel.of(context); +} diff --git a/example/lib/packages/qr_flutter/package.dart b/example/lib/packages/qr_flutter/package.dart new file mode 100644 index 0000000..59000c0 --- /dev/null +++ b/example/lib/packages/qr_flutter/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageQrFlutter = PackagePage( + key: 'qr_flutter', + descEN: ''' + QR.Flutter is a Flutter library for simple and fast QR code rendering + via a Widget or custom painter. + ''', + descRU: ''' + ПQR.Flutter — это библиотека Flutter для простого и быстрого рендеринга + QR-кода с помощью виджета или пользовательского рисовальщика. + ''', + version: '4.0.0', + isPlatformDependent: false, + page: () => QrFlutterPage(), + init: () { + GetIt.instance.registerFactory(() => QrFlutterModel()); + }, +); diff --git a/example/lib/packages/qr_flutter/page.dart b/example/lib/packages/qr_flutter/page.dart new file mode 100644 index 0000000..ee10c68 --- /dev/null +++ b/example/lib/packages/qr_flutter/page.dart @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import 'model.dart'; +import 'package.dart'; + +class QrFlutterPage extends AppStatefulWidget { + QrFlutterPage({ + super.key, + }); + + final Package package = packageQrFlutter; + + @override + State createState() => _QrFlutterPageState(); +} + +class _QrFlutterPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + Center( + child: QrImage( + data: '1234567890', + version: QrVersions.auto, + size: 200.0, + ), + ) + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/rxdart/model.dart b/example/lib/packages/rxdart/model.dart new file mode 100644 index 0000000..94d01b7 --- /dev/null +++ b/example/lib/packages/rxdart/model.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:rxdart/rxdart.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [RxdartPage] +class RxdartModel extends Model { + /// Get [ScopedModel] + static RxdartModel of(BuildContext context) => + ScopedModel.of(context); + + final listObjects = [1, 'First', 2, 'Second', 3, 'Third', null]; + + /// Example of using rxdart + Future> getNumberList() { + return Stream.fromIterable(listObjects) + .doOnEach((notification) { + debugPrint(notification.toString()); + }) + .whereNotNull() + .whereType() + .toList(); + } +} diff --git a/example/lib/packages/rxdart/package.dart b/example/lib/packages/rxdart/package.dart new file mode 100644 index 0000000..861c863 --- /dev/null +++ b/example/lib/packages/rxdart/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageRxdart = PackagePage( + key: 'rxdart', + descEN: ''' + RxDart extends the capabilities of Dart Streams and StreamControllers. + ''', + descRU: ''' + RxDart расширяет возможности Dart Streams и StreamControllers. + ''', + version: '0.27.7', + isPlatformDependent: false, + page: () => RxdartPage(), + init: () { + GetIt.instance.registerFactory(() => RxdartModel()); + }, +); diff --git a/example/lib/packages/rxdart/page.dart b/example/lib/packages/rxdart/page.dart new file mode 100644 index 0000000..60eb8c6 --- /dev/null +++ b/example/lib/packages/rxdart/page.dart @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import 'model.dart'; +import 'package.dart'; + +class RxdartPage extends AppStatefulWidget { + RxdartPage({ + super.key, + }); + + final Package package = packageRxdart; + + @override + State createState() => _RxdartPageState(); +} + +class _RxdartPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockItem( + title: l10n.rxdartTitle, + desc: l10n.rxdartSubtitle, + future: model.getNumberList(), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/scoped_model/package.dart b/example/lib/packages/scoped_model/package.dart new file mode 100644 index 0000000..7189f4d --- /dev/null +++ b/example/lib/packages/scoped_model/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageScopedModel = PackageDialog( + key: 'scoped_model', + descEN: ''' + A set of utilities that allow you to easily pass a data Model + from a parent Widget down to its descendants. + ''', + descRU: ''' + Набор утилит, позволяющих легко передать Модель данных + от родительского виджета до его потомков. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '2.0.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/shared_preferences/model.dart b/example/lib/packages/shared_preferences/model.dart new file mode 100644 index 0000000..aa6cd81 --- /dev/null +++ b/example/lib/packages/shared_preferences/model.dart @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +/// Model for [SharedPreferencesPage] +class SharedPreferencesModel extends Model { + /// Get [ScopedModel] + static SharedPreferencesModel of(BuildContext context) => + ScopedModel.of(context); + + /// Get Aurora info + Future get _prefs async => + await SharedPreferences.getInstance(); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Read shared preferences + Map? _readValues; + + /// Public values + Map? get readValues => _readValues; + + /// Save int value + Future setValueInt(int value) async { + try { + await (await _prefs).setInt('int', value); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Save bool value + Future setValueBool(bool value) async { + try { + await (await _prefs).setBool('bool', value); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Save double value + Future setValueDouble(double value) async { + try { + await (await _prefs).setDouble('double', value); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Save string value + Future setValueString(String value) async { + try { + await (await _prefs).setString('string', value); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Save list value + Future setValueList(List value) async { + try { + await (await _prefs).setStringList('list', value); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Clear all data + Future clear() async { + try { + await (await _prefs).clear(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Read values + Future reloadValues() async { + try { + final prefs = await _prefs; + _readValues = { + 'int': prefs.getInt('int'), + 'bool': prefs.getBool('bool'), + 'double': prefs.getDouble('double'), + 'string': prefs.getString('string'), + 'list': prefs.getStringList('list'), + }; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } +} diff --git a/example/lib/packages/shared_preferences/package.dart b/example/lib/packages/shared_preferences/package.dart new file mode 100644 index 0000000..c405053 --- /dev/null +++ b/example/lib/packages/shared_preferences/package.dart @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/shared_preferences/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageSharedPreferences = PackagePage( + key: 'shared_preferences', + descEN: ''' + Wraps platform-specific persistent storage for simple data. + ''', + descRU: ''' + Обертывает постоянное хранилище для конкретных платформ для простых данных. + ''', + version: '2.1.2', + isPlatformDependent: true, + page: () => SharedPreferencesPage(), + init: () { + GetIt.instance.registerFactory( + () => SharedPreferencesModel()); + }, +); diff --git a/example/lib/packages/shared_preferences/page.dart b/example/lib/packages/shared_preferences/page.dart new file mode 100644 index 0000000..d926aaa --- /dev/null +++ b/example/lib/packages/shared_preferences/page.dart @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/foundation.dart' show kIsAurora; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/shared_preferences/model.dart'; +import 'package:flutter_example_packages/packages/shared_preferences/package.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; + +class SharedPreferencesPage extends AppStatefulWidget { + SharedPreferencesPage({ + super.key, + }); + + final Package package = packageSharedPreferences; + + @override + State createState() => _SharedPreferencesPageState(); +} + +class _SharedPreferencesPageState extends AppState { + double _keyboardHeight = 0; + StreamSubscription? _streamSub; + final _controllerAurora = FlutterKeyboardVisibilityAurora(); + final ScrollController _scrollController = ScrollController(); + final model = getIt(); + + bool _formIsValid = true; + final _formKey = GlobalKey(); + + final TextEditingController _intController = + TextEditingController(text: '100'); + final TextEditingController _boolController = + TextEditingController(text: 'true'); + final TextEditingController _doubleController = + TextEditingController(text: '100.5'); + final TextEditingController _stringController = + TextEditingController(text: 'My text'); + final TextEditingController _listController = + TextEditingController(text: 'First, Second, Third'); + + @override + void initState() { + super.initState(); + model.reloadValues(); + if (kIsAurora) { + _streamSub = _controllerAurora.onChangeHeight.listen((event) { + setState(() { + _keyboardHeight = event; + }); + }); + } + } + + @override + void dispose() { + super.dispose(); + _streamSub?.cancel(); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: model, + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + controller: _scrollController, + padding: EdgeInsets.only(bottom: _keyboardHeight), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(l10n.sharedPreferencesTitleState), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium( + const JsonEncoder.withIndent(' ') + .convert(model.readValues), + ), + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: () async { + // reload data + await model.clear(); + // reload data + await model.reloadValues(); + // disable keyboard + FocusManager.instance.primaryFocus?.unfocus(); + // scroll to top + _scrollController.animateTo( + 0, + duration: const Duration(milliseconds: 500), + curve: Curves.ease, + ); + }, + child: TextBodyLarge( + l10n.sharedPreferencesFieldBtnClean, + color: AppColors.secondary, + ), + ), + ), + const SizedBox(height: 20), + TextTitleLarge(l10n.sharedPreferencesTitleUpdate), + const SizedBox(height: 14), + TextFormField( + controller: _intController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sharedPreferencesFieldInt, + ), + validator: (value) { + if (int.tryParse(value ?? '') == null) { + return l10n.sharedPreferencesFieldError('int'); + } + return null; + }, + onChanged: (_) => setState(() { + _formIsValid = + _formKey.currentState?.validate() ?? true; + }), + ), + const SizedBox(height: 16), + TextFormField( + controller: _boolController, + decoration: InputDecoration( + labelText: l10n.sharedPreferencesFieldBool, + ), + validator: (value) { + if (value != 'true' && value != 'false') { + return l10n.sharedPreferencesFieldError('bool'); + } + return null; + }, + onChanged: (_) => setState(() { + _formIsValid = + _formKey.currentState?.validate() ?? true; + }), + ), + const SizedBox(height: 16), + TextFormField( + controller: _doubleController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sharedPreferencesFieldDouble, + ), + validator: (value) { + if (double.tryParse(value ?? '') == null) { + return l10n.sharedPreferencesFieldError('double'); + } + return null; + }, + onChanged: (_) => setState(() { + _formIsValid = + _formKey.currentState?.validate() ?? true; + }), + ), + const SizedBox(height: 16), + TextFormField( + controller: _stringController, + decoration: InputDecoration( + labelText: l10n.sharedPreferencesFieldString, + ), + ), + const SizedBox(height: 16), + TextFormField( + controller: _listController, + decoration: InputDecoration( + labelText: l10n.sharedPreferencesFieldList, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _formIsValid + ? () async { + // add int + await model.setValueInt( + int.parse(_intController.text)); + // add bool + await model.setValueBool( + _boolController.text == 'true'); + // add double + await model.setValueDouble( + double.parse(_doubleController.text)); + // add string + await model + .setValueString(_stringController.text); + // add list + await model.setValueList( + _listController.text.split(', ')); + // reload data + await model.reloadValues(); + // disable keyboard + FocusManager.instance.primaryFocus + ?.unfocus(); + // scroll to top + _scrollController.animateTo( + 0, + duration: + const Duration(milliseconds: 500), + curve: Curves.ease, + ); + } + : null, + child: TextBodyLarge( + l10n.sharedPreferencesFieldBtn, + color: Colors.white, + ), + ), + ), + ], + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/sqflite/model.dart b/example/lib/packages/sqflite/model.dart new file mode 100644 index 0000000..5992840 --- /dev/null +++ b/example/lib/packages/sqflite/model.dart @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:path/path.dart' as p; +import 'package:scoped_model/scoped_model.dart'; +import 'package:sqflite/sqflite.dart'; + +/// Model for [SqflitePage] +class SqfliteModel extends Model { + /// Get [ScopedModel] + static SqfliteModel of(BuildContext context) => + ScopedModel.of(context); + + /// Database + Database? _db; + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Public data + List get data => _data ?? []; + + /// Private data + List? _data; + + /// Init database + Future init() async { + // Get a location using getDatabasesPath + var databasesPath = await getDatabasesPath(); + String path = p.join(databasesPath, 'demo.db'); + + // Delete the database + await deleteDatabase(path); + + // open the database + _db = await openDatabase( + path, + version: 1, + onCreate: (Database db, int version) async { + // When creating the db, create the table + await db.execute('''CREATE TABLE Test ( + name TEXT, + value INTEGER, + num REAL + )'''); + }, + ); + } + + /// Close database + Future close() async { + await _db?.close(); + } + + /// Remove all rows + Future clear() async { + try { + // Query + await _db?.rawDelete('DELETE FROM Test'); + // Update data + _data = await _allSelect(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Insert data + Future insert( + String name, + int value, + double num, + ) async { + try { + // Query + await _db?.transaction((txn) async { + await txn.rawInsert( + 'INSERT INTO Test(name, value, num) VALUES(?, ?, ?)', + [name, value, num]); + }); + // Update data + _data = await _allSelect(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } + + /// Update data by ID + Future update( + int id, + String name, + int value, + double num, + ) async { + int? count = 0; + try { + // Query + count = await _db?.rawUpdate( + 'UPDATE Test SET name = ?, value = ?, num = ? WHERE rowid = ?', + [name, value, num, id]); + // Update data + _data = await _allSelect(); + // Check state + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return count == 1; + } + + /// Delete data by ID + Future delete( + int id, + ) async { + int? count = 0; + try { + // Query + count = await _db?.rawDelete('DELETE FROM Test WHERE rowid = ?', [id]); + // Update data + _data = await _allSelect(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return count == 1; + } + + /// Select all rows + Future?> _allSelect() async { + try { + return await _db?.rawQuery('SELECT rowid as id, * FROM Test'); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } +} diff --git a/example/lib/packages/sqflite/package.dart b/example/lib/packages/sqflite/package.dart new file mode 100644 index 0000000..bce64ea --- /dev/null +++ b/example/lib/packages/sqflite/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageSqflite = PackagePage( + key: 'sqflite', + descEN: ''' + SQLite plugin for Flutter. Supports iOS, Android, MacOS and Aurora OS. + ''', + descRU: ''' + Плагин SQLite для Flutter. Поддерживает iOS, Android, MacOS и ОС Аврора. + ''', + version: '2.2.6', + isPlatformDependent: true, + page: () => SqflitePage(), + init: () { + GetIt.instance.registerFactory(() => SqfliteModel()); + }, +); diff --git a/example/lib/packages/sqflite/page.dart b/example/lib/packages/sqflite/page.dart new file mode 100644 index 0000000..81609d1 --- /dev/null +++ b/example/lib/packages/sqflite/page.dart @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/foundation.dart' show kIsAurora; +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/sqflite/widgets/form_delete.dart'; +import 'package:flutter_example_packages/packages/sqflite/widgets/form_insert.dart'; +import 'package:flutter_example_packages/packages/sqflite/widgets/form_update.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; + +import 'model.dart'; +import 'package.dart'; + +class SqflitePage extends AppStatefulWidget { + SqflitePage({ + super.key, + }); + + final Package package = packageSqflite; + + @override + State createState() => _SqflitePageState(); +} + +class _SqflitePageState extends AppState { + final _model = getIt(); + bool _loading = true; + + final ScrollController _scrollController = ScrollController(); + final _controllerAurora = FlutterKeyboardVisibilityAurora(); + StreamSubscription? _streamSub; + double _keyboardHeight = 0; + + @override + void initState() { + super.initState(); + // Init database + _model.init().then((_) { + if (mounted) { + setState(() { + _loading = false; + }); + } + }); + // Get keyboard height + if (kIsAurora) { + _streamSub = _controllerAurora.onChangeHeight.listen((event) { + setState(() { + _keyboardHeight = event; + }); + }); + } + } + + @override + void dispose() { + super.dispose(); + // Close database + _model.close(); + // Cancel listen + _streamSub?.cancel(); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: _model, + loading: _loading, + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + controller: _scrollController, + padding: EdgeInsets.only(bottom: _keyboardHeight), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(l10n.sqfliteTitleState), + const SizedBox(height: 14), + Container( + width: double.infinity, + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.all(10), + child: TextBodyMedium( + const JsonEncoder.withIndent(' ') + .convert(model.data), + ), + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: model.data.isEmpty + ? null + : () async { + await model.clear(); + _scrollToTop(); + }, + child: TextBodyLarge( + l10n.sqfliteTitleBtnClear, + color: Colors.white, + ), + ), + ), + const SizedBox(height: 20), + TextTitleLarge(l10n.sqfliteTitleInsert), + const SizedBox(height: 20), + SqfliteFormInsert(( + String name, + int value, + double num, + ) async { + await model.insert(name, value, num); + _scrollToTop(); + }), + const SizedBox(height: 20), + TextTitleLarge(l10n.sqfliteTitleUpdate), + const SizedBox(height: 20), + SqfliteFormUpdate(( + int id, + String name, + int value, + double num, + ) async { + if (await model.update(id, name, value, num)) { + _scrollToTop(); + return true; + } + return false; + }), + const SizedBox(height: 20), + TextTitleLarge(l10n.sqfliteTitleDelete), + const SizedBox(height: 20), + SqfliteFormDelete((int id) async { + if (await model.delete(id)) { + _scrollToTop(); + return true; + } + return false; + }), + ], + ) + ], + ), + ), + ); + }, + ); + } + + void _scrollToTop() { + // scroll to top + _scrollController.animateTo( + 0, + duration: const Duration(milliseconds: 500), + curve: Curves.ease, + ); + } +} diff --git a/example/lib/packages/sqflite/widgets/form_delete.dart b/example/lib/packages/sqflite/widgets/form_delete.dart new file mode 100644 index 0000000..ac5969d --- /dev/null +++ b/example/lib/packages/sqflite/widgets/form_delete.dart @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class SqfliteFormDelete extends AppStatefulWidget { + const SqfliteFormDelete( + this.submit, { + super.key, + }); + + final Future Function( + int id, + ) submit; + + @override + State createState() => _SqfliteFormDeleteState(); +} + +class _SqfliteFormDeleteState extends AppState { + final _formKey = GlobalKey(); + final TextEditingController _idController = TextEditingController(); + bool _isError = false; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + controller: _idController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldID, + errorText: _isError ? l10n.sqfliteTitleError : null, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (int.tryParse(value) == null) { + return l10n.sqfliteTitleValidateType('int'); + } + return null; + }, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () async { + if (_formKey.currentState?.validate() == true) { + // Send submit + if (await widget.submit( + int.parse(_idController.text), + )) { + // Clear focus + FocusScope.of(context).unfocus(); + // Clear form + _idController.clear(); + // Clear error + setState(() { + _isError = false; + }); + } else { + // Show error + setState(() { + _isError = true; + }); + } + } + }, + child: TextBodyLarge( + l10n.sqfliteTitleBtnSubmit, + color: Colors.white, + ), + ), + ), + ], + ), + ); + } +} diff --git a/example/lib/packages/sqflite/widgets/form_insert.dart b/example/lib/packages/sqflite/widgets/form_insert.dart new file mode 100644 index 0000000..0406fc3 --- /dev/null +++ b/example/lib/packages/sqflite/widgets/form_insert.dart @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class SqfliteFormInsert extends AppStatefulWidget { + const SqfliteFormInsert( + this.submit, { + super.key, + }); + + final Future Function( + String name, + int value, + double num, + ) submit; + + @override + State createState() => _SqfliteFormInsertState(); +} + +class _SqfliteFormInsertState extends AppState { + final _formKey = GlobalKey(); + final TextEditingController _nameController = TextEditingController(); + final TextEditingController _valueController = TextEditingController(); + final TextEditingController _numController = TextEditingController(); + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + controller: _nameController, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldName, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _valueController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldValue, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (int.tryParse(value) == null) { + return l10n.sqfliteTitleValidateType('int'); + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _numController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldNum, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (double.tryParse(value.replaceAll(',', '.')) == null) { + return l10n.sqfliteTitleValidateType('double'); + } + return null; + }, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () async { + if (_formKey.currentState?.validate() == true) { + // Clear focus + FocusScope.of(context).unfocus(); + // Send submit + await widget.submit( + _nameController.text, + int.parse(_valueController.text), + double.parse(_numController.text.replaceAll(',', '.')), + ); + // Clear form + _nameController.clear(); + _valueController.clear(); + _numController.clear(); + } + }, + child: TextBodyLarge( + l10n.sqfliteTitleBtnSubmit, + color: Colors.white, + ), + ), + ), + ], + ), + ); + } +} diff --git a/example/lib/packages/sqflite/widgets/form_update.dart b/example/lib/packages/sqflite/widgets/form_update.dart new file mode 100644 index 0000000..17f4b01 --- /dev/null +++ b/example/lib/packages/sqflite/widgets/form_update.dart @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class SqfliteFormUpdate extends AppStatefulWidget { + const SqfliteFormUpdate( + this.submit, { + super.key, + }); + + final Future Function( + int id, + String name, + int value, + double num, + ) submit; + + @override + State createState() => _SqfliteFormUpdateState(); +} + +class _SqfliteFormUpdateState extends AppState { + final _formKey = GlobalKey(); + final TextEditingController _idController = TextEditingController(); + final TextEditingController _nameController = TextEditingController(); + final TextEditingController _valueController = TextEditingController(); + final TextEditingController _numController = TextEditingController(); + bool _isError = false; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + controller: _idController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldID, + errorText: _isError ? l10n.sqfliteTitleError : null, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (int.tryParse(value) == null) { + return l10n.sqfliteTitleValidateType('int'); + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _nameController, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldName, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _valueController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldValue, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (int.tryParse(value) == null) { + return l10n.sqfliteTitleValidateType('int'); + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _numController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: l10n.sqfliteTitleFieldNum, + ), + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.sqfliteTitleValidateRequired; + } + if (double.tryParse(value.replaceAll(',', '.')) == null) { + return l10n.sqfliteTitleValidateType('double'); + } + return null; + }, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () async { + if (_formKey.currentState?.validate() == true) { + // Send submit + if (await widget.submit( + int.parse(_idController.text), + _nameController.text, + int.parse(_valueController.text), + double.parse(_numController.text.replaceAll(',', '.')), + )) { + // Clear focus + FocusScope.of(context).unfocus(); + // Clear form + _idController.clear(); + _nameController.clear(); + _valueController.clear(); + _numController.clear(); + // Clear error + setState(() { + _isError = false; + }); + } else { + // Show error + setState(() { + _isError = true; + }); + } + } + }, + child: TextBodyLarge( + l10n.sqfliteTitleBtnSubmit, + color: Colors.white, + ), + ), + ), + ], + ), + ); + } +} diff --git a/example/lib/packages/translator/model.dart b/example/lib/packages/translator/model.dart new file mode 100644 index 0000000..a3e2500 --- /dev/null +++ b/example/lib/packages/translator/model.dart @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:translator/translator.dart'; + +/// Model for [TranslatorPage] +class TranslatorModel extends Model { + /// Get [ScopedModel] + static TranslatorModel of(BuildContext context) => + ScopedModel.of(context); + + final translator = GoogleTranslator(); + + Future translate( + String value, + ) async { + return await translator.translate(value, from: 'en', to: 'ru'); + } +} diff --git a/example/lib/packages/translator/package.dart b/example/lib/packages/translator/package.dart new file mode 100644 index 0000000..e60879c --- /dev/null +++ b/example/lib/packages/translator/package.dart @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; +import 'page.dart'; + +/// Package values +final packageTranslator = PackagePage( + key: 'translator', + descEN: ''' + Free Google Translate API for Dart. + ''', + descRU: ''' + Бесплатный API Google Translate для Dart. + ''', + version: '0.1.7', + isPlatformDependent: false, + page: () => TranslatorPage(), + init: () { + GetIt.instance.registerFactory(() => TranslatorModel()); + }, +); diff --git a/example/lib/packages/translator/page.dart b/example/lib/packages/translator/page.dart new file mode 100644 index 0000000..dee8e34 --- /dev/null +++ b/example/lib/packages/translator/page.dart @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import 'model.dart'; +import 'package.dart'; + +class TranslatorPage extends AppStatefulWidget { + TranslatorPage({ + super.key, + }); + + final Package package = packageTranslator; + + @override + State createState() => _TranslatorPageState(); +} + +class _TranslatorPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockItem( + title: l10n.translatorTitle, + desc: l10n.translatorSubtitle, + future: model.translate(l10n.translatorText), + builder: (value) => value.text, + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/universal_io/package.dart b/example/lib/packages/universal_io/package.dart new file mode 100644 index 0000000..ea0b867 --- /dev/null +++ b/example/lib/packages/universal_io/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_dialog.dart'; + +/// Package values +final packageUniversalIO = PackageDialog( + key: 'universal_io', + descEN: ''' + A cross-platform dart:io that works on all platforms, + including browsers. + ''', + descRU: ''' + Кроссплатформенный dart:io, который работает на всех платформах, + включая браузеры. + ''', + messageEN: ''' + This is a platform independent plugin used in this app, should work + for you too. + ''', + messageRU: ''' + Это плагин независимый от платформы, используется в этом приложении, + должен работать и у вас. + ''', + version: '2.2.0', + isPlatformDependent: false, +); diff --git a/example/lib/packages/wakelock/model.dart b/example/lib/packages/wakelock/model.dart new file mode 100644 index 0000000..dfecfb4 --- /dev/null +++ b/example/lib/packages/wakelock/model.dart @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:wakelock/wakelock.dart'; + +/// Model for [WakelockPage] +class WakelockModel extends Model { + /// Get [ScopedModel] + static WakelockModel of(BuildContext context) => + ScopedModel.of(context); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// Check is enable Wakelock + Future isEnable() async { + try { + return await Wakelock.enabled; + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// Set state Wakelock + Future setStateWakelock(bool enable) async { + try { + await Wakelock.toggle(enable: enable); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + } +} diff --git a/example/lib/packages/wakelock/package.dart b/example/lib/packages/wakelock/package.dart new file mode 100644 index 0000000..bf678cd --- /dev/null +++ b/example/lib/packages/wakelock/package.dart @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/wakelock/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageWakelock = PackagePage( + key: 'wakelock', + descEN: ''' + Plugin that allows you to keep the device screen awake, i.e. + prevent the screen from sleeping. + ''', + descRU: ''' + Плагин, который позволяет держать экран устройства в активном состоянии, + т. е. предотвращать переход экрана в спящий режим. + ''', + version: '0.6.2', + isPlatformDependent: true, + page: () => WakelockPage(), + init: () { + GetIt.instance.registerFactory(() => WakelockModel()); + }, +); diff --git a/example/lib/packages/wakelock/page.dart b/example/lib/packages/wakelock/page.dart new file mode 100644 index 0000000..a14a971 --- /dev/null +++ b/example/lib/packages/wakelock/page.dart @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/wakelock/model.dart'; +import 'package:flutter_example_packages/packages/wakelock/package.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class WakelockPage extends AppStatefulWidget { + WakelockPage({ + super.key, + }); + + final Package package = packageWakelock; + + @override + State createState() => _WakelockPageState(); +} + +class _WakelockPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Row( + children: [ + Expanded( + flex: 1, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(l10n.wakelockTitle), + const SizedBox(height: 8), + TextBodyMedium(l10n.wakelockDesc), + ], + ), + ), + FutureBuilder( + future: model.isEnable(), + builder: ( + BuildContext context, + AsyncSnapshot snapshot, + ) { + final value = snapshot.data ?? false; + return Expanded( + flex: 0, + child: Switch( + // This bool value toggles the switch. + value: value, + activeColor: AppColors.secondary, + onChanged: (bool value) { + model.setStateWakelock(value); + }, + ), + ); + }, + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/packages/xdga_directories/model.dart b/example/lib/packages/xdga_directories/model.dart new file mode 100644 index 0000000..7511ab5 --- /dev/null +++ b/example/lib/packages/xdga_directories/model.dart @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:scoped_model/scoped_model.dart'; +import 'package:xdga_directories/xdga_directories.dart' as xdga; + +/// Model for [XdgaDirectoriesPage] +class XdgaDirectoriesModel extends Model { + /// Get [ScopedModel] + static XdgaDirectoriesModel of(BuildContext context) => + ScopedModel.of(context); + + /// Error + String? _error; + + /// Public error + String? get error => _error; + + /// Public is error + bool get isError => _error != null; + + /// QStandardPaths::CacheLocation + String? getCacheLocation() { + try { + return xdga.getCacheLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::AppDataLocation + String? getAppDataLocation() { + try { + return xdga.getAppDataLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::DocumentsLocation + String? getDocumentsLocation() { + try { + return xdga.getDocumentsLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::DownloadLocation + String? getDownloadLocation() { + try { + return xdga.getDownloadLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::MusicLocation + String? getMusicLocation() { + try { + return xdga.getMusicLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::PicturesLocation + String? getPicturesLocation() { + try { + return xdga.getPicturesLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::GenericDataLocation + String? getGenericDataLocation() { + try { + return xdga.getGenericDataLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } + + /// QStandardPaths::MoviesLocation + String? getMoviesLocation() { + try { + return xdga.getMoviesLocation(); + } catch (e) { + _error = e.toString(); + } + notifyListeners(); + return null; + } +} diff --git a/example/lib/packages/xdga_directories/package.dart b/example/lib/packages/xdga_directories/package.dart new file mode 100644 index 0000000..56c4c30 --- /dev/null +++ b/example/lib/packages/xdga_directories/package.dart @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/xdga_directories/page.dart'; +import 'package:get_it/get_it.dart'; + +import 'model.dart'; + +/// Package values +final packageXdgaDirectories = PackagePage( + key: 'xdga_directories', + descEN: ''' + A Dart package for reading XDG directory configuration information + on Aurora OS. + ''', + descRU: ''' + Пакет Dart для чтения информации о конфигурации каталога XDG + на ОС Аврора. + ''', + version: '0.0.1', + isPlatformDependent: true, + page: () => XdgaDirectoriesPage(), + init: () { + GetIt.instance + .registerFactory(() => XdgaDirectoriesModel()); + }, +); diff --git a/example/lib/packages/xdga_directories/page.dart b/example/lib/packages/xdga_directories/page.dart new file mode 100644 index 0000000..83b4a87 --- /dev/null +++ b/example/lib/packages/xdga_directories/page.dart @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/packages/xdga_directories/model.dart'; +import 'package:flutter_example_packages/packages/xdga_directories/package.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; +import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class XdgaDirectoriesPage extends AppStatefulWidget { + XdgaDirectoriesPage({ + super.key, + }); + + final Package package = packageXdgaDirectories; + + @override + State createState() => _XdgaDirectoriesPageState(); +} + +class _XdgaDirectoriesPageState extends AppState { + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: getIt(), + title: widget.package.key, + builder: (context, child, model) { + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockInfoPackage(widget.package), + BlockAlert(model.error), + if (!model.isError) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BlockItem( + title: l10n.xdgaDirectoriesTitleCacheLocation, + desc: l10n.xdgaDirectoriesDescCacheLocation, + value: model.getCacheLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleAppDataLocation, + desc: l10n.xdgaDirectoriesDescAppDataLocation, + value: model.getAppDataLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleDocumentsLocation, + desc: l10n.xdgaDirectoriesDescDocumentsLocation, + value: model.getDocumentsLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleDownloadLocation, + desc: l10n.xdgaDirectoriesDescDownloadLocation, + value: model.getDownloadLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleMusicLocation, + desc: l10n.xdgaDirectoriesDescMusicLocation, + value: model.getMusicLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitlePicturesLocation, + desc: l10n.xdgaDirectoriesDescPicturesLocation, + value: model.getPicturesLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleGenericDataLocation, + desc: l10n.xdgaDirectoriesDescGenericDataLocation, + value: model.getGenericDataLocation(), + ), + BlockItem( + title: l10n.xdgaDirectoriesTitleMoviesLocation, + desc: l10n.xdgaDirectoriesDescMoviesLocation, + value: model.getMoviesLocation(), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/example/lib/pages/home/model.dart b/example/lib/pages/home/model.dart new file mode 100644 index 0000000..f0518b6 --- /dev/null +++ b/example/lib/pages/home/model.dart @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/widgets.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/packages/packages.dart' as list; +import 'package:flutter_example_packages/pages/home/widgets/home_app_bar.dart'; +import 'package:scoped_model/scoped_model.dart'; + +/// Model for [HomePage] +class HomeModel extends Model { + /// Get [ScopedModel] + static HomeModel of(BuildContext context) => + ScopedModel.of(context); + + /// Get all list packages + final List packages = list.packages; + + /// Filtered list packages + List _filteredPackages = list.packages; + + /// Public filtered list packages + List get filteredPackages => _filteredPackages; + + /// Get count packages + int get fullSize => packages.length; + + /// Check is search + bool get isSearch => _search.isNotEmpty; + + /// Search text + String _search = ""; + + /// Filter list packages + PlatformFilter _filter = PlatformFilter.disable; + + /// Update state filtered + void updateFilterState( + String search, + PlatformFilter filter, + ) { + _search = search; + _filter = filter; + _filteredPackages = _filterPackages(); + notifyListeners(); + } + + /// Filter list packages + List _filterPackages() { + return packages.where((element) { + bool result = true; + switch (_filter) { + case PlatformFilter.dependent: + result = element.isPlatformDependent == true; + break; + case PlatformFilter.independent: + result = element.isPlatformDependent == false; + break; + case PlatformFilter.demo: + result = element is PackagePage; + break; + case PlatformFilter.disable: + break; + } + if (_search.isNotEmpty) { + if (!element.key.contains(_search)) { + result = false; + } + } + return result; + }).toList(); + } +} diff --git a/example/lib/pages/home/page.dart b/example/lib/pages/home/page.dart new file mode 100644 index 0000000..98e6022 --- /dev/null +++ b/example/lib/pages/home/page.dart @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/di/app_di.dart'; +import 'package:flutter_example_packages/extensions/keys_ext.dart'; +import 'package:flutter_example_packages/pages/home/model.dart'; +import 'package:flutter_example_packages/pages/home/widgets/home_app_bar.dart'; +import 'package:flutter_example_packages/pages/home/widgets/package_list_item.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/widgets/base/app_state.dart'; +import 'package:flutter_example_packages/widgets/base/app_stateful_widget.dart'; +import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class HomePage extends AppStatefulWidget { + const HomePage({ + super.key, + }); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends AppState { + double _hH = 0; + final _header = GlobalKey(); + final HomeModel _model = getIt(); + final ScrollController _controllerListView = ScrollController(); + + @override + void onDidChangeMetrics() { + setState(() { + _hH = _header.getHeight() ?? 0; + }); + } + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return BlockLayout( + model: _model, + builder: (context, child, model) { + return Scaffold( + backgroundColor: Colors.blueGrey, + appBar: HomeAppBar( + onChangeFiltered: (String search, PlatformFilter filter) { + if (model.filteredPackages.isNotEmpty) { + _controllerListView.jumpTo(0); + } + model.updateFilterState(search, filter); + }, + ), + body: GestureDetector( + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + }, + child: Stack( + children: [ + Visibility( + visible: !model.isSearch, + child: Container( + height: _hH > 0 ? _hH : 0, + color: AppColors.primary, + width: double.infinity, + child: Center( + child: Align( + alignment: FractionalOffset.bottomRight, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 40, + ), + child: Opacity( + opacity: 0.2, + child: Image.asset( + 'assets/images/logo-head.png', + width: 250, + ), + ), + ), + ), + ), + ), + ), + Visibility( + visible: !model.isSearch, + child: Container( + key: _header, + width: double.infinity, + padding: EdgeInsets.only( + left: 20, + right: 20, + top: + media.orientation == Orientation.portrait ? 30 : 10, + bottom: + media.orientation == Orientation.portrait ? 90 : 70, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextHeadlineMedium( + l10n.homeWelcomeTitle, + color: Colors.white, + ), + SizedBox( + height: media.orientation == Orientation.portrait + ? 40 + : 20, + ), + TextTitleMedium( + l10n.homeWelcomeText(model.fullSize), + color: Colors.white, + ) + ], + ), + ), + ), + if (model.filteredPackages.isNotEmpty) + ListView.builder( + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, + controller: _controllerListView, + padding: EdgeInsets.only( + top: _hH > 0 && !model.isSearch ? _hH - 20 : 0), + itemCount: model.filteredPackages.length, + itemBuilder: (context, index) { + return PackageListItemWidget( + index: index, + item: model.filteredPackages[index], + ); + }, + ), + if (model.filteredPackages.isEmpty) + Container( + width: double.infinity, + height: double.infinity, + color: Colors.white, + child: Padding( + padding: const EdgeInsets.only( + left: 20, + right: 20, + top: 20, + bottom: 0, + ), + child: Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextTitleLarge( + l10n.homeNotFoundTitle, + textAlign: TextAlign.center, + ), + const SizedBox(height: 40), + TextBodyMedium( + l10n.homeNotFoundSubtitle, + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ), + ), + ], + ), + ), + ); + }); + } +} diff --git a/example/lib/pages/home/widgets/home_app_bar.dart b/example/lib/pages/home/widgets/home_app_bar.dart new file mode 100644 index 0000000..0450387 --- /dev/null +++ b/example/lib/pages/home/widgets/home_app_bar.dart @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +enum PlatformFilter { + disable, + dependent, + independent, + demo, +} + +class HomeAppBar extends AppStatefulWidget implements PreferredSizeWidget { + const HomeAppBar({ + super.key, + required this.onChangeFiltered, + }); + + final void Function(String, PlatformFilter) onChangeFiltered; + + @override + State createState() => _HomeAppBarState(); + + @override + Size get preferredSize => const Size.fromHeight(60.0); +} + +class _HomeAppBarState extends AppState { + String? _search; + PlatformFilter _filter = PlatformFilter.disable; + + final _searchController = TextEditingController(); + final _searchFocus = FocusNode(); + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + final theme = Theme.of(context); + return AppBar( + centerTitle: true, + shape: const Border(bottom: BorderSide(width: 0)), + leading: _search != null + ? Padding( + padding: const EdgeInsets.all(8.0), + child: ClipOval( + child: Material( + color: Colors.blueGrey, + child: IconButton( + icon: const Icon(Icons.close), + tooltip: l10n.homeSearch, + onPressed: () { + setState(() { + _search = null; + widget.onChangeFiltered.call("", _filter); + _searchController.clear(); + }); + }, + ), + ), + ), + ) + : null, + title: _search != null + ? TextField( + focusNode: _searchFocus, + controller: _searchController, + style: theme.textTheme.titleLarge?.copyWith(color: Colors.white), + cursorColor: Colors.white, + decoration: InputDecoration( + hintText: l10n.homeSearchTitle, + hintStyle: + theme.textTheme.titleLarge?.copyWith(color: Colors.white54), + border: InputBorder.none, + contentPadding: const EdgeInsets.all(0), + ), + onChanged: (value) { + _search = value; + widget.onChangeFiltered.call(value, _filter); + }, + ) + : null, + actions: [ + if (_search == null) + Padding( + padding: const EdgeInsets.all(8.0), + child: SizedBox( + width: 40, + height: 40, + child: ClipOval( + child: Material( + color: Colors.blueGrey, + child: IconButton( + icon: const Icon(Icons.search), + tooltip: l10n.homeSearch, + onPressed: () { + setState(() { + _search = ""; + _searchFocus.requestFocus(); + }); + }, + ), + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: SizedBox( + width: 40, + height: 40, + child: ClipOval( + child: Material( + color: () { + switch (_filter) { + case PlatformFilter.disable: + return Colors.blueGrey; + case PlatformFilter.dependent: + return Colors.deepOrangeAccent; + case PlatformFilter.independent: + return Colors.blueAccent; + case PlatformFilter.demo: + return Colors.green; + } + }.call(), + child: IconButton( + icon: () { + switch (_filter) { + case PlatformFilter.disable: + return const Icon(Icons.filter_list_off); + case PlatformFilter.dependent: + return const Icon(Icons.filter_list); + case PlatformFilter.independent: + return const Icon(Icons.filter_list); + case PlatformFilter.demo: + return const Icon(Icons.visibility); + } + }.call(), + tooltip: l10n.homeFilter, + onPressed: () { + setState(() { + switch (_filter) { + case PlatformFilter.disable: + _filter = PlatformFilter.dependent; + break; + case PlatformFilter.dependent: + _filter = PlatformFilter.independent; + break; + case PlatformFilter.independent: + _filter = PlatformFilter.demo; + break; + case PlatformFilter.demo: + _filter = PlatformFilter.disable; + break; + } + widget.onChangeFiltered.call(_search ?? "", _filter); + }); + }, + ), + ), + ), + ), + ), + ], + ); + } +} diff --git a/example/lib/pages/home/widgets/package_info_dialog.dart b/example/lib/pages/home/widgets/package_info_dialog.dart new file mode 100644 index 0000000..944770b --- /dev/null +++ b/example/lib/pages/home/widgets/package_info_dialog.dart @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/package/package_dialog.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class PackageInfoDialog extends AppStatelessWidget { + const PackageInfoDialog({ + super.key, + required this.package, + }); + + final PackageDialog package; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Dialog( + shape: RoundedRectangleBorder(borderRadius: AppRadius.small), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(package.key), + const SizedBox(height: 15), + TextBodyMedium(package.message), + const SizedBox(height: 10), + Row( + children: [ + const Spacer(), + OutlinedButton( + style: OutlinedButton.styleFrom( + fixedSize: const Size.fromHeight(33), + ), + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(l10n.commonClose), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/example/lib/pages/home/widgets/package_list_item.dart b/example/lib/pages/home/widgets/package_list_item.dart new file mode 100644 index 0000000..e243271 --- /dev/null +++ b/example/lib/pages/home/widgets/package_list_item.dart @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/base/package/package_dialog.dart'; +import 'package:flutter_example_packages/base/package/package_page.dart'; +import 'package:flutter_example_packages/pages/home/widgets/package_info_dialog.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +class PackageListItemWidget extends AppStatelessWidget { + const PackageListItemWidget({ + super.key, + required this.index, + required this.item, + }); + + final int index; + final Package item; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Stack( + children: [ + Visibility( + visible: index != 0, + child: Container( + height: 10, + width: double.infinity, + transform: Matrix4.translationValues(0.0, -10, 0.0), + color: Colors.blueGrey, + ), + ), + Container( + decoration: BoxDecoration( + color: Colors.blueGrey, + borderRadius: index == 0 + ? const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20), + ) + : null, + ), + child: Padding( + padding: index == 0 + ? const EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 0) + : const EdgeInsets.symmetric(horizontal: 20), + child: Column( + children: [ + Stack( + children: [ + Padding( + padding: const EdgeInsets.only(top: 10), + child: Stack( + children: [ + SizedBox( + width: double.infinity, + child: Card( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextTitleLarge(item.key), + const SizedBox(height: 10), + TextBodyMedium( + item.desc, + color: Colors.black.withOpacity(0.6), + ), + const SizedBox(height: 12), + Divider( + height: 1, + color: AppColors.primary.withOpacity(0.2), + ), + const SizedBox(height: 12), + Row( + children: [ + Visibility( + visible: item is PackagePage, + child: Row( + children: const [ + Icon( + Icons.visibility, + size: 16, + color: Colors.green, + ), + SizedBox(width: 6), + ], + ), + ), + TextBodySmall( + l10n.homeListVersion(item.version), + color: AppColors.primary + .withOpacity(0.7), + ), + ], + ), + ], + ), + ), + ), + ), + Positioned.fill( + child: Material( + color: Colors.transparent, + child: InkWell( + customBorder: RoundedRectangleBorder( + borderRadius: AppRadius.small, + ), + hoverColor: Colors.transparent, + onTap: () { + if (item is PackagePage) { + Navigator.pushNamed( + context, '/${item.key}'); + } else if (item is PackageDialog) { + showDialog( + context: context, + builder: (BuildContext context) { + return PackageInfoDialog( + package: item as PackageDialog, + ); + }); + } + }, + ), + ), + ), + ], + ), + ), + Align( + alignment: FractionalOffset.topRight, + child: Container( + margin: const EdgeInsets.only(right: 16), + decoration: BoxDecoration( + color: item.isPlatformDependent + ? Colors.deepOrangeAccent + : Colors.blueAccent, + borderRadius: AppRadius.small, + ), + child: Padding( + padding: const EdgeInsets.only( + left: 6, + top: 6, + right: 6, + bottom: 6, + ), + child: TextBodySmall( + item.isPlatformDependent + ? l10n.homeListStateDependent + : l10n.homeListStateIndependent, + color: Colors.white, + ), + ), + ), + ), + ], + ), + const SizedBox(height: 20), + ], + ), + ), + ), + ], + ); + } +} diff --git a/example/lib/theme/colors.dart b/example/lib/theme/colors.dart new file mode 100644 index 0000000..0b87bf2 --- /dev/null +++ b/example/lib/theme/colors.dart @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +class AppColors { + static const Color primary = Color(0xFF080614); + static const Color secondary = Colors.blueGrey; + static const Color warning = Color(0xFFfb7d4a); +} diff --git a/example/lib/theme/radius.dart b/example/lib/theme/radius.dart new file mode 100644 index 0000000..73d566f --- /dev/null +++ b/example/lib/theme/radius.dart @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +class AppRadius { + static final large = BorderRadius.circular(24.0); + static final medium = BorderRadius.circular(16.0); + static final small = BorderRadius.circular(8.0); +} diff --git a/example/lib/theme/theme.dart b/example/lib/theme/theme.dart new file mode 100644 index 0000000..274418f --- /dev/null +++ b/example/lib/theme/theme.dart @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:google_fonts/google_fonts.dart'; + +final theme = ThemeData.light(); + +final appTheme = ThemeData( + colorScheme: theme.colorScheme.copyWith( + primary: AppColors.primary, + secondary: AppColors.secondary, + ), + + /// [Card] + cardTheme: CardTheme( + clipBehavior: Clip.antiAlias, + margin: const EdgeInsets.all(0), + color: AppColors.primary.withOpacity(0.4), + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: AppRadius.small, + ), + ), + + /// [TextField] + inputDecorationTheme: theme.inputDecorationTheme.copyWith( + contentPadding: const EdgeInsets.symmetric( + vertical: 14, + horizontal: 16, + ), + border: const OutlineInputBorder(), + ), + + /// [ElevatedButton] + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.secondary, + minimumSize: const Size.fromHeight(45), + ), + ), + + /// [OutlinedButton] + outlinedButtonTheme: OutlinedButtonThemeData( + style: OutlinedButton.styleFrom( + foregroundColor: AppColors.secondary, + fixedSize: const Size.fromHeight(45), + side: const BorderSide(color: AppColors.secondary), + ), + ), + + /// [Text] + textTheme: TextTheme( + headlineLarge: GoogleFonts.roboto( + fontSize: 44, + fontWeight: FontWeight.bold, + ), + headlineMedium: GoogleFonts.roboto( + fontSize: 30, + fontWeight: FontWeight.bold, + ), + headlineSmall: GoogleFonts.roboto( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + titleLarge: GoogleFonts.roboto( + fontSize: 20, + height: 1.3, + ), + titleMedium: GoogleFonts.roboto( + fontSize: 18, + height: 1.3, + ), + titleSmall: GoogleFonts.roboto( + fontSize: 14, + height: 1.3, + ), + bodyLarge: GoogleFonts.openSans( + fontSize: 18, + height: 1.3, + ), + bodyMedium: GoogleFonts.openSans( + fontSize: 16, + height: 1.3, + ), + bodySmall: GoogleFonts.openSans( + fontSize: 12, + height: 1.3, + ), + ), +); diff --git a/example/lib/widgets/base/app_state.dart b/example/lib/widgets/base/app_state.dart new file mode 100644 index 0000000..5034616 --- /dev/null +++ b/example/lib/widgets/base/app_state.dart @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +abstract class AppState extends State + with WidgetsBindingObserver { + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ); + + void onPostFrameCallback() {} + void onDidChangeMetrics() {} + + void _delayedChangeMetrics() { + for (int i = 0; i <= 5; i++) { + Future.delayed(Duration(milliseconds: 100 * i), () { + if (mounted) { + onDidChangeMetrics(); + } + }); + } + } + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + WidgetsBinding.instance.addPostFrameCallback((_) { + _delayedChangeMetrics(); + }); + } + + @override + void didChangeMetrics() { + _delayedChangeMetrics(); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + Widget build(BuildContext context) => buildWide( + context, + MediaQuery.of(context), + AppLocalizations.of(context)!, + ); +} diff --git a/example/lib/widgets/base/app_stateful_widget.dart b/example/lib/widgets/base/app_stateful_widget.dart new file mode 100644 index 0000000..9830ed7 --- /dev/null +++ b/example/lib/widgets/base/app_stateful_widget.dart @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +abstract class AppStatefulWidget extends StatefulWidget { + const AppStatefulWidget({super.key}); +} diff --git a/example/lib/widgets/base/app_stateless_widget.dart b/example/lib/widgets/base/app_stateless_widget.dart new file mode 100644 index 0000000..658f2c7 --- /dev/null +++ b/example/lib/widgets/base/app_stateless_widget.dart @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +abstract class AppStatelessWidget extends StatelessWidget { + const AppStatelessWidget({super.key}); + + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ); + + void onPostFrameCallback() {} + + @override + Widget build(BuildContext context) => buildWide( + context, + MediaQuery.of(context), + AppLocalizations.of(context)!, + ); +} diff --git a/example/lib/widgets/base/export.dart b/example/lib/widgets/base/export.dart new file mode 100644 index 0000000..34f4070 --- /dev/null +++ b/example/lib/widgets/base/export.dart @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +library base; + +export 'package:flutter_example_packages/widgets/base/app_state.dart'; +export 'package:flutter_example_packages/widgets/base/app_stateful_widget.dart'; +export 'package:flutter_example_packages/widgets/base/app_stateless_widget.dart'; diff --git a/example/lib/widgets/blocks/block_alert.dart b/example/lib/widgets/blocks/block_alert.dart new file mode 100644 index 0000000..90dd385 --- /dev/null +++ b/example/lib/widgets/blocks/block_alert.dart @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; + +/// Alert +class BlockAlert extends StatelessWidget { + const BlockAlert( + this.text, { + super.key, + this.color = Colors.redAccent, + this.padding = const EdgeInsets.only(bottom: 20), + }); + + final EdgeInsets padding; + final Color color; + final String? text; + + @override + Widget build(BuildContext context) { + return Visibility( + visible: text != null, + child: Padding( + padding: padding, + child: Container( + width: double.infinity, + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: color, + borderRadius: AppRadius.small, + ), + child: TextBodyMedium( + '$text', + color: Colors.white, + ), + ), + ), + ); + } +} diff --git a/example/lib/widgets/blocks/block_info_package.dart b/example/lib/widgets/blocks/block_info_package.dart new file mode 100644 index 0000000..f7353f0 --- /dev/null +++ b/example/lib/widgets/blocks/block_info_package.dart @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/base/package/package.dart'; +import 'package:flutter_example_packages/theme/radius.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +/// Block info package in page +class BlockInfoPackage extends AppStatelessWidget { + const BlockInfoPackage( + this.package, { + super.key, + }); + + final Package package; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return Container( + padding: const EdgeInsets.all(12), + margin: const EdgeInsets.only(bottom: 20), + decoration: BoxDecoration( + color: Colors.grey.shade200, + borderRadius: AppRadius.small, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextBodyMedium(package.desc), + const SizedBox(height: 8), + Divider( + height: 1, + color: Colors.grey.shade400, + ), + const SizedBox(height: 8), + Row( + children: [ + const Icon(Icons.verified, size: 14, color: Colors.green), + const SizedBox(width: 6), + TextBodySmall(package.version), + const SizedBox(width: 10), + Icon( + Icons.auto_awesome_motion, + size: 14, + color: package.isPlatformDependent + ? Colors.deepOrange + : Colors.blueAccent, + ), + const SizedBox(width: 6), + TextBodySmall( + package.isPlatformDependent + ? l10n.homeListStateDependent + : l10n.homeListStateIndependent, + ), + ], + ), + ], + ), + ); + } +} diff --git a/example/lib/widgets/blocks/block_item.dart b/example/lib/widgets/blocks/block_item.dart new file mode 100644 index 0000000..09d6b46 --- /dev/null +++ b/example/lib/widgets/blocks/block_item.dart @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +/// Block list item +class BlockItem extends AppStatelessWidget { + const BlockItem({ + super.key, + this.title, + this.desc, + this.value, + this.future, + this.stream, + this.builder, + }); + + final String? title; + final String? desc; + final T? value; + final Stream? stream; + final Future? future; + final Function(T)? builder; + + AsyncWidgetBuilder get widgetBuilder => + (BuildContext context, AsyncSnapshot snapshot) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Visibility( + visible: title != null, + child: Column( + children: [ + TextTitleLarge(title ?? ''), + const SizedBox(height: 8), + ], + ), + ), + Visibility( + visible: desc != null, + child: Column( + children: [ + TextBodyMedium(desc ?? ''), + const SizedBox(height: 8), + ], + ), + ), + if (snapshot.hasData) + TextBodyMedium( + builder == null + ? snapshot.data.toString() + : builder?.call(snapshot.data as T), + fontWeight: FontWeight.bold, + ), + if (!snapshot.hasData) + const SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + color: Colors.blueAccent, + strokeWidth: 2, + ), + ), + const SizedBox(height: 20), + ], + ); + }; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + if (stream != null) { + return StreamBuilder( + stream: stream, + builder: widgetBuilder, + ); + } + if (future != null) { + return FutureBuilder( + future: future, + builder: widgetBuilder, + ); + } + return FutureBuilder( + future: Future.value(value), + builder: widgetBuilder, + ); + } +} diff --git a/example/lib/widgets/layouts/block_layout.dart b/example/lib/widgets/layouts/block_layout.dart new file mode 100644 index 0000000..d37bb2d --- /dev/null +++ b/example/lib/widgets/layouts/block_layout.dart @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/theme/colors.dart'; +import 'package:flutter_example_packages/widgets/base/export.dart'; +import 'package:flutter_example_packages/widgets/texts/export.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:scoped_model/scoped_model.dart'; + +class BlockLayout extends AppStatelessWidget { + const BlockLayout({ + super.key, + this.title, + required this.model, + required this.builder, + this.loading, + }); + + final T model; + final String? title; + final bool? loading; + final Widget Function(BuildContext context, Widget? child, T model) builder; + + @override + Widget buildWide( + BuildContext context, + MediaQueryData media, + AppLocalizations l10n, + ) { + return ScopedModel( + model: model, + child: ScopedModelDescendant( + builder: (context, child, model) { + return Scaffold( + appBar: title == null + ? null + : AppBar( + leading: Padding( + padding: const EdgeInsets.all(8.0), + child: ClipOval( + child: Material( + color: Colors.blueGrey, + child: IconButton( + icon: const Icon(Icons.arrow_back), + tooltip: 'Back', + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ), + ), + backgroundColor: AppColors.primary, + title: TextTitleLarge( + title!, + color: Colors.white, + ), + ), + body: loading == true + ? const Center( + child: CircularProgressIndicator(), + ) + : builder.call(context, child, model), + ); + }, + ), + ); + } +} diff --git a/example/lib/widgets/layouts/page_layout.dart b/example/lib/widgets/layouts/page_layout.dart new file mode 100644 index 0000000..2bafe59 --- /dev/null +++ b/example/lib/widgets/layouts/page_layout.dart @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +class PageLayout extends StatefulWidget { + const PageLayout({ + super.key, + required this.child, + }); + + final Widget child; + + @override + State createState() => _PageLayoutState(); +} + +class _PageLayoutState extends State { + @override + Widget build(BuildContext context) { + return Localizations.override( + context: context, + child: Builder( + builder: (context) { + return widget.child; + }, + ), + ); + } +} diff --git a/example/lib/widgets/texts/export.dart b/example/lib/widgets/texts/export.dart new file mode 100644 index 0000000..a98add8 --- /dev/null +++ b/example/lib/widgets/texts/export.dart @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +library texts; + +export 'package:flutter_example_packages/widgets/texts/text_body_large.dart'; +export 'package:flutter_example_packages/widgets/texts/text_body_medium.dart'; +export 'package:flutter_example_packages/widgets/texts/text_body_small.dart'; +export 'package:flutter_example_packages/widgets/texts/text_headline_large.dart'; +export 'package:flutter_example_packages/widgets/texts/text_headline_medium.dart'; +export 'package:flutter_example_packages/widgets/texts/text_headline_small.dart'; +export 'package:flutter_example_packages/widgets/texts/text_title_large.dart'; +export 'package:flutter_example_packages/widgets/texts/text_title_medium.dart'; +export 'package:flutter_example_packages/widgets/texts/text_title_small.dart'; diff --git a/example/lib/widgets/texts/text_base.dart b/example/lib/widgets/texts/text_base.dart new file mode 100644 index 0000000..8249b26 --- /dev/null +++ b/example/lib/widgets/texts/text_base.dart @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; + +class TextBase extends StatelessWidget { + const TextBase( + this.data, { + super.key, + this.color, + this.textAlign, + this.fontWeight, + }); + + final String data; + final Color? color; + final TextAlign? textAlign; + final FontWeight? fontWeight; + + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.bodyMedium; + } + + @override + Widget build(BuildContext context) { + return Text( + data, + style: getStyle(context)?.copyWith(color: color ?? Colors.black).copyWith( + fontWeight: fontWeight, + ), + textAlign: textAlign, + ); + } +} diff --git a/example/lib/widgets/texts/text_body_large.dart b/example/lib/widgets/texts/text_body_large.dart new file mode 100644 index 0000000..e85a84d --- /dev/null +++ b/example/lib/widgets/texts/text_body_large.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextBodyLarge extends TextBase { + const TextBodyLarge( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.bodyLarge; + } +} diff --git a/example/lib/widgets/texts/text_body_medium.dart b/example/lib/widgets/texts/text_body_medium.dart new file mode 100644 index 0000000..62bea46 --- /dev/null +++ b/example/lib/widgets/texts/text_body_medium.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextBodyMedium extends TextBase { + const TextBodyMedium( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.bodyMedium; + } +} diff --git a/example/lib/widgets/texts/text_body_small.dart b/example/lib/widgets/texts/text_body_small.dart new file mode 100644 index 0000000..e7aeee9 --- /dev/null +++ b/example/lib/widgets/texts/text_body_small.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextBodySmall extends TextBase { + const TextBodySmall( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.bodySmall; + } +} diff --git a/example/lib/widgets/texts/text_headline_large.dart b/example/lib/widgets/texts/text_headline_large.dart new file mode 100644 index 0000000..3344740 --- /dev/null +++ b/example/lib/widgets/texts/text_headline_large.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextHeadlineLarge extends TextBase { + const TextHeadlineLarge( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.headlineLarge; + } +} diff --git a/example/lib/widgets/texts/text_headline_medium.dart b/example/lib/widgets/texts/text_headline_medium.dart new file mode 100644 index 0000000..153277c --- /dev/null +++ b/example/lib/widgets/texts/text_headline_medium.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextHeadlineMedium extends TextBase { + const TextHeadlineMedium( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.headlineMedium; + } +} diff --git a/example/lib/widgets/texts/text_headline_small.dart b/example/lib/widgets/texts/text_headline_small.dart new file mode 100644 index 0000000..90028e1 --- /dev/null +++ b/example/lib/widgets/texts/text_headline_small.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextHeadlineSmall extends TextBase { + const TextHeadlineSmall( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.headlineSmall; + } +} diff --git a/example/lib/widgets/texts/text_title_large.dart b/example/lib/widgets/texts/text_title_large.dart new file mode 100644 index 0000000..f391f84 --- /dev/null +++ b/example/lib/widgets/texts/text_title_large.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextTitleLarge extends TextBase { + const TextTitleLarge( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.titleLarge; + } +} diff --git a/example/lib/widgets/texts/text_title_medium.dart b/example/lib/widgets/texts/text_title_medium.dart new file mode 100644 index 0000000..dacdae7 --- /dev/null +++ b/example/lib/widgets/texts/text_title_medium.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextTitleMedium extends TextBase { + const TextTitleMedium( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.titleMedium; + } +} diff --git a/example/lib/widgets/texts/text_title_small.dart b/example/lib/widgets/texts/text_title_small.dart new file mode 100644 index 0000000..601d16e --- /dev/null +++ b/example/lib/widgets/texts/text_title_small.dart @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023. Open Mobile Platform LLC. + * License: Proprietary. + */ +import 'package:flutter/material.dart'; +import 'package:flutter_example_packages/widgets/texts/text_base.dart'; + +class TextTitleSmall extends TextBase { + const TextTitleSmall( + super.data, { + super.key, + super.color, + super.textAlign, + super.fontWeight, + }); + + @override + TextStyle? getStyle(BuildContext context) { + return Theme.of(context).textTheme.titleSmall; + } +} diff --git a/example/pubspec.lock b/example/pubspec.lock new file mode 100644 index 0000000..392c8ed --- /dev/null +++ b/example/pubspec.lock @@ -0,0 +1,1145 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "50.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.1" + asn1lib: + dependency: transitive + description: + name: asn1lib + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.1" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.9.0" + battery_plus: + dependency: "direct main" + description: + name: battery_plus + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" + battery_plus_aurora: + dependency: "direct main" + description: + path: "packages/battery_plus/battery_plus_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + battery_plus_platform_interface: + dependency: transitive + description: + name: battery_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.3" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.7" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.6.1" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.3" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.4.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.16.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" + crypto: + dependency: "direct main" + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.5" + dartz: + dependency: "direct main" + description: + name: dartz + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.1" + dbus: + dependency: transitive + description: + name: dbus + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.8" + device_info_plus: + dependency: "direct main" + description: + name: device_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "8.2.2" + device_info_plus_aurora: + dependency: "direct main" + description: + path: "packages/device_info_plus/device_info_plus_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "7.0.0" + encrypt: + dependency: transitive + description: + name: encrypt + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.1" + equatable: + dependency: "direct main" + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.0" + flutter_cache_manager: + dependency: "direct main" + description: + name: flutter_cache_manager + url: "https://pub.dartlang.org" + source: hosted + version: "3.3.1" + flutter_keyboard_visibility: + dependency: "direct main" + description: + name: flutter_keyboard_visibility + url: "https://pub.dartlang.org" + source: hosted + version: "5.4.1" + flutter_keyboard_visibility_aurora: + dependency: "direct main" + description: + path: "packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + flutter_keyboard_visibility_linux: + dependency: transitive + description: + name: flutter_keyboard_visibility_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_macos: + dependency: transitive + description: + name: flutter_keyboard_visibility_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + flutter_keyboard_visibility_platform_interface: + dependency: transitive + description: + name: flutter_keyboard_visibility_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_web: + dependency: transitive + description: + name: flutter_keyboard_visibility_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_keyboard_visibility_windows: + dependency: transitive + description: + name: flutter_keyboard_visibility_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + flutter_local_notifications: + dependency: "direct main" + description: + name: flutter_local_notifications + url: "https://pub.dartlang.org" + source: hosted + version: "14.1.2" + flutter_local_notifications_aurora: + dependency: "direct main" + description: + path: "packages/flutter_local_notifications/flutter_local_notifications_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + flutter_local_notifications_linux: + dependency: transitive + description: + name: flutter_local_notifications_linux + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0+1" + flutter_local_notifications_platform_interface: + dependency: transitive + description: + name: flutter_local_notifications_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "7.0.0+1" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_markdown: + dependency: "direct main" + description: + name: flutter_markdown + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.15" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.0" + flutter_secure_storage_aurora: + dependency: "direct main" + description: + path: "packages/flutter_secure_storage/flutter_secure_storage_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.3" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.0" + get_it: + dependency: "direct main" + description: + name: get_it + url: "https://pub.dartlang.org" + source: hosted + version: "7.6.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.4" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + url: "https://pub.dartlang.org" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.2" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" + io: + dependency: transitive + description: + name: io + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.4" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.8.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + url: "https://pub.dartlang.org" + source: hosted + version: "6.6.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + markdown: + dependency: transitive + description: + name: markdown + url: "https://pub.dartlang.org" + source: hosted + version: "7.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + mime: + dependency: transitive + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + nested: + dependency: transitive + description: + name: nested + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + octo_image: + dependency: transitive + description: + name: octo_image + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.2" + package_info_plus_aurora: + dependency: "direct main" + description: + path: "packages/package_info_plus/package_info_plus_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + path: + dependency: "direct main" + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.2" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.15" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.27" + path_provider_aurora: + dependency: "direct main" + description: + path: "packages/path_provider/path_provider_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.11" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.7" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + photo_view: + dependency: "direct main" + description: + name: photo_view + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" + pointycastle: + dependency: transitive + description: + name: pointycastle + url: "https://pub.dartlang.org" + source: hosted + version: "3.7.3" + pool: + dependency: transitive + description: + name: pool + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.1" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" + provider: + dependency: "direct main" + description: + name: provider + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.5" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.3" + qr: + dependency: transitive + description: + name: qr + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + qr_flutter: + dependency: "direct main" + description: + name: qr_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + rxdart: + dependency: "direct main" + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.27.7" + scoped_model: + dependency: "direct main" + description: + name: scoped_model + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + shared_preferences_aurora: + dependency: "direct main" + description: + path: "packages/shared_preferences/shared_preferences_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + shelf: + dependency: transitive + description: + name: shelf + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2" + source_helper: + dependency: transitive + description: + name: source_helper + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.3" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + sqflite: + dependency: "direct main" + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.8+4" + sqflite_aurora: + dependency: "direct main" + description: + path: "packages/sqflite/sqflite_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "2.2.6+aurora1" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.5+1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.12" + timezone: + dependency: transitive + description: + name: timezone + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.2" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + translator: + dependency: "direct main" + description: + name: translator + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.7" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.2" + universal_io: + dependency: "direct main" + description: + name: universal_io + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" + upower: + dependency: transitive + description: + name: upower + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.0" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.7" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + wakelock: + dependency: "direct main" + description: + name: wakelock + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2" + wakelock_aurora: + dependency: "direct main" + description: + path: "packages/wakelock/wakelock_aurora" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + wakelock_macos: + dependency: transitive + description: + name: wakelock_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_platform_interface: + dependency: transitive + description: + name: wakelock_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" + wakelock_web: + dependency: transitive + description: + name: wakelock_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.0" + wakelock_windows: + dependency: transitive + description: + name: wakelock_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.4" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + xdga_directories: + dependency: "direct main" + description: + path: "packages/xdga_directories" + ref: flutter_example_packages + resolved-ref: b2be3b38dcf55c327ebcfb5cb887993cb247dcff + url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" + source: git + version: "0.0.1" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" +sdks: + dart: ">=2.18.6 <3.0.0" + flutter: ">=3.3.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..5bf727a --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,175 @@ +# Copyright (c) 2023. Open Mobile Platform LLC. +# License: Proprietary. + +name: flutter_example_packages +description: Examples of the flutter plugins for Aurora OS. + +publish_to: "none" + +version: 1.0.0+1 + +environment: + sdk: ">=2.18.6 <3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + ## https://pub.dev/packages/cupertino_icons + cupertino_icons: ^1.0.5 + ## https://pub.dev/packages/google_fonts + google_fonts: ^4.0.4 + ## https://pub.dev/packages/scoped_model + scoped_model: ^2.0.0 + ## https://pub.dev/packages/get_it + get_it: ^7.6.0 + ## https://pub.dev/packages/intl + intl: ^0.17.0 + ## https://pub.dev/packages/universal_io + universal_io: ^2.2.0 + ## https://pub.dev/packages/crypto + crypto: ^3.0.2 + ## https://pub.dev/packages/cached_network_image + cached_network_image: ^3.2.3 + ## https://pub.dev/packages/flutter_cache_manager + flutter_cache_manager: ^3.3.0 + ## https://pub.dev/packages/photo_view + photo_view: ^0.14.0 + ## https://pub.dev/packages/path + path: ^1.8.2 + ## https://pub.dev/packages/dartz + dartz: ^0.10.1 + ## https://pub.dev/packages/provider + provider: ^6.0.5 + ## https://pub.dev/packages/equatable + equatable: ^2.0.5 + ## https://pub.dev/packages/qr_flutter + qr_flutter: ^4.0.0 + ## https://pub.dev/packages/rxdart + rxdart: ^0.27.7 + ## https://pub.dev/packages/translator + translator: ^0.1.7 + ## https://pub.dev/packages/flutter_markdown + flutter_markdown: ^0.6.15 + ## https://pub.dev/packages/freezed_annotation + freezed_annotation: ^2.2.0 + ## https://pub.dev/packages/json_annotation + json_annotation: ^4.8.0 + + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/xdga_directories + xdga_directories: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/xdga_directories + + ## https://pub.dev/packages/battery_plus + battery_plus: ^4.0.1 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/battery_plus/battery_plus_aurora + battery_plus_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/battery_plus/battery_plus_aurora + + ## https://pub.dev/packages/device_info_plus + device_info_plus: ^8.2.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/device_info_plus/device_info_plus_aurora + device_info_plus_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/device_info_plus/device_info_plus_aurora + + ## https://pub.dev/packages/flutter_local_notifications + flutter_local_notifications: ^14.1.1 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_local_notifications/flutter_local_notifications_aurora + flutter_local_notifications_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/flutter_local_notifications/flutter_local_notifications_aurora + + ## https://pub.dev/packages/flutter_secure_storage + flutter_secure_storage: ^8.0.0 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_secure_storage/flutter_secure_storage_aurora + flutter_secure_storage_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/flutter_secure_storage/flutter_secure_storage_aurora + + ## https://pub.dev/packages/package_info_plus + package_info_plus: 3.1.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/package_info_plus/package_info_plus_aurora + package_info_plus_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/package_info_plus/package_info_plus_aurora + + ## https://pub.dev/packages/path_provider + path_provider: ^2.0.15 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/path_provider/path_provider_aurora + path_provider_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/path_provider/path_provider_aurora + + ## https://pub.dev/packages/shared_preferences + shared_preferences: ^2.1.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/shared_preferences/shared_preferences_aurora + shared_preferences_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/shared_preferences/shared_preferences_aurora + + ## https://pub.dev/packages/wakelock + wakelock: ^0.6.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/wakelock/wakelock_aurora + wakelock_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/wakelock/wakelock_aurora + + ## https://pub.dev/packages/flutter_keyboard_visibility + flutter_keyboard_visibility: ^5.4.1 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora + flutter_keyboard_visibility_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora + + ## https://pub.dev/packages/sqflite + sqflite: ^2.2.6 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/sqflite/sqflite_aurora + sqflite_aurora: + git: + url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git + ref: flutter_example_packages + path: packages/sqflite/sqflite_aurora + +dev_dependencies: + flutter_test: + sdk: + flutter + ## https://pub.dev/packages/flutter_lints @todo + flutter_lints: ^2.0.0 + ## https://pub.dev/packages/build_runner + build_runner: ^2.3.3 + ## https://pub.dev/packages/freezed + freezed: ^2.3.3 + ## https://pub.dev/packages/json_serializable + json_serializable: ^6.6.1 + +flutter: + generate: true + uses-material-design: true + assets: + - assets/ + - assets/images/ diff --git a/packages/battery_plus/battery_plus_aurora/data/preview.png b/packages/battery_plus/battery_plus_aurora/data/preview.png deleted file mode 100644 index 924f871..0000000 Binary files a/packages/battery_plus/battery_plus_aurora/data/preview.png and /dev/null differ diff --git a/packages/battery_plus/battery_plus_aurora/example/.gitignore b/packages/battery_plus/battery_plus_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/battery_plus/battery_plus_aurora/example/README.md b/packages/battery_plus/battery_plus_aurora/example/README.md deleted file mode 100644 index 9110259..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# battery_plus_aurora_example - -Demonstrates how to use the battery_plus_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/battery_plus/battery_plus_aurora/example/analysis_options.yaml b/packages/battery_plus/battery_plus_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/CMakeLists.txt b/packages/battery_plus/battery_plus_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 048467b..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.battery_plus_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/desktop/com.example.battery_plus_aurora_example.desktop b/packages/battery_plus/battery_plus_aurora/example/aurora/desktop/com.example.battery_plus_aurora_example.desktop deleted file mode 100644 index a6aeb93..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/aurora/desktop/com.example.battery_plus_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=battery_plus_aurora_example -Comment=Demonstrates how to use the battery_plus_aurora plugin. -Icon=com.example.battery_plus_aurora_example -Exec=/usr/bin/com.example.battery_plus_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=battery_plus_aurora_example diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/108x108.png b/packages/battery_plus/battery_plus_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/128x128.png b/packages/battery_plus/battery_plus_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/172x172.png b/packages/battery_plus/battery_plus_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/86x86.png b/packages/battery_plus/battery_plus_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/battery_plus/battery_plus_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/battery_plus/battery_plus_aurora/example/aurora/rpm/com.example.battery_plus_aurora_example.spec b/packages/battery_plus/battery_plus_aurora/example/aurora/rpm/com.example.battery_plus_aurora_example.spec deleted file mode 100644 index a06d8f3..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/aurora/rpm/com.example.battery_plus_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.battery_plus_aurora_example -Summary: Demonstrates how to use the battery_plus_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/battery_plus/battery_plus_aurora/example/lib/main.dart b/packages/battery_plus/battery_plus_aurora/example/lib/main.dart deleted file mode 100644 index 4d6723f..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/lib/main.dart +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:battery_plus/battery_plus.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - final _battery = Battery(); - String? _error; - int? _batteryLevel; - String? _batteryState; - bool? _isInBatterySaveMode; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - try { - // Get current battery level - final batteryLevel = await _battery.batteryLevel; - // Get current battery state - final batteryState = await _battery.batteryState; - // Check is enable SaveMode - final isInBatterySaveMode = await _battery.isInBatterySaveMode; - - // Be informed when the state (full, charging, discharging) changes - _battery.onBatteryStateChanged.listen((BatteryState state) { - debugPrint(state.toString()); - }); - - setState(() { - _batteryLevel = batteryLevel; - _batteryState = batteryState.name; - _isInBatterySaveMode = isInBatterySaveMode; - }); - } on Exception catch (e) { - setState(() { - _error = e.toString(); - }); - } - } - - @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('Example battery_plus'), - ), - 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 battery_plus', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - const Text( - 'Battery Level', - style: textStyleTitle, - ), - spaceSmall, - Text( - "$_batteryLevel%", - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Battery State', - style: textStyleTitle, - ), - spaceSmall, - Text( - _batteryState.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Is In Battery SaveMode', - style: textStyleTitle, - ), - spaceSmall, - Text( - _isInBatterySaveMode.toString(), - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/packages/battery_plus/battery_plus_aurora/example/pubspec.lock b/packages/battery_plus/battery_plus_aurora/example/pubspec.lock deleted file mode 100644 index 0c1972b..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/pubspec.lock +++ /dev/null @@ -1,243 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - battery_plus: - dependency: "direct main" - description: - name: battery_plus - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.1" - battery_plus_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - battery_plus_platform_interface: - dependency: transitive - description: - name: battery_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.2" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - dbus: - dependency: transitive - description: - name: dbus - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.8" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - upower: - dependency: transitive - description: - name: upower - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.0" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.0" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/battery_plus/battery_plus_aurora/example/pubspec.yaml b/packages/battery_plus/battery_plus_aurora/example/pubspec.yaml deleted file mode 100644 index 42def81..0000000 --- a/packages/battery_plus/battery_plus_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: battery_plus_aurora_example -description: Demonstrates how to use the battery_plus_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - battery_plus: ^4.0.1 - battery_plus_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/battery_plus/battery_plus_aurora/lib/battery_plus_aurora.dart b/packages/battery_plus/battery_plus_aurora/lib/battery_plus_aurora.dart index 94040d0..4eaf451 100644 --- a/packages/battery_plus/battery_plus_aurora/lib/battery_plus_aurora.dart +++ b/packages/battery_plus/battery_plus_aurora/lib/battery_plus_aurora.dart @@ -6,16 +6,13 @@ import 'package:battery_plus_aurora/com_nokia_mce_request.dart'; import 'package:battery_plus_aurora/com_nokia_mce_signal.dart'; import 'package:dbus/dbus.dart'; import 'package:battery_plus_platform_interface/battery_plus_platform_interface.dart'; -import 'package:flutter/foundation.dart'; import 'dart:async' show Stream; import 'package:async/async.dart' show StreamGroup; class BatteryPlusAurora extends BatteryPlatform { /// Register this dart class as the platform implementation for aurora static void registerWith() { - if (TargetPlatform.aurora == defaultTargetPlatform) { - BatteryPlatform.instance = BatteryPlusAurora(); - } + BatteryPlatform.instance = BatteryPlusAurora(); } /// Returns the current battery level in percent. diff --git a/packages/battery_plus/battery_plus_aurora/pubspec.yaml b/packages/battery_plus/battery_plus_aurora/pubspec.yaml index 87fb4e2..5759bc0 100644 --- a/packages/battery_plus/battery_plus_aurora/pubspec.yaml +++ b/packages/battery_plus/battery_plus_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: diff --git a/packages/device_info_plus/device_info_plus_aurora/README.md b/packages/device_info_plus/device_info_plus_aurora/README.md index b85db91..7df523e 100644 --- a/packages/device_info_plus/device_info_plus_aurora/README.md +++ b/packages/device_info_plus/device_info_plus_aurora/README.md @@ -37,7 +37,7 @@ Therefore, you have to include `device_info_plus_aurora` alongside `device_info_ ```yaml dependencies: - device_info_plus: ^9.0.1 + device_info_plus: ^8.2.2 device_info_plus_aurora: path: # path to folder with plugin ``` diff --git a/packages/device_info_plus/device_info_plus_aurora/data/preview.png b/packages/device_info_plus/device_info_plus_aurora/data/preview.png deleted file mode 100644 index b7d356e..0000000 Binary files a/packages/device_info_plus/device_info_plus_aurora/data/preview.png and /dev/null differ diff --git a/packages/device_info_plus/device_info_plus_aurora/example/README.md b/packages/device_info_plus/device_info_plus_aurora/example/README.md deleted file mode 100644 index ae0d7d1..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# device_info_plus_aurora - -Demonstrates how to use the device_info_plus plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/device_info_plus/device_info_plus_aurora/example/analysis_options.yaml b/packages/device_info_plus/device_info_plus_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/.gitignore b/packages/device_info_plus/device_info_plus_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/CMakeLists.txt b/packages/device_info_plus/device_info_plus_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index ef6d32e..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.device_info_plus_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/desktop/com.example.device_info_plus_aurora_example.desktop b/packages/device_info_plus/device_info_plus_aurora/example/aurora/desktop/com.example.device_info_plus_aurora_example.desktop deleted file mode 100644 index 88c8b51..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/aurora/desktop/com.example.device_info_plus_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=device_info_plus_aurora_example -Comment=Demonstrates how to use the device_info_plus_aurora plugin. -Icon=com.example.device_info_plus_aurora_example -Exec=/usr/bin/com.example.device_info_plus_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions=DeviceInfo -OrganizationName=com.example -ApplicationName=device_info_plus_aurora_example diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/108x108.png b/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/128x128.png b/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/172x172.png b/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/86x86.png b/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/device_info_plus/device_info_plus_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/main.cpp b/packages/device_info_plus/device_info_plus_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/device_info_plus/device_info_plus_aurora/example/aurora/rpm/com.example.device_info_plus_aurora_example.spec b/packages/device_info_plus/device_info_plus_aurora/example/aurora/rpm/com.example.device_info_plus_aurora_example.spec deleted file mode 100644 index 8706033..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/aurora/rpm/com.example.device_info_plus_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.device_info_plus_aurora_example -Summary: Demonstrates how to use the device_info_plus_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/device_info_plus/device_info_plus_aurora/example/lib/main.dart b/packages/device_info_plus/device_info_plus_aurora/example/lib/main.dart deleted file mode 100644 index 26c9b63..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/lib/main.dart +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:device_info_plus_aurora/aurora_device_info.dart'; -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:device_info_plus/device_info_plus.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - String? _error; - String? _id; - String? _name; - String? _version; - String? _prettyName; - bool? _hasGNSS; - bool? _hasNFC; - bool? _hasBluetooth; - bool? _hasWlan; - int? _maxCpuClockSpeed; - int? _numberCpuCores; - int? _batteryChargePercentage; - double? _mainCameraResolution; - double? _frontalCameraResolution; - int? _ramTotalSize; - int? _ramFreeSize; - String? _screenResolution; - String? _osVersion; - String? _deviceModel; - Map? _externalStorage; - Map? _internalStorage; - List>? _simCards; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - final deviceInfoPlugin = DeviceInfoPlugin(); - - try { - final deviceInfo = await deviceInfoPlugin.linuxInfo as AuroraDeviceInfo; - setState(() { - _id = deviceInfo.id; - _name = deviceInfo.name; - _version = deviceInfo.version; - _prettyName = deviceInfo.prettyName; - _hasGNSS = deviceInfo.hasGNSS; - _hasNFC = deviceInfo.hasNFC; - _hasBluetooth = deviceInfo.hasBluetooth; - _hasWlan = deviceInfo.hasWlan; - _maxCpuClockSpeed = deviceInfo.maxCpuClockSpeed; - _numberCpuCores = deviceInfo.numberCpuCores; - _batteryChargePercentage = deviceInfo.batteryChargePercentage; - _mainCameraResolution = deviceInfo.mainCameraResolution; - _frontalCameraResolution = deviceInfo.frontalCameraResolution; - _ramTotalSize = deviceInfo.ramTotalSize; - _ramFreeSize = deviceInfo.ramFreeSize; - _screenResolution = deviceInfo.screenResolution; - _osVersion = deviceInfo.osVersion; - _deviceModel = deviceInfo.deviceModel; - _externalStorage = deviceInfo.externalStorage; - _internalStorage = deviceInfo.internalStorage; - _simCards = deviceInfo.simCards; - }); - } on Exception catch (e) { - setState(() { - _error = e.toString(); - }); - } - } - - @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('Example device_info_plus'), - ), - 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 device_info_plus', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - const Text( - 'ID', - style: textStyleTitle, - ), - spaceSmall, - Text( - _id.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Name', - style: textStyleTitle, - ), - spaceSmall, - Text( - _name.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Version', - style: textStyleTitle, - ), - spaceSmall, - Text( - _version.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Pretty Name', - style: textStyleTitle, - ), - spaceSmall, - Text( - _prettyName.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Has GNSS', - style: textStyleTitle, - ), - spaceSmall, - Text( - _hasGNSS.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Has NFC', - style: textStyleTitle, - ), - spaceSmall, - Text( - _hasNFC.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Has Bluetooth', - style: textStyleTitle, - ), - spaceSmall, - Text( - _hasBluetooth.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Has Wlan', - style: textStyleTitle, - ), - spaceSmall, - Text( - _hasWlan.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Max Cpu Clock Speed', - style: textStyleTitle, - ), - spaceSmall, - Text( - _maxCpuClockSpeed.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Number Cpu Cores', - style: textStyleTitle, - ), - spaceSmall, - Text( - _numberCpuCores.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Battery Charge Percentage', - style: textStyleTitle, - ), - spaceSmall, - Text( - _batteryChargePercentage.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Main Camera Resolution', - style: textStyleTitle, - ), - spaceSmall, - Text( - _mainCameraResolution.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Frontal Camera Resolution', - style: textStyleTitle, - ), - spaceSmall, - Text( - _frontalCameraResolution.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Ram Total Size', - style: textStyleTitle, - ), - spaceSmall, - Text( - _ramTotalSize.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Ram Free Size', - style: textStyleTitle, - ), - spaceSmall, - Text( - _ramFreeSize.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Screen Resolution', - style: textStyleTitle, - ), - spaceSmall, - Text( - _screenResolution.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'OS Version', - style: textStyleTitle, - ), - spaceSmall, - Text( - _osVersion.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Device Model', - style: textStyleTitle, - ), - spaceSmall, - Text( - _deviceModel.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'External Storage Info', - style: textStyleTitle, - ), - spaceSmall, - Text( - _externalStorage.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Internal Storage Info', - style: textStyleTitle, - ), - spaceSmall, - Text( - _internalStorage.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'SIM Cards Info', - style: textStyleTitle, - ), - spaceSmall, - Text( - _simCards.toString(), - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/packages/device_info_plus/device_info_plus_aurora/example/pubspec.lock b/packages/device_info_plus/device_info_plus_aurora/example/pubspec.lock deleted file mode 100644 index 98de599..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/pubspec.lock +++ /dev/null @@ -1,257 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - dbus: - dependency: transitive - description: - name: dbus - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.8" - device_info_plus: - dependency: "direct main" - description: - name: device_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "9.0.2" - device_info_plus_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "7.0.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.4" - win32_registry: - dependency: transitive - description: - name: win32_registry - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.0" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/device_info_plus/device_info_plus_aurora/example/pubspec.yaml b/packages/device_info_plus/device_info_plus_aurora/example/pubspec.yaml deleted file mode 100644 index 4ccd339..0000000 --- a/packages/device_info_plus/device_info_plus_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: device_info_plus_aurora_example -description: Demonstrates how to use the device_info_plus_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - device_info_plus: ^9.0.1 - device_info_plus_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/device_info_plus/device_info_plus_aurora/lib/device_info_plus_aurora.dart b/packages/device_info_plus/device_info_plus_aurora/lib/device_info_plus_aurora.dart index df96320..1324047 100644 --- a/packages/device_info_plus/device_info_plus_aurora/lib/device_info_plus_aurora.dart +++ b/packages/device_info_plus/device_info_plus_aurora/lib/device_info_plus_aurora.dart @@ -8,17 +8,12 @@ import 'package:device_info_plus_aurora/ru_omp_deviceinfo_features.dart'; import 'package:device_info_plus_aurora/ru_omp_deviceinfo_sim.dart'; import 'package:device_info_plus_aurora/ru_omp_deviceinfo_storages.dart'; import 'package:device_info_plus_platform_interface/device_info_plus_platform_interface.dart'; -import 'package:flutter/foundation.dart'; import 'aurora_device_info.dart'; class DeviceInfoPlusAurora extends DeviceInfoPlatform { /// Register this dart class as the platform implementation for aurora static void registerWith() { - if (TargetPlatform.aurora == defaultTargetPlatform) { - DeviceInfoPlatform.instance = DeviceInfoPlusAurora(); - } else { - DeviceInfoPlatform.instance = DeviceInfoPlusLinuxPlugin(); - } + DeviceInfoPlatform.instance = DeviceInfoPlusAurora(); } @override diff --git a/packages/device_info_plus/device_info_plus_aurora/pubspec.yaml b/packages/device_info_plus/device_info_plus_aurora/pubspec.yaml index 7953d23..6944e40 100644 --- a/packages/device_info_plus/device_info_plus_aurora/pubspec.yaml +++ b/packages/device_info_plus/device_info_plus_aurora/pubspec.yaml @@ -7,13 +7,13 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: sdk: flutter dbus: ^0.7.8 - device_info_plus: ^9.0.1 + device_info_plus: ^8.2.2 plugin_platform_interface: ^2.0.2 device_info_plus_platform_interface: ^7.0.0 diff --git a/packages/sqflite/sqflite_aurora/example/.gitignore b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.gitignore similarity index 56% rename from packages/sqflite/sqflite_aurora/example/.gitignore rename to packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.gitignore index f432907..96486fd 100644 --- a/packages/sqflite/sqflite_aurora/example/.gitignore +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.gitignore @@ -22,27 +22,9 @@ migrate_working_dir/ #.vscode/ # Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock **/doc/api/ -**/ios/Flutter/.last_build_id .dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies .packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/pubspec.lock -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter +build/ diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.metadata b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.metadata new file mode 100644 index 0000000..641645c --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 135454af32477f815a7525073027a3ff9eff1bfd + channel: aurora + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + - platform: aurora + create_revision: 135454af32477f815a7525073027a3ff9eff1bfd + base_revision: 135454af32477f815a7525073027a3ff9eff1bfd + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/c_cpp_properties.json b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..13d0b90 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/c_cpp_properties.json @@ -0,0 +1,22 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/lib", + "/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include", + "/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include/flutter-embedder", + "/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include/flutter-embedder/flutter" + ], + "defines": [ + "__ARM_PCS_VFP" + ], + "compilerPath": "/usr/bin/g++", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/settings.json b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/settings.json new file mode 100644 index 0000000..d9db8dd --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/.vscode/settings.json @@ -0,0 +1,60 @@ +{ + "files.associations": { + "variant": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "random": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "typeinfo": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "ctime": "cpp", + "ratio": "cpp", + "iomanip": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stop_token": "cpp", + "thread": "cpp" + } +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/README.md b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/README.md new file mode 100644 index 0000000..39405a2 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/README.md @@ -0,0 +1,45 @@ +# flutter_keyboard_visibility_aurora + +The Aurora implementation of [flutter_keyboard_visibility](https://pub.dev/packages/flutter_keyboard_visibility). + +## Usage +This package is not an _endorsed_ implementation of `flutter_keyboard_visibility`. +Therefore, you have to include `flutter_local_notifications_aurora` alongside `flutter_keyboard_visibility` as dependencies in your `pubspec.yaml` file. + +**pubspec.yaml** + +```yaml +dependencies: + flutter_keyboard_visibility: 5.4.1 + flutter_keyboard_visibility_aurora: + path: # path to folder with plugin +``` + +***.dart** + +```dart +/// Default plugin component +final _controller = KeyboardVisibilityController(); + +/// Custom platform component with keyboard height +final _controllerAurora = FlutterKeyboardVisibilityAurora(); + +/// Stream change visibility +Stream onChangeKeyboard() async* { + yield _controller.isVisible; + + await for (final state in _controller.onChange) { + yield state; + } +} + +/// Stream change height +Stream onChangeKeyboardHeight() async* { + yield await _controllerAurora.height; + + await for (final state in _controllerAurora.onChangeHeight) { + yield state; + } +} +``` + diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/analysis_options.yaml b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/CMakeLists.txt b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/CMakeLists.txt new file mode 100644 index 0000000..00df708 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) + +set(PROJECT_NAME flutter_keyboard_visibility_aurora) +set(PLUGIN_NAME flutter_keyboard_visibility_aurora_platform_plugin) + +project(${PROJECT_NAME} LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi") +set(CMAKE_CXX_FLAGS_RELEASE "-O3") + +find_package(PkgConfig REQUIRED) +pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) + +add_library(${PLUGIN_NAME} SHARED flutter_keyboard_visibility_aurora_plugin.cpp) + +set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) +target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) + +target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/flutter_keyboard_visibility_aurora_plugin.cpp b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/flutter_keyboard_visibility_aurora_plugin.cpp new file mode 100644 index 0000000..f95a4a8 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/flutter_keyboard_visibility_aurora_plugin.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include + +FlutterKeyboardVisibilityAuroraPlugin::FlutterKeyboardVisibilityAuroraPlugin() +{ + PlatformEvents::SubscribeKeyboardVisibilityChanged( + [this](bool state) + { + if (this->m_sendEventVisibility) + { + EventChannel("flutter_keyboard_visibility_aurora_state", MethodCodecType::Standard) + .SendEvent(state); + } + + if (this->m_sendEventHeight) + { + EventChannel("flutter_keyboard_visibility_aurora_height", MethodCodecType::Standard) + .SendEvent(PlatformMethods::GetKeyboardHeight()); + } + }); +} + +void FlutterKeyboardVisibilityAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) +{ + registrar.RegisterMethodChannel("flutter_keyboard_visibility_aurora", + MethodCodecType::Standard, + [this](const MethodCall &call) + { this->onMethodCall(call); }); + + registrar.RegisterEventChannel( + "flutter_keyboard_visibility_aurora_state", + MethodCodecType::Standard, + [this](const Encodable &) + { + this->m_sendEventVisibility = true; + return EventResponse(); + }, + [this](const Encodable &) + { + this->m_sendEventVisibility = false; + return EventResponse(); + }); + + registrar.RegisterEventChannel( + "flutter_keyboard_visibility_aurora_height", + MethodCodecType::Standard, + [this](const Encodable &) + { + this->m_sendEventHeight = true; + return EventResponse(); + }, + [this](const Encodable &) + { + this->m_sendEventHeight = false; + return EventResponse(); + }); +} + +void FlutterKeyboardVisibilityAuroraPlugin::onMethodCall(const MethodCall &call) +{ + const auto &method = call.GetMethod(); + + if (method == "getKeyboardHeight") + { + onGetKeyboardHeight(call); + return; + } + + unimplemented(call); +} + +void FlutterKeyboardVisibilityAuroraPlugin::onGetKeyboardHeight(const MethodCall &call) +{ + call.SendSuccessResponse(PlatformMethods::GetKeyboardHeight()); +} + +void FlutterKeyboardVisibilityAuroraPlugin::unimplemented(const MethodCall &call) +{ + call.SendSuccessResponse(nullptr); +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora_plugin.h b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora_plugin.h new file mode 100644 index 0000000..980fa93 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora_plugin.h @@ -0,0 +1,22 @@ +#ifndef FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H +#define FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H + +#include +#include + +class PLUGIN_EXPORT FlutterKeyboardVisibilityAuroraPlugin final : public PluginInterface +{ +public: + FlutterKeyboardVisibilityAuroraPlugin(); + void RegisterWithRegistrar(PluginRegistrar ®istrar) override; + +private: + bool m_sendEventVisibility = false; + bool m_sendEventHeight = false; + + void onMethodCall(const MethodCall &call); + void onGetKeyboardHeight(const MethodCall &call); + void unimplemented(const MethodCall &call); +}; + +#endif /* FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H */ diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/globals.h b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/globals.h new file mode 100644 index 0000000..69bb59e --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/aurora/include/flutter_keyboard_visibility_aurora/globals.h @@ -0,0 +1,10 @@ +#ifndef FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H +#define FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H + +#ifdef PLUGIN_IMPL +#define PLUGIN_EXPORT __attribute__((visibility("default"))) +#else +#define PLUGIN_EXPORT +#endif + +#endif /* FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H */ diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora.dart b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora.dart new file mode 100644 index 0000000..c3522c2 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora.dart @@ -0,0 +1,26 @@ +import 'package:flutter_keyboard_visibility_platform_interface/flutter_keyboard_visibility_platform_interface.dart'; + +import 'flutter_keyboard_visibility_aurora_platform_interface.dart'; + +class FlutterKeyboardVisibilityAurora + extends FlutterKeyboardVisibilityPlatform { + /// Factory method that initializes the FlutterKeyboardVisibility plugin + /// platform with an instance of the plugin for Aurora OS. + static void registerWith() { + FlutterKeyboardVisibilityPlatform.instance = + FlutterKeyboardVisibilityAurora(); + } + + /// Emits changes to keyboard visibility from the platform. + @override + Stream get onChange => + FlutterKeyboardVisibilityAuroraPlatform.instance.onChangeVisibility(); + + /// Emits changes to keyboard height from the platform. + Stream get onChangeHeight => + FlutterKeyboardVisibilityAuroraPlatform.instance.onChangeHeight(); + + /// Get keyboard height. + Future get height => + FlutterKeyboardVisibilityAuroraPlatform.instance.getKeyboardHeight(); +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_method_channel.dart b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_method_channel.dart new file mode 100644 index 0000000..ac1d10b --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_method_channel.dart @@ -0,0 +1,33 @@ +import 'package:flutter/services.dart'; + +import 'flutter_keyboard_visibility_aurora_platform_interface.dart'; + +/// An implementation of [FlutterKeyboardVisibilityAuroraPlatform] that uses method channels. +class MethodChannelFlutterKeyboardVisibilityAurora + extends FlutterKeyboardVisibilityAuroraPlatform { + final methodChannel = + const MethodChannel('flutter_keyboard_visibility_aurora'); + + @override + Future getKeyboardHeight() async { + return await methodChannel.invokeMethod('getKeyboardHeight') ?? 0.0; + } + + @override + Stream onChangeVisibility() async* { + await for (final event + in const EventChannel('flutter_keyboard_visibility_aurora_state') + .receiveBroadcastStream()) { + yield event == true; + } + } + + @override + Stream onChangeHeight() async* { + await for (final event + in const EventChannel('flutter_keyboard_visibility_aurora_height') + .receiveBroadcastStream()) { + yield event as double; + } + } +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_platform_interface.dart b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_platform_interface.dart new file mode 100644 index 0000000..1cb5199 --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/lib/flutter_keyboard_visibility_aurora_platform_interface.dart @@ -0,0 +1,39 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'flutter_keyboard_visibility_aurora_method_channel.dart'; + +abstract class FlutterKeyboardVisibilityAuroraPlatform + extends PlatformInterface { + /// Constructs a FlutterKeyboardVisibilityAuroraPlatform. + FlutterKeyboardVisibilityAuroraPlatform() : super(token: _token); + + static final Object _token = Object(); + + static FlutterKeyboardVisibilityAuroraPlatform _instance = + MethodChannelFlutterKeyboardVisibilityAurora(); + + /// The default instance of [FlutterKeyboardVisibilityAuroraPlatform] to use. + /// + /// Defaults to [MethodChannelFlutterKeyboardVisibilityAurora]. + static FlutterKeyboardVisibilityAuroraPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [FlutterKeyboardVisibilityAuroraPlatform] when + /// they register themselves. + static set instance(FlutterKeyboardVisibilityAuroraPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getKeyboardHeight() { + throw UnimplementedError('getKeyboardHeight() has not been implemented.'); + } + + Stream onChangeVisibility() { + throw UnimplementedError('onChangeVisibility() has not been implemented.'); + } + + Stream onChangeHeight() { + throw UnimplementedError('onChangeHeight() has not been implemented.'); + } +} diff --git a/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/pubspec.yaml b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/pubspec.yaml new file mode 100644 index 0000000..c472a3c --- /dev/null +++ b/packages/flutter_keyboard_visibility/flutter_keyboard_visibility_aurora/pubspec.yaml @@ -0,0 +1,25 @@ +name: flutter_keyboard_visibility_aurora +description: A new Flutter plugin project. +version: 0.0.1 + +environment: + sdk: '>=2.18.6 <3.0.0' + flutter: ">=3.0.0" + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + flutter_keyboard_visibility_platform_interface: ^2.0.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +flutter: + plugin: + platforms: + aurora: + dartPluginClass: FlutterKeyboardVisibilityAurora + pluginClass: FlutterKeyboardVisibilityAuroraPlugin diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/data/preview.gif b/packages/flutter_local_notifications/flutter_local_notifications_aurora/data/preview.gif deleted file mode 100644 index f2975bf..0000000 Binary files a/packages/flutter_local_notifications/flutter_local_notifications_aurora/data/preview.gif and /dev/null differ diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/.gitignore b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/README.md b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/README.md deleted file mode 100644 index e1c48db..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# flutter_local_notifications_aurora_example - -Demonstrates how to use the flutter_local_notifications_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.gif) diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/analysis_options.yaml b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/.gitignore b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/CMakeLists.txt b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 786144b..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.flutter_local_notifications_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/desktop/com.example.flutter_local_notifications_aurora_example.desktop b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/desktop/com.example.flutter_local_notifications_aurora_example.desktop deleted file mode 100644 index d2a6a7e..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/desktop/com.example.flutter_local_notifications_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Flutter Notification -Comment=Demonstrates how to use the flutter_local_notifications_aurora plugin. -Icon=com.example.flutter_local_notifications_aurora_example -Exec=/usr/bin/com.example.flutter_local_notifications_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=flutter_local_notifications_aurora_example diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/108x108.png b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/128x128.png b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/172x172.png b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/86x86.png b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/main.cpp b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/rpm/com.example.flutter_local_notifications_aurora_example.spec b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/rpm/com.example.flutter_local_notifications_aurora_example.spec deleted file mode 100644 index 640103e..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/aurora/rpm/com.example.flutter_local_notifications_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.flutter_local_notifications_aurora_example -Summary: Demonstrates how to use the flutter_local_notifications_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/lib/main.dart b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/lib/main.dart deleted file mode 100644 index c7f8d84..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/lib/main.dart +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - final notificationID = 1; - final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = - FlutterLocalNotificationsPlugin(); - - @override - void initState() { - super.initState(); - } - - Future _showNotification() async { - await flutterLocalNotificationsPlugin.show( - notificationID, - "Title notification", - "My long body text notification", - null, - ); - } - - Future _cancelNotification() async { - await flutterLocalNotificationsPlugin.cancel(notificationID); - } - - @override - Widget build(BuildContext context) { - const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); - const spaceMedium = SizedBox(height: 20); - - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Example flutter_local_notifications'), - ), - body: 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 flutter_local_notifications', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - ElevatedButton( - onPressed: _showNotification, - child: const Text('Show notification'), - ), - - spaceMedium, - - ElevatedButton( - onPressed: _cancelNotification, - child: const Text('Cancel notification'), - ) - ], - ), - ), - ), - ), - ), - ); - } -} diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.lock b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.lock deleted file mode 100644 index 55b2525..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.lock +++ /dev/null @@ -1,329 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - dbus: - dependency: transitive - description: - name: dbus - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.8" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_local_notifications: - dependency: "direct main" - description: - name: flutter_local_notifications - url: "https://pub.dartlang.org" - source: hosted - version: "14.1.1" - flutter_local_notifications_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - flutter_local_notifications_linux: - dependency: transitive - description: - name: flutter_local_notifications_linux - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0+1" - flutter_local_notifications_platform_interface: - dependency: transitive - description: - name: flutter_local_notifications_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "7.0.0+1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.5" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - package_info_plus_aurora: - dependency: transitive - description: - path: "packages/package_info_plus/package_info_plus_aurora" - ref: dev - resolved-ref: "7120c2554963ce9e7600730b2657b387d3a86d9c" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.0" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - timezone: - dependency: transitive - description: - name: timezone - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.2" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.4" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.0" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.yaml b/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.yaml deleted file mode 100644 index 0dd0b40..0000000 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: flutter_local_notifications_aurora_example -description: Demonstrates how to use the flutter_local_notifications_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - flutter_local_notifications: ^14.0.0+2 - flutter_local_notifications_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/flutter_local_notifications/flutter_local_notifications_aurora/pubspec.yaml b/packages/flutter_local_notifications/flutter_local_notifications_aurora/pubspec.yaml index 3508107..318b97c 100644 --- a/packages/flutter_local_notifications/flutter_local_notifications_aurora/pubspec.yaml +++ b/packages/flutter_local_notifications/flutter_local_notifications_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: @@ -15,11 +15,13 @@ dependencies: dbus: ^0.7.8 plugin_platform_interface: ^2.0.2 flutter_local_notifications_platform_interface: ^7.0.0 - package_info_plus: ^4.0.0 + ## https://pub.dev/packages/package_info_plus + package_info_plus: 3.1.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/package_info_plus/package_info_plus_aurora package_info_plus_aurora: git: url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git - ref: dev + ref: flutter_example_packages path: packages/package_info_plus/package_info_plus_aurora dev_dependencies: diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/data/preview.png b/packages/flutter_secure_storage/flutter_secure_storage_aurora/data/preview.png deleted file mode 100644 index 5108a25..0000000 Binary files a/packages/flutter_secure_storage/flutter_secure_storage_aurora/data/preview.png and /dev/null differ diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/.gitignore b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/README.md b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/README.md deleted file mode 100644 index 2e79332..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# flutter_secure_storage_aurora_example - -Demonstrates how to use the flutter_secure_storage_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/analysis_options.yaml b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/.gitignore b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/CMakeLists.txt b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 44c0ad2..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.flutter_secure_storage_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/desktop/com.example.flutter_secure_storage_aurora_example.desktop b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/desktop/com.example.flutter_secure_storage_aurora_example.desktop deleted file mode 100644 index 6441560..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/desktop/com.example.flutter_secure_storage_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=flutter_secure_storage_aurora_example -Comment=Demonstrates how to use the flutter_secure_storage_aurora plugin. -Icon=com.example.flutter_secure_storage_aurora_example -Exec=/usr/bin/com.example.flutter_secure_storage_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=flutter_secure_storage_aurora_example diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/108x108.png b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/128x128.png b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/172x172.png b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/86x86.png b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/main.cpp b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/rpm/com.example.flutter_secure_storage_aurora_example.spec b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/rpm/com.example.flutter_secure_storage_aurora_example.spec deleted file mode 100644 index 278fb13..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/aurora/rpm/com.example.flutter_secure_storage_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.flutter_secure_storage_aurora_example -Summary: Demonstrates how to use the flutter_secure_storage_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/lib/main.dart b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/lib/main.dart deleted file mode 100644 index fb7cf59..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/lib/main.dart +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:flutter_secure_storage_aurora/flutter_secure_storage_aurora.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - final _flutterSecureStorage = const FlutterSecureStorage(); - String? _error; - String? _data; - String? _all; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - Future initPlatformState() async { - try { - // https://pub.dev/packages/encrypt - // Encrypter(AES(key)) - // secure-random --length 16 --base 16 - // You can generate a secret key based on user data, as an example of a hash pincode - FlutterSecureStorageAurora.setSecret('5872747ed1ceda363808efb8b2b18b20'); - - const key = 'my_key'; - const data = 'Something secret'; - - // Write value - await _flutterSecureStorage.write(key: key, value: data); - - // Read value - String? value = await _flutterSecureStorage.read(key: key); - - // Read all values - Map allValues = await _flutterSecureStorage.readAll(); - - setState(() { - _data = value; - _all = allValues.toString(); - }); - } on Exception catch (e) { - setState(() { - _error = e.toString(); - }); - } - } - - @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('Example flutter_secure_storage'), - ), - 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 flutter_secure_storage', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - const Text( - 'After write/read secret data', - style: textStyleTitle, - ), - spaceSmall, - Text( - _data.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'All data', - style: textStyleTitle, - ), - spaceSmall, - Text( - _all.toString(), - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.lock b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.lock deleted file mode 100644 index dc902b2..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.lock +++ /dev/null @@ -1,380 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - asn1lib: - dependency: transitive - description: - name: asn1lib - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.0" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.2" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - encrypt: - dependency: transitive - description: - name: encrypt - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.1" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_secure_storage: - dependency: "direct main" - description: - name: flutter_secure_storage - url: "https://pub.dartlang.org" - source: hosted - version: "8.0.0" - flutter_secure_storage_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - flutter_secure_storage_linux: - dependency: transitive - description: - name: flutter_secure_storage_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.3" - flutter_secure_storage_macos: - dependency: transitive - description: - name: flutter_secure_storage_macos - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - flutter_secure_storage_platform_interface: - dependency: transitive - description: - name: flutter_secure_storage_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - flutter_secure_storage_web: - dependency: transitive - description: - name: flutter_secure_storage_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - flutter_secure_storage_windows: - dependency: transitive - description: - name: flutter_secure_storage_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - path_provider: - dependency: transitive - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.15" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.27" - path_provider_aurora: - dependency: transitive - description: - path: "packages/path_provider/path_provider_aurora" - ref: dev - resolved-ref: "7120c2554963ce9e7600730b2657b387d3a86d9c" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" - path_provider_foundation: - dependency: transitive - description: - name: path_provider_foundation - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.3" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.11" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.7" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - pointycastle: - dependency: transitive - description: - name: pointycastle - url: "https://pub.dartlang.org" - source: hosted - version: "3.7.3" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "2.6.1" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - xdga_directories: - dependency: transitive - description: - path: "packages/xdga_directories" - ref: dev - resolved-ref: "7120c2554963ce9e7600730b2657b387d3a86d9c" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.yaml b/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.yaml deleted file mode 100644 index 50e5e47..0000000 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: flutter_secure_storage_aurora_example -description: Demonstrates how to use the flutter_secure_storage_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - flutter_secure_storage: ^8.0.0 - flutter_secure_storage_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/lib/flutter_secure_storage_aurora.dart b/packages/flutter_secure_storage/flutter_secure_storage_aurora/lib/flutter_secure_storage_aurora.dart index e7e4f29..a56ce05 100644 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/lib/flutter_secure_storage_aurora.dart +++ b/packages/flutter_secure_storage/flutter_secure_storage_aurora/lib/flutter_secure_storage_aurora.dart @@ -3,7 +3,6 @@ * License: Proprietary. */ import 'package:flutter_secure_storage_platform_interface/flutter_secure_storage_platform_interface.dart'; -import 'package:flutter/foundation.dart'; import 'package:path_provider_aurora/path_provider_aurora.dart'; import 'null_secret_exception.dart'; import 'flutter_secure_storage_aurora_api.dart'; @@ -23,11 +22,8 @@ class FlutterSecureStorageAurora extends FlutterSecureStoragePlatform { ); } - static void registerWith() async { - if (TargetPlatform.aurora == defaultTargetPlatform) { - PathProviderAurora.registerWith(); - FlutterSecureStoragePlatform.instance = FlutterSecureStorageAurora(); - } + static void registerWith() { + FlutterSecureStoragePlatform.instance = FlutterSecureStorageAurora(); } static FlutterSecureStorageAuroraApi _getAPI() { diff --git a/packages/flutter_secure_storage/flutter_secure_storage_aurora/pubspec.yaml b/packages/flutter_secure_storage/flutter_secure_storage_aurora/pubspec.yaml index a6bebce..7c8a38b 100644 --- a/packages/flutter_secure_storage/flutter_secure_storage_aurora/pubspec.yaml +++ b/packages/flutter_secure_storage/flutter_secure_storage_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: @@ -16,11 +16,13 @@ dependencies: plugin_platform_interface: ^2.0.2 flutter_secure_storage_platform_interface: ^1.0.1 path: ^1.8.2 - path_provider: ^2.0.14 + ## https://pub.dev/packages/path_provider + path_provider: ^2.0.15 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/path_provider/path_provider_aurora path_provider_aurora: git: url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git - ref: dev + ref: flutter_example_packages path: packages/path_provider/path_provider_aurora dev_dependencies: diff --git a/packages/package_info_plus/package_info_plus_aurora/README.md b/packages/package_info_plus/package_info_plus_aurora/README.md index c4f2f56..6da57d6 100644 --- a/packages/package_info_plus/package_info_plus_aurora/README.md +++ b/packages/package_info_plus/package_info_plus_aurora/README.md @@ -11,7 +11,7 @@ Therefore, you have to include `package_info_plus_aurora` alongside `package_inf ```yaml dependencies: - package_info_plus: 4.0.0 + package_info_plus: 3.1.2 package_info_plus_aurora: path: # path to folder with plugin ``` diff --git a/packages/package_info_plus/package_info_plus_aurora/aurora/package_info_plus_aurora_plugin.cpp b/packages/package_info_plus/package_info_plus_aurora/aurora/package_info_plus_aurora_plugin.cpp index 4d8a580..1aba0d2 100644 --- a/packages/package_info_plus/package_info_plus_aurora/aurora/package_info_plus_aurora_plugin.cpp +++ b/packages/package_info_plus/package_info_plus_aurora/aurora/package_info_plus_aurora_plugin.cpp @@ -4,7 +4,7 @@ */ #include #include -#include +#include #include void PackageInfoPlusAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) @@ -33,12 +33,12 @@ void PackageInfoPlusAuroraPlugin::onMethodCall(const MethodCall &call) void PackageInfoPlusAuroraPlugin::onGetApplicationOrg(const MethodCall &call) { - call.SendSuccessResponse(Application::GetID().orgname); + call.SendSuccessResponse(PlatformMethods::GetOrgname()); } void PackageInfoPlusAuroraPlugin::onGetApplicationName(const MethodCall &call) { - call.SendSuccessResponse(Application::GetID().appname); + call.SendSuccessResponse(PlatformMethods::GetAppname()); } void PackageInfoPlusAuroraPlugin::unimplemented(const MethodCall &call) diff --git a/packages/package_info_plus/package_info_plus_aurora/data/preview.png b/packages/package_info_plus/package_info_plus_aurora/data/preview.png deleted file mode 100644 index e70f4b1..0000000 Binary files a/packages/package_info_plus/package_info_plus_aurora/data/preview.png and /dev/null differ diff --git a/packages/package_info_plus/package_info_plus_aurora/example/.gitignore b/packages/package_info_plus/package_info_plus_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/package_info_plus/package_info_plus_aurora/example/README.md b/packages/package_info_plus/package_info_plus_aurora/example/README.md deleted file mode 100644 index c7ef8e1..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# package_info_plus_aurora_example - -Demonstrates how to use the package_info_plus_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/package_info_plus/package_info_plus_aurora/example/analysis_options.yaml b/packages/package_info_plus/package_info_plus_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/.gitignore b/packages/package_info_plus/package_info_plus_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/CMakeLists.txt b/packages/package_info_plus/package_info_plus_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index c75fffe..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.package_info_plus_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/desktop/com.example.package_info_plus_aurora_example.desktop b/packages/package_info_plus/package_info_plus_aurora/example/aurora/desktop/com.example.package_info_plus_aurora_example.desktop deleted file mode 100644 index 1e01856..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/aurora/desktop/com.example.package_info_plus_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Example Info Plus -Comment=Demonstrates how to use the package_info_plus_aurora plugin. -Icon=com.example.package_info_plus_aurora_example -Exec=/usr/bin/com.example.package_info_plus_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=package_info_plus_aurora_example diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/108x108.png b/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/128x128.png b/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/172x172.png b/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/86x86.png b/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/package_info_plus/package_info_plus_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/main.cpp b/packages/package_info_plus/package_info_plus_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/package_info_plus/package_info_plus_aurora/example/aurora/rpm/com.example.package_info_plus_aurora_example.spec b/packages/package_info_plus/package_info_plus_aurora/example/aurora/rpm/com.example.package_info_plus_aurora_example.spec deleted file mode 100644 index 6a0c214..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/aurora/rpm/com.example.package_info_plus_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.package_info_plus_aurora_example -Summary: Demonstrates how to use the package_info_plus_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/package_info_plus/package_info_plus_aurora/example/lib/main.dart b/packages/package_info_plus/package_info_plus_aurora/example/lib/main.dart deleted file mode 100644 index 230fa54..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/lib/main.dart +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:package_info_plus/package_info_plus.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - String? _error; - String? _appName; - String? _packageName; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - Future initPlatformState() async { - try { - PackageInfo packageInfo = await PackageInfo.fromPlatform(); - - String appName = packageInfo.appName; - String packageName = packageInfo.packageName; - - // Update state variable - setState(() { - _appName = appName; - _packageName = packageName; - }); - } on Exception catch (e) { - setState(() { - _error = e.toString(); - }); - } - } - - @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('Example package_info_plus'), - ), - 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 package_info_plus', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - const Text( - 'Application Name', - style: textStyleTitle, - ), - spaceSmall, - Text( - _appName ?? 'Not found.', - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Package Name', - style: textStyleTitle, - ), - spaceSmall, - Text( - _packageName ?? 'Not found.', - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/packages/package_info_plus/package_info_plus_aurora/example/pubspec.lock b/packages/package_info_plus/package_info_plus_aurora/example/pubspec.lock deleted file mode 100644 index 910942c..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/pubspec.lock +++ /dev/null @@ -1,236 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.5" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - package_info_plus: - dependency: "direct main" - description: - name: package_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - package_info_plus_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.4" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/package_info_plus/package_info_plus_aurora/example/pubspec.yaml b/packages/package_info_plus/package_info_plus_aurora/example/pubspec.yaml deleted file mode 100644 index 5b48f42..0000000 --- a/packages/package_info_plus/package_info_plus_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: package_info_plus_aurora_example -description: Demonstrates how to use the package_info_plus_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - package_info_plus: ^4.0.0 - package_info_plus_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/package_info_plus/package_info_plus_aurora/pubspec.yaml b/packages/package_info_plus/package_info_plus_aurora/pubspec.yaml index ede11bc..bb59832 100644 --- a/packages/package_info_plus/package_info_plus_aurora/pubspec.yaml +++ b/packages/package_info_plus/package_info_plus_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: diff --git a/packages/path_provider/path_provider_aurora/README.md b/packages/path_provider/path_provider_aurora/README.md index f72c75b..79b6773 100644 --- a/packages/path_provider/path_provider_aurora/README.md +++ b/packages/path_provider/path_provider_aurora/README.md @@ -31,11 +31,11 @@ final Directory? downloadsDir = await getDownloadsDirectory(); ## Supported APIs -- [x] `getTemporaryDirectory` - Returns a directory location where user-specific non-essential (cached) data should be written -- [ ] `getApplicationSupportDirectory` +- [x] `getTemporaryDirectory` - Directory location where user-specific non-essential (cached) data should be written +- [x] `getApplicationSupportDirectory` - Directory where the application may place application support files. - [ ] `getLibraryDirectory` -- [x] `getApplicationDocumentsDirectory` - Returns the directory containing user document files. +- [x] `getApplicationDocumentsDirectory` - Directory containing user document files. - [ ] `getExternalStorageDirectory` - [ ] `getExternalCacheDirectories` - [x] `getExternalStorageDirectories` - There is no concept of External in Aurora OS, but this interface allows you to get the pictures/music/movies directory -- [x] `getDownloadsDirectory`- Returns a directory for user's downloaded files. +- [x] `getDownloadsDirectory`- Directory for user's downloaded files. diff --git a/packages/path_provider/path_provider_aurora/data/preview.png b/packages/path_provider/path_provider_aurora/data/preview.png deleted file mode 100644 index 311649c..0000000 Binary files a/packages/path_provider/path_provider_aurora/data/preview.png and /dev/null differ diff --git a/packages/path_provider/path_provider_aurora/example/.gitignore b/packages/path_provider/path_provider_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/path_provider/path_provider_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/path_provider/path_provider_aurora/example/README.md b/packages/path_provider/path_provider_aurora/example/README.md deleted file mode 100644 index 54caa24..0000000 --- a/packages/path_provider/path_provider_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# path_provider_aurora_example - -Demonstrates how to use the path_provider_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/path_provider/path_provider_aurora/example/analysis_options.yaml b/packages/path_provider/path_provider_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/path_provider/path_provider_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/path_provider/path_provider_aurora/example/aurora/.gitignore b/packages/path_provider/path_provider_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/path_provider/path_provider_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt b/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 90a772f..0000000 --- a/packages/path_provider/path_provider_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.path_provider_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop b/packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop deleted file mode 100644 index 69eeffc..0000000 --- a/packages/path_provider/path_provider_aurora/example/aurora/desktop/com.example.path_provider_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=path_provider_aurora_example -Comment=Demonstrates how to use the path_provider_aurora plugin. -Icon=com.example.path_provider_aurora_example -Exec=/usr/bin/com.example.path_provider_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions=UserDirs -OrganizationName=com.example -ApplicationName=path_provider_aurora_example diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/path_provider/path_provider_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/path_provider/path_provider_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/path_provider/path_provider_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png b/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/path_provider/path_provider_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/path_provider/path_provider_aurora/example/aurora/main.cpp b/packages/path_provider/path_provider_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/path_provider/path_provider_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec b/packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec deleted file mode 100644 index fb1eaa6..0000000 --- a/packages/path_provider/path_provider_aurora/example/aurora/rpm/com.example.path_provider_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.path_provider_aurora_example -Summary: Demonstrates how to use the path_provider_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/path_provider/path_provider_aurora/example/lib/main.dart b/packages/path_provider/path_provider_aurora/example/lib/main.dart deleted file mode 100644 index 014c460..0000000 --- a/packages/path_provider/path_provider_aurora/example/lib/main.dart +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:path_provider_aurora/path_provider_aurora.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - String? _error; - String? _pathApplicationSupportDirectory; - String? _pathTempDirectory; - String? _pathApplicationDocumentsPath; - String? _pathDownloadsPath; - String? _pathPictures; - String? _pathMusic; - String? _pathMovies; - - @override - void initState() { - super.initState(); - loadPathDirectory(); - } - - /// Asynchronous function receiving directory paths - Future loadPathDirectory() async { - try { - // Get directories - Directory? applicationSupportDirectory = - await getApplicationSupportDirectory(); - Directory? tempDirectory = await getTemporaryDirectory(); - Directory? pathApplicationDocumentsPath = - await getApplicationDocumentsDirectory(); - Directory? pathDownloadsPath = await getDownloadsDirectory(); - List? pathPictures = - await getExternalStorageDirectories(type: StorageDirectory.pictures); - List? pathMusic = - await getExternalStorageDirectories(type: StorageDirectory.music); - List? pathMovies = - await getExternalStorageDirectories(type: StorageDirectory.movies); - - // Update state variable - setState(() { - _pathApplicationSupportDirectory = applicationSupportDirectory.path; - _pathTempDirectory = tempDirectory.path; - _pathApplicationDocumentsPath = pathApplicationDocumentsPath.path; - _pathDownloadsPath = pathDownloadsPath?.path; - _pathPictures = pathPictures?.first.path; - _pathMusic = pathMusic?.first.path; - _pathMovies = pathMovies?.first.path; - }); - } on Exception catch (e) { - setState(() { - _error = e.toString(); - }); - } - } - - @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('Example path_provider'), - ), - 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 path_provider', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - // TempDirectory - const Text( - 'ApplicationSupportDirectory', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathApplicationSupportDirectory ?? 'Not found.', - style: textStylePath, - ), - - spaceMedium, - // TempDirectory - const Text( - 'TempDirectory', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathTempDirectory ?? 'Not found.', - style: textStylePath, - ), - spaceMedium, - - // ApplicationDocumentsPath - const Text( - 'ApplicationDocumentsPath', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathApplicationDocumentsPath ?? 'Not found.', - style: textStylePath, - ), - spaceMedium, - - // DownloadsPath - const Text( - 'DownloadsPath', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathDownloadsPath ?? 'Not found.', - style: textStylePath, - ), - spaceMedium, - - // Pictures - const Text( - 'Pictures', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathPictures ?? 'Not found.', - style: textStylePath, - ), - spaceMedium, - - // Music - const Text( - 'Music', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathMusic ?? 'Not found.', - style: textStylePath, - ), - spaceMedium, - - // Movies - const Text( - 'Movies', - style: textStyleTitle, - ), - spaceSmall, - Text( - _pathMovies ?? 'Not found.', - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} diff --git a/packages/path_provider/path_provider_aurora/example/pubspec.lock b/packages/path_provider/path_provider_aurora/example/pubspec.lock deleted file mode 100644 index 3d425d7..0000000 --- a/packages/path_provider/path_provider_aurora/example/pubspec.lock +++ /dev/null @@ -1,324 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.5" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.2" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - package_info_plus_aurora: - dependency: transitive - description: - path: "packages/package_info_plus/package_info_plus_aurora" - ref: dev - resolved-ref: "47dd76ca473269566811d8c48fbfd22f1d8120f9" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - path_provider: - dependency: "direct main" - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.15" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.27" - path_provider_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - path_provider_foundation: - dependency: transitive - description: - name: path_provider_foundation - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.3" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.11" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.7" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.4" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - xdga_directories: - dependency: transitive - description: - path: "packages/xdga_directories" - ref: dev - resolved-ref: "47dd76ca473269566811d8c48fbfd22f1d8120f9" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/path_provider/path_provider_aurora/example/pubspec.yaml b/packages/path_provider/path_provider_aurora/example/pubspec.yaml deleted file mode 100644 index 648f1ef..0000000 --- a/packages/path_provider/path_provider_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: path_provider_aurora_example -description: Demonstrates how to use the path_provider_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - path_provider: ^2.0.7 - path_provider_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart index 59b9140..687439d 100644 --- a/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart +++ b/packages/path_provider/path_provider_aurora/lib/path_provider_aurora.dart @@ -6,7 +6,6 @@ import 'package:package_info_plus_aurora/package_info_plus_aurora.dart'; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:xdga_directories/xdga_directories.dart' as xdga_directories; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:flutter/foundation.dart'; import 'package:path/path.dart' as p; /// The aurora implementation of [PathProviderPlatform] @@ -15,21 +14,22 @@ import 'package:path/path.dart' as p; class PathProviderAurora extends PathProviderPlatform { /// Registers this class as the default instance of [PathProviderPlatform] static void registerWith() { - if (TargetPlatform.aurora == defaultTargetPlatform) { - PackageInfoPlusAurora.registerWith(); - PathProviderPlatform.instance = PathProviderAurora(); - } + PathProviderPlatform.instance = PathProviderAurora(); } /// Path to a directory where the application may place application support files. @override Future getApplicationSupportPath() async { PackageInfo info = await PackageInfo.fromPlatform(); + + final appName = info.packageName.split('.').last; + final orgName = info.packageName.replaceAll('.$appName', ''); + // QStandardPaths::AppDataLocation return p.join( xdga_directories.getAppDataLocation(), - info.packageName, - info.appName, + orgName, + appName, ); } @@ -38,11 +38,15 @@ class PathProviderAurora extends PathProviderPlatform { @override Future getTemporaryPath() async { PackageInfo info = await PackageInfo.fromPlatform(); + + final appName = info.packageName.split('.').last; + final orgName = info.packageName.replaceAll('.$appName', ''); + // QStandardPaths::CacheLocation return p.join( xdga_directories.getCacheLocation(), - info.packageName, - info.appName, + orgName, + appName, ); } diff --git a/packages/path_provider/path_provider_aurora/pubspec.yaml b/packages/path_provider/path_provider_aurora/pubspec.yaml index 7af36fa..786ec6f 100644 --- a/packages/path_provider/path_provider_aurora/pubspec.yaml +++ b/packages/path_provider/path_provider_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: @@ -15,16 +15,21 @@ dependencies: path: ^1.8.2 plugin_platform_interface: ^2.0.2 path_provider_platform_interface: ^2.0.6 + + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/xdga_directories xdga_directories: git: url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git - ref: dev + ref: flutter_example_packages path: packages/xdga_directories - package_info_plus: 4.0.0 + + ## https://pub.dev/packages/package_info_plus + package_info_plus: 3.1.2 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/package_info_plus/package_info_plus_aurora package_info_plus_aurora: git: url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git - ref: dev + ref: flutter_example_packages path: packages/package_info_plus/package_info_plus_aurora dev_dependencies: diff --git a/packages/shared_preferences/shared_preferences_aurora/data/preview.png b/packages/shared_preferences/shared_preferences_aurora/data/preview.png deleted file mode 100644 index c6f0708..0000000 Binary files a/packages/shared_preferences/shared_preferences_aurora/data/preview.png and /dev/null differ diff --git a/packages/shared_preferences/shared_preferences_aurora/example/.gitignore b/packages/shared_preferences/shared_preferences_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/shared_preferences/shared_preferences_aurora/example/README.md b/packages/shared_preferences/shared_preferences_aurora/example/README.md deleted file mode 100644 index 7633274..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# shared_preferences_aurora_example - -Demonstrates how to use the shared_preferences_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) - diff --git a/packages/shared_preferences/shared_preferences_aurora/example/analysis_options.yaml b/packages/shared_preferences/shared_preferences_aurora/example/analysis_options.yaml deleted file mode 100644 index 1c55a5e..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/.gitignore b/packages/shared_preferences/shared_preferences_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/CMakeLists.txt b/packages/shared_preferences/shared_preferences_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 781f9e8..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.shared_preferences_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/desktop/com.example.shared_preferences_aurora_example.desktop b/packages/shared_preferences/shared_preferences_aurora/example/aurora/desktop/com.example.shared_preferences_aurora_example.desktop deleted file mode 100644 index ebb83d1..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/aurora/desktop/com.example.shared_preferences_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=shared_preferences_aurora_example -Comment=Demonstrates how to use the shared_preferences_aurora plugin. -Icon=com.example.shared_preferences_aurora_example -Exec=/usr/bin/com.example.shared_preferences_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=shared_preferences_aurora_example diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/108x108.png b/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/128x128.png b/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/172x172.png b/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/86x86.png b/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/shared_preferences/shared_preferences_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/main.cpp b/packages/shared_preferences/shared_preferences_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/shared_preferences/shared_preferences_aurora/example/aurora/rpm/com.example.shared_preferences_aurora_example.spec b/packages/shared_preferences/shared_preferences_aurora/example/aurora/rpm/com.example.shared_preferences_aurora_example.spec deleted file mode 100644 index a05f586..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/aurora/rpm/com.example.shared_preferences_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.shared_preferences_aurora_example -Summary: Demonstrates how to use the shared_preferences_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart b/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart deleted file mode 100644 index 2e79433..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/lib/main.dart +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'dart:async'; - -import 'package:flutter/services.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - int? _counter; - bool? _repeat; - double? _decimal; - String? _action; - List? _items; - String? _error; - - @override - void initState() { - super.initState(); - initPlatformState(); - } - - Future initPlatformState() async { - try { - SharedPreferences.setPrefix("my_prefix."); - - final SharedPreferences prefs = await SharedPreferences.getInstance(); - - // Save an integer value to 'counter' key. - await prefs.setInt('counter', 10); - // Save an boolean value to 'repeat' key. - await prefs.setBool('repeat', true); - // Save an double value to 'decimal' key. - await prefs.setDouble('decimal', 1.5); - // Save an String value to 'action' key. - await prefs.setString('action', 'Start'); - // Save an list of strings to 'items' key. - await prefs.setStringList('items', ['Earth', 'Moon', 'Sun']); - - // Try reading data from the 'counter' key. If it doesn't exist, returns null. - final int? counter = prefs.getInt('counter'); - // Try reading data from the 'repeat' key. If it doesn't exist, returns null. - final bool? repeat = prefs.getBool('repeat'); - // Try reading data from the 'decimal' key. If it doesn't exist, returns null. - final double? decimal = prefs.getDouble('decimal'); - // Try reading data from the 'action' key. If it doesn't exist, returns null. - final String? action = prefs.getString('action'); - // Try reading data from the 'items' key. If it doesn't exist, returns null. - final List? items = prefs.getStringList('items'); - - setState(() { - _counter = counter; - _repeat = repeat; - _decimal = decimal; - _action = action; - _items = items; - }); - } on PlatformException { - setState(() { - _error = 'Platform exception'; - }); - } - } - - @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('Example shared_preferences'), - ), - 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( - 'Counter / int', - style: textStyleTitle, - ), - spaceSmall, - Text( - _counter.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Repeat / bool', - style: textStyleTitle, - ), - spaceSmall, - Text( - _repeat.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Decimal / double', - style: textStyleTitle, - ), - spaceSmall, - Text( - _decimal.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Action / String', - style: textStyleTitle, - ), - spaceSmall, - Text( - _action.toString(), - style: textStylePath, - ), - - spaceMedium, - const Text( - 'Items / String List', - style: textStyleTitle, - ), - spaceSmall, - Text( - _items.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 deleted file mode 100644 index 9e61cb7..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/pubspec.lock +++ /dev/null @@ -1,338 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.4" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - path_provider: - dependency: transitive - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.15" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.27" - path_provider_aurora: - dependency: transitive - description: - path: "packages/path_provider/path_provider_aurora" - ref: dev - resolved-ref: "7120c2554963ce9e7600730b2657b387d3a86d9c" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" - path_provider_foundation: - dependency: transitive - description: - name: path_provider_foundation - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.3" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.11" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.7" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.4" - shared_preferences: - dependency: "direct main" - description: - name: shared_preferences - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - shared_preferences_android: - dependency: transitive - description: - name: shared_preferences_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - shared_preferences_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - shared_preferences_foundation: - dependency: transitive - description: - name: shared_preferences_foundation - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.2" - shared_preferences_linux: - dependency: transitive - description: - name: shared_preferences_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" - shared_preferences_platform_interface: - dependency: transitive - description: - name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" - shared_preferences_web: - dependency: transitive - description: - name: shared_preferences_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - shared_preferences_windows: - dependency: transitive - description: - name: shared_preferences_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "2.6.1" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - xdga_directories: - dependency: transitive - description: - path: "packages/xdga_directories" - ref: dev - resolved-ref: "7120c2554963ce9e7600730b2657b387d3a86d9c" - url: "git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git" - source: git - version: "0.0.1" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=3.3.0" diff --git a/packages/shared_preferences/shared_preferences_aurora/example/pubspec.yaml b/packages/shared_preferences/shared_preferences_aurora/example/pubspec.yaml deleted file mode 100644 index 17dde92..0000000 --- a/packages/shared_preferences/shared_preferences_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: shared_preferences_aurora_example -description: Demonstrates how to use the shared_preferences_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - shared_preferences: ^2.1.1 - shared_preferences_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true 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 e8c606d..2605b8f 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 @@ -3,18 +3,13 @@ * License: Proprietary. */ import 'package:flutter/services.dart'; -import 'package:path_provider_aurora/path_provider_aurora.dart'; import 'package:shared_preferences_aurora/shared_preferences_aurora_api.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; -import 'package:flutter/foundation.dart'; class SharedPreferencesAurora extends SharedPreferencesStorePlatform { /// Registers this class as the default instance of [SharedPreferencesStorePlatform]. static void registerWith() { - if (TargetPlatform.aurora == defaultTargetPlatform) { - PathProviderAurora.registerWith(); - SharedPreferencesStorePlatform.instance = SharedPreferencesAurora(); - } + SharedPreferencesStorePlatform.instance = SharedPreferencesAurora(); } static const String _defaultPrefix = 'flutter.'; diff --git a/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml b/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml index a2d9531..7e88b5c 100644 --- a/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml +++ b/packages/shared_preferences/shared_preferences_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: @@ -16,11 +16,14 @@ dependencies: shared_preferences: ^2.1.1 shared_preferences_platform_interface: ^2.2.0 path: ^1.8.2 - path_provider: ^2.0.14 + + ## https://pub.dev/packages/path_provider + path_provider: ^2.0.15 + ## https://os-git.omprussia.ru/non-oss/flutter/flutter-plugins/-/tree/master/packages/path_provider/path_provider_aurora path_provider_aurora: git: url: git@os-git.omprussia.ru:non-oss/flutter/flutter-plugins.git - ref: dev + ref: flutter_example_packages path: packages/path_provider/path_provider_aurora dev_dependencies: diff --git a/packages/sqflite/sqflite_aurora/aurora/lib/sqflite_aurora_plugin.cpp b/packages/sqflite/sqflite_aurora/aurora/lib/sqflite_aurora_plugin.cpp index c60d17c..056d977 100644 --- a/packages/sqflite/sqflite_aurora/aurora/lib/sqflite_aurora_plugin.cpp +++ b/packages/sqflite/sqflite_aurora/aurora/lib/sqflite_aurora_plugin.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2023. Open Mobile Platform LLC. * License: Proprietary. */ -#include +#include #include #include @@ -260,7 +260,8 @@ void SqfliteAuroraPlugin::onGetDatabasesPathCall(const MethodCall &call) return; } - const auto [orgname, appname] = Application::GetID(); + const auto orgname = PlatformMethods::GetOrgname(); + const auto appname = PlatformMethods::GetAppname(); const auto directory = std::filesystem::path(home) / ".local/share" / orgname / appname; sendSuccess(call, directory.generic_string()); diff --git a/packages/sqflite/sqflite_aurora/example/LICENSE b/packages/sqflite/sqflite_aurora/example/LICENSE deleted file mode 100644 index 5385068..0000000 --- a/packages/sqflite/sqflite_aurora/example/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -BSD 2-Clause License - -Copyright (c) 2019, Alexandre Roux Tekartik -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/sqflite/sqflite_aurora/example/README.md b/packages/sqflite/sqflite_aurora/example/README.md deleted file mode 100644 index f138b66..0000000 --- a/packages/sqflite/sqflite_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Sqflite example for Aurora OS - -Demonstrates how to use the `sqflite_aurora` plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/sqflite/sqflite_aurora/example/analysis_options.yaml b/packages/sqflite/sqflite_aurora/example/analysis_options.yaml deleted file mode 100644 index fe99e5f..0000000 --- a/packages/sqflite/sqflite_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,87 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -analyzer: - language: - strict-casts: true - strict-inference: true - - errors: - missing_required_param: warning - missing_return: warning - todo: ignore - included_file_warning: ignore - -linter: - rules: - - always_declare_return_types - - avoid_dynamic_calls - - avoid_empty_else - - avoid_relative_lib_imports - - avoid_shadowing_type_parameters - - avoid_slow_async_io - - avoid_types_as_parameter_names - - await_only_futures - - camel_case_extensions - - camel_case_types - - cancel_subscriptions - - curly_braces_in_flow_control_structures - - directives_ordering - - empty_catches - - hash_and_equals - - iterable_contains_unrelated_type - - list_remove_unrelated_type - - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names - - omit_local_variable_types - - package_api_docs - - package_prefixed_library_names - - prefer_generic_function_type_aliases - - prefer_is_empty - - prefer_is_not_empty - - prefer_iterable_whereType - - prefer_single_quotes - - prefer_typing_uninitialized_variables - - sort_child_properties_last - - test_types_in_equals - - throw_in_finally - - unawaited_futures - - unnecessary_null_aware_assignments - - unnecessary_statements - - unrelated_type_equality_checks - - unsafe_html - - valid_regexps - - - constant_identifier_names - - control_flow_in_finally - - empty_statements - - implementation_imports - - overridden_fields - - package_names - - prefer_const_constructors - - prefer_initializing_formals - - prefer_void_to_null - - - always_require_non_null_named_parameters - - annotate_overrides - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - empty_constructor_bodies - - library_names - - library_prefixes - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_contains - - prefer_equal_for_default_values - - slash_for_doc_comments - - type_init_formals - - unnecessary_const - - unnecessary_new - - unnecessary_null_in_if_null_operators - - use_rethrow_when_possible - - - public_member_api_docs - - - sort_constructors_first - - sort_unnamed_constructors_first diff --git a/packages/sqflite/sqflite_aurora/example/assets/example.db b/packages/sqflite/sqflite_aurora/example/assets/example.db deleted file mode 100644 index e3db112..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/assets/example.db and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/assets/issue_64.db b/packages/sqflite/sqflite_aurora/example/assets/issue_64.db deleted file mode 100644 index d26f958..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/assets/issue_64.db and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/aurora/.gitignore b/packages/sqflite/sqflite_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/sqflite/sqflite_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/sqflite/sqflite_aurora/example/aurora/CMakeLists.txt b/packages/sqflite/sqflite_aurora/example/aurora/CMakeLists.txt deleted file mode 100644 index 96c8fe6..0000000 --- a/packages/sqflite/sqflite_aurora/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.sqflite_aurora_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/sqflite/sqflite_aurora/example/aurora/desktop/com.example.sqflite_aurora_example.desktop b/packages/sqflite/sqflite_aurora/example/aurora/desktop/com.example.sqflite_aurora_example.desktop deleted file mode 100644 index dbc40db..0000000 --- a/packages/sqflite/sqflite_aurora/example/aurora/desktop/com.example.sqflite_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Sqflite Example -Comment=Demonstrates how to use the sqflite_aurora plugin. -Icon=com.example.sqflite_aurora_example -Exec=/usr/bin/com.example.sqflite_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=sqflite_aurora_example diff --git a/packages/sqflite/sqflite_aurora/example/aurora/icons/108x108.png b/packages/sqflite/sqflite_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/aurora/icons/128x128.png b/packages/sqflite/sqflite_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/aurora/icons/172x172.png b/packages/sqflite/sqflite_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/aurora/icons/86x86.png b/packages/sqflite/sqflite_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/sqflite/sqflite_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/sqflite/sqflite_aurora/example/aurora/main.cpp b/packages/sqflite/sqflite_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/sqflite/sqflite_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/batch_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/batch_test_page.dart deleted file mode 100644 index 66cb011..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/batch_test_page.dart +++ /dev/null @@ -1,215 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:sqflite/sqflite.dart'; - -import 'test_page.dart'; - -/// Batch test page. -class BatchTestPage extends TestPage { - /// Batch test page. - BatchTestPage({Key? key}) : super('Batch tests', key: key) { - test('BatchQuery', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('batch_query.db'); - final db = await openDatabase(path); - - // empty batch - var batch = db.batch(); - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - var results = await batch.commit(); - expect(results, [null, 1]); - - final dbResult = await db.rawQuery('SELECT id, name FROM Test'); - // devPrint('dbResult $dbResult'); - expect(dbResult, [ - {'id': 1, 'name': 'item1'} - ]); - - // one query - batch = db.batch(); - batch.rawQuery('SELECT id, name FROM Test'); - batch.query('Test', columns: ['id', 'name']); - results = await batch.commit(); - // devPrint('select $results ${results?.first}'); - expect(results, [ - [ - {'id': 1, 'name': 'item1'} - ], - [ - {'id': 1, 'name': 'item1'} - ] - ]); - await db.close(); - }); - test('Batch', () async { - // await databaseFactory.devSetDebugModeOn(); - final path = await initDeleteDb('batch.db'); - final db = await openDatabase(path); - - // empty batch - var batch = db.batch(); - var results = await batch.commit(); - expect(results.length, 0); - expect(results, isEmpty); - - // one create table - batch = db.batch(); - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - results = await batch.commit(); - // devPrint('1 $results ${results?.first}'); - expect(results, [null]); - expect(results[0], null); - - // one insert - batch = db.batch(); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - results = await batch.commit(); - expect(results, [1]); - - // one query - batch = db.batch(); - batch.rawQuery('SELECT id, name FROM Test'); - batch.query('Test', columns: ['id', 'name']); - results = await batch.commit(); - // devPrint('select $results ${results?.first}'); - expect(results, [ - [ - {'id': 1, 'name': 'item1'} - ], - [ - {'id': 1, 'name': 'item1'} - ] - ]); - - // two insert - batch = db.batch(); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item2']); - batch.insert('Test', {'name': 'item3'}); - results = await batch.commit(); - expect(results, [2, 3]); - - // update - batch = db.batch(); - batch.rawUpdate( - 'UPDATE Test SET name = ? WHERE name = ?', ['new_item', 'item1']); - batch.update('Test', {'name': 'new_other_item'}, - where: 'name != ?', whereArgs: ['new_item']); - results = await batch.commit(); - expect(results, [1, 2]); - - // delete - batch = db.batch(); - batch.rawDelete('DELETE FROM Test WHERE name = ?', ['new_item']); - batch.delete('Test', - where: 'name = ?', whereArgs: ['new_other_item']); - results = await batch.commit(); - expect(results, [1, 2]); - - // No result - batch = db.batch(); - batch.insert('Test', {'name': 'item'}); - batch.update('Test', {'name': 'new_item'}, - where: 'name = ?', whereArgs: ['item']); - batch.delete('Test', where: 'name = ?', whereArgs: ['item']); - results = await batch.commit(noResult: true); - expect(results, isEmpty); - - await db.close(); - }); - - test('Batch in transaction', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('batch_in_transaction.db'); - final db = await openDatabase(path); - - late List results; - - await db.transaction((txn) async { - final batch1 = txn.batch(); - batch1.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - final batch2 = txn.batch(); - batch2.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - results = await batch1.commit(); - expect(results, [null]); - - results = await batch2.commit(); - expect(results, [1]); - }); - - await db.close(); - }); - - test('Apply in database', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('apply_in_database.db'); - final db = await openDatabase(path); - - late List results; - - final batch1 = db.batch(); - batch1.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - final batch2 = db.batch(); - batch2.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - results = await batch1.apply(); - expect(results, [null]); - - results = await batch2.apply(); - expect(results, [1]); - await db.close(); - }); - - test('Apply in transaction', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('apply_in_transaction.db'); - final db = await openDatabase(path); - - late List results; - - await db.transaction((txn) async { - final batch1 = txn.batch(); - batch1.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - final batch2 = txn.batch(); - batch2.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - results = await batch1.apply(); - expect(results, [null]); - - results = await batch2.apply(); - expect(results, [1]); - }); - - await db.close(); - }); - - test('Batch continue on error', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('batch_continue_on_error.db'); - final db = await openDatabase(path); - try { - final batch = db.batch(); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - batch.execute('DUMMY'); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']); - batch.rawQuery('SELECT * FROM Test'); - final results = await batch.commit(continueOnError: true); - // devPrint(results); - // First result is an exception - var exception = results[0] as DatabaseException; - expect(exception.isNoSuchTableError(), true); - // Second result is null (create table) - expect(results[1], null); - // Third result is an exception - exception = results[2] as DatabaseException; - expect(exception.isSyntaxError(), true); - // Fourth result is an insert - expect(results[3], 1); - // Fifth is a select - expect(results[4], [ - {'id': 1, 'name': 'item1'} - ]); - } finally { - await db.close(); - } - }); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/database/database.dart b/packages/sqflite/sqflite_aurora/example/lib/database/database.dart deleted file mode 100644 index 0fb2b9b..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/database/database.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'database_impl.dart'; -export 'database_io.dart' if (dart.library.html) 'database_web.dart'; diff --git a/packages/sqflite/sqflite_aurora/example/lib/database/database_impl.dart b/packages/sqflite/sqflite_aurora/example/lib/database/database_impl.dart deleted file mode 100644 index ab9c3a0..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/database/database_impl.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'dart:typed_data'; - -import 'package:sqflite/sqflite.dart'; - -import 'database.dart'; - -/// Custom platform Handler, need to handle Web or IO differently or from a -/// custom app -abstract class PlatformHandler { - /// delete the db, create the folder and returns its path - Future initDeleteDb(String dbName) async { - if (await databaseExists(dbName)) { - await deleteDatabase(dbName); - } - return dbName; - } - - /// Write the db file directly to the file system - Future writeFileAsBytes(String path, List bytes, - {bool flush = false}); - - /// Read a file as bytes - Future readFileAsBytes(String path); - - /// Write a file as a string - Future writeFileAsString(String path, String text, - {bool flush = false}); - - /// Read a file as a string - Future readFileAsString(String path); - - /// Check if a path exists. - Future pathExists(String path); - - /// Recursively create a directory - Future createDirectory(String path); - - /// Recursively delete a directory - Future deleteDirectory(String path); - - /// Check if a directory exists - Future existsDirectory(String path); -} - -// --- -// Compat, to keep the example page as is -// --- - -/// delete the db, create the folder and returnes its path -Future initDeleteDb(String dbName) => - platformHandler.initDeleteDb(dbName); - -/// Write the db file directly to the file system -Future writeFileAsBytes(String path, List bytes, - {bool flush = false}) => - platformHandler.writeFileAsBytes(path, bytes, flush: flush); - -/// Read a file as bytes -Future readFileAsBytes(String path) => - platformHandler.readFileAsBytes(path); - -/// Write a file as a string -Future writeFileAsString(String path, String text, - {bool flush = false}) => - platformHandler.writeFileAsString(path, text, flush: flush); - -/// Read a file as a string -Future readFileAsString(String path) => - platformHandler.readFileAsString(path); - -/// Check if a path exists. -Future pathExists(String path) => platformHandler.pathExists(path); - -/// Recursively create a directory -Future createDirectory(String path) => - platformHandler.createDirectory(path); - -/// Recursively delete a directory -Future deleteDirectory(String path) => - platformHandler.deleteDirectory(path); - -/// Check if a directory exists -Future existsDirectory(String path) => - platformHandler.existsDirectory(path); - -PlatformHandler? _platformHandler; - -/// Platform handler (can be overriden, needed for the web test app) -PlatformHandler get platformHandler => _platformHandler ??= platformHandlerIo; -set platformHandler(PlatformHandler handler) => _platformHandler = handler; diff --git a/packages/sqflite/sqflite_aurora/example/lib/database/database_io.dart b/packages/sqflite/sqflite_aurora/example/lib/database/database_io.dart deleted file mode 100644 index 58592dd..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/database/database_io.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:path/path.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite_example/database/database.dart'; - -class _PlatformHandlerIo extends PlatformHandler { - /// delete the db, create the folder and returns its path - @override - Future initDeleteDb(String dbName) async { - final databasePath = await getDatabasesPath(); - // print(databasePath); - final path = join(databasePath, dbName); - - // make sure the folder exists - // ignore: avoid_slow_async_io - if (await Directory(dirname(path)).exists()) { - await deleteDatabase(path); - } else { - try { - await Directory(dirname(path)).create(recursive: true); - } catch (e) { - // ignore: avoid_print - print(e); - } - } - return path; - } - - /// Write the db file directly to the file system - @override - Future writeFileAsBytes(String path, List bytes, - {bool flush = false}) async { - await File(path).writeAsBytes(bytes, flush: flush); - } - - /// Read a file as bytes - @override - Future readFileAsBytes(String path) async { - return File(path).readAsBytes(); - } - - /// Write a file as a string - @override - Future writeFileAsString(String path, String text, - {bool flush = false}) async { - await File(path).writeAsString(text, flush: true); - } - - /// Read a file as a string - @override - Future readFileAsString(String path) async { - return File(path).readAsString(); - } - - /// Check if a path exists. - @override - Future pathExists(String path) async { - // ignore: avoid_slow_async_io - return File(path).exists(); - } - - /// Recursively create a directory - @override - Future createDirectory(String path) async { - await Directory(dirname(path)).create(recursive: true); - } - - /// Recursively delete a directory - @override - Future deleteDirectory(String path) async { - await Directory(path).delete(recursive: true); - } - - /// Check if a directory exists - @override - Future existsDirectory(String path) async { - // ignore: avoid_slow_async_io - return Directory(path).exists(); - } -} - -/// Io platform handler -PlatformHandler platformHandlerIo = _PlatformHandlerIo(); diff --git a/packages/sqflite/sqflite_aurora/example/lib/database/database_web.dart b/packages/sqflite/sqflite_aurora/example/lib/database/database_web.dart deleted file mode 100644 index a0047aa..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/database/database_web.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:sqflite_example/database/database.dart'; - -/// platform handler io not supported on the web. -PlatformHandler get platformHandlerIo => - throw UnsupportedError('platform handler io not supported on the web'); diff --git a/packages/sqflite/sqflite_aurora/example/lib/deprecated_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/deprecated_test_page.dart deleted file mode 100644 index a03d30b..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/deprecated_test_page.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter/foundation.dart'; - -import 'test_page.dart'; - -/// Deprecated test page. -class DeprecatedTestPage extends TestPage { - /// Deprecated test page. - DeprecatedTestPage({Key? key}) : super('Deprecated tests', key: key) { - test('None', () async {}); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/exception_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/exception_test_page.dart deleted file mode 100644 index e360990..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/exception_test_page.dart +++ /dev/null @@ -1,723 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite/sql.dart'; - -import 'src/common_import.dart'; -import 'test_page.dart'; - -// ignore_for_file: avoid_print -/// Exception test page. -class ExceptionTestPage extends TestPage { - /// Exception test page. - ExceptionTestPage({Key? key}) : super('Exception tests', key: key) { - test('Transaction failed', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('transaction_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - // insert then fails to make sure the transaction is cancelled - var hasFailed = false; - try { - await db.transaction((txn) async { - await txn.rawInsert( - 'INSERT INTO Test (name) VALUES (?)', ['item']); - final afterCount = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 1); - - hasFailed = true; - // this failure should cancel the insertion before - await txn.execute('DUMMY CALL'); - hasFailed = false; - }); - } on DatabaseException catch (e) { - // iOS: native_error: PlatformException(sqlite_error, Error Domain=FMDatabase Code=1 'near 'DUMMY': syntax error' UserInfo={NSLocalizedDescription=near 'DUMMY': syntax error}, null) - print('native_error: $e'); - } - verify(hasFailed); - - final afterCount = - Sqflite.firstIntValue(await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 0); - - await db.close(); - }); - - test('Batch failed', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('batch_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - final batch = db.batch(); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item']); - batch.execute('DUMMY CALL'); - - var hasFailed = true; - try { - await batch.commit(); - hasFailed = false; - } on DatabaseException catch (e) { - print('native_error: $e'); - } - - verify(hasFailed); - - final afterCount = - Sqflite.firstIntValue(await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 0); - - await db.close(); - }); - - test('Sqlite Exception', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('exception.db'); - final db = await openDatabase(path); - - // Query - try { - await db.rawQuery('SELECT COUNT(*) FROM Test'); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isNoSuchTableError('Test')); - // Error Domain=FMDatabase Code=1 'no such table: Test' UserInfo={NSLocalizedDescription=no such table: Test}) - } - - // Catch without using on DatabaseException - try { - await db.rawQuery('malformed query'); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - //verify(e.toString().contains('sql 'malformed query' args')); - // devPrint(e); - } - - try { - await db.rawQuery('malformed query with args ?', [1]); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - print(e); - verify(e - .toString() - .contains("sql 'malformed query with args ?' args [1]")); - } - - try { - await db.execute('DUMMY'); - fail(); // should fail before - } on Exception catch (e) { - //verify(e.isSyntaxError()); - print(e); - verify(e.toString().contains('DUMMY')); - } - - try { - await db.rawInsert('DUMMY'); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - verify(e.toString().contains('DUMMY')); - } - - try { - await db.rawUpdate('DUMMY'); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - verify(e.toString().contains('DUMMY')); - } - - await db.close(); - }); - - test('Sqlite constraint Exception', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('constraint_exception.db'); - final db = await openDatabase(path, version: 1, onCreate: (db, version) { - db.execute('CREATE TABLE Test (name TEXT UNIQUE)'); - }); - await db.insert('Test', {'name': 'test1'}); - - try { - await db.insert('Test', {'name': 'test1'}); - } on DatabaseException catch (e) { - // iOS: Error Domain=FMDatabase Code=19 'UNIQUE constraint failed: Test.name' UserInfo={NSLocalizedDescription=UNIQUE constraint failed: Test.name}) s - // Android: UNIQUE constraint failed: Test.name (code 2067)) - print(e); - - verify(e.isUniqueConstraintError()); - expect(e.getResultCode(), 2067); - verify(e.isUniqueConstraintError('Test.name')); - } - - await db.close(); - }); - - test('Sqlite constraint primary key', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('constraint_primary_key_exception.db'); - final db = await openDatabase(path, version: 1, onCreate: (db, version) { - db.execute('CREATE TABLE Test (name TEXT PRIMARY KEY)'); - }); - await db.insert('Test', {'name': 'test1'}); - - try { - await db.insert('Test', {'name': 'test1'}); - } on DatabaseException catch (e) { - // iOS: Error Domain=FMDatabase Code=19 'UNIQUE constraint failed: Test.name' UserInfo={NSLocalizedDescription=UNIQUE constraint failed: Test.name}) s - // Android: UNIQUE constraint failed: Test.name (code 1555)) - print(e); - verify(e.isUniqueConstraintError()); - verify(e.isUniqueConstraintError('Test.name')); - - expect(e.getResultCode(), 1555); - } - - await db.close(); - }); - - test('Sqlite batch Exception', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('batch_exception.db'); - final db = await openDatabase(path); - - // Query - try { - final batch = db.batch(); - batch.rawQuery('SELECT COUNT(*) FROM Test'); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - print(e); - verify(e.isNoSuchTableError('Test')); - } - - // Catch without using on DatabaseException - try { - final batch = db.batch(); - batch.rawQuery('malformed query'); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - print(e); - verify(e.toString().contains("sql 'malformed query'")); - } - - try { - final batch = db.batch(); - batch.rawQuery('malformed query with args ?', [1]); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - print(e); - verify(e - .toString() - .contains("sql 'malformed query with args ?' args [1]")); - } - - try { - final batch = db.batch(); - batch.execute('DUMMY'); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - // devPrint(e); - // iOS Error Domain=FMDatabase Code=1 "near "DUMMY": syntax error" UserInfo={NSLocalizedDescription=near "DUMMY": syntax error}) - verify(e.toString().contains("sql 'DUMMY'")); - } - - try { - final batch = db.batch(); - batch.rawInsert('DUMMY'); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - verify(e.toString().contains("sql 'DUMMY'")); - } - - try { - final batch = db.batch(); - batch.rawUpdate('DUMMY'); - await batch.commit(); - fail(); // should fail before - } on DatabaseException catch (e) { - verify(e.isSyntaxError()); - verify(e.toString().contains("sql 'DUMMY'")); - } - - await db.close(); - }); - - test('Open onDowngrade fail', () async { - final path = await initDeleteDb('open_on_downgrade_fail.db'); - var database = await openDatabase(path, version: 2, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE Test(id INTEGER PRIMARY KEY)'); - }); - await database.close(); - - // currently this is crashing... - // should fail going back in versions - try { - database = await openDatabase(path, - version: 1, onDowngrade: onDatabaseVersionChangeError); - verify(false); - } catch (e) { - print(e); - } - - // should work - database = await openDatabase(path, - version: 2, onDowngrade: onDatabaseVersionChangeError); - print(database); - await database.close(); - }); - - test('Access after close', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('access_after_close.db'); - final database = await openDatabase(path, version: 3, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE Test(id INTEGER PRIMARY KEY)'); - }); - await database.close(); - try { - await database.getVersion(); - verify(false); - } on DatabaseException catch (e) { - print(e); - verify(e.isDatabaseClosedError()); - } - - try { - await database.setVersion(1); - fail(); - } on DatabaseException catch (e) { - print(e); - verify(e.isDatabaseClosedError()); - } - }); - - test('Non escaping fields', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('non_escaping_fields.db'); - final db = await openDatabase(path); - - const table = 'table'; - try { - await db.execute('CREATE TABLE $table (group INTEGER)'); - fail('should fail'); - } on DatabaseException catch (e) { - print(e); - verify(e.isSyntaxError()); - } - try { - await db.execute('INSERT INTO $table (group) VALUES (1)'); - fail('should fail'); - } on DatabaseException catch (e) { - print(e); - verify(e.isSyntaxError()); - } - try { - await db.rawQuery('SELECT * FROM $table ORDER BY group DESC'); - } on DatabaseException catch (e) { - print(e); - verify(e.isSyntaxError()); - } - - try { - await db.rawQuery('DELETE FROM $table'); - } on DatabaseException catch (e) { - print(e); - verify(e.isSyntaxError()); - } - - // Build our escape list from all the sqlite keywords - final toExclude = []; - for (var name in allEscapeNames) { - try { - await db.execute('CREATE TABLE $name (value INTEGER)'); - } on DatabaseException catch (e) { - await db.execute('CREATE TABLE ${escapeName(name)} (value INTEGER)'); - - verify(e.isSyntaxError()); - toExclude.add(name); - } - } - - print(json.encode(toExclude)); - - await db.close(); - }); - - test('Bind no argument (no iOS)', () async { - if (!platform.isIOS) { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('bind_no_arg_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (name TEXT)'); - - await db.rawInsert('INSERT INTO Test (name) VALUES ("?")', []); - - await db.rawQuery('SELECT * FROM Test WHERE name = ?', []); - - await db.rawDelete('DELETE FROM Test WHERE name = ?', []); - - await db.close(); - } - }); - - test('crash ios (no iOS)', () async { - // This crashes natively on iOS...can't catch it yet - if (!platform.isIOS) { - //if (true) { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('bind_no_arg_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (name TEXT)'); - - await db.rawInsert('INSERT INTO Test (name) VALUES ("?")', []); - - await db.rawQuery('SELECT * FROM Test WHERE name = ?', []); - - await db.close(); - } - }); - - test('Bind null argument', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('bind_null_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (name TEXT)'); - - //await db.rawInsert("INSERT INTO Test (name) VALUES (\"?\")", [null]); - /* - nnbd this can no longer be tested! - - try { - await db.rawInsert('INSERT INTO Test (name) VALUES (?)', [null]); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'INSERT"), true); - } - - try { - await db.rawQuery('SELECT * FROM Test WHERE name = ?', [null]); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'SELECT * FROM Test"), true); - } - - try { - await db.rawDelete('DELETE FROM Test WHERE name = ?', [null]); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'DELETE FROM Test"), true); - } - - */ - - await db.close(); - }); - - test('Bind no parameter', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('bind_no_parameter_failed.db'); - final db = await openDatabase(path); - - await db.execute('CREATE TABLE Test (name TEXT)'); - - try { - await db - .rawInsert('INSERT INTO Test (name) VALUES ("value")', ['value2']); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'INSERT INTO Test"), true); - } - - try { - await db - .rawQuery('SELECT * FROM Test WHERE name = "value"', ['value2']); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'SELECT * FROM Test"), true); - } - - try { - await db.rawDelete('DELETE FROM Test WHERE name = "value"', ['value2']); - } on DatabaseException catch (e) { - print('ERR: $e'); - expect(e.toString().contains("sql 'DELETE FROM Test"), true); - } - - await db.close(); - }); - - // Using the db object in a transaction lead to a deadlock... - test('Dead lock', () async { - final path = await initDeleteDb('dead_lock.db'); - final db = await openDatabase(path); - try { - var hasTimedOut = false; - var callbackCount = 0; - Sqflite.setLockWarningInfo( - duration: const Duration(milliseconds: 200), - callback: () { - callbackCount++; - }); - - await db.transaction((txn) async { - try { - await db.getVersion().timeout(const Duration(milliseconds: 1500)); - fail('should fail'); - } on TimeoutException catch (_) { - hasTimedOut = true; - } - }); - - expect(hasTimedOut, true); - expect(callbackCount, 1); - } finally { - await db.close(); - } - }); - - test('Thread dead lock', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('thread_dead_lock.db'); - final db1 = await openDatabase(path, singleInstance: false); - final db2 = await openDatabase(path, singleInstance: false); - try { - await db1.execute('BEGIN IMMEDIATE TRANSACTION'); - - try { - // this should block the main thread - await db2 - .execute('BEGIN IMMEDIATE TRANSACTION') - .timeout(const Duration(milliseconds: 500)); - fail('should timeout'); - } on TimeoutException catch (e) { - print('caught $e'); - } - - // Try to open another db to check that the main thread is free - final db = await openDatabase(inMemoryDatabasePath); - await db.close(); - - try { - // clean up - await db1.execute('ROLLBACK'); - } catch (_) {} - - try { - await db2.execute('ROLLBACK'); - } catch (_) {} - } finally { - await db1.close(); - await db2.close(); - } - }); - } -} - -/// Name that should be escaped. -var escapeNames = [ - 'add', - 'all', - 'alter', - 'and', - 'as', - 'autoincrement', - 'between', - 'case', - 'check', - 'collate', - 'commit', - 'constraint', - 'create', - 'default', - 'deferrable', - 'delete', - 'distinct', - 'drop', - 'else', - 'escape', - 'except', - 'exists', - 'foreign', - 'from', - 'group', - 'having', - 'if', - 'in', - 'index', - 'insert', - 'intersect', - 'into', - 'is', - 'isnull', - 'join', - 'limit', - 'not', - 'notnull', - 'null', - 'on', - 'or', - 'order', - 'primary', - 'references', - 'select', - 'set', - 'table', - 'then', - 'to', - 'transaction', - 'union', - 'unique', - 'update', - 'using', - 'values', - 'when', - 'where' -]; - -/// all SQLite keywords to escape. -var allEscapeNames = [ - 'abort', - 'action', - 'add', - 'after', - 'all', - 'alter', - 'analyze', - 'and', - 'as', - 'asc', - 'attach', - 'autoincrement', - 'before', - 'begin', - 'between', - 'by', - 'cascade', - 'case', - 'cast', - 'check', - 'collate', - 'column', - 'commit', - 'conflict', - 'constraint', - 'create', - 'cross', - 'current_date', - 'current_time', - 'current_timestamp', - 'database', - 'default', - 'deferrable', - 'deferred', - 'delete', - 'desc', - 'detach', - 'distinct', - 'drop', - 'each', - 'else', - 'end', - 'escape', - 'except', - 'exclusive', - 'exists', - 'explain', - 'fail', - 'for', - 'foreign', - 'from', - 'full', - 'glob', - 'group', - 'having', - 'if', - 'ignore', - 'immediate', - 'in', - 'index', - 'indexed', - 'initially', - 'inner', - 'insert', - 'instead', - 'intersect', - 'into', - 'is', - 'isnull', - 'join', - 'key', - 'left', - 'like', - 'limit', - 'match', - 'natural', - 'no', - 'not', - 'notnull', - 'null', - 'of', - 'offset', - 'on', - 'or', - 'order', - 'outer', - 'plan', - 'pragma', - 'primary', - 'query', - 'raise', - 'recursive', - 'references', - 'regexp', - 'reindex', - 'release', - 'rename', - 'replace', - 'restrict', - 'right', - 'rollback', - 'row', - 'savepoint', - 'select', - 'set', - 'table', - 'temp', - 'temporary', - 'then', - 'to', - 'transaction', - 'trigger', - 'union', - 'unique', - 'update', - 'using', - 'vacuum', - 'values', - 'view', - 'virtual', - 'when', - 'where', - 'with', - 'without' -]; diff --git a/packages/sqflite/sqflite_aurora/example/lib/exp_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/exp_test_page.dart deleted file mode 100644 index d67ce66..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/exp_test_page.dart +++ /dev/null @@ -1,777 +0,0 @@ -import 'dart:isolate'; -import 'dart:typed_data'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; -import 'package:path/path.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite_common/sqflite_dev.dart'; -import 'package:sqflite_example/src/common_import.dart'; -import 'package:sqflite_example/utils.dart'; - -import 'test_page.dart'; - -// ignore_for_file: avoid_print - -/// `todo` table name -const String tableTodo = 'todo'; - -/// id column name -const String columnId = '_id'; - -/// title column name -const String columnTitle = 'title'; - -/// done column name -const String columnDone = 'done'; - -/// Experiment test page. -class ExpTestPage extends TestPage { - /// Experiment test page. - ExpTestPage({Key? key}) : super('Exp Tests', key: key) { - test('order_by', () async { - //await Sqflite.setDebugModeOn(true); - final path = await initDeleteDb('order_by_exp.db'); - final db = await openDatabase(path); - - const table = 'test'; - await db - .execute('CREATE TABLE $table (column_1 INTEGER, column_2 INTEGER)'); - // inserted in a wrong order to check ASC/DESC - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (11, 180)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (10, 180)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (10, 2000)'); - - final expectedResult = [ - {'column_1': 10, 'column_2': 2000}, - {'column_1': 10, 'column_2': 180}, - {'column_1': 11, 'column_2': 180} - ]; - - var result = await db.rawQuery( - 'SELECT * FROM $table ORDER BY column_1 ASC, column_2 DESC'); - //print(JSON.encode(result)); - expect(result, expectedResult); - result = await db.query(table, orderBy: 'column_1 ASC, column_2 DESC'); - expect(result, expectedResult); - - await db.close(); - }); - - test('in', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('simple_exp.db'); - final db = await openDatabase(path); - - const table = 'test'; - await db - .execute('CREATE TABLE $table (column_1 INTEGER, column_2 INTEGER)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (1, 1001)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (2, 1002)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (2, 1012)'); - await db - .execute('INSERT INTO $table (column_1, column_2) VALUES (3, 1003)'); - - final expectedResult = [ - {'column_1': 1, 'column_2': 1001}, - {'column_1': 2, 'column_2': 1002}, - {'column_1': 2, 'column_2': 1012} - ]; - - // testing with value in the In clause - var result = await db.query(table, - where: 'column_1 IN (1, 2)', orderBy: 'column_1 ASC, column_2 ASC'); - //print(JSON.encode(result)); - expect(result, expectedResult); - - // testing with value as arguments - result = await db.query(table, - where: 'column_1 IN (?, ?)', - whereArgs: ['1', '2'], - orderBy: 'column_1 ASC, column_2 ASC'); - expect(result, expectedResult); - - await db.close(); - }); - - test('Raw escaping', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('raw_escaping_fields.db'); - final db = await openDatabase(path); - - const table = 'table'; - await db.execute('CREATE TABLE "$table" ("group" INTEGER)'); - // inserted in a wrong order to check ASC/DESC - await db.execute('INSERT INTO "$table" ("group") VALUES (1)'); - - final expectedResult = [ - {'group': 1} - ]; - - var result = await db - .rawQuery('SELECT "group" FROM "$table" ORDER BY "group" DESC'); - - print(result); - expect(result, expectedResult); - result = - await db.rawQuery("SELECT * FROM '$table' ORDER BY `group` DESC"); - //print(JSON.encode(result)); - expect(result, expectedResult); - - await db.rawDelete("DELETE FROM '$table'"); - - await db.close(); - }); - - test('Escaping fields', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('escaping_fields.db'); - final db = await openDatabase(path); - - const table = 'group'; - await db.execute('CREATE TABLE "$table" ("group" TEXT)'); - // inserted in a wrong order to check ASC/DESC - - await db.insert(table, {'group': 'group_value'}); - await db.update(table, {'group': 'group_new_value'}, - where: "\"group\" = 'group_value'"); - - final expectedResult = [ - {'group': 'group_new_value'} - ]; - - final result = - await db.query(table, columns: ['group'], orderBy: '"group" DESC'); - //print(JSON.encode(result)); - expect(result, expectedResult); - - await db.delete(table); - - await db.close(); - }); - - test('Functions', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('exp_functions.db'); - final db = await openDatabase(path); - - const table = 'functions'; - await db.execute('CREATE TABLE "$table" (one TEXT, another TEXT)'); - await db.insert(table, {'one': '1', 'another': '2'}); - await db.insert(table, {'one': '1', 'another': '3'}); - await db.insert(table, {'one': '2', 'another': '2'}); - - var result = await db.rawQuery(''' - select one, GROUP_CONCAT(another) as my_col - from $table - GROUP BY one'''); - //print('result :$result'); - expect(result, [ - {'one': '1', 'my_col': '2,3'}, - {'one': '2', 'my_col': '2'} - ]); - - result = await db.rawQuery(''' - select one, GROUP_CONCAT(another) - from $table - GROUP BY one'''); - // print('result :$result'); - expect(result, [ - {'one': '1', 'GROUP_CONCAT(another)': '2,3'}, - {'one': '2', 'GROUP_CONCAT(another)': '2'} - ]); - - // user alias - result = await db.rawQuery(''' - select t.one, GROUP_CONCAT(t.another) - from $table as t - GROUP BY t.one'''); - //print('result :$result'); - expect(result, [ - {'one': '1', 'GROUP_CONCAT(t.another)': '2,3'}, - {'one': '2', 'GROUP_CONCAT(t.another)': '2'} - ]); - - await db.close(); - }); - - test('Alias', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('exp_alias.db'); - final db = await openDatabase(path); - - try { - const table = 'alias'; - await db.execute( - 'CREATE TABLE $table (column_1 INTEGER, column_2 INTEGER)'); - await db.insert(table, {'column_1': 1, 'column_2': 2}); - - final result = await db.rawQuery(''' - select t.column_1, t.column_1 as "t.column1", column_1 as column_alias_1, column_2 - from $table as t'''); - print('result :$result'); - expect(result, [ - {'t.column1': 1, 'column_1': 1, 'column_alias_1': 1, 'column_2': 2} - ]); - } finally { - await db.close(); - } - }); - - test('Dart2 query', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('exp_dart2_query.db'); - final db = await openDatabase(path); - - try { - const table = 'test'; - await db.execute( - 'CREATE TABLE $table (column_1 INTEGER, column_2 INTEGER)'); - await db.insert(table, {'column_1': 1, 'column_2': 2}); - - final result = await db.rawQuery(''' - select column_1, column_2 - from $table as t - '''); - print('result: $result'); - // test output types - print('result.first: ${result.first}'); - final first = result.first; - print('result.first.keys: ${first.keys}'); - var keys = result.first.keys; - var values = result.first.values; - verify(keys.first == 'column_1' || keys.first == 'column_2'); - verify(values.first == 1 || values.first == 2); - print('result.last.keys: ${result.last.keys}'); - keys = result.last.keys; - values = result.last.values; - verify(keys.last == 'column_1' || keys.last == 'column_2'); - verify(values.last == 1 || values.last == 2); - } finally { - await db.close(); - } - }); - /* - - Save code that modify a map from a result - unused - var rawResult = await rawQuery(builder.sql, builder.arguments); - - // Super slow if we escape a name, please avoid it - // This won't be called if no keywords were used - if (builder.hasEscape) { - for (Map map in rawResult) { - var keys = new Set(); - - for (String key in map.keys) { - if (isEscapedName(key)) { - keys.add(key); - } - } - if (keys.isNotEmpty) { - for (var key in keys) { - var value = map[key]; - map.remove(key); - map[unescapeName(key)] = value; - } - } - } - } - return rawResult; - */ - test('Issue#48', () async { - // Sqflite.devSetDebugModeOn(true); - // devPrint('issue #48'); - // Try to query on a non-indexed field - final path = await initDeleteDb('exp_issue_48.db'); - final db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE npa (id INT, title TEXT, identifier TEXT)'); - await db.insert( - 'npa', {'id': 128, 'title': 'title 1', 'identifier': '0001'}); - await db.insert('npa', - {'id': 215, 'title': 'title 1', 'identifier': '0008120150514'}); - }); - var resultSet = await db.query('npa', - columns: ['id', 'title', 'identifier'], - where: '"identifier" = ?', - whereArgs: ['0008120150514']); - // print(resultSet); - expect(resultSet.length, 1); - // but the results is always - empty QueryResultSet[]. - // If i'm trying to do the same with the id field and integer value like - resultSet = await db.query('npa', - columns: ['id', 'title', 'identifier'], - where: '"id" = ?', - whereArgs: [215]); - // print(resultSet); - expect(resultSet.length, 1); - await db.close(); - }); - - test('Issue#52', () async { - // Sqflite.devSetDebugModeOn(true); - // Try to insert string with quote - final path = await initDeleteDb('exp_issue_52.db'); - final db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE test (id INT, value TEXT)'); - await db.insert('test', {'id': 1, 'value': 'without quote'}); - await db.insert('test', {'id': 2, 'value': 'with " quote'}); - }); - var resultSet = await db - .query('test', where: 'value = ?', whereArgs: ['with " quote']); - expect(resultSet.length, 1); - expect(resultSet.first['id'], 2); - - resultSet = await db - .rawQuery('SELECT * FROM test WHERE value = ?', ['with " quote']); - expect(resultSet.length, 1); - expect(resultSet.first['id'], 2); - await db.close(); - }); - - test('Issue#64', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('issue_64.db'); - - // delete existing if any - await deleteDatabase(path); - - // Copy from asset - final data = await rootBundle.load(join('assets', 'issue_64.db')); - final bytes = - data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); - await writeFileAsBytes(path, bytes); - - // open the database - final db = await openDatabase(path); - - var result = await db.query('recordings', - columns: ['id', 'content', 'file', 'speaker', 'reference']); - print('result1: $result'); - expect(result.length, 2); - - // This one does not work - // to investigate - result = await db.query('recordings', - columns: ['id', 'content', 'file', 'speaker', 'reference'], - where: 'speaker = ?', - whereArgs: [1]); - - print('result2: $result'); - expect(result.length, 2); - - result = await db.query( - 'recordings', - columns: ['id', 'content', 'file', 'speaker', 'reference'], - where: 'speaker = 1', - ); - print('result3: $result'); - expect(result.length, 2); - - await db.close(); - }); - - test('sql dump file', () async { - // await Sqflite.devSetDebugModeOn(true); - - // try to import an sql dump file (not working) - final path = await initDeleteDb('sql_file.db'); - final db = await openDatabase(path); - try { - const table = 'test'; - const sql = ''' -CREATE TABLE test (value INTEGER); -INSERT INTO test (value) VALUES (1); -INSERT INTO test (value) VALUES (10); -'''; - await db.execute(sql); - // that should be the expected result - // var expectedResult = [ - // {'value': 1}, - // {'value': 10} - // ]; - final result = await db.rawQuery('SELECT * FROM $table'); - print(json.encode(result)); - - // However (at least on Android) - // result is empty, only the first statement is executed - // Ok when using ffi... - if (platform.isLinux) { - // Ok when using ffi linux implementation - // TODO check windows and mac. - // that should be the expected result - var expectedResult = [ - {'value': 1}, - {'value': 10} - ]; - expect(result, expectedResult); - } else { - expect(result, isEmpty); - } - } finally { - await db.close(); - } - }); - - test('Issue#164', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('issue_164.db'); - - final db = await openDatabase(path); - try { - await db.execute(''' -CREATE TABLE test ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - label TEXT NOT NULL, - UNIQUE (label) ON CONFLICT IGNORE -); -'''); - // inserted in a wrong order to check ASC/DESC - var id = await db.rawInsert(''' - INSERT INTO test (label) VALUES(?) - ''', ['label-1']); - expect(id, 1); - - id = await db.rawInsert(''' - INSERT INTO test (label) VALUES(?) - ''', ['label-2']); - expect(id, 2); - - id = await db.rawInsert(''' - INSERT INTO test (label) VALUES(?) - ''', ['label-1']); - expect(id, 0); - } finally { - await db.close(); - } - }); - - test('Defensive mode', () async { - // This shold succeed even on on iOS 14 - final db = await openDatabase(inMemoryDatabasePath); - try { - await db.execute('CREATE TABLE Test(value TEXT)'); - // Workaround for iOS 14 - await db.execute('PRAGMA sqflite -- db_config_defensive_off'); - await db.execute('PRAGMA writable_schema = ON'); - expect( - await db.update( - 'sqlite_master', {'sql': 'CREATE TABLE Test(value BLOB)'}, - where: 'name = \'Test\' and type = \'table\''), - 1); - } finally { - await db.close(); - } - }); - - test('Defensive mode (should fail on iOS 14)', () async { - // This shold fail on iOS 14 - final db = await openDatabase(inMemoryDatabasePath); - try { - await db.execute('CREATE TABLE Test(value TEXT)'); - await db.execute('PRAGMA writable_schema = ON'); - expect( - await db.update( - 'sqlite_master', {'sql': 'CREATE TABLE Test(value BLOB)'}, - where: 'name = \'Test\' and type = \'table\''), - 1); - } finally { - await db.close(); - } - }); - - test('ATTACH database', () async { - final db1Path = await initDeleteDb('attach1.db'); - final db2Path = await initDeleteDb('attach2.db'); - - // Create some data on db1 and close it - var db1 = await databaseFactory.openDatabase(db1Path); - try { - var batch = db1.batch(); - batch.execute('CREATE TABLE table1 (col1 INTEGER)'); - batch.insert('table1', {'col1': 1234}); - await batch.commit(); - } finally { - await db1.close(); - } - - // Open a new db2 database, attach db1 and query it - - var db2 = await databaseFactory.openDatabase(db2Path); - try { - await db2.execute('ATTACH DATABASE \'$db1Path\' AS db1'); - var rows = await db2.query('db1.table1'); - expect(rows, [ - {'col1': 1234} - ]); - } finally { - await db2.close(); - } - }); - - /// fts4 - var fts4Supports = supportsCompatMode; - if (fts4Supports) { - test('Issue#206', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('issue_206.db'); - - final db = await openDatabase(path); - try { - final sqls = LineSplitter.split( - '''CREATE VIRTUAL TABLE Food using fts4(description TEXT) - INSERT Into Food (description) VALUES ('banana') - INSERT Into Food (description) VALUES ('apple')'''); - final batch = db.batch(); - for (var sql in sqls) { - batch.execute(sql); - } - await batch.commit(); - - final results = await db.rawQuery( - 'SELECT description, matchinfo(Food) as matchinfo FROM Food WHERE Food MATCH ?', - ['ban*']); - print(results); - // matchinfo is currently returned as binary bloc - expect(results.length, 1); - final map = results.first; - final matchInfo = map['matchinfo'] as Uint8List; - - // Convert to Uint32List - final uint32ListLength = matchInfo.length ~/ 4; - final uint32List = Uint32List(uint32ListLength); - final data = ByteData.view( - matchInfo.buffer, matchInfo.offsetInBytes, matchInfo.length); - for (var i = 0; i < uint32ListLength; i++) { - uint32List[i] = data.getUint32(i * 4, Endian.host); - } - // print(uint32List); - expect(uint32List, [1, 1, 1, 1, 1]); - expect(map['matchinfo'], const TypeMatcher()); - } finally { - await db.close(); - } - }); - } - - test('Log level', () async { - // test setting log level - Database? db; - try { - // ignore: deprecated_member_use - await databaseFactory.setLogLevel(sqfliteLogLevelVerbose); - //await databaseFactory.setLogLevel(sqfliteLogLevelSql); - db = await openDatabase(inMemoryDatabasePath); - await db.execute('CREATE TABLE test (value TEXT UNIQUE)'); - const table = 'test'; - final map = {'value': 'test'}; - await db.insert(table, map, - conflictAlgorithm: ConflictAlgorithm.replace); - expect( - Sqflite.firstIntValue(await db.query(table, columns: ['COUNT(*)'])), - 1); - } finally { - // ignore: deprecated_member_use - await databaseFactory.setLogLevel(sqfliteLogLevelNone); - await db?.close(); - } - }); - - Future testBigBlog(int size) async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('big_blob.db'); - var db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value BLOB)'); - }); - try { - var blob = - Uint8List.fromList(List.generate(size, (index) => index % 256)); - var id = await db.insert('Test', {'value': blob}); - - /// Get the value field from a given id - Future getValue(int id) async { - return ((await db.query('Test', where: 'id = $id')).first)['value'] - as Uint8List; - } - - expect((await getValue(id)).length, blob.length); - } finally { - await db.close(); - } - } - - // We don't test automatically above as it crashes seriously on Android - test('big blob 800 Ko', () async { - await testBigBlog(800000); - }); - - Future testBigText(int size) async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('big_text.db'); - var db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - }); - try { - var text = List.generate(size, (index) => 'A').join(); - var id = await db.insert('Test', {'value': text}); - - /// Get the value field from a given id - Future getValue(int id) async { - return ((await db.query('Test', where: 'id = $id')).first)['value'] - as String; - } - - expect((await getValue(id)).length, text.length); - } finally { - await db.close(); - } - } - - // We don't test automatically above as it crashes seriously on Android - test('big text 800 Ko', () async { - await testBigText(800000); - }); - /* - test('big blob 1500 Ko (fails on Android sqlite)', () async { - await testBigBlog(1500000); - }); - test('big blob 2 Mo (fails on Android sqlite)', () async { - await testBigBlog(2000000); - }); - test('big blob 15 Mo (fails on Android sqlite)', () async { - await testBigBlog(15000000); - }); - */ - /* - test('Isolate', () async { - // This test does not work yet - // Need background registration. I Kept the code for future reference - await Future.sync(() async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('isolate.db'); - - // Open the db in the main isolate - Database db = - await openDatabase(path, version: 1, onCreate: (db, version) { - db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - }); - try { - await insert(db, 1); - expect(await db.rawQuery('SELECT id, name FROM Test'), [ - {'id': 1, 'name': 'item 1'} - ]); - - // Keep it open and run the isolate - final receivePort = ReceivePort(); - await Isolate.spawn(simpleInsertQueryIsolate, receivePort.sendPort); - - int index = 0; - SendPort sendPort; - List> results; - var completer = Completer(); - var subscription = receivePort.listen((data) { - switch (index++) { - case 0: - // first is the port to send - sendPort = data as SendPort; - // Send path - sendPort.send(path); - break; - case 1: - // second is result - results = data as List>; - completer.complete(); - break; - } - }); - await completer.future; - await subscription?.cancel(); - - print(results); - expect(results, {}); - - // Query again in main isolate - expect(await db.rawQuery('SELECT id, name FROM Test'), {}); - } finally { - await db.close(); - } - }).timeout(Duration(seconds: 3)); - }); - */ - test('missing parameter', () async { - var db = await openDatabase(inMemoryDatabasePath); - await db.execute( - 'CREATE TABLE IF NOT EXISTS foo (id int primary key, name text)'); - var missingParameterShouldFail = !supportsCompatMode; - try { - await db.rawQuery('SELECT * FROM foo WHERE id=?'); - } catch (e) { - expect(missingParameterShouldFail, isTrue); - } - await db.close(); - }); - // Issue https://github.com/tekartik/sqflite/issues/929 - // Pragma has to use rawQuery...why, on sqflite Android - test('wal', () async { - // await Sqflite.devSetDebugModeOn(true); - var db = await openDatabase(inMemoryDatabasePath); - try { - await db.execute('PRAGMA journal_mode=WAL'); - } catch (e) { - print(e); - await db.rawQuery('PRAGMA journal_mode=WAL'); - } - await db.execute('CREATE TABLE test (id INTEGER)'); - await db.insert('test', {'id': 1}); - try { - var resultSet = await db.rawQuery('SELECT id FROM test'); - expect(resultSet, [ - {'id': 1}, - ]); - } finally { - await db.close(); - } - }); - } -} - -/// Insert a record with a given id. -Future insert(Database db, int id) async { - await db.insert('Test', {'id': id, 'name': 'item $id'}); -} - -/// Open, insert and query for isolate testing. -Future simpleInsertQueryIsolate(SendPort sendPort) async { - final receivePort = ReceivePort(); - // First share our receive port - sendPort.send(receivePort.sendPort); - - // Get the path - final path = await receivePort.first as String; - final db = await openDatabase(path, version: 1, onCreate: (db, version) { - db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - }); - List> results; - try { - await insert(db, 2); - results = await db.rawQuery('SELECT id, name FROM Test'); - print(results); - } finally { - await db.close(); - } - - // Done send the result - sendPort.send(results); -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/main.dart b/packages/sqflite/sqflite_aurora/example/lib/main.dart deleted file mode 100644 index 01783fe..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/main.dart +++ /dev/null @@ -1,204 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:sqflite_example/batch_test_page.dart'; -import 'package:sqflite_example/deprecated_test_page.dart'; -import 'package:sqflite_example/exception_test_page.dart'; -import 'package:sqflite_example/exp_test_page.dart'; -import 'package:sqflite_example/manual_test_page.dart'; -import 'package:sqflite_example/src/dev_utils.dart'; - -import 'model/main_item.dart'; -import 'open_test_page.dart'; -import 'raw_test_page.dart'; -import 'slow_test_page.dart'; -import 'src/main_item_widget.dart'; -import 'todo_test_page.dart'; -import 'type_test_page.dart'; - -void main() { - mainExampleApp(); -} - -/// Example app main entry point, exported for external application -/// -/// might move to a different shared package. -void mainExampleApp() { - WidgetsFlutterBinding.ensureInitialized(); - // debugAutoStartRouteName = testOpenRoute; - runApp(const SqfliteExampleApp()); -} - -/// Sqflite test app -class SqfliteExampleApp extends StatefulWidget { - /// test app. - const SqfliteExampleApp({Key? key}) : super(key: key); - // This widget is the root of your application. - - @override - // ignore: library_private_types_in_public_api - _SqfliteExampleAppState createState() => _SqfliteExampleAppState(); -} - -/// Simple test page. -const String testRawRoute = '/test/simple'; - -/// Open test page. -const String testOpenRoute = '/test/open'; - -/// Slow test page. -const String testSlowRoute = '/test/slow'; - -/// Type test page. -const String testTypeRoute = '/test/type'; - -/// Batch test page. -const String testBatchRoute = '/test/batch'; - -/// `todo` example test page. -const String testTodoRoute = '/test/todo'; - -/// Exception test page. -const String testExceptionRoute = '/test/exception'; - -/// Manual test page. -const String testManualRoute = '/test/manual'; - -/// Experiment test page. -const String testExpRoute = '/test/exp'; - -/// Deprecated test page. -const String testDeprecatedRoute = '/test/deprecated'; - -class _SqfliteExampleAppState extends State { - var routes = { - '/test': (BuildContext context) => MyHomePage(), - testRawRoute: (BuildContext context) => RawTestPage(), - testOpenRoute: (BuildContext context) => OpenTestPage(), - testSlowRoute: (BuildContext context) => SlowTestPage(), - testTodoRoute: (BuildContext context) => TodoTestPage(), - testTypeRoute: (BuildContext context) => TypeTestPage(), - testManualRoute: (BuildContext context) => const ManualTestPage(), - testBatchRoute: (BuildContext context) => BatchTestPage(), - testExceptionRoute: (BuildContext context) => ExceptionTestPage(), - testExpRoute: (BuildContext context) => ExpTestPage(), - testDeprecatedRoute: (BuildContext context) => DeprecatedTestPage(), - }; - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Sqflite Demo', - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with 'flutter run'. You'll see - // the application has a blue toolbar. Then, without quitting - // the app, try changing the primarySwatch below to Colors.green - // and then invoke 'hot reload' (press 'r' in the console where - // you ran 'flutter run', or press Run > Hot Reload App in IntelliJ). - // Notice that the counter didn't reset back to zero -- the application - // is not restarted. - primarySwatch: Colors.blue, - ), - home: MyHomePage(title: 'Sqflite Demo Home Page'), - routes: routes); - } -} - -/// App home menu page. -class MyHomePage extends StatefulWidget { - /// App home menu page. - MyHomePage({Key? key, this.title}) : super(key: key) { - _items.add( - MainItem('Raw tests', 'Raw SQLite operations', route: testRawRoute)); - _items.add(MainItem('Open tests', 'Open onCreate/onUpgrade/onDowngrade', - route: testOpenRoute)); - _items - .add(MainItem('Type tests', 'Test value types', route: testTypeRoute)); - _items.add(MainItem('Batch tests', 'Test batch operations', - route: testBatchRoute)); - _items.add( - MainItem('Slow tests', 'Lengthy operations', route: testSlowRoute)); - _items.add(MainItem( - 'Todo database example', 'Simple Todo-like database usage example', - route: testTodoRoute)); - _items.add(MainItem('Exp tests', 'Experimental and various tests', - route: testExpRoute)); - _items.add(MainItem('Exception tests', 'Tests that trigger exceptions', - route: testExceptionRoute)); - _items.add(MainItem('Manual tests', 'Tests that requires manual execution', - route: testManualRoute)); - _items.add(MainItem('Deprecated test', - 'Keeping some old tests for deprecated functionalities', - route: testDeprecatedRoute)); - - // Uncomment to view all logs - //Sqflite.devSetDebugModeOn(true); - } - - final List _items = []; - - /// Page title. - final String? title; - - @override - // ignore: library_private_types_in_public_api - _MyHomePageState createState() => _MyHomePageState(); -} - -String? _debugAutoStartRouteName; - -/// (debug) set the route to start with. -String? get debugAutoStartRouteName => _debugAutoStartRouteName; - -/// Deprecated to avoid calls -@Deprecated('Deb only') -set debugAutoStartRouteName(String? routeName) => - _debugAutoStartRouteName = routeName; - -class _MyHomePageState extends State { - int get _itemCount => widget._items.length; - - @override - void initState() { - super.initState(); - - Future.delayed(Duration.zero).then((_) async { - if (mounted) { - // Use it to auto start a test page - if (debugAutoStartRouteName != null) { - // only once - - // await Navigator.of(context).pushNamed(testExpRoute); - // await Navigator.of(context).pushNamed(testRawRoute); - final future = - Navigator.of(context).pushNamed(debugAutoStartRouteName!); - // ignore: deprecated_member_use_from_same_package - debugAutoStartRouteName = null; - await future; - // await Navigator.of(context).pushNamed(testExceptionRoute); - } - } - }); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Center( - child: Text('Sqflite demo', textAlign: TextAlign.center)), - ), - body: - ListView.builder(itemBuilder: _itemBuilder, itemCount: _itemCount)); - } - - //new Center(child: new Text('Running on: $_platformVersion\n')), - - Widget _itemBuilder(BuildContext context, int index) { - return MainItemWidget(widget._items[index], (MainItem item) { - Navigator.of(context).pushNamed(item.route!); - }); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/manual_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/manual_test_page.dart deleted file mode 100644 index c602122..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/manual_test_page.dart +++ /dev/null @@ -1,364 +0,0 @@ -import 'dart:typed_data'; - -import 'package:flutter/material.dart'; -import 'package:sqflite/sqflite.dart'; -// ignore: implementation_imports -import 'package:sqflite/src/factory_mixin.dart' as impl; -import 'package:sqflite/utils/utils.dart'; -import 'package:sqflite_example/src/item_widget.dart'; -import 'package:sqflite_example/utils.dart'; - -// ignore_for_file: avoid_print - -import 'model/item.dart'; -import 'src/common_import.dart'; - -/// Manual test page. -class ManualTestPage extends StatefulWidget { - /// Test page. - const ManualTestPage({Key? key}) : super(key: key); - - @override - // ignore: library_private_types_in_public_api - _ManualTestPageState createState() => _ManualTestPageState(); -} - -class _ManualTestPageState extends State { - Database? database; - static const String dbName = 'manual_test.db'; - - Future showToast(String message) async { - ScaffoldMessenger.of(context) - ..clearSnackBars() - ..showSnackBar(SnackBar( - content: Text(message), duration: const Duration(milliseconds: 300))); - } - - Future _openDatabase() async { - return database ??= await databaseFactory.openDatabase(dbName); - } - - Future _closeDatabase() async { - await database?.close(); - database = null; - } - - Future _deleteDatabase() async { - await databaseFactory.deleteDatabase(dbName); - } - - Future _incrementVersion() async { - final version = await database!.getVersion(); - print('version $version'); - await database!.setVersion(version + 1); - } - - late List items; - late List itemWidgets; - - Future pop() async { - return true; - } - - Future _addAndQuery({int? msDelay, bool? noSynchronized}) async { - // await databaseFactory.debugSetLogLevel(sqfliteLogLevelVerbose); - var db = await _openDatabase(); - - // ignore: invalid_use_of_visible_for_testing_member - db.internalsDoNotUseSynchronized = noSynchronized ?? false; - await db.transaction((txn) async { - await txn.execute( - 'CREATE TABLE IF NOT EXISTS Task(id INTEGER PRIMARY KEY, name TEXT)'); - await txn.execute('INSERT INTO Task(name) VALUES (?)', - ['task ${DateTime.now().toIso8601String()}']); - var count = - firstIntValue(await txn.query('Task', columns: [sqlCountColumn])); - unawaited(showToast('$count task(s)')); - if (msDelay != null) { - await Future.delayed(Duration(milliseconds: msDelay)); - } - }); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - items = [ - SqfMenuItem('SQLite version', () async { - final db = await openDatabase(inMemoryDatabasePath); - - final results = await db.rawQuery('select sqlite_version()'); - print('select sqlite_version(): $results'); - var version = results.first.values.first; - print('sqlite version: $version'); - await db.close(); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text('select sqlite_version(): $version'), - )); - } - }, summary: 'select sqlite_version()'), - SqfMenuItem('Factory information', () async { - var info = databaseFactory.toString(); - print('sqlite database factory: $info'); - unawaited(showToast(info)); - }, summary: 'toString()'), - SqfMenuItem('openDatabase', () async { - await _openDatabase(); - }, summary: 'Open the database'), - SqfMenuItem('transaction add and query and pause', () async { - await _addAndQuery(msDelay: 5000); - }, summary: 'open/create table/add/query/pause'), - SqfMenuItem('transaction add and query and pause no synchronized', - () async { - await _addAndQuery(msDelay: 5000, noSynchronized: true); - }, summary: 'open/create table/add/query/pause'), - SqfMenuItem('BEGIN EXCLUSIVE', () async { - final db = await _openDatabase(); - await db.execute('BEGIN EXCLUSIVE'); - }, - summary: - 'Execute than exit or hot-restart the application. Open the database if needed'), - SqfMenuItem('close', () async { - await _closeDatabase(); - }, - summary: - 'Execute after starting then exit the app using the back button on Android and restart from the launcher.'), - SqfMenuItem('delete', () async { - await _deleteDatabase(); - }, - summary: - 'Try open (then optionally) delete, exit or hot-restart then delete then open'), - SqfMenuItem('log level: none', () async { - // ignore: deprecated_member_use - await Sqflite.devSetOptions( - // ignore: deprecated_member_use - SqfliteOptions(logLevel: sqfliteLogLevelNone)); - }, summary: 'No logs'), - SqfMenuItem('log level: sql', () async { - // ignore: deprecated_member_use - await Sqflite.devSetOptions( - // ignore: deprecated_member_use - SqfliteOptions(logLevel: sqfliteLogLevelSql)); - }, summary: 'Log sql command and basic database operation'), - SqfMenuItem('log level: verbose', () async { - // ignore: deprecated_member_use - await Sqflite.devSetOptions( - // ignore: deprecated_member_use - SqfliteOptions(logLevel: sqfliteLogLevelVerbose)); - }, summary: 'Verbose logs, for debugging'), - SqfMenuItem('Get info', () async { - final factory = databaseFactory as impl.SqfliteDatabaseFactoryMixin; - final info = await factory.getDebugInfo(); - print(info.toString()); - }, summary: 'Implementation info (dev only)'), - SqfMenuItem('Increment version', () async { - print(await _incrementVersion()); - }, summary: 'Implementation info (dev only)'), - SqfMenuItem('Multiple db', () async { - await Navigator.of(context).push(MaterialPageRoute(builder: (_) { - return const MultipleDbTestPage(); - })); - }, summary: 'Open multiple databases'), - ...[800000, 1500000, 15000000, 150000000] - .map((size) => SqfMenuItem('Big blob $size', () async { - await testBigBlog(size); - })) - ]; - } - - Future testBigBlog(int size) async { - // await Sqflite.devSetDebugModeOn(true); - var db = await openDatabase(inMemoryDatabasePath, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value BLOB)'); - }); - try { - var blob = - Uint8List.fromList(List.generate(size, (index) => index % 256)); - var id = await db.insert('Test', {'value': blob}); - - /// Get the value field from a given id - Future getValue(int id) async { - return ((await db.query('Test', where: 'id = $id')).first)['value'] - as Uint8List; - } - - var ok = (await getValue(id)).length == blob.length; - if (mounted) { - ScaffoldMessenger.of(context) - .showSnackBar(SnackBar(content: Text('$size: $ok'))); - } - } finally { - await db.close(); - } - } - - @override - Widget build(BuildContext context) { - itemWidgets = items - .map((item) => ItemWidget( - item, - (item) async { - final stopwatch = Stopwatch()..start(); - final future = (item as SqfMenuItem).run(); - setState(() {}); - await future; - // always add a small delay - final elapsed = stopwatch.elapsedMilliseconds; - if (elapsed < 300) { - await sleep(300 - elapsed); - } - setState(() {}); - }, - summary: item.summary, - )) - .toList(growable: false); - return Scaffold( - appBar: AppBar( - title: const Text('Manual tests'), - ), - body: WillPopScope( - onWillPop: pop, - child: ListView( - children: itemWidgets, - ), - ), - ); - } -} - -/// Multiple db test page. -class MultipleDbTestPage extends StatelessWidget { - /// Test page. - const MultipleDbTestPage({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - Widget dbTile(String name) { - return ListTile( - title: Text(name), - onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (_) { - return SimpleDbTestPage( - dbName: name, - ); - })); - }, - ); - } - - return Scaffold( - appBar: AppBar( - title: const Text('Multiple databases'), - ), - body: ListView( - children: [ - dbTile('data1.db'), - dbTile('data2.db'), - dbTile('data3.db') - ], - ), - ); - } -} - -/// Simple db test page. -class SimpleDbTestPage extends StatefulWidget { - /// Simple db test page. - const SimpleDbTestPage({Key? key, required this.dbName}) : super(key: key); - - /// db name. - final String dbName; - - @override - // ignore: library_private_types_in_public_api - _SimpleDbTestPageState createState() => _SimpleDbTestPageState(); -} - -class _SimpleDbTestPageState extends State { - Database? database; - - Future _openDatabase() async { - // await Sqflite.devSetOptions(SqfliteOptions(logLevel: sqfliteLogLevelVerbose)); - return database ??= await databaseFactory.openDatabase(widget.dbName, - options: OpenDatabaseOptions( - version: 1, - onCreate: (db, version) async { - await db.execute('CREATE TABLE Test (value TEXT)'); - })); - } - - Future _closeDatabase() async { - await database?.close(); - database = null; - } - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('Simple db ${widget.dbName}'), - ), - body: Builder( - builder: (context) { - Widget menuItem(String title, void Function() onTap, - {String? summary}) { - return ListTile( - title: Text(title), - subtitle: summary == null ? null : Text(summary), - onTap: onTap, - ); - } - - Future countRecord() async { - final db = await _openDatabase(); - final result = - firstIntValue(await db.query('test', columns: ['COUNT(*)'])); - // Temp for nnbd successfull lint - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text('$result records'), - duration: const Duration(milliseconds: 700), - )); - } - } - - final items = [ - menuItem('open Database', () async { - await _openDatabase(); - }, summary: 'Open the database'), - menuItem('Add record', () async { - final db = await _openDatabase(); - await db.insert('test', {'value': 'some_value'}); - await countRecord(); - }, summary: 'Add one record. Open the database if needed'), - menuItem('Count record', () async { - await countRecord(); - }, summary: 'Count records. Open the database if needed'), - menuItem( - 'Close Database', - () async { - await _closeDatabase(); - }, - ), - menuItem( - 'Delete database', - () async { - await databaseFactory.deleteDatabase(widget.dbName); - }, - ), - ]; - return ListView( - children: items, - ); - }, - )); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/model/item.dart b/packages/sqflite/sqflite_aurora/example/lib/model/item.dart deleted file mode 100644 index 33569db..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/model/item.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:sqflite_example/src/common_import.dart'; - -/// Item states. -enum ItemState { - /// test not run yet. - none, - - /// test is running. - running, - - /// test succeeded. - success, - - /// test fails. - failure -} - -/// Menu item. -class Item { - /// Menu item. - Item(this.name); - - /// Menu item state. - ItemState state = ItemState.running; - - /// Menu item name/ - String name; -} - -/// Menu item implementation. -class SqfMenuItem extends Item { - /// Menu item implementation. - SqfMenuItem(String name, this.body, {this.summary}) : super(name) { - state = ItemState.none; - } - - /// Summary. - String? summary; - - /// Run the item. - Future run() { - state = ItemState.running; - return Future.delayed(const Duration()).then((_) async { - try { - await body(); - state = ItemState.success; - } catch (e) { - state = ItemState.failure; - rethrow; - } - }); - } - - /// Menu item body. - final FutureOr Function() body; -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/model/main_item.dart b/packages/sqflite/sqflite_aurora/example/lib/model/main_item.dart deleted file mode 100644 index 63fee3e..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/model/main_item.dart +++ /dev/null @@ -1,29 +0,0 @@ -/// Main item. -class MainItem { - /// Main item. - MainItem(this.title, this.description, {this.route}); - - /// Title. - String title; - - /// Description. - String description; - - /// Page route. - String? route; -} - -/// Main route item. -class MainRouteItem { - /// Main route item. - MainRouteItem(this.title, this.description, {this.route}); - - /// Title. - String title; - - /// Description. - String description; - - /// Page route. - MainRouteItem? route; -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/model/test.dart b/packages/sqflite/sqflite_aurora/example/lib/model/test.dart deleted file mode 100644 index fad2fd7..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/model/test.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'dart:async'; - -/// Test definition. -class Test { - /// Test definition. - Test(this.name, this.fn, {bool? solo, bool? skip}) - : solo = solo == true, - skip = skip == true; - - /// Only run this test. - final bool solo; - - /// Skip this test. - final bool skip; - - /// Test name. - String name; - - /// Test body. - FutureOr Function() fn; -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/open_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/open_test_page.dart deleted file mode 100644 index ed353da..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/open_test_page.dart +++ /dev/null @@ -1,955 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart' show rootBundle; -import 'package:flutter/services.dart'; -import 'package:path/path.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite/src/database_mixin.dart' // ignore: implementation_imports - show - SqfliteDatabaseMixin; -import 'package:sqflite/src/factory_mixin.dart' // ignore: implementation_imports - show - SqfliteDatabaseFactoryMixin; -import 'package:sqflite_example/utils.dart'; -import 'package:synchronized/synchronized.dart'; - -import 'src/common_import.dart'; -import 'test_page.dart'; -// ignore_for_file: avoid_slow_async_io -// ignore_for_file: avoid_print - -/// Open callbacks. -class OpenCallbacks { - /// Open callbacks. - OpenCallbacks() { - onConfigure = (Database db) { - // devPrint('onConfigure'); - //verify(!onConfigureCalled, 'onConfigure must be called once'); - expect(onConfigureCalled, false, - reason: - 'onConfigure already called'); // onConfigure must be called once - onConfigureCalled = true; - }; - - onCreate = (Database db, int version) { - //print('onCreate'); - expect(onConfigureCalled, true, reason: 'onConfigure not called'); - expect(onCreateCalled, false, reason: 'onCreate already called'); - onCreateCalled = true; - }; - - onOpen = (Database db) { - //print('onOpen'); - verify(onConfigureCalled, 'onConfigure must be called before onOpen'); - verify(!onOpenCalled!, 'onOpen already called'); - onOpenCalled = true; - }; - - onUpgrade = (Database db, int oldVersion, int newVersion) { - verify(onConfigureCalled, 'onConfigure not called in onUpgrade'); - verify(!onUpgradeCalled!, 'onUpgradeCalled already called'); - onUpgradeCalled = true; - }; - - onDowngrade = (Database db, int oldVersion, int newVersion) { - verify(onConfigureCalled, 'onConfigure not called'); - verify(!onDowngradeCalled!, 'onDowngrade already called'); - onDowngradeCalled = true; - }; - - reset(); - } - - /// true when onConfigure is called. - bool? onConfigureCalled; - - /// true when onOpen is called. - bool? onOpenCalled; - - /// true when onCreate is called. - bool? onCreateCalled; - - /// true when onDowngrade is called. - bool? onDowngradeCalled; - - /// true when onUpgrade is called. - bool? onUpgradeCalled; - - /// onCreate callback. - late OnDatabaseCreateFn onCreate; - - /// onConfigure callback. - OnDatabaseConfigureFn? onConfigure; - - /// onDowngrade callback. - late OnDatabaseVersionChangeFn onDowngrade; - - /// onUpgrade callback. - late OnDatabaseVersionChangeFn onUpgrade; - - /// onOpen callback. - late OnDatabaseOpenFn onOpen; - - /// reset callbacks called information. - void reset() { - onConfigureCalled = false; - onOpenCalled = false; - onCreateCalled = false; - onDowngradeCalled = false; - onUpgradeCalled = false; - } - - /// open the database. - Future open(String path, {required int version}) async { - reset(); - return await databaseFactory.openDatabase(path, - options: OpenDatabaseOptions( - version: version, - onCreate: onCreate, - onConfigure: onConfigure!, - onDowngrade: onDowngrade, - onUpgrade: onUpgrade, - onOpen: onOpen)); - } -} - -/// Check if a file is a valid database file -/// -/// An empty file is a valid empty sqlite file -Future isDatabase(String path) async { - Database? db; - var isDatabase = false; - try { - db = await openReadOnlyDatabase(path); - await db.getVersion(); - isDatabase = true; - } catch (_) { - } finally { - await db?.close(); - } - return isDatabase; -} - -/// Open test page. -class OpenTestPage extends TestPage { - /// Open test page. - OpenTestPage({Key? key}) : super('Open tests', key: key) { - final factory = databaseFactory; - - test('Databases path', () async { - // await Sqflite.devSetDebugModeOn(false); - final databasesPath = await factory.getDatabasesPath(); - // On Android we know it is current a 'databases' folder in the package folder - print('databasesPath: $databasesPath'); - if (platform.isAndroid) { - expect(basename(databasesPath), 'databases'); - } else if (platform.isIOS) { - expect(basename(databasesPath), 'Documents'); - } - final path = join(databasesPath, 'in_default_directory.db'); - await factory.deleteDatabase(path); - final db = await factory.openDatabase(path); - await db.close(); - }); - test('Delete database', () async { - // await Sqflite.devSetDebugModeOn(false); - final path = await initDeleteDb('delete_database.db'); - expect(await databaseExists(path), false); - final db = await openDatabase(path); - await db.close(); - expect((await pathExists(path)), true); - expect(await databaseExists(path), true); - print('Deleting database $path'); - await deleteDatabase(path); - expect((await pathExists(path)), false); - expect(await databaseExists(path), false); - }); - - test('Open no version', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_no_version.db'); - expect((await pathExists(path)), false); - final db = await openDatabase(path); - verify(await pathExists(path)); - expect(await db.getVersion(), 0); - await db.close(); - }); - - test('isOpen', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('is_open.db'); - expect((await pathExists(path)), false); - final db = await openDatabase(path); - expect(db.isOpen, true); - verify(await pathExists(path)); - await db.close(); - expect(db.isOpen, false); - }); - - test('Open no version onCreate', () async { - // should fail - final path = await initDeleteDb('open_no_version_on_create.db'); - verify(!(await pathExists(path))); - Database? db; - try { - db = await openDatabase(path, onCreate: (Database db, int version) { - // never called - verify(false); - }); - verify(false); - } on ArgumentError catch (_) {} - verify(!await pathExists(path)); - expect(db, null); - }); - - test('Open onCreate', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_test2.db'); - var onCreate = false; - var onCreateTransaction = false; - final db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - expect(version, 1); - onCreate = true; - - await db.transaction((txn) async { - await txn.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)'); - onCreateTransaction = true; - }); - }); - verify(onCreate); - expect(onCreateTransaction, true); - expect(await db.getVersion(), 1); - await db.close(); - }); - - test('Simple onCreate', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_simple_on_create.db'); - expect(await isDatabase(path), isFalse); - - final db = - await openDatabase(path, version: 1, onCreate: (db, version) async { - final batch = db.batch(); - - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, text NAME)'); - await batch.commit(); - }); - try { - expect( - await db.rawInsert('INSERT INTO Test (text) VALUES (?)', ['test']), - 1); - final result = await db.query('Test'); - final expected = [ - {'id': 1, 'text': 'test'} - ]; - expect(result, expected); - - expect(await isDatabase(path), isTrue); - } finally { - await db.close(); - } - expect(await isDatabase(path), isTrue); - }); - - test('Open 2 databases', () async { - //await Sqflite.devSetDebugModeOn(true); - final path1 = await initDeleteDb('open_db_1.db'); - final path2 = await initDeleteDb('open_db_2.db'); - final db1 = await openDatabase(path1, version: 1); - final db2 = await openDatabase(path2, version: 1); - await db1.close(); - await db2.close(); - }); - - test('Open onUpgrade', () async { - // await Sqflite.devSetDebugModeOn(true); - var onUpgrade = false; - final path = await initDeleteDb('open_on_upgrade.db'); - var database = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE Test(id INTEGER PRIMARY KEY)'); - }); - try { - await database - .insert('Test', {'id': 1, 'name': 'test'}); - fail('should fail'); - } on DatabaseException catch (e) { - print(e); - } - expect(await database.getVersion(), 1); - await database.close(); - database = await openDatabase(path, version: 2, - onUpgrade: (Database db, int oldVersion, int newVersion) async { - expect(oldVersion, 1); - expect(newVersion, 2); - await db.execute('ALTER TABLE Test ADD name TEXT'); - onUpgrade = true; - }); - verify(onUpgrade); - expect(await database.getVersion(), 2); - try { - expect( - await database - .insert('Test', {'id': 1, 'name': 'test'}), - 1); - } finally { - await database.close(); - } - }); - - test('Open onDowngrade', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_on_downgrade.db'); - var database = await openDatabase(path, version: 2, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE Test(id INTEGER PRIMARY KEY)'); - }, onDowngrade: (Database db, int oldVersion, int newVersion) async { - verify(false, 'should not be called'); - }); - expect(await database.getVersion(), 2); - await database.close(); - - var onDowngrade = false; - database = await openDatabase(path, version: 1, - onDowngrade: (Database db, int oldVersion, int newVersion) async { - expect(oldVersion, 2); - expect(newVersion, 1); - await db.execute('ALTER TABLE Test ADD name TEXT'); - onDowngrade = true; - }); - verify(onDowngrade); - expect(await database.getVersion(), 1); - - await database.close(); - }); - - test('Open bad path', () async { - try { - await openDatabase('/invalid_path'); - fail(); - } on DatabaseException catch (e) { - verify(e.isOpenFailedError()); - } - }); - - test('Open asset database', () async { - // await Sqflite.devSetDebugModeOn(false); - final databasesPath = await getDatabasesPath(); - final path = join(databasesPath, 'asset_example.db'); - - // delete existing if any - await deleteDatabase(path); - - // Make sure the parent directory exists - try { - await createDirectory(path); - } catch (_) {} - - // Copy from asset - final data = await rootBundle.load(join('assets', 'example.db')); - final List bytes = - data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); - // Write and flush the bytes written - await writeFileAsBytes(path, bytes, flush: true); - - // open the database - final db = await openDatabase(path); - - // Our database as a single table with a single element - final list = await db.rawQuery('SELECT * FROM Test'); - print('list $list'); - expect(list.first['name'], 'simple value'); - - await db.close(); - }); - - test('Open on configure', () async { - final path = await initDeleteDb('open_on_configure.db'); - - var onConfigured = false; - var onConfiguredTransaction = false; - Future onConfigure(Database db) async { - onConfigured = true; - await db.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)'); - await db.transaction((txn) async { - await txn.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)'); - onConfiguredTransaction = true; - }); - } - - final db = await openDatabase(path, onConfigure: onConfigure); - expect(onConfigured, true); - expect(onConfiguredTransaction, true); - - await db.close(); - }); - - test('Open onDowngrade delete', () async { - // await Sqflite.devSetDebugModeOn(false); - - final path = await initDeleteDb('open_on_downgrade_delete.db'); - var database = await openDatabase(path, version: 3, - onCreate: (Database db, int version) async { - await db.execute('CREATE TABLE Test(id INTEGER PRIMARY KEY)'); - }); - await database.close(); - - // should fail going back in versions - var onCreated = false; - var onOpened = false; - var onConfiguredOnce = false; // onConfigure will be called twice here - // since the database is re-opened - var onConfigured = false; - database = - await openDatabase(path, version: 2, onConfigure: (Database db) { - // Must not be configured nor created yet - verify(!onConfigured); - verify(!onCreated); - if (!onConfiguredOnce) { - // first time - onConfiguredOnce = true; - } else { - onConfigured = true; - } - }, onCreate: (Database db, int version) { - verify(onConfigured); - verify(!onCreated); - verify(!onOpened); - onCreated = true; - expect(version, 2); - }, onOpen: (Database db) { - verify(onCreated); - onOpened = true; - }, onDowngrade: onDatabaseDowngradeDelete); - await database.close(); - - expect(onCreated, true); - expect(onOpened, true); - expect(onConfigured, true); - - onCreated = false; - onOpened = false; - - database = await openDatabase(path, version: 2, - onCreate: (Database db, int version) { - expect(false, 'should not be called'); - }, onOpen: (Database db) { - onOpened = true; - }, onDowngrade: onDatabaseDowngradeDelete); - expect(onOpened, true); - await database.close(); - }); - - test('All open callback', () async { - // await Sqflite.devSetDebugModeOn(false); - final path = await initDeleteDb('open_all_callbacks.db'); - - var step = 1; - final openCallbacks = OpenCallbacks(); - var db = await openCallbacks.open(path, version: 1); - try { - verify(openCallbacks.onConfigureCalled, 'onConfiguredCalled $step'); - verify(openCallbacks.onCreateCalled, 'onCreateCalled $step'); - verify(openCallbacks.onOpenCalled, 'onOpenCalled $step'); - verify(!openCallbacks.onUpgradeCalled!, 'onUpgradeCalled $step'); - verify(!openCallbacks.onDowngradeCalled!, 'onDowngradeCalled $step'); - await db.close(); - - ++step; - db = await openCallbacks.open(path, version: 3); - verify(openCallbacks.onConfigureCalled, 'onConfiguredCalled $step'); - verify(!openCallbacks.onCreateCalled!, 'onCreateCalled $step'); - verify(openCallbacks.onOpenCalled, 'onOpenCalled $step'); - verify(openCallbacks.onUpgradeCalled, 'onUpgradeCalled $step'); - verify(!openCallbacks.onDowngradeCalled!, 'onDowngradeCalled $step'); - await db.close(); - - ++step; - // devPrint('downgrading'); - db = await openCallbacks.open(path, version: 2); - verify(openCallbacks.onConfigureCalled, 'onConfiguredCalled $step'); - verify(!openCallbacks.onCreateCalled!, 'onCreateCalled $step'); - verify(openCallbacks.onOpenCalled, 'onOpenCalled $step'); - verify(!openCallbacks.onUpgradeCalled!, 'onDowngradeCalled $step'); - verify(openCallbacks.onDowngradeCalled, 'onDowngradCalled $step'); - await db.close(); - // devPrint('downgrading delete'); - openCallbacks.onDowngrade = onDatabaseDowngradeDelete; - var configureCount = 0; - final callback = openCallbacks.onConfigure; - // allow being called twice - openCallbacks.onConfigure = (Database db) { - if (configureCount == 1) { - openCallbacks.onConfigureCalled = false; - } - configureCount++; - callback!(db); - }; - ++step; - db = await openCallbacks.open(path, version: 1); - - /* - verify(openCallbacks.onConfigureCalled,'onConfiguredCalled $step'); - verify(configureCount == 2, 'onConfigure count'); - verify(openCallbacks.onCreateCalled, 'onCreateCalled $step'); - verify(openCallbacks.onOpenCalled, 'onOpenCalled $step'); - verify(!openCallbacks.onUpgradeCalled, 'onUpgradeCalled $step'); - verify(!openCallbacks.onDowngradeCalled, 'onDowngradCalled $step'); - */ - } finally { - await db.close(); - } - }); - - test('Open batch', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_batch.db'); - - Future onConfigure(Database db) async { - final batch = db.batch(); - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - await batch.commit(); - } - - Future onCreate(Database db, int version) async { - final batch = db.batch(); - // await db.execute('INSERT INTO Test(value) VALUES("value1")'); This does not work using ffi! - batch.execute('INSERT INTO Test(value) VALUES(?)', ['value1']); - await batch.commit(); - } - - Future onOpen(Database db) async { - final batch = db.batch(); - //batch.rawInsert('INSERT INTO Test(value) VALUES("value2")'); - batch.rawInsert('INSERT INTO Test(value) VALUES(?)', ['value2']); - await batch.commit(); - } - - final db = await openDatabase(path, - version: 1, - onConfigure: onConfigure, - onCreate: onCreate, - onOpen: onOpen); - expect( - Sqflite.firstIntValue(await db.rawQuery('SELECT COUNT(*) FROM Test')), - 2); - - await db.close(); - }); - - test('Open read-only', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_read_only.db'); - - Future onCreate(Database db, int version) async { - final batch = db.batch(); - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - //batch.rawInsert('INSERT INTO Test(value) VALUES("value1")'); This does not work using ffi - batch.rawInsert('INSERT INTO Test(value) VALUES(?)', ['value1']); - await batch.commit(); - } - - var db = await openDatabase(path, version: 1, onCreate: onCreate); - expect( - Sqflite.firstIntValue(await db.rawQuery('SELECT COUNT(*) FROM Test')), - 1); - - await db.close(); - - db = await openReadOnlyDatabase(path); - expect( - Sqflite.firstIntValue(await db.rawQuery('SELECT COUNT(*) FROM Test')), - 1); - - try { - await db.rawInsert('INSERT INTO Test(value) VALUES(?)', ['value1']); - fail('should fail'); - } on DatabaseException catch (e) { - // Error DatabaseException(attempt to write a readonly database (code 8)) running Open read-only - expect(e.isReadOnlyError(), true); - } - - final batch = db.batch(); - batch.rawQuery('SELECT COUNT(*) FROM Test'); - await batch.commit(); - - await db.close(); - }); - - test('Open demo (doc)', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_read_only.db'); - - { - Future onConfigure(Database db) async { - // Add support for cascade delete - await db.execute('PRAGMA foreign_keys = ON'); - } - - final db = await openDatabase(path, onConfigure: onConfigure); - await db.close(); - } - - { - Future onCreate(Database db, int version) async { - // Database is created, delete the table - await db.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - } - - Future onUpgrade(Database db, int oldVersion, int newVersion) async { - // Database version is updated, alter the table - await db.execute('ALTER TABLE Test ADD name TEXT'); - } - - // Special callback used for onDowngrade here to recreate the database - final db = await openDatabase(path, - version: 1, - onCreate: onCreate, - onUpgrade: onUpgrade, - onDowngrade: onDatabaseDowngradeDelete); - await db.close(); - } - - { - Future onOpen(Database db) async { - // Database is open, print its version - print('db version ${await db.getVersion()}'); - } - - final db = await openDatabase( - path, - onOpen: onOpen, - ); - await db.close(); - } - - // asset (use existing copy if any - { - // Check if we have an existing copy first - final databasesPath = await getDatabasesPath(); - final path = join(databasesPath, 'demo_asset_example.db'); - - // try opening (will work if it exists) - Database? db; - try { - db = await openDatabase(path, readOnly: true); - } catch (e) { - print('Error $e'); - } - - if (db == null) { - // Should happen only the first time you launch your application - print('Creating new copy from asset'); - - // Copy from asset - final data = await rootBundle.load(join('assets', 'example.db')); - final bytes = - data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); - await writeFileAsBytes(path, bytes); - - // open the database - db = await openDatabase(path, readOnly: true); - } else { - print('Opening existing database'); - } - - await db.close(); - } - }); - - test('Database locked (doc)', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_locked.db'); - final helper = Helper(path); - - // without the synchronized fix, this could faild - for (var i = 0; i < 100; i++) { - // ignore: unawaited_futures - helper.getDb(); - } - final db = await helper.getDb(); - await db.close(); - }); - - test('single/multi instance (using factory)', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('instances_test.db'); - Database? db1, db2, db3; - try { - db1 = await databaseFactory.openDatabase(path, - options: OpenDatabaseOptions(singleInstance: false)); - db2 = await databaseFactory.openDatabase(path, - options: OpenDatabaseOptions(singleInstance: true)); - db3 = await databaseFactory.openDatabase(path, - options: OpenDatabaseOptions(singleInstance: true)); - expect(db1, isNot(db2)); - expect(db2, db3); - } finally { - await db1!.close(); - await db2!.close(); - await db3!.close(); // safe to close the same instance - } - }); - - test('single/multi instance', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('instances_test.db'); - final db1 = await openDatabase(path, singleInstance: false); - final db2 = await openDatabase(path, singleInstance: true); - final db3 = await openDatabase(path, singleInstance: true); - verify(db1 != db2); - verify(db2 == db3); - await db1.close(); - await db2.close(); - await db3.close(); // safe to close the same instance - }); - - test('In memory database', () async { - const inMemoryPath = - inMemoryDatabasePath; // tried null without success, as it crashes on Android - const path = inMemoryPath; - - var db = await openDatabase(path); - await db - .execute('CREATE TABLE IF NOT EXISTS Test(id INTEGER PRIMARY KEY)'); - await db.insert('Test', {'id': 1}); - expect(await db.query('Test'), [ - {'id': 1} - ]); - await db.close(); - - // reopen, content should be gone - db = await openDatabase(path); - try { - await db.query('Test'); - fail('fail'); - } on DatabaseException catch (e) { - print(e); - } - await db.close(); - }); - - test('Not in memory database', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('not_in_memory.db'); - - var db = await openDatabase(path); - await db - .execute('CREATE TABLE IF NOT EXISTS Test(id INTEGER PRIMARY KEY)'); - await db.insert('Test', {'id': 1}); - expect(await db.query('Test'), [ - {'id': 1} - ]); - await db.close(); - - // reopen, content should be done - db = await openDatabase(path); - expect(await db.query('Test'), [ - {'id': 1} - ]); - await db.close(); - }); - - test('open in sub directory', () async { - final databasesPath = await factory.getDatabasesPath(); - final path = join(databasesPath, 'sub_that_should_not_exists'); - try { - await deleteDirectory(path); - } catch (_) {} - final dbPath = join(path, 'open.db'); - final db = await factory.openDatabase(dbPath); - try {} finally { - await db.close(); - } - }); - - test('open in sub sub directory', () async { - // await Sqflite.devSetDebugModeOn(true); - final databasesPath = await factory.getDatabasesPath(); - final path = - join(databasesPath, 'sub2_that_should_not_exists', 'sub_sub'); - try { - await deleteDirectory(path); - } catch (_) {} - expect(await existsDirectory(path), false); - final dbPath = join(path, 'open.db'); - final db = await factory.openDatabase(dbPath); - try {} finally { - await db.close(); - } - }); - - test('open_close_open_no_wait', () async { - // await Sqflite.devSetDebugModeOn(true); - const path = 'open_close_open_no_wait.db'; - final factory = databaseFactory; - await factory.deleteDatabase(path); - final db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - try { - expect(await db.getVersion(), 1); - // close no wait - unawaited(db.close()); - final db2 = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - print('$db, $db2'); - verify(db != db2); - verify((db as SqfliteDatabaseMixin).id != - (db2 as SqfliteDatabaseMixin).id); - expect(await db2.getVersion(), 1); - } finally { - await db.close(); - } - }); - test('close in transaction', () async { - // await Sqflite.devSetDebugModeOn(true); - const path = 'test_close_in_transaction.db'; - final factory = databaseFactory; - await factory.deleteDatabase(path); - var db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - try { - //await db.getVersion(); - await db.execute('BEGIN IMMEDIATE'); - await db.close(); - - db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - } finally { - await db.close(); - } - }); - - test('Open in transaction', () async { - // await Sqflite.devSetDebugModeOn(true); - const path = 'test_open_in_transaction.db'; - final factory = databaseFactory; - await factory.deleteDatabase(path); - var db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - try { - //await db.getVersion(); - await db.execute('BEGIN IMMEDIATE'); - // Trick to make sure we don't reuse the same instance during open - (factory as SqfliteDatabaseFactoryMixin) - .databaseOpenHelpers - .remove(db.path); - - final db2 = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - print('after open'); - verify(db != db2); - expect( - (db as SqfliteDatabaseMixin).id, (db2 as SqfliteDatabaseMixin).id); - //await db.getVersion(); - //await db.execute('ROLLBACK'); - - db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - expect(db, db2); - } finally { - await db.close(); - } - }); - - test('Open non sqlite file', () async { - // Kind of corruption simulation - // await Sqflite.devSetDebugModeOn(true); - final factory = databaseFactory; - final path = - join(await factory.getDatabasesPath(), 'test_non_sqlite_file.db'); - - await factory.deleteDatabase(path); - // Write dummy content - await writeFileAsString(path, 'dummy', flush: true); - // check content - expect(await readFileAsString(path), 'dummy'); - - // try read-only - { - late Database db; - try { - db = await factory.openDatabase(path, - options: OpenDatabaseOptions(readOnly: true)); - } catch (e) { - print('open error'); - } - try { - await db.getVersion(); - } catch (e) { - print('getVersion error'); - } - await db.close(); - - // check content - expect(await readFileAsString(path), 'dummy'); - } - - expect(await isDatabase(path), isFalse); - // try read-write - const minExpectedSize = 1000; - expect((await readFileAsBytes(path)).length, lessThan(minExpectedSize)); - - var db = await factory.openDatabase(path); - var versionShouldFail = - !supportsCompatMode || platform.isIOS || platform.isMacOS; - if (versionShouldFail) { - // On iOS it fails - try { - await db.getVersion(); - } catch (e) { - print('getVersion error'); - } - } else { - // On Android the database is re-created - await db.getVersion(); - } - await db.close(); - - if (versionShouldFail) { - // On iOS it fails - try { - db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - } catch (e) { - print('getVersion error'); - } - } else { - db = await factory.openDatabase(path, - options: OpenDatabaseOptions(version: 1)); - // On Android the database is re-created - await db.getVersion(); - } - await db.close(); - - if (platform.isAndroid) { - // Content has changed, it is a big file now! - expect( - (await readFileAsBytes(path)).length, greaterThan(minExpectedSize)); - } - }); - } -} - -/// Open helper. -class Helper { - /// Open helper. - Helper(this.path); - - /// Datebase path. - final String path; - Database? _db; - final _lock = Lock(); - - /// Open the database if not done. - Future getDb() async { - if (_db == null) { - await _lock.synchronized(() async { - // Check again once entering the synchronized block - _db ??= await openDatabase(path); - }); - } - return _db!; - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/raw_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/raw_test_page.dart deleted file mode 100644 index 2f146b4..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/raw_test_page.dart +++ /dev/null @@ -1,667 +0,0 @@ -import 'dart:io' as io; - -import 'package:flutter/foundation.dart'; -import 'package:path/path.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite/utils/utils.dart'; -import 'package:sqflite_example/utils.dart'; - -import 'src/common_import.dart'; -import 'test_page.dart'; - -// ignore_for_file: avoid_print - -/// Raw test page. -class RawTestPage extends TestPage { - /// Raw test page. - RawTestPage({Key? key}) : super('Raw tests', key: key) { - test('Simple', () async { - // await Sqflite.devSetDebugModeOn(true); - - final path = await initDeleteDb('raw_simple.db'); - final db = await openDatabase(path); - try { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - expect( - await db.rawInsert('INSERT INTO Test (name) VALUES (?)', ['test']), - 1); - - final result = await db.query('Test'); - final expected = [ - {'id': 1, 'name': 'test'} - ]; - expect(result, expected); - } finally { - await db.close(); - } - }); - - test('Sqlite version', () async { - final db = await openDatabase(inMemoryDatabasePath); - final results = await db.rawQuery('select sqlite_version()'); - print('sqlite version: ${results.first.values.first}'); - await db.close(); - }); - - test('Options', () async { - // Sqflite.devSetDebugModeOn(true); - - final path = await initDeleteDb('raw_query_format.db'); - final db = await openDatabase(path); - try { - final batch = db.batch(); - - batch.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 1']); - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 2']); - await batch.commit(); - - var sql = 'SELECT id, name FROM Test'; - // ignore: deprecated_member_use - var resultSet = await db.devInvokeSqlMethod('query', sql); - var expectedResultSetMap = { - 'columns': ['id', 'name'], - 'rows': [ - [1, 'item 1'], - [2, 'item 2'] - ] - }; - print('result as r/c $resultSet'); - expect(resultSet, expectedResultSetMap); - - // empty - sql = 'SELECT id, name FROM Test WHERE id=1234'; - // ignore: deprecated_member_use - resultSet = await db.devInvokeSqlMethod('query', sql); - expectedResultSetMap = {}; - print('result as r/c $resultSet'); - try { - // This might be just for compatibility - expect(resultSet, expectedResultSetMap); - } catch (e) { - // Allow empty result - expectedResultSetMap = { - 'columns': ['id', 'name'], - 'rows': [] - }; - expect(resultSet, expectedResultSetMap); - } - } finally { - await db.close(); - } - }); - - test('Transaction', () async { - //Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('simple_transaction.db'); - final db = await openDatabase(path); - try { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - Future testItem(int i) async { - await db.transaction((txn) async { - final count = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test'))!; - await Future.delayed(const Duration(milliseconds: 40)); - await txn - .rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - //print(await db.query('SELECT COUNT(*) FROM Test')); - final afterCount = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count + 1, afterCount); - }); - } - - final futures = []; - for (var i = 0; i < 4; i++) { - futures.add(testItem(i)); - } - await Future.wait(futures); - } finally { - await db.close(); - } - }); - - test('Concurrency 1', () async { - // Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('simple_concurrency_1.db'); - final db = await openDatabase(path); - try { - final step1 = Completer(); - final step2 = Completer(); - final step3 = Completer(); - - Future action1() async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - step1.complete(); - - await step2.future; - try { - await db - .rawQuery('SELECT COUNT(*) FROM Test') - .timeout(const Duration(seconds: 1)); - throw 'should fail'; - } catch (e) { - expect(e is TimeoutException, true); - } - - step3.complete(); - } - - Future action2() async { - await db.transaction((txn) async { - // Wait for table being created; - await step1.future; - await txn - .rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 1']); - step2.complete(); - - await step3.future; - - final count = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count, 1); - }); - } - - final future1 = action1(); - final future2 = action2(); - - await Future.wait([future1, future2]); - - final count = Sqflite.firstIntValue( - await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count, 1); - } finally { - await db.close(); - } - }); - - test('Concurrency 2', () async { - // Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('simple_concurrency_2.db'); - final db = await openDatabase(path); - try { - final step1 = Completer(); - final step2 = Completer(); - final step3 = Completer(); - - Future action1() async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - step1.complete(); - - await step2.future; - try { - await db - .rawQuery('SELECT COUNT(*) FROM Test') - .timeout(const Duration(seconds: 1)); - throw 'should fail'; - } catch (e) { - expect(e is TimeoutException, true); - } - - step3.complete(); - } - - Future action2() async { - // This is the change from concurrency 1 - // Wait for table being created; - await step1.future; - - await db.transaction((txn) async { - // Wait for table being created; - await txn - .rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 1']); - step2.complete(); - - await step3.future; - - final count = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count, 1); - }); - } - - final future1 = action1(); - final future2 = action2(); - - await Future.wait([future1, future2]); - - final count = Sqflite.firstIntValue( - await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count, 1); - } finally { - await db.close(); - } - }); - - test('Transaction recursive', () async { - final path = await initDeleteDb('transaction_recursive.db'); - final db = await openDatabase(path); - try { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - // insert then fails to make sure the transaction is cancelled - await db.transaction((txn) async { - await txn.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 1']); - - await txn.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item 2']); - }); - final afterCount = Sqflite.firstIntValue( - await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 2); - } finally { - await db.close(); - } - }); - - test('Transaction open twice', () async { - //Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('transaction_open_twice.db'); - final db = await openDatabase(path); - Database? db2; - try { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - db2 = await openDatabase(path); - - await db.transaction((txn) async { - await txn.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item']); - final afterCount = Sqflite.firstIntValue( - await txn.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 1); - - /* - // this is not working on Android - int db2AfterCount = - Sqflite.firstIntValue(await db2.rawQuery('SELECT COUNT(*) FROM Test')); - assert(db2AfterCount == 0); - */ - }); - final db2AfterCount = Sqflite.firstIntValue( - await db2.rawQuery('SELECT COUNT(*) FROM Test')); - expect(db2AfterCount, 1); - - final afterCount = Sqflite.firstIntValue( - await db.rawQuery('SELECT COUNT(*) FROM Test')); - expect(afterCount, 1); - } finally { - await db.close(); - await db2?.close(); - } - }); - - if (supportsCompatMode) { - test('Debug mode (log)', () async { - //await Sqflite.devSetDebugModeOn(false); - final path = await initDeleteDb('debug_mode.db'); - final db = await openDatabase(path); - try { - final debugModeOn = await Sqflite.getDebugModeOn(); - await Sqflite.setDebugModeOn(true); - await db.setVersion(1); - await Sqflite.setDebugModeOn(false); - // this message should not appear - await db.setVersion(2); - await Sqflite.setDebugModeOn(true); - await db.setVersion(3); - // restore - await Sqflite.setDebugModeOn(debugModeOn); - } finally { - await db.close(); - } - }); - } - - test('Demo', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('simple_demo.db'); - final database = await openDatabase(path); - try { - //int version = await database.update('PRAGMA user_version'); - //print('version: ${await database.update('PRAGMA user_version')}'); - print('version: ${await database.rawQuery('PRAGMA user_version')}'); - - //print('drop: ${await database.update('DROP TABLE IF EXISTS Test')}'); - await database.execute('DROP TABLE IF EXISTS Test'); - - print('dropped'); - await database.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER, num REAL)'); - print('table created'); - var id = await database.rawInsert( - // This does not work using ffi - // 'INSERT INTO Test(name, value, num) VALUES("some name",1234,?)', - // [456.789]); - 'INSERT INTO Test(name, value, num) VALUES(?,1234,?)', - ['some name', 456.789]); - print('inserted1: $id'); - id = await database.rawInsert( - 'INSERT INTO Test(name, value) VALUES(?, ?)', - ['another name', 12345678]); - print('inserted2: $id'); - var count = await database.rawUpdate( - 'UPDATE Test SET name = ?, value = ? WHERE name = ?', - ['updated name', '9876', 'some name']); - print('updated: $count'); - expect(count, 1); - var list = await database.rawQuery('SELECT * FROM Test'); - var expectedList = [ - {'name': 'updated name', 'id': 1, 'value': 9876, 'num': 456.789}, - {'name': 'another name', 'id': 2, 'value': 12345678, 'num': null} - ]; - - print('list: ${json.encode(list)}'); - print('expected $expectedList'); - expect(list, expectedList); - - count = await database - .rawDelete('DELETE FROM Test WHERE name = ?', ['another name']); - print('deleted: $count'); - expect(count, 1); - list = await database.rawQuery('SELECT * FROM Test'); - expectedList = [ - {'name': 'updated name', 'id': 1, 'value': 9876, 'num': 456.789}, - ]; - - print('list: ${json.encode(list)}'); - print('expected $expectedList'); - expect(list, expectedList); - } finally { - await database.close(); - } - }); - - test('Demo clean', () async { - // Get a location - final databasesPath = await getDatabasesPath(); - - // Make sure the directory exists - try { - if (!kIsWeb) { - // ignore: avoid_slow_async_io - if (!await io.Directory(databasesPath).exists()) { - await io.Directory(databasesPath).create(recursive: true); - } - } - } catch (_) {} - - final path = join(databasesPath, 'demo.db'); - - // Delete the database - await deleteDatabase(path); - - // open the database - final database = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - // When creating the db, create the table - await db.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER, num REAL)'); - }); - - // Insert some records in a transaction - await database.transaction((txn) async { - final id1 = await txn.rawInsert( - // 'INSERT INTO Test(name, value, num) VALUES("some name", 1234, 456.789)'); This does not work using ffi - 'INSERT INTO Test(name, value, num) VALUES(?, 1234, 456.789)', - ['some name']); - print('inserted1: $id1'); - final id2 = await txn.rawInsert( - 'INSERT INTO Test(name, value, num) VALUES(?, ?, ?)', - ['another name', 12345678, 3.1416]); - print('inserted2: $id2'); - }); - - // Update some record - var count = await database.rawUpdate( - 'UPDATE Test SET name = ?, value = ? WHERE name = ?', - ['updated name', '9876', 'some name']); - print('updated: $count'); - - // Get the records - final list = await database.rawQuery('SELECT * FROM Test'); - final expectedList = [ - {'name': 'updated name', 'id': 1, 'value': 9876, 'num': 456.789}, - {'name': 'another name', 'id': 2, 'value': 12345678, 'num': 3.1416} - ]; - print(list); - print(expectedList); - //assert(const DeepCollectionEquality().equals(list, expectedList)); - expect(list, expectedList); - - // Count the records - count = (Sqflite.firstIntValue( - await database.rawQuery('SELECT COUNT(*) FROM Test')))!; - expect(count, 2); - - // Delete a record - count = await database - .rawDelete('DELETE FROM Test WHERE name = ?', ['another name']); - expect(count, 1); - - // Close the database - await database.close(); - }); - - test('Open twice', () async { - // Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('open_twice.db'); - final db = await openDatabase(path); - Database? db2; - try { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - db2 = await openReadOnlyDatabase(path); - - final count = Sqflite.firstIntValue( - await db2.rawQuery('SELECT COUNT(*) FROM Test')); - expect(count, 0); - } finally { - await db.close(); - await db2?.close(); - } - }); - - test('text primary key', () async { - // Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('text_primary_key.db'); - final db = await openDatabase(path); - try { - // This table has no primary key however sqlite generates an hidden row id - await db.execute('CREATE TABLE Test (name TEXT PRIMARY KEY)'); - var id = await db.insert('Test', {'name': 'test'}); - expect(id, 1); - id = await db.insert('Test', {'name': 'other'}); - expect(id, 2); - // row id is not retrieve by default - var list = await db.query('Test'); - expect(list, [ - {'name': 'test'}, - {'name': 'other'} - ]); - list = await db.query('Test', columns: ['name', 'rowid']); - expect(list, [ - {'name': 'test', 'rowid': 1}, - {'name': 'other', 'rowid': 2} - ]); - } finally { - await db.close(); - } - }); - - test('Without rowid', () async { - // Sqflite.devSetDebugModeOn(true); - // this fails on iOS - - late Database db; - try { - final path = await initDeleteDb('without_rowid.db'); - db = await openDatabase(path); - // This table has no primary key and we ask sqlite not to generate - // a rowid - await db - .execute('CREATE TABLE Test (name TEXT PRIMARY KEY) WITHOUT ROWID'); - var id = await db.insert('Test', {'name': 'test'}); - - // it seems to always return 1 on Android, 0 on iOS..., 0 using ffi - var rowIdAlways0 = - (!supportsCompatMode || (platform.isIOS || platform.isMacOS)); - - if (rowIdAlways0) { - expect(id, 0); - } else { - expect(id, 1); - } - id = await db.insert('Test', {'name': 'other'}); - // it seems to always return 1 - if (rowIdAlways0) { - expect(id, 0); - } else { - expect(id, 1); - } - - // Insert conflict - // Only tested on Android for now... - try { - id = await db.insert('Test', {'name': 'other'}); - } on DatabaseException catch (e) { - // Test.name (code 1555 SQLITE_CONSTRAINT_PRIMARYKEY)) sql 'INSERT INTO Test (name) VALUES (?)' args [other] running without rowid - expect(e.getResultCode(), 1555); - } - - // notice the order is based on the primary key - final list = await db.query('Test'); - expect(list, [ - {'name': 'other'}, - {'name': 'test'} - ]); - } finally { - await db.close(); - } - }); - - test('Reference query', () async { - final path = await initDeleteDb('reference_query.db'); - final db = await openDatabase(path); - try { - final batch = db.batch(); - - batch.execute('CREATE TABLE Other (id INTEGER PRIMARY KEY, name TEXT)'); - batch.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT, other REFERENCES Other(id))'); - batch.rawInsert('INSERT INTO Other (name) VALUES (?)', ['other 1']); - batch.rawInsert( - 'INSERT INTO Test (other, name) VALUES (?, ?)', [1, 'item 2']); - await batch.commit(); - - var result = await db.query('Test', - columns: ['other', 'name'], where: 'other = 1'); - print(result); - expect(result, [ - {'other': 1, 'name': 'item 2'} - ]); - result = await db.query('Test', - columns: ['other', 'name'], where: 'other = ?', whereArgs: [1]); - print(result); - expect(result, [ - {'other': 1, 'name': 'item 2'} - ]); - } finally { - await db.close(); - } - }); - - test('Binding null (fails on Android)', () async { - final db = await openDatabase(inMemoryDatabasePath); - try { - for (var value in [null, 2]) { - expect( - firstIntValue(await db.rawQuery( - 'SELECT CASE WHEN 0 = 1 THEN 1 ELSE ? END', [value])), - value); - } - } finally { - await db.close(); - } - }); - - test('Query by page', () async { - // await databaseFactory.debugSetLogLevel(sqfliteLogLevelVerbose); - - //final path = await initDeleteDb('query_by_page.db'); - //final db = await openDatabase(path); - final db = await openDatabase(inMemoryDatabasePath); - try { - await db.execute(''' - CREATE TABLE test ( - id INTEGER PRIMARY KEY - )'''); - await db.insert('test', {'id': 1}); - await db.insert('test', {'id': 2}); - await db.insert('test', {'id': 3}); - var resultsList = []; - - // Use a cursor - var cursor = - await db.rawQueryCursor('SELECT * FROM test', null, bufferSize: 2); - resultsList.clear(); - var results = >[]; - while (await cursor.moveNext()) { - results.add(cursor.current); - } - expect(results, [ - {'id': 1}, - {'id': 2}, - {'id': 3} - ]); - - // Multiple cursors a cursor - var cursor1 = - await db.rawQueryCursor('SELECT * FROM test', null, bufferSize: 2); - var cursor2 = - await db.rawQueryCursor('SELECT * FROM test', null, bufferSize: 1); - await cursor1.moveNext(); - expect(cursor1.current.values, [1]); - await cursor2.moveNext(); - await cursor2.moveNext(); - expect(cursor2.current.values, [2]); - await cursor1.moveNext(); - expect(cursor1.current.values, [2]); - await cursor1.close(); - await cursor1.close(); // ok to call twice - try { - cursor1.current.values; - fail('should fail get current'); - } on StateError catch (_) {} - await cursor2.moveNext(); - expect(cursor2.current.values, [3]); - expect(await cursor2.moveNext(), isFalse); - expect(await cursor1.moveNext(), isFalse); - try { - cursor2.current.values; - fail('should fail get current'); - } on StateError catch (_) {} - - // No data - cursor = await db.rawQueryCursor('SELECT * FROM test WHERE id > ?', [3], - bufferSize: 2); - expect(await cursor.moveNext(), isFalse); - - // Matching page size - cursor = await db.rawQueryCursor('SELECT * FROM test WHERE id > ?', [1], - bufferSize: 2); - expect(await cursor.moveNext(), isTrue); - expect(await cursor.moveNext(), isTrue); - expect(await cursor.moveNext(), isFalse); - } finally { - await db.close(); - } - }); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/slow_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/slow_test_page.dart deleted file mode 100644 index a1d8a0c..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/slow_test_page.dart +++ /dev/null @@ -1,153 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:sqflite/sqflite.dart'; - -import 'src/common_import.dart'; -import 'test_page.dart'; - -// ignore_for_file: avoid_print - -/// Slow test page. -class SlowTestPage extends TestPage { - /// Slow test page. - SlowTestPage({Key? key}) : super('Slow tests', key: key) { - test('Perf 100 insert', () async { - final path = await initDeleteDb('slow_txn_100_insert.db'); - final db = await openDatabase(path); - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - await db.transaction((txn) async { - for (var i = 0; i < 100; i++) { - await txn - .rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - }); - await db.close(); - }); - - test('Perf 100 insert no txn', () async { - final path = await initDeleteDb('slow_100_insert.db'); - final db = await openDatabase(path); - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - for (var i = 0; i < 1000; i++) { - await db.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - await db.close(); - }); - - test('Perf 1000 insert', () async { - await perfInsert(); - }); - - test('Perf 1000 insert batch', () async { - final path = await initDeleteDb('slow_txn_1000_insert_batch.db'); - final db = await openDatabase(path); - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - final sw = Stopwatch()..start(); - final batch = db.batch(); - - for (var i = 0; i < 1000; i++) { - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - await batch.commit(); - print('1000 insert batch ${sw.elapsed}'); - await db.close(); - }); - - test('Perf 1000 insert batch no result', () async { - final path = - await initDeleteDb('slow_txn_1000_insert_batch_no_result.db'); - final db = await openDatabase(path); - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - final sw = Stopwatch()..start(); - final batch = db.batch(); - - for (var i = 0; i < 1000; i++) { - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - await batch.commit(noResult: true); - - print('1000 insert batch no result ${sw.elapsed}'); - await db.close(); - }); - - const count = 10000; - - test('Perf $count item', () async { - //Sqflite.devSetDebugModeOn(true); - await perfDo(count); - }); - - if (platform.isAndroid) { - test('Perf android NORMAL_PRIORITY', () async { - // ignore_for_file: deprecated_member_use, deprecated_member_use_from_same_package - await Sqflite.devSetOptions( - SqfliteOptions()..androidThreadPriority = 0); - try { - await perfInsert(); - await perfDo(count); - } finally { - // Background priority - await Sqflite.devSetOptions( - SqfliteOptions()..androidThreadPriority = 10); - } - }); - } - } - - /// basic performance testing. - Future perfDo(int count) async { - final path = await initDeleteDb('pref_${count}_items.db'); - final db = await openDatabase(path); - try { - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - var sw = Stopwatch()..start(); - final batch = db.batch(); - - for (var i = 0; i < count; i++) { - batch.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - await batch.commit(); - print('sw ${sw.elapsed} insert $count items batch '); - - sw = Stopwatch()..start(); - var result = await db.query('Test'); - print('sw ${sw.elapsed} SELECT * From Test : ${result.length} items'); - - sw = Stopwatch()..start(); - result = - await db.query('Test', where: 'name LIKE ?', whereArgs: ['%item%']); - print( - 'sw ${sw.elapsed} SELECT * FROM Test WHERE name LIKE %item% ${result.length} items'); - - sw = Stopwatch()..start(); - result = - await db.query('Test', where: 'name LIKE ?', whereArgs: ['%dummy%']); - print( - 'sw ${sw.elapsed} SELECT * FROM Test WHERE name LIKE %dummy% ${result.length} items'); - } finally { - await db.close(); - } - } - - /// Insert perf testing. - Future perfInsert() async { - final path = await initDeleteDb('slow_txn_1000_insert.db'); - final db = await openDatabase(path); - await db.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)'); - - final sw = Stopwatch()..start(); - await db.transaction((txn) async { - for (var i = 0; i < 1000; i++) { - await txn.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item $i']); - } - }); - print('1000 insert ${sw.elapsed}'); - await db.close(); - } - -// 2019-02-26 - -// BACKGROUND -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/src/common_import.dart b/packages/sqflite/sqflite_aurora/example/lib/src/common_import.dart deleted file mode 100644 index 9637df3..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/src/common_import.dart +++ /dev/null @@ -1,8 +0,0 @@ -export 'dart:async'; -export 'dart:convert'; - -export 'package:collection/collection.dart'; -export 'package:sqflite_common/src/internals.dart'; -export 'package:sqflite_common/src/platform/platform.dart'; - -export 'dev_utils.dart'; diff --git a/packages/sqflite/sqflite_aurora/example/lib/src/dev_utils.dart b/packages/sqflite/sqflite_aurora/example/lib/src/dev_utils.dart deleted file mode 100644 index 63423cd..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/src/dev_utils.dart +++ /dev/null @@ -1,16 +0,0 @@ -export 'dart:async'; - -// ignore_for_file: avoid_print - -/// Deprecated to prevent keeping the code used. -@Deprecated('Dev only') -void devPrint(Object object) { - print(object); -} - -/// Deprecated to prevent keeping the code used. -/// -/// Can be use as a todo for weird code. int value = devWarning(myFunction()); -/// The function is always called -@Deprecated('Dev only') -T devWarning(T value) => value; diff --git a/packages/sqflite/sqflite_aurora/example/lib/src/expect.dart b/packages/sqflite/sqflite_aurora/example/lib/src/expect.dart deleted file mode 100644 index 46c9e8d..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/src/expect.dart +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:async'; - -import 'package:matcher/matcher.dart'; - -/// An exception thrown when a test assertion fails. -class TestFailure { - /// An exception thrown when a test assertion fails. - TestFailure(this.message); - - /// Exception message - final String message; - - @override - String toString() => message; -} - -/// The type used for functions that can be used to build up error reports -/// upon failures in [expect]. -@Deprecated('Will be removed in 0.13.0.') -typedef ErrorFormatter = String Function(dynamic actual, Matcher matcher, - String? reason, Map matchState, bool verbose); - -/// Assert that [actual] matches [matcher]. -/// -/// This is the main assertion function. [reason] is optional and is typically -/// not supplied, as a reason is generated from [matcher]; if [reason] -/// is included it is appended to the reason generated by the matcher. -/// -/// [matcher] can be a value in which case it will be wrapped in an -/// [equals] matcher. -/// -/// If the assertion fails a [TestFailure] is thrown. -/// -/// If [skip] is a String or `true`, the assertion is skipped. The arguments are -/// still evaluated, but [actual] is not verified to match [matcher]. If -/// [actual] is a [Future], the test won't complete until the future emits a -/// value. -/// -/// If [skip] is a string, it should explain why the assertion is skipped; this -/// reason will be printed when running the test. -/// -/// Certain matchers, like [completion] and [throwsA], either match or fail -/// asynchronously. When you use [expect] with these matchers, it ensures that -/// the test doesn't complete until the matcher has either matched or failed. If -/// you want to wait for the matcher to complete before continuing the test, you -/// can call [expectLater] instead and `await` the result. -void expect( - Object? actual, - Object? matcher, { - String? reason, - Object? skip, -}) { - _expect(actual, matcher, reason: reason, skip: skip); -} - -/// Just like [expect], but returns a [Future] that completes when the matcher -/// has finished matching. -/// -/// For the [completes] and [completion] matchers, as well as [throwsA] and -/// related matchers when they're matched against a [Future], the returned -/// future completes when the matched future completes. For the [prints] -/// matcher, it completes when the future returned by the callback completes. -/// Otherwise, it completes immediately. -/// -/// If the matcher fails asynchronously, that failure is piped to the returned -/// future where it can be handled by user code. -Future expectLater(Object? actual, Object? matcher, - {String? reason, Object? skip}) => - _expect(actual, matcher, reason: reason, skip: skip) as Future; - -String _formatFailure(Matcher expected, Object? actual, String which, - {String? reason}) { - final buffer = StringBuffer(); - buffer.writeln(indent(prettyPrint(expected), first: 'Expected: ')); - buffer.writeln(indent(prettyPrint(actual), first: ' Actual: ')); - if (which.isNotEmpty) buffer.writeln(indent(which, first: ' Which: ')); - if (reason != null) buffer.writeln(reason); - return buffer.toString(); -} - -/// The implementation of [expect] and [expectLater]. -FutureOr _expect(Object? actual, Object? matcher, - {String? reason, - Object? skip, - bool verbose = false, - // ignore: deprecated_member_use, deprecated_member_use_from_same_package - ErrorFormatter? formatter}) { - formatter ??= (actual, matcher, reason, matchState, verbose) { - final mismatchDescription = StringDescription(); - matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); - - // ignore: deprecated_member_use - return _formatFailure(matcher, actual, mismatchDescription.toString(), - reason: reason); - }; - - if (skip != null && skip is! bool && skip is! String) { - throw ArgumentError.value(skip, 'skip', 'must be a bool or a String'); - } - - matcher = wrapMatcher(matcher); - - final matchState = {}; - try { - if ((matcher as Matcher).matches(actual, matchState)) { - return Future.sync(() {}); - } - } catch (e, trace) { - reason ??= '$e at $trace'; - } - fail(formatter(actual, matcher as Matcher, reason, matchState, verbose)); -} - -/// Convenience method for throwing a new [TestFailure] with the provided -/// [message]. -Never fail([String? message]) => throw TestFailure(message ?? 'should fail'); - -/// index text helper. -String indent(String text, {String? first}) { - if (first != null) { - return '$first $text'; - } - return text; -} - -/// index text helper. -String prettyPrint(dynamic text, {String? first}) { - if (first != null) { - return '$first $text'; - } - return '$text'; -} - -/// The default error formatter. -@Deprecated('Will be removed in 0.13.0.') -String formatFailure(Matcher expected, Object? actual, String which, - {String? reason}) { - final buffer = StringBuffer(); - buffer.writeln(indent(prettyPrint(expected), first: 'Expected: ')); - buffer.writeln(indent(prettyPrint(actual), first: ' Actual: ')); - if (which.isNotEmpty) buffer.writeln(indent(which, first: ' Which: ')); - if (reason != null) buffer.writeln(reason); - return buffer.toString(); -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/src/item_widget.dart b/packages/sqflite/sqflite_aurora/example/lib/src/item_widget.dart deleted file mode 100644 index 1c618f4..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/src/item_widget.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:sqflite_example/model/item.dart'; - -/// Item widget. -class ItemWidget extends StatefulWidget { - /// Item widget. - const ItemWidget(this.item, this.onTap, {this.summary, Key? key}) - : super(key: key); - - /// item summary. - final String? summary; - - /// item data. - final Item item; - - /// Action when pressed (typically run). - final void Function(Item item) onTap; // = Function(MainItem item); - - @override - // ignore: library_private_types_in_public_api - _ItemWidgetState createState() => _ItemWidgetState(); -} - -class _ItemWidgetState extends State { - @override - Widget build(BuildContext context) { - IconData? icon; - Color? color; - - switch (widget.item.state) { - case ItemState.none: - icon = Icons.arrow_forward_ios; - break; - case ItemState.running: - icon = Icons.more_horiz; - break; - case ItemState.success: - icon = Icons.check; - color = Colors.green; - break; - case ItemState.failure: - icon = Icons.close; - color = Colors.red; - break; - } - return ListTile( - // isThreeLine: widget.summary != null, - leading: SizedBox( - child: IconButton( - icon: Icon(icon, color: color), - - onPressed: null, // null disables the button - )), - title: Text(widget.item.name), - subtitle: widget.summary != null ? Text(widget.summary!) : null, - onTap: _onTap); - } - - void _onTap() { - widget.onTap(widget.item); - - //print(widget.item.route); - //Navigator.pushNamed(context, widget.item.route); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/src/main_item_widget.dart b/packages/sqflite/sqflite_aurora/example/lib/src/main_item_widget.dart deleted file mode 100644 index d97d226..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/src/main_item_widget.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:sqflite_example/model/main_item.dart'; - -/// Main item widget. -class MainItemWidget extends StatefulWidget { - /// Main item widget. - const MainItemWidget(this.item, this.onTap, {Key? key}) : super(key: key); - - /// item data. - final MainItem item; - - /// onTap action (typically run or open). - final void Function(MainItem item) onTap; // = Function(MainItem item); - - @override - // ignore: library_private_types_in_public_api - _MainItemWidgetState createState() => _MainItemWidgetState(); -} - -class _MainItemWidgetState extends State { - @override - Widget build(BuildContext context) { - return ListTile( - title: Text(widget.item.title), - subtitle: Text(widget.item.description), - onTap: _onTap); - } - - void _onTap() { - widget.onTap(widget.item); - - //print(widget.item.route); - //Navigator.pushNamed(context, widget.item.route); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/test_page.dart deleted file mode 100644 index 0964716..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/test_page.dart +++ /dev/null @@ -1,217 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; -import 'package:sqflite_example/src/common_import.dart'; -import 'package:sqflite_example/src/expect.dart'; - -import 'model/item.dart'; -import 'model/test.dart'; -import 'src/item_widget.dart'; - -export 'package:matcher/matcher.dart'; -export 'package:sqflite_example/database/database.dart'; - -export 'src/expect.dart' show expect, fail; -// ignore_for_file: avoid_print - -/// Base test page. -class TestPage extends StatefulWidget { - /// Base test page. - TestPage(this.title, {Key? key}) : super(key: key); - - /// The title. - final String title; - - /// Test list. - final List tests = []; - - /// define a test. - void test(String name, FutureOr Function() fn) { - tests.add(Test(name, fn)); - } - - /// define a solo test. - @Deprecated('SOLO_TEST - On purpose to remove before checkin') - // ignore: non_constant_identifier_names - void solo_test(String name, FutureOr Function() fn) { - tests.add(Test(name, fn, solo: true)); - } - - /// skip a test. - @Deprecated('SKIP_TEST - On purpose to remove before checkin') - // ignore: non_constant_identifier_names - void skip_test(String name, FutureOr Function() fn) { - tests.add(Test(name, fn, skip: true)); - } - - /// Thrown an exception - void fail([String? message]) { - throw Exception(message ?? 'should fail'); - } - - @override - // ignore: library_private_types_in_public_api - _TestPageState createState() => _TestPageState(); -} - -/// Verify a condition. -bool? verify(bool? condition, [String? message]) { - message ??= 'verify failed'; - expect(condition, true, reason: message); - /* - if (condition == null) { - throw new Exception(''$message' null condition'); - } - if (!condition) { - throw new Exception(''$message''); - } - */ - return condition; -} - -/// Group. -abstract class Group { - /// List of tests. - List get tests; - - bool? _hasSolo; - final _tests = []; - - /// Add a test. - void add(Test test) { - if (!test.skip) { - if (test.solo) { - if (_hasSolo != true) { - _hasSolo = true; - _tests.clear(); - } - _tests.add(test); - } else if (_hasSolo != true) { - _tests.add(test); - } - } - } - - /// true if it has solo or contains item with solo feature - bool? get hasSolo => _hasSolo; -} - -class _TestPageState extends State with Group { - int get _itemCount => items.length; - - List items = []; - - Future _run() async { - if (!mounted) { - return null; - } - - setState(() { - items.clear(); - }); - _tests.clear(); - for (var test in widget.tests) { - add(test); - } - for (var test in _tests) { - var item = Item(test.name); - - late int position; - setState(() { - position = items.length; - items.add(item); - }); - try { - await test.fn(); - - item = Item(test.name)..state = ItemState.success; - } catch (e, st) { - print(e); - print(st); - item = Item(test.name)..state = ItemState.failure; - } - - if (!mounted) { - return null; - } - - setState(() { - items[position] = item; - }); - } - } - - Future _runTest(int index) async { - if (!mounted) { - return null; - } - - final test = _tests[index]; - - var item = items[index]; - setState(() { - item.state = ItemState.running; - }); - try { - print('TEST Running ${test.name}'); - await test.fn(); - print('TEST Done ${test.name}'); - - item = Item(test.name)..state = ItemState.success; - } catch (e, st) { - print('TEST Error $e running ${test.name}'); - try { - print(st); - } catch (_) {} - item = Item(test.name)..state = ItemState.failure; - } - - if (!mounted) { - return null; - } - - setState(() { - items[index] = item; - }); - } - - @override - void initState() { - super.initState(); - /* - setState(() { - _itemCount = 3; - }); - */ - _run(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text(widget.title), actions: [ - IconButton( - icon: const Icon(Icons.refresh), - tooltip: 'Run again', - onPressed: _run, - ), - ]), - body: - ListView.builder(itemBuilder: _itemBuilder, itemCount: _itemCount)); - } - - Widget _itemBuilder(BuildContext context, int index) { - final item = getItem(index); - return ItemWidget(item, (Item item) { - //Navigator.of(context).pushNamed(item.route); - _runTest(index); - }); - } - - Item getItem(int index) { - return items[index]; - } - - @override - List get tests => widget.tests; -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/todo_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/todo_test_page.dart deleted file mode 100644 index 6b30149..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/todo_test_page.dart +++ /dev/null @@ -1,150 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/foundation.dart'; -import 'package:sqflite/sqflite.dart'; - -import 'test_page.dart'; - -/// `todo` table name -const String tableTodo = 'todo'; - -/// id column name -const String columnId = '_id'; - -/// title column name -const String columnTitle = 'title'; - -/// done column name -const String columnDone = 'done'; - -/// Todo model. -class Todo { - /// Todo model. - Todo(); - - /// Read from a record. - Todo.fromMap(Map map) { - id = map[columnId] as int?; - title = map[columnTitle] as String?; - done = map[columnDone] == 1; - } - - /// id. - int? id; - - /// title. - String? title; - - /// done. - bool? done; - - /// Convert to a record. - Map toMap() { - final map = { - columnTitle: title, - columnDone: done == true ? 1 : 0 - }; - if (id != null) { - map[columnId] = id; - } - return map; - } -} - -/// Todo provider. -class TodoProvider { - /// The database when opened. - late Database db; - - /// Open the database. - Future open(String path) async { - db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db.execute(''' -create table $tableTodo ( - $columnId integer primary key autoincrement, - $columnTitle text not null, - $columnDone integer not null) -'''); - }); - } - - /// Insert a todo. - Future insert(Todo todo) async { - todo.id = await db.insert(tableTodo, todo.toMap()); - return todo; - } - - /// Get a todo. - Future getTodo(int id) async { - final List maps = await db.query(tableTodo, - columns: [columnId, columnDone, columnTitle], - where: '$columnId = ?', - whereArgs: [id]); - if (maps.isNotEmpty) { - return Todo.fromMap(maps.first); - } - return null; - } - - /// Delete a todo. - Future delete(int id) async { - return await db.delete(tableTodo, where: '$columnId = ?', whereArgs: [id]); - } - - /// Update a todo. - Future update(Todo todo) async { - return await db.update(tableTodo, todo.toMap(), - where: '$columnId = ?', whereArgs: [todo.id!]); - } - - /// Close database. - Future close() async => db.close(); -} - -/// Todo test page. -class TodoTestPage extends TestPage { - /// Todo test page. - TodoTestPage({Key? key}) : super('Todo example', key: key) { - test('open', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('simple_todo_open.db'); - final todoProvider = TodoProvider(); - await todoProvider.open(path); - - await todoProvider.close(); - //await Sqflite.setDebugModeOn(false); - }); - - test('insert/query/update/delete', () async { - // await Sqflite.devSetDebugModeOn(); - final path = await initDeleteDb('simple_todo.db'); - final todoProvider = TodoProvider(); - await todoProvider.open(path); - - var todo = Todo()..title = 'test'; - await todoProvider.insert(todo); - expect(todo.id, 1); - - expect(await todoProvider.getTodo(0), null); - todo = (await todoProvider.getTodo(1))!; - expect(todo.id, 1); - expect(todo.title, 'test'); - expect(todo.done, false); - - todo.done = true; - expect(await todoProvider.update(todo), 1); - todo = (await todoProvider.getTodo(1))!; - expect(todo.id, 1); - expect(todo.title, 'test'); - expect(todo.done, true); - - expect(await todoProvider.delete(0), 0); - expect(await todoProvider.delete(1), 1); - expect(await todoProvider.getTodo(1), null); - - await todoProvider.close(); - //await Sqflite.setDebugModeOn(false); - }); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/type_test_page.dart b/packages/sqflite/sqflite_aurora/example/lib/type_test_page.dart deleted file mode 100644 index 6d1355a..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/type_test_page.dart +++ /dev/null @@ -1,269 +0,0 @@ -import 'dart:async'; -import 'dart:math'; - -import 'package:flutter/foundation.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite_example/utils.dart'; - -import 'test_page.dart'; - -// ignore_for_file: avoid_print - -class _Data { - late Database db; -} - -/// Type test page. -class TypeTestPage extends TestPage { - /// Type test page. - TypeTestPage({Key? key}) : super('Type tests', key: key) { - test('int', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_int.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER)'); - }); - var id = await insertValue(-1); - expect(await getValue(id), -1); - - // less than 32 bits - id = await insertValue(pow(2, 31)); - expect(await getValue(id), pow(2, 31)); - - // more than 32 bits - id = await insertValue(pow(2, 33)); - //devPrint('2^33: ${await getValue(id)}'); - expect(await getValue(id), pow(2, 33)); - - id = await insertValue(pow(2, 62)); - //devPrint('2^62: ${pow(2, 62)} ${await getValue(id)}'); - expect(await getValue(id), pow(2, 62), - reason: '2^62: ${pow(2, 62)} ${await getValue(id)}'); - - var value = pow(2, 63).round() - 1; - id = await insertValue(value); - //devPrint('${value} ${await getValue(id)}'); - expect(await getValue(id), value, reason: '$value ${await getValue(id)}'); - - value = -(pow(2, 63)).round(); - id = await insertValue(value); - //devPrint('${value} ${await getValue(id)}'); - expect(await getValue(id), value, reason: '$value ${await getValue(id)}'); - /* - id = await insertValue(pow(2, 63)); - devPrint('2^63: ${pow(2, 63)} ${await getValue(id)}'); - assert(await getValue(id) == pow(2, 63), '2^63: ${pow(2, 63)} ${await getValue(id)}'); - - // more then 64 bits - id = await insertValue(pow(2, 65)); - assert(await getValue(id) == pow(2, 65)); - - // more then 128 bits - id = await insertValue(pow(2, 129)); - assert(await getValue(id) == pow(2, 129)); - */ - await data.db.close(); - }); - - test('real', () async { - //await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_real.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value REAL)'); - }); - var id = await insertValue(-1.1); - expect(await getValue(id), -1.1); - // big float - id = await insertValue(1 / 3); - expect(await getValue(id), 1 / 3); - id = await insertValue(pow(2, 63) + .1); - expect(await getValue(id), pow(2, 63) + 0.1); - - // integer? - id = await insertValue(pow(2, 62)); - expect(await getValue(id), pow(2, 62)); - await data.db.close(); - }); - - test('text', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_text.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)'); - }); - try { - var id = await insertValue('simple text'); - expect(await getValue(id), 'simple text'); - // null - id = await insertValue(null); - expect(await getValue(id), null); - - // utf-8 - id = await insertValue('àöé'); - expect(await getValue(id), 'àöé'); - } finally { - await data.db.close(); - } - }); - - test('blob', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_blob.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value BLOB)'); - }); - int id; - try { - // insert text in blob - id = await insertValue('simple text'); - expect(await getValue(id), 'simple text'); - - // UInt8List - default - final byteData = ByteData(1); - byteData.setInt8(0, 1); - final blob = byteData.buffer.asUint8List(); - id = await insertValue(blob); - //print(await getValue(id)); - final result = (await getValue(id)) as List; - print(result.runtimeType); - expect(result is Uint8List, true); - expect(result.length, 1); - expect(result, [1]); - - // empty array not supported - //id = await insertValue([]); - //print(await getValue(id)); - //assert(eq.equals(await getValue(id), [])); - - var blob1234 = [1, 2, 3, 4]; - if (!supportsCompatMode) { - blob1234 = Uint8List.fromList(blob1234); - } - id = await insertValue(blob1234); - dynamic value = (await getValue(id)) as List; - print(value); - print('${(value as List).length}'); - expect(value, blob1234, reason: '${await getValue(id)}'); - - // test hex feature on sqlite - final hexResult = await data.db - .rawQuery('SELECT hex(value) FROM Test WHERE id = ?', [id]); - expect(hexResult[0].values.first, '01020304'); - - // try blob lookup (works on Android since 2022-09-19) - var rows = await data.db - .rawQuery('SELECT * FROM Test WHERE value = ?', [blob1234]); - expect(rows.length, 1); - - // try blob lookup using hex - rows = await data.db.rawQuery( - 'SELECT * FROM Test WHERE hex(value) = ?', [Sqflite.hex(blob1234)]); - expect(rows.length, 1); - expect(rows[0]['id'], 3); - - // Insert empty blob - final blobEmpty = Uint8List(0); - id = await insertValue(blobEmpty); - value = await getValue(id); - expect(value, const TypeMatcher()); - expect(value, isEmpty); - } finally { - await data.db.close(); - } - }); - - test('null', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_null.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - }); - try { - final id = await insertValue(null); - expect(await getValue(id), null); - - // Make a string - expect(await updateValue(id, 'dummy'), 1); - expect(await getValue(id), 'dummy'); - - expect(await updateValue(id, null), 1); - expect(await getValue(id), null); - } finally { - await data.db.close(); - } - }); - - test('date_time', () async { - // await Sqflite.devSetDebugModeOn(true); - final path = await initDeleteDb('type_date_time.db'); - data.db = await openDatabase(path, version: 1, - onCreate: (Database db, int version) async { - await db - .execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, value TEXT)'); - }); - try { - var failed = false; - try { - await insertValue(DateTime.fromMillisecondsSinceEpoch(1234567890)); - } on ArgumentError catch (_) { - failed = true; - } - expect(failed, true); - } finally { - await data.db.close(); - } - }); - - test('bool', () async { - //await Sqflite.devSetDebugModeOn(true); - data.db = await openDatabase(inMemoryDatabasePath, version: 1, - onCreate: (Database db, int version) async { - await db.execute( - 'CREATE TABLE Test (id INTEGER PRIMARY KEY, value BOOLEAN)'); - }); - try { - var failed = false; - try { - await insertValue(true); - } on ArgumentError catch (_) { - failed = true; - } - if (supportsCompatMode) { - print('for now bool are accepted but inconsistent on iOS/Android'); - expect(failed, isFalse); - } - } finally { - await data.db.close(); - } - }); - } - - /// Out internal data. - // ignore: library_private_types_in_public_api - final _Data data = _Data(); - - /// Get the value field from a given id - Future getValue(int id) async { - return ((await data.db.query('Test', where: 'id = $id')).first)['value']; - } - - /// insert the value field and return the id - Future insertValue(dynamic value) async { - return await data.db.insert('Test', {'value': value}); - } - - /// insert the value field and return the id - Future updateValue(int id, dynamic value) async { - return await data.db.update('Test', {'value': value}, where: 'id = $id'); - } -} diff --git a/packages/sqflite/sqflite_aurora/example/lib/utils.dart b/packages/sqflite/sqflite_aurora/example/lib/utils.dart deleted file mode 100644 index cf8cfc7..0000000 --- a/packages/sqflite/sqflite_aurora/example/lib/utils.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite/sqflite_dev.dart'; - -/// Usage: await sleep(500); -Future sleep([int milliseconds = 0]) => - Future.delayed(Duration(milliseconds: milliseconds)); - -/// Supports compat mode (devSetDebugModeOn, queryAsMap, fts4, some error handled - missing parameter, bad file) -bool get supportsCompatMode { - // ignore: invalid_use_of_visible_for_testing_member - return databaseFactory == sqfliteDatabaseFactoryDefault; -} diff --git a/packages/sqflite/sqflite_aurora/example/pubspec.yaml b/packages/sqflite/sqflite_aurora/example/pubspec.yaml deleted file mode 100644 index 320712f..0000000 --- a/packages/sqflite/sqflite_aurora/example/pubspec.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: sqflite_example -description: Demonstrates how to use the sqflite_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - - sqflite: ^2.2.6 - sqflite_common: ^2.4.4 - sqflite_aurora: - path: ../ - - cupertino_icons: ^1.0.2 - path: ^1.8.2 - synchronized: ^3.1.0 - collection: ^1.16.0 - matcher: ^0.12.12 - -dev_dependencies: - flutter_test: - sdk: flutter - - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true - assets: - - assets/example.db - - assets/issue_64.db diff --git a/packages/sqflite/sqflite_aurora/pubspec.yaml b/packages/sqflite/sqflite_aurora/pubspec.yaml index f072d72..586b70d 100644 --- a/packages/sqflite/sqflite_aurora/pubspec.yaml +++ b/packages/sqflite/sqflite_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 2.2.6+aurora1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: diff --git a/packages/wakelock/wakelock_aurora/data/preview.png b/packages/wakelock/wakelock_aurora/data/preview.png deleted file mode 100644 index 9f6ec78..0000000 Binary files a/packages/wakelock/wakelock_aurora/data/preview.png and /dev/null differ diff --git a/packages/wakelock/wakelock_aurora/example/.gitignore b/packages/wakelock/wakelock_aurora/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/wakelock/wakelock_aurora/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/wakelock/wakelock_aurora/example/README.md b/packages/wakelock/wakelock_aurora/example/README.md deleted file mode 100644 index 386ac6c..0000000 --- a/packages/wakelock/wakelock_aurora/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# wakelock_aurora_example - -Demonstrates how to use the wakelock_aurora plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/wakelock/wakelock_aurora/example/analysis_options.yaml b/packages/wakelock/wakelock_aurora/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/wakelock/wakelock_aurora/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/wakelock/wakelock_aurora/example/aurora/.gitignore b/packages/wakelock/wakelock_aurora/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/wakelock/wakelock_aurora/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/wakelock/wakelock_aurora/example/aurora/desktop/com.example.wakelock_aurora_example.desktop b/packages/wakelock/wakelock_aurora/example/aurora/desktop/com.example.wakelock_aurora_example.desktop deleted file mode 100644 index a2f7f06..0000000 --- a/packages/wakelock/wakelock_aurora/example/aurora/desktop/com.example.wakelock_aurora_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=wakelock_aurora_example -Comment=Demonstrates how to use the wakelock_aurora plugin. -Icon=com.example.wakelock_aurora_example -Exec=/usr/bin/com.example.wakelock_aurora_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=wakelock_aurora_example diff --git a/packages/wakelock/wakelock_aurora/example/aurora/icons/108x108.png b/packages/wakelock/wakelock_aurora/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/wakelock/wakelock_aurora/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/wakelock/wakelock_aurora/example/aurora/icons/128x128.png b/packages/wakelock/wakelock_aurora/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/wakelock/wakelock_aurora/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/wakelock/wakelock_aurora/example/aurora/icons/172x172.png b/packages/wakelock/wakelock_aurora/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/wakelock/wakelock_aurora/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/wakelock/wakelock_aurora/example/aurora/icons/86x86.png b/packages/wakelock/wakelock_aurora/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/wakelock/wakelock_aurora/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/wakelock/wakelock_aurora/example/aurora/main.cpp b/packages/wakelock/wakelock_aurora/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/wakelock/wakelock_aurora/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/wakelock/wakelock_aurora/example/aurora/rpm/com.example.wakelock_aurora_example.spec b/packages/wakelock/wakelock_aurora/example/aurora/rpm/com.example.wakelock_aurora_example.spec deleted file mode 100644 index d646922..0000000 --- a/packages/wakelock/wakelock_aurora/example/aurora/rpm/com.example.wakelock_aurora_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.wakelock_aurora_example -Summary: Demonstrates how to use the wakelock_aurora plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/wakelock/wakelock_aurora/example/lib/main.dart b/packages/wakelock/wakelock_aurora/example/lib/main.dart deleted file mode 100644 index 182567e..0000000 --- a/packages/wakelock/wakelock_aurora/example/lib/main.dart +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'dart:async'; -import 'package:flutter/material.dart'; -import 'package:wakelock/wakelock.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - bool _enableWakelock = false; - - @override - void initState() { - super.initState(); - } - - Future _toggleWakelock() async { - final enableWakelock = !(await Wakelock.enabled); - await Wakelock.toggle(enable: enableWakelock); - setState(() { - _enableWakelock = enableWakelock; - }); - } - - @override - Widget build(BuildContext context) { - const textStyleWhite = TextStyle(fontSize: 18, color: Colors.white); - - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Example wakelock'), - ), - body: 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 wakelock', - style: textStyleWhite, - textAlign: TextAlign.center, - ), - ), - const SizedBox(height: 30), - - ElevatedButton( - onPressed: _toggleWakelock, - child: Text('Toggle wakelock: $_enableWakelock'), - ), - ], - ), - ), - ), - ), - ), - ); - } -} diff --git a/packages/wakelock/wakelock_aurora/example/pubspec.lock b/packages/wakelock/wakelock_aurora/example/pubspec.lock deleted file mode 100644 index b5355f0..0000000 --- a/packages/wakelock/wakelock_aurora/example/pubspec.lock +++ /dev/null @@ -1,264 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.1" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - dbus: - dependency: transitive - description: - name: dbus - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.8" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.4" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - wakelock: - dependency: "direct main" - description: - name: wakelock - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.2" - wakelock_aurora: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" - wakelock_macos: - dependency: transitive - description: - name: wakelock_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.0" - wakelock_platform_interface: - dependency: transitive - description: - name: wakelock_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.0" - wakelock_web: - dependency: transitive - description: - name: wakelock_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.0" - wakelock_windows: - dependency: transitive - description: - name: wakelock_windows - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.1" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.4" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.0" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=2.5.0" diff --git a/packages/wakelock/wakelock_aurora/example/pubspec.yaml b/packages/wakelock/wakelock_aurora/example/pubspec.yaml deleted file mode 100644 index b4f684b..0000000 --- a/packages/wakelock/wakelock_aurora/example/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: wakelock_aurora_example -description: Demonstrates how to use the wakelock_aurora plugin. - -publish_to: 'none' - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - wakelock: ^0.6.2 - wakelock_aurora: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/wakelock/wakelock_aurora/lib/wakelock_aurora.dart b/packages/wakelock/wakelock_aurora/lib/wakelock_aurora.dart index a3eac33..90851a0 100644 --- a/packages/wakelock/wakelock_aurora/lib/wakelock_aurora.dart +++ b/packages/wakelock/wakelock_aurora/lib/wakelock_aurora.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:dbus/dbus.dart'; -import 'package:flutter/foundation.dart'; import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; import 'com_nokia_mce_request.dart'; @@ -14,9 +13,7 @@ class WakelockAurora extends WakelockPlatformInterface { Timer? _timer; static void registerWith() { - if (TargetPlatform.aurora == defaultTargetPlatform) { - WakelockPlatformInterface.instance = WakelockAurora(); - } + WakelockPlatformInterface.instance = WakelockAurora(); } @override diff --git a/packages/wakelock/wakelock_aurora/pubspec.yaml b/packages/wakelock/wakelock_aurora/pubspec.yaml index bfa506a..47dfab0 100644 --- a/packages/wakelock/wakelock_aurora/pubspec.yaml +++ b/packages/wakelock/wakelock_aurora/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.5.0" + flutter: ">=3.0.0" dependencies: flutter: diff --git a/packages/xdga_directories/data/preview.png b/packages/xdga_directories/data/preview.png deleted file mode 100644 index 1fc2f51..0000000 Binary files a/packages/xdga_directories/data/preview.png and /dev/null differ diff --git a/packages/xdga_directories/example/.gitignore b/packages/xdga_directories/example/.gitignore deleted file mode 100644 index 3db3823..0000000 --- a/packages/xdga_directories/example/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# Aurora generated -/aurora/flutter diff --git a/packages/xdga_directories/example/README.md b/packages/xdga_directories/example/README.md deleted file mode 100644 index f407146..0000000 --- a/packages/xdga_directories/example/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# xdga_directories_example - -Demonstrates how to use the xdga_directories plugin. - -## Build - -```shell -# Add an alias if it doesn't already exist -alias flutter-aurora=$HOME/.local/opt/flutter-sdk/bin/flutter -# Get dependencies -flutter-aurora pub get -# Run build -flutter-aurora build aurora --release # [--release|--debug|--profile] -``` - -You can collect, sign, run an example on the device with a script located in the `script/build_example.sh` -More information in `build_example.sh`. - -### Preview example - -![preview.png](../data/preview.png) diff --git a/packages/xdga_directories/example/analysis_options.yaml b/packages/xdga_directories/example/analysis_options.yaml deleted file mode 100644 index 566c597..0000000 --- a/packages/xdga_directories/example/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -include: package:flutter_lints/flutter.yaml diff --git a/packages/xdga_directories/example/aurora/.gitignore b/packages/xdga_directories/example/aurora/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/packages/xdga_directories/example/aurora/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/packages/xdga_directories/example/aurora/CMakeLists.txt b/packages/xdga_directories/example/aurora/CMakeLists.txt deleted file mode 100644 index 0495b62..0000000 --- a/packages/xdga_directories/example/aurora/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -cmake_minimum_required(VERSION 3.10) -project(com.example.xdga_directories_example LANGUAGES CXX) - -include(GNUInstallDirs) - -set(BINARY_NAME ${CMAKE_PROJECT_NAME}) -set(FLUTTER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flutter) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") - -set(CMAKE_SKIP_RPATH OFF) -set(CMAKE_INSTALL_RPATH "\$ORIGIN/../share/${BINARY_NAME}/lib") - -find_package(PkgConfig REQUIRED) -find_package(Qt5 COMPONENTS Core REQUIRED) -pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) - -add_executable(${BINARY_NAME} main.cpp ${FLUTTER_DIR}/generated_plugin_registrant.cpp) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::FlutterEmbedder Qt5::Core) -target_include_directories(${BINARY_NAME} PRIVATE ${FLUTTER_DIR}) - -include(flutter/generated_plugins.cmake) - -set(PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}) -set(DESKTOP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/applications) -set(ICONS_INSTALL_ROOT_DIR ${CMAKE_INSTALL_DATADIR}/icons/hicolor) - -add_custom_command(TARGET ${BINARY_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libflutter-embedder.so - ${PROJECT_BINARY_DIR}/bundle/lib/libflutter-embedder.so) - -install(FILES ${PROJECT_BINARY_DIR}/bundle/icudtl.dat DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/flutter_assets DESTINATION ${PACKAGE_INSTALL_DIR}) -install(DIRECTORY ${PROJECT_BINARY_DIR}/bundle/lib DESTINATION ${PACKAGE_INSTALL_DIR}) - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES desktop/${BINARY_NAME}.desktop DESTINATION ${DESKTOP_INSTALL_DIR}) - -foreach(ICONS_SIZE 86x86 108x108 128x128 172x172) - install(FILES icons/${ICONS_SIZE}.png - RENAME ${BINARY_NAME}.png - DESTINATION ${ICONS_INSTALL_ROOT_DIR}/${ICONS_SIZE}/apps/) -endforeach(ICONS_SIZE) diff --git a/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop b/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop deleted file mode 100644 index b025d3c..0000000 --- a/packages/xdga_directories/example/aurora/desktop/com.example.xdga_directories_example.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Type=Application -Name=xdga_directories_example -Comment=Demonstrates how to use the xdga_directories plugin. -Icon=com.example.xdga_directories_example -Exec=/usr/bin/com.example.xdga_directories_example -X-Nemo-Application-Type=silica-qt5 - -[X-Application] -Permissions= -OrganizationName=com.example -ApplicationName=xdga_directories_example diff --git a/packages/xdga_directories/example/aurora/icons/108x108.png b/packages/xdga_directories/example/aurora/icons/108x108.png deleted file mode 100644 index 984893d..0000000 Binary files a/packages/xdga_directories/example/aurora/icons/108x108.png and /dev/null differ diff --git a/packages/xdga_directories/example/aurora/icons/128x128.png b/packages/xdga_directories/example/aurora/icons/128x128.png deleted file mode 100644 index 2d552ef..0000000 Binary files a/packages/xdga_directories/example/aurora/icons/128x128.png and /dev/null differ diff --git a/packages/xdga_directories/example/aurora/icons/172x172.png b/packages/xdga_directories/example/aurora/icons/172x172.png deleted file mode 100644 index 9dc271b..0000000 Binary files a/packages/xdga_directories/example/aurora/icons/172x172.png and /dev/null differ diff --git a/packages/xdga_directories/example/aurora/icons/86x86.png b/packages/xdga_directories/example/aurora/icons/86x86.png deleted file mode 100644 index 5923bb1..0000000 Binary files a/packages/xdga_directories/example/aurora/icons/86x86.png and /dev/null differ diff --git a/packages/xdga_directories/example/aurora/main.cpp b/packages/xdga_directories/example/aurora/main.cpp deleted file mode 100644 index 83f2ca8..0000000 --- a/packages/xdga_directories/example/aurora/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -#include -#include "generated_plugin_registrant.h" - -int main(int argc, char *argv[]) { - Application::Initialize(argc, argv); - RegisterPlugins(); - Application::Launch(); - return 0; -} diff --git a/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec b/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec deleted file mode 100644 index 36130d1..0000000 --- a/packages/xdga_directories/example/aurora/rpm/com.example.xdga_directories_example.spec +++ /dev/null @@ -1,31 +0,0 @@ -%global __provides_exclude_from ^%{_datadir}/%{name}/lib/.*$ -%global __requires_exclude ^lib(dconf|flutter-embedder|maliit-glib|appmanifest-.+|.+_platform_plugin)\\.so.*$ - -Name: com.example.xdga_directories_example -Summary: Demonstrates how to use the xdga_directories plugin. -Version: 0.1.0 -Release: 1 -License: Proprietary -Source0: %{name}-%{version}.tar.zst - -BuildRequires: cmake -BuildRequires: pkgconfig(flutter-embedder) - -%description -%{summary}. - -%prep -%autosetup - -%build -%cmake -DCMAKE_BUILD_TYPE=%{_flutter_build_type} -%make_build - -%install -%make_install - -%files -%{_bindir}/%{name} -%{_datadir}/%{name}/* -%{_datadir}/applications/%{name}.desktop -%{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/packages/xdga_directories/example/lib/main.dart b/packages/xdga_directories/example/lib/main.dart deleted file mode 100644 index 860ac8a..0000000 --- a/packages/xdga_directories/example/lib/main.dart +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2023. Open Mobile Platform LLC. - * License: Proprietary. - */ -import 'package:flutter/material.dart'; -import 'package:xdga_directories/xdga_directories.dart' as xdga; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatefulWidget { - const MyApp({super.key}); - - @override - State createState() => _MyAppState(); -} - -class _MyAppState extends State { - late String appDataLocation; - late String cacheLocation; - late String documentsLocation; - late String downloadLocation; - late String musicLocation; - late String picturesLocation; - late String genericDataLocation; - late String moviesLocation; - - @override - void initState() { - super.initState(); - // Get paths - appDataLocation = xdga.getAppDataLocation(); - cacheLocation = xdga.getCacheLocation(); - documentsLocation = xdga.getDocumentsLocation(); - downloadLocation = xdga.getDownloadLocation(); - musicLocation = xdga.getMusicLocation(); - picturesLocation = xdga.getPicturesLocation(); - genericDataLocation = xdga.getGenericDataLocation(); - moviesLocation = xdga.getMoviesLocation(); - } - - @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: 16); - const spacerSmall = SizedBox(height: 8); - - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Example xdga_directories'), - ), - body: SingleChildScrollView( - child: Center( - child: Container( - padding: const EdgeInsets.all(10), - child: Column( - children: [ - Container( - decoration: const BoxDecoration( - color: Colors.green, - borderRadius: BorderRadius.all(Radius.circular(10.0)), - ), - child: const Padding( - padding: EdgeInsets.all(20), - child: Text( - 'Demo application demonstration use xdga_directories', - style: textStyleWhite, - ), - ), - ), - const SizedBox(height: 30), - - // getAppDataLocation - const Text( - 'getAppDataLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - appDataLocation, - style: textStylePath, - ), - spaceMedium, - - // getCacheLocation - const Text( - 'getCacheLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - cacheLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getDocumentsLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - documentsLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getDownloadLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - downloadLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getMusicLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - musicLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getPicturesLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - picturesLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getGenericDataLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - genericDataLocation, - style: textStylePath, - ), - spaceMedium, - - // getDocumentsLocation - const Text( - 'getMoviesLocation()', - style: textStyleTitle, - ), - spacerSmall, - Text( - moviesLocation, - style: textStylePath, - ), - ], - ), - ), - ), - ), - ), - ); - } -} diff --git a/packages/xdga_directories/example/pubspec.lock b/packages/xdga_directories/example/pubspec.lock deleted file mode 100644 index 2ee3257..0000000 --- a/packages/xdga_directories/example/pubspec.lock +++ /dev/null @@ -1,182 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.2" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - xdga_directories: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "0.0.1" -sdks: - dart: ">=2.18.6 <3.0.0" - flutter: ">=2.11.0" diff --git a/packages/xdga_directories/example/pubspec.yaml b/packages/xdga_directories/example/pubspec.yaml deleted file mode 100644 index be27c0e..0000000 --- a/packages/xdga_directories/example/pubspec.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -name: xdga_directories_example -description: Demonstrates how to use the xdga_directories plugin. - -publish_to: 'none' - -version: 1.0.0+1 - -environment: - sdk: '>=2.18.6 <3.0.0' - -dependencies: - flutter: - sdk: flutter - xdga_directories: - path: ../ - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - -flutter: - uses-material-design: true diff --git a/packages/xdga_directories/pubspec.yaml b/packages/xdga_directories/pubspec.yaml index d358645..8fc911e 100644 --- a/packages/xdga_directories/pubspec.yaml +++ b/packages/xdga_directories/pubspec.yaml @@ -7,7 +7,7 @@ version: 0.0.1 environment: sdk: '>=2.18.6 <3.0.0' - flutter: ">=2.11.0" + flutter: ">=3.0.0" dependencies: flutter: diff --git a/script/build_example.sh b/script/build_example.sh deleted file mode 100755 index bac91f4..0000000 --- a/script/build_example.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -## Build example, sign rpm, upload/install/run rpm to device - -## Usage -## -## chmod +x ./build_example.sh -## -## ./build_example.sh \ -## -p xdga_directories \ -## -d : \ -## -s /home/user/sign/system_keys - -## Flutter path -FLUTTER="$HOME/.local/opt/flutter-sdk/bin/flutter" - -## 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 - -while getopts p:d:s: flag; do - case "${flag}" in - p) package=${OPTARG} ;; - d) device=${OPTARG} ;; - s) sign=${OPTARG} ;; - *) - echo "usage: $0 [-p] [-d] [-s]" >&2 - exit 1 - ;; - esac -done - -if [ -z "$package" ]; then - echo "Specify a build package" - exit -else - cd "../packages/$package" 2>/dev/null || eval 'echo "Package \"$package\" not found." && exit' - ## Update dependency - $FLUTTER pub get - ## Run ffigen if has - $FLUTTER pub run ffigen --config ffigen.yaml 2>/dev/null - ## Open example dir - cd "example" || exit - ## Build aurora example app - { - $FLUTTER build aurora --release - } || { - exit 1; - } -fi - -if [ -n "$sign" ]; then - - key=$(ls "$sign"/*key.pem) - - if [ -z "$key" ]; then - echo "Key *key.pem not found." - exit - fi - - cert=$(ls "$sign"/*cert.pem) - - if [ -z "$cert" ]; then - echo "Key *cert.pem not found." - exit - fi - - ## Sign rpm system key - "$PSDK_DIR"/sdk-chroot rpmsign-external sign \ - --key "$key" \ - --cert "$cert" \ - build/aurora/arm/release/RPMS/*.rpm -fi - -if [ -n "$device" ]; then - - IFS=':' read -ra ADDR <<< "$device" - IFS='/' read -ra ADDP <<< "$package" - - D_IP="${ADDR[0]}" - D_PASS="${ADDR[1]}" - APP_KEY="${ADDP[-1]}" - - # shellcheck disable=SC2012 - rpm=$(ls "$PWD"/build/aurora/arm/release/RPMS/*.rpm | sort -r | head -n 1) - - # upload rpm - scp "$rpm" defaultuser@"$D_IP:/home/defaultuser/Downloads" - - # install rpm - ssh -t defaultuser@$D_IP "echo $D_PASS | devel-su pkcon -y install-local /home/defaultuser/Downloads/*$APP_KEY*.rpm" - - # run application - ssh -t defaultuser@$D_IP "/usr/bin/com.example.${APP_KEY}_example" -fi diff --git a/script/vscode_properties.sh b/script/vscode_properties.sh deleted file mode 100755 index e80ab79..0000000 --- a/script/vscode_properties.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2023. Open Mobile Platform LLC. -# License: Proprietary. - -## 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