From 481b9837f49138ce2b2d316506d41a97e5e48ea6 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Wed, 4 Dec 2024 10:33:18 +0100 Subject: [PATCH] Added feedback button --- lib/openvino_console_app.dart | 50 +++--- .../text_generation/text_generation.dart | 11 +- lib/theme_fluent.dart | 4 + lib/widgets/feedback_button.dart | 38 +++++ lib/widgets/help_button.dart | 0 linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 + macos/Podfile.lock | 8 +- pubspec.lock | 144 +++++++++++++----- pubspec.yaml | 1 + .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 13 files changed, 203 insertions(+), 64 deletions(-) create mode 100644 lib/widgets/feedback_button.dart create mode 100644 lib/widgets/help_button.dart diff --git a/lib/openvino_console_app.dart b/lib/openvino_console_app.dart index 8b3b97fe..7a1c50c9 100644 --- a/lib/openvino_console_app.dart +++ b/lib/openvino_console_app.dart @@ -6,6 +6,7 @@ import 'package:inference/providers/preference_provider.dart'; import 'package:inference/providers/project_provider.dart'; import 'package:inference/theme_fluent.dart'; import 'package:inference/utils.dart'; +import 'package:inference/widgets/feedback_button.dart'; import 'package:provider/provider.dart'; import 'package:fluent_ui/fluent_ui.dart'; @@ -124,26 +125,35 @@ class _OpenVINOTestDriveAppState extends State { @override Widget build(BuildContext context) { - return NavigationView( - appBar: NavigationAppBar( - leading: Container(), - height: 48, + return Stack( + children: [ + NavigationView( + appBar: NavigationAppBar( + leading: Container(), + height: 48, + ), + paneBodyBuilder: (item, child) { + final name = + item?.key is ValueKey ? (item!.key as ValueKey).value : null; + return FocusTraversalGroup( + key: ValueKey('body$name'), + child: widget.child, + ); + }, + pane: NavigationPane( + selected: _calculateSelectedIndex(context), + toggleable: false, + displayMode: PaneDisplayMode.compact, + items: originalNavigationItems, + footerItems: footerNavigationItems, + ), ), - paneBodyBuilder: (item, child) { - final name = - item?.key is ValueKey ? (item!.key as ValueKey).value : null; - return FocusTraversalGroup( - key: ValueKey('body$name'), - child: widget.child, - ); - }, - pane: NavigationPane( - selected: _calculateSelectedIndex(context), - toggleable: false, - displayMode: PaneDisplayMode.compact, - items: originalNavigationItems, - footerItems: footerNavigationItems, - ), - ); + const Positioned( + right: 24, + bottom: 24, + child: FeedbackButton() + ) + ], + ); } } diff --git a/lib/pages/text_generation/text_generation.dart b/lib/pages/text_generation/text_generation.dart index 637683c9..fd58d0fc 100644 --- a/lib/pages/text_generation/text_generation.dart +++ b/lib/pages/text_generation/text_generation.dart @@ -36,9 +36,14 @@ class _TextGenerationPageState extends State { !textInferenceProvider.sameProps(widget.project, preferences.device); if (init) { final textInferenceProvider = TextInferenceProvider(widget.project, preferences.device); - textInferenceProvider.loadModel().catchError((e) { - // TODO: Error handling - print(e); + textInferenceProvider.loadModel().catchError((e) async { + // ignore: use_build_context_synchronously + await displayInfoBar(context, builder: (context, close) => InfoBar( + title: const Text('Error loading model'), + content: Text(e.toString()), + severity: InfoBarSeverity.error, + action: IconButton(icon: const Icon(FluentIcons.clear), onPressed: close), + )); }); return textInferenceProvider; } diff --git a/lib/theme_fluent.dart b/lib/theme_fluent.dart index 9f965a27..2bed6ffa 100644 --- a/lib/theme_fluent.dart +++ b/lib/theme_fluent.dart @@ -110,6 +110,10 @@ const cosmosBackground = DarkLightColor(Color(0xFFEFEAFF), Color(0xFF463d66)); const userMessageColor = DarkLightColor(Color(0xFFe0d6fd), Color(0xFF463D66)); const modelMessageColor = DarkLightColor(Color(0xFFF5F5F5), Color(0xFF343434)); +final AccentColor electricCoral = AccentColor.swatch(const { + 'normal': Color(0xFFFE5A80), +}); + final AccentColor electricCosmos = AccentColor.swatch(const { 'normal': Color(0xFF7000FF), }); diff --git a/lib/widgets/feedback_button.dart b/lib/widgets/feedback_button.dart new file mode 100644 index 00000000..8a28149d --- /dev/null +++ b/lib/widgets/feedback_button.dart @@ -0,0 +1,38 @@ +import 'package:fluent_ui/fluent_ui.dart'; +import 'package:inference/theme_fluent.dart'; +import 'package:inference/widgets/elevation.dart'; +import 'package:url_launcher/url_launcher.dart'; + +final Uri _url = Uri.parse('https://github.com/openvinotoolkit/openvino_testdrive/issues/new'); + + +class FeedbackButton extends StatelessWidget { + const FeedbackButton({super.key}); + + @override + Widget build(BuildContext context) { + return MouseRegion( + cursor: SystemMouseCursors.click, + child: Elevation( + elevation: 8, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), + child: IconButton( + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll(electricCoral.normal), + foregroundColor: const WidgetStatePropertyAll(Colors.white), + shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.circular(24))), + padding: const WidgetStatePropertyAll(EdgeInsets.all(16.0)), + ), + icon: const Icon(FluentIcons.megaphone, size: 16,), + onPressed: () async { + if (await canLaunchUrl(_url)) { + await launchUrl(_url); + } else { + throw 'Could not launch $_url'; + } + }, + ), + ), + ); + } +} diff --git a/lib/widgets/help_button.dart b/lib/widgets/help_button.dart new file mode 100644 index 00000000..e69de29b diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 59809532..260d2f27 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -13,6 +13,7 @@ #include #include #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) desktop_drop_registrar = @@ -36,4 +37,7 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) system_theme_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin"); system_theme_plugin_register_with_registrar(system_theme_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 26f3ca23..b1216525 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_video super_native_extensions system_theme + url_launcher_linux ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index be4f83c6..5b889ac2 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -16,6 +16,7 @@ import path_provider_foundation import screen_brightness_macos import super_native_extensions import system_theme +import url_launcher_macos import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -30,5 +31,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ScreenBrightnessMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenBrightnessMacosPlugin")) SuperNativeExtensionsPlugin.register(with: registry.registrar(forPlugin: "SuperNativeExtensionsPlugin")) SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 79283cb0..2b0c5a5e 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -25,6 +25,8 @@ PODS: - FlutterMacOS - system_theme (0.0.1): - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS - wakelock_plus (0.0.1): - FlutterMacOS @@ -42,6 +44,7 @@ DEPENDENCIES: - screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`) - super_native_extensions (from `Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos`) - system_theme (from `Flutter/ephemeral/.symlinks/plugins/system_theme/macos`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`) EXTERNAL SOURCES: @@ -71,6 +74,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/super_native_extensions/macos system_theme: :path: Flutter/ephemeral/.symlinks/plugins/system_theme/macos + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos wakelock_plus: :path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos @@ -83,11 +88,12 @@ SPEC CHECKSUMS: media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82 media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5 media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5 - package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b + package_info_plus: d2f71247aab4b6521434f887276093acc70d214c path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3 system_theme: c7b9f6659a5caa26c9bc2284da096781e9a6fcbc + url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269 PODFILE CHECKSUM: 16208599a12443d53889ba2270a4985981cfb204 diff --git a/pubspec.lock b/pubspec.lock index e5fd0af8..a6a20aaa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -138,10 +138,10 @@ packages: dependency: transitive description: name: cli_util - sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "0.4.1" clock: dependency: transitive description: @@ -194,18 +194,18 @@ packages: dependency: transitive description: name: crypto - sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27 url: "https://pub.dev" source: hosted - version: "3.0.6" + version: "3.0.5" csslib: dependency: transitive description: name: csslib - sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.0" csv: dependency: "direct main" description: @@ -314,18 +314,18 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "16dc141db5a2ccc6520ebb6a2eb5945b1b09e95085c021d9f914f8ded7f1465c" + sha256: "167bb619cdddaa10ef2907609feb8a79c16dfa479d3afaf960f8e223f754bf12" url: "https://pub.dev" source: hosted - version: "8.1.4" + version: "8.1.2" fixnum: dependency: transitive description: name: fixnum - sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.0" fluent_ui: dependency: "direct main" description: @@ -385,10 +385,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "578bd8c508144fdaffd4f77b8ef2d8c523602275cd697cc3db284dbd762ef4ce" + sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" url: "https://pub.dev" source: hosted - version: "2.0.14" + version: "2.0.10+1" flutter_test: dependency: "direct dev" description: flutter @@ -432,10 +432,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: ce89c5a993ca5eea74535f798478502c30a625ecb10a1de4d7fef5cd1bcac2a4 + sha256: "6f1b756f6e863259a99135ff3c95026c3cdca17d10ebef2bba2261a25ddc8bbc" url: "https://pub.dev" source: hosted - version: "14.4.1" + version: "14.3.0" graphs: dependency: transitive description: @@ -448,10 +448,10 @@ packages: dependency: "direct dev" description: name: html - sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec" + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" url: "https://pub.dev" source: hosted - version: "0.15.5" + version: "0.15.4" http: dependency: "direct main" description: @@ -480,10 +480,10 @@ packages: dependency: "direct main" description: name: image - sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d + sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" url: "https://pub.dev" source: hosted - version: "4.3.0" + version: "4.2.0" integration_test: dependency: "direct dev" description: flutter @@ -573,18 +573,18 @@ packages: dependency: transitive description: name: logging - sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.2.0" macos_window_utils: dependency: transitive description: name: macos_window_utils - sha256: "3d3982495376077f23556b1e235faab3c6d478fe1238766f824e920708d60eba" + sha256: "3534f2af024f2f24112ca28789a44e6750083f8c0065414546c6593ee48a5009" url: "https://pub.dev" source: hosted - version: "1.6.0" + version: "1.6.1" macros: dependency: transitive description: @@ -741,10 +741,10 @@ packages: dependency: transitive description: name: package_info_plus - sha256: da8d9ac8c4b1df253d1a328b7bf01ae77ef132833479ab40763334db13b91cce + sha256: "894f37107424311bdae3e476552229476777b8752c5a2a2369c0cb9a2d5442ef" url: "https://pub.dev" source: hosted - version: "8.1.1" + version: "8.0.3" package_info_plus_platform_interface: dependency: transitive description: @@ -765,18 +765,18 @@ packages: dependency: transitive description: name: path_parsing - sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca" + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.0.1" path_provider: dependency: "direct main" description: name: path_provider - sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.4" path_provider_android: dependency: transitive description: @@ -981,10 +981,10 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" shimmer: dependency: "direct main" description: @@ -1122,10 +1122,10 @@ packages: dependency: transitive description: name: typed_data - sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.3.2" universal_platform: dependency: transitive description: @@ -1142,6 +1142,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603" + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193" + url: "https://pub.dev" + source: hosted + version: "6.3.14" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e" + url: "https://pub.dev" + source: hosted + version: "2.3.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "44cf3aabcedde30f2dba119a9dea3b0f2672fbe6fa96e85536251d678216b3c4" + url: "https://pub.dev" + source: hosted + version: "3.1.3" uuid: dependency: "direct main" description: @@ -1154,26 +1218,26 @@ packages: dependency: transitive description: name: vector_graphics - sha256: "773c9522d66d523e1c7b25dfb95cc91c26a1e17b107039cfe147285e92de7878" + sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" url: "https://pub.dev" source: hosted - version: "1.1.14" + version: "1.1.11+1" vector_graphics_codec: dependency: transitive description: name: vector_graphics_codec - sha256: "2430b973a4ca3c4dbc9999b62b8c719a160100dcbae5c819bae0cacce32c9cdb" + sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da url: "https://pub.dev" source: hosted - version: "1.1.12" + version: "1.1.11+1" vector_graphics_compiler: dependency: transitive description: name: vector_graphics_compiler - sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1 + sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" url: "https://pub.dev" source: hosted - version: "1.1.15" + version: "1.1.11+1" vector_math: dependency: transitive description: @@ -1258,10 +1322,10 @@ packages: dependency: transitive description: name: win32 - sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2" + sha256: e5c39a90447e7c81cfec14b041cdbd0d0916bd9ebbc7fe02ab69568be703b9bd url: "https://pub.dev" source: hosted - version: "5.8.0" + version: "5.6.0" win32_registry: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index aece2933..f69f2c0b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,7 @@ dependencies: media_kit_video: ^1.2.5 # For video rendering. media_kit_libs_video: ^1.0.5 # Native video dependencies. super_clipboard: ^0.8.24 + url_launcher: ^6.3.1 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 201a8b8f..16ca8fb2 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -14,6 +14,7 @@ #include #include #include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopDropPluginRegisterWithRegistrar( @@ -32,4 +33,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("SuperNativeExtensionsPluginCApi")); SystemThemePluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SystemThemePlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 02d7ea45..e85198e7 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -11,6 +11,7 @@ list(APPEND FLUTTER_PLUGIN_LIST screen_brightness_windows super_native_extensions system_theme + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST