From 410e43fbc17190af2b636a3f9866c5c1473a8280 Mon Sep 17 00:00:00 2001 From: Abdullah Deshmukh Date: Mon, 23 Aug 2021 16:26:55 -0700 Subject: [PATCH] [linting_tool] Prepare for release (#880) --- experimental/linting_tool/README.md | 3 +-- experimental/linting_tool/lib/main.dart | 10 ++++++++++ .../lib/model/editing_controller.dart | 1 + .../lib/model/profiles_store.dart | 1 + .../linting_tool/lib/model/rules_store.dart | 1 + .../lib/pages/default_lints_page.dart | 8 ++++---- .../lib/pages/default_rules_page.dart | 8 ++++---- .../linting_tool/lib/pages/home_page.dart | 8 ++++---- .../linting_tool/lib/pages/rules_page.dart | 12 +++++++---- .../lib/pages/saved_lints_page.dart | 13 ++++++------ .../linting_tool/lib/theme/app_theme.dart | 20 ++++++++++++++----- .../lib/widgets/adaptive_nav.dart | 11 ++++++++-- .../lib/widgets/lint_expansion_tile.dart | 17 +++++++++------- .../flutter/generated_plugin_registrant.cc | 4 ++++ .../linux/flutter/generated_plugins.cmake | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 2 ++ experimental/linting_tool/macos/Podfile.lock | 8 +++++++- experimental/linting_tool/pubspec.lock | 13 ++++++++++-- experimental/linting_tool/pubspec.yaml | 7 +++++++ .../flutter/generated_plugin_registrant.cc | 9 ++++++--- .../windows/flutter/generated_plugins.cmake | 1 + platform_channels/pubspec.lock | 6 +++--- 22 files changed, 117 insertions(+), 47 deletions(-) diff --git a/experimental/linting_tool/README.md b/experimental/linting_tool/README.md index e60a1be20..65f33e549 100644 --- a/experimental/linting_tool/README.md +++ b/experimental/linting_tool/README.md @@ -2,13 +2,12 @@ A desktop tool that helps you manage linter rules for your Flutter project. -This sample is currently being built. Not all platforms and functionality are in place. - ## Goals for this sample * Show how to read and write files on Desktop * Show how to create, parse and use yaml files * Show how to implement basic navigation in Desktop apps +* Show how to implement right-click popup menus ## Questions/issues diff --git a/experimental/linting_tool/lib/main.dart b/experimental/linting_tool/lib/main.dart index e9e6543ed..65bfbbe82 100644 --- a/experimental/linting_tool/lib/main.dart +++ b/experimental/linting_tool/lib/main.dart @@ -7,11 +7,21 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:linting_tool/app.dart'; import 'package:linting_tool/model/profile.dart'; import 'package:linting_tool/model/rule.dart'; +import 'package:window_size/window_size.dart'; Future main() async { + /// Initiliaze Hive DB. await Hive.initFlutter(); + + /// Register adapters for [Rule] and [RulesProfile] + /// so that their objects can be directly saved to the DB. Hive.registerAdapter(RuleAdapter()); Hive.registerAdapter(RulesProfileAdapter()); + + /// Open a [LazyBox] to retrieve data from it await Hive.openLazyBox('rules_profile'); + + setWindowMinSize(const Size(600, 600)); + runApp(const LintingTool()); } diff --git a/experimental/linting_tool/lib/model/editing_controller.dart b/experimental/linting_tool/lib/model/editing_controller.dart index 50e32abde..f9ce4a5dd 100644 --- a/experimental/linting_tool/lib/model/editing_controller.dart +++ b/experimental/linting_tool/lib/model/editing_controller.dart @@ -7,6 +7,7 @@ import 'package:linting_tool/model/profile.dart'; import 'package:linting_tool/model/profiles_store.dart'; import 'package:linting_tool/model/rule.dart'; +/// Used to control editing of the saved profiles on the RulesPage. class EditingController extends ChangeNotifier { bool _isEditing; diff --git a/experimental/linting_tool/lib/model/profiles_store.dart b/experimental/linting_tool/lib/model/profiles_store.dart index e6618d03a..b18a32470 100644 --- a/experimental/linting_tool/lib/model/profiles_store.dart +++ b/experimental/linting_tool/lib/model/profiles_store.dart @@ -111,6 +111,7 @@ class ProfilesStore extends ChangeNotifier { try { var templateFileData = await repository.getTemplateFile(); + /// Fetch formatted data to create new YamlFile. String newYamlFile = _prepareYamlFile(profile, templateFileData, rulesStyle); diff --git a/experimental/linting_tool/lib/model/rules_store.dart b/experimental/linting_tool/lib/model/rules_store.dart index b95f0dfb6..e1024762f 100644 --- a/experimental/linting_tool/lib/model/rules_store.dart +++ b/experimental/linting_tool/lib/model/rules_store.dart @@ -11,6 +11,7 @@ import 'package:linting_tool/model/rule.dart'; import 'package:linting_tool/repository/repository.dart'; import 'package:http/http.dart' as http; +/// Manages fetching rules from the web. class RuleStore extends ChangeNotifier { late final Repository repository; diff --git a/experimental/linting_tool/lib/pages/default_lints_page.dart b/experimental/linting_tool/lib/pages/default_lints_page.dart index 043198b88..31dd2958c 100644 --- a/experimental/linting_tool/lib/pages/default_lints_page.dart +++ b/experimental/linting_tool/lib/pages/default_lints_page.dart @@ -28,19 +28,19 @@ class DefaultLintsPage extends StatelessWidget { ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; final endPadding = isTablet ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; return ListView.separated( padding: EdgeInsetsDirectional.only( start: startPadding, end: endPadding, - top: isDesktop ? 28 : 0, - bottom: isDesktop ? kToolbarHeight : 0, + top: isDesktop ? 28 : 16, + bottom: isDesktop ? kToolbarHeight : 16, ), cacheExtent: 5, itemCount: defaultSets.length, diff --git a/experimental/linting_tool/lib/pages/default_rules_page.dart b/experimental/linting_tool/lib/pages/default_rules_page.dart index f0b20768a..ee5c84aba 100644 --- a/experimental/linting_tool/lib/pages/default_rules_page.dart +++ b/experimental/linting_tool/lib/pages/default_rules_page.dart @@ -24,12 +24,12 @@ class DefaultRulesPage extends StatelessWidget { ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; final endPadding = isTablet ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; return Scaffold( appBar: AppBar( title: Text( @@ -57,8 +57,8 @@ class DefaultRulesPage extends StatelessWidget { padding: EdgeInsetsDirectional.only( start: startPadding, end: endPadding, - top: isDesktop ? 28 : 0, - bottom: isDesktop ? kToolbarHeight : 0, + top: isDesktop ? 28 : 16, + bottom: isDesktop ? kToolbarHeight : 16, ), itemCount: profile.rules.length, cacheExtent: 5, diff --git a/experimental/linting_tool/lib/pages/home_page.dart b/experimental/linting_tool/lib/pages/home_page.dart index 03287da9d..6a1173a1b 100644 --- a/experimental/linting_tool/lib/pages/home_page.dart +++ b/experimental/linting_tool/lib/pages/home_page.dart @@ -27,19 +27,19 @@ class HomePage extends StatelessWidget { ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; final endPadding = isTablet ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; return ListView.separated( padding: EdgeInsetsDirectional.only( start: startPadding, end: endPadding, - top: isDesktop ? 28 : 0, - bottom: isDesktop ? kToolbarHeight : 0, + top: isDesktop ? 28 : 16, + bottom: isDesktop ? kToolbarHeight : 16, ), itemCount: rulesStore.rules.length, cacheExtent: 5, diff --git a/experimental/linting_tool/lib/pages/rules_page.dart b/experimental/linting_tool/lib/pages/rules_page.dart index 7c3f6a8f9..e1315f961 100644 --- a/experimental/linting_tool/lib/pages/rules_page.dart +++ b/experimental/linting_tool/lib/pages/rules_page.dart @@ -27,7 +27,7 @@ class RulesPage extends StatelessWidget { ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; final endPadding = isTablet ? 60.0 : isDesktop @@ -59,6 +59,9 @@ class RulesPage extends StatelessWidget { backgroundColor: Colors.white, brightness: Brightness.light, ), + + /// ContextMenuOverlay is required to show + /// right-click context menus using ContextMenuRegion. body: ContextMenuOverlay( child: Consumer( builder: (context, profilesStore, child) { @@ -75,17 +78,18 @@ class RulesPage extends StatelessWidget { padding: EdgeInsetsDirectional.only( start: startPadding, end: endPadding, - top: isDesktop ? 28 : 0, - bottom: isDesktop ? kToolbarHeight : 0, + top: isDesktop ? 28 : 16, + bottom: isDesktop ? kToolbarHeight : 16, ), itemCount: profile.rules.length, cacheExtent: 5, itemBuilder: (context, index) { + /// Show righ-click context menu to delete rule. return ContextMenuRegion( contextMenu: GenericContextMenu( buttonConfigs: [ ContextMenuButtonConfig( - 'Remove from profile', + 'Remove rule from profile', onPressed: () { context .read() diff --git a/experimental/linting_tool/lib/pages/saved_lints_page.dart b/experimental/linting_tool/lib/pages/saved_lints_page.dart index 7b1b06a1f..73af8b98c 100644 --- a/experimental/linting_tool/lib/pages/saved_lints_page.dart +++ b/experimental/linting_tool/lib/pages/saved_lints_page.dart @@ -30,19 +30,19 @@ class SavedLintsPage extends StatelessWidget { ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; final endPadding = isTablet ? 60.0 : isDesktop ? 120.0 - : 4.0; + : 16.0; return ListView.separated( padding: EdgeInsetsDirectional.only( start: startPadding, end: endPadding, - top: isDesktop ? 28 : 0, - bottom: isDesktop ? kToolbarHeight : 0, + top: isDesktop ? 28 : 16, + bottom: isDesktop ? kToolbarHeight : 16, ), itemCount: profilesStore.savedProfiles.length, cacheExtent: 5, @@ -74,8 +74,9 @@ class SavedLintsPage extends StatelessWidget { context, MaterialPageRoute( builder: (context) => ChangeNotifierProvider( - create: (context) => - EditingController(isEditing: true), + create: (context) => EditingController( + isEditing: true, + ), child: RulesPage(selectedProfileIndex: index), ), ), diff --git a/experimental/linting_tool/lib/theme/app_theme.dart b/experimental/linting_tool/lib/theme/app_theme.dart index cc728ff69..9e9c51383 100644 --- a/experimental/linting_tool/lib/theme/app_theme.dart +++ b/experimental/linting_tool/lib/theme/app_theme.dart @@ -18,12 +18,16 @@ class AppTheme { ), navigationRailTheme: NavigationRailThemeData( backgroundColor: AppColors.blue700, - selectedIconTheme: const IconThemeData(color: AppColors.orange500), + selectedIconTheme: const IconThemeData( + color: AppColors.orange500, + ), selectedLabelTextStyle: GoogleFonts.workSansTextTheme().headline5!.copyWith( color: AppColors.orange500, ), - unselectedIconTheme: const IconThemeData(color: AppColors.blue200), + unselectedIconTheme: const IconThemeData( + color: AppColors.blue200, + ), unselectedLabelTextStyle: GoogleFonts.workSansTextTheme().headline5!.copyWith( color: AppColors.blue200, @@ -36,7 +40,9 @@ class AppTheme { AppColors.lightChipBackground, Brightness.light, ), - colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blueGrey), + colorScheme: ColorScheme.fromSwatch( + primarySwatch: Colors.blueGrey, + ), textTheme: _buildReplyLightTextTheme(base.textTheme), scaffoldBackgroundColor: AppColors.blue50, ); @@ -52,12 +58,16 @@ class AppTheme { ), navigationRailTheme: NavigationRailThemeData( backgroundColor: AppColors.darkBottomAppBarBackground, - selectedIconTheme: const IconThemeData(color: AppColors.orange300), + selectedIconTheme: const IconThemeData( + color: AppColors.orange300, + ), selectedLabelTextStyle: GoogleFonts.workSansTextTheme().headline5!.copyWith( color: AppColors.orange300, ), - unselectedIconTheme: const IconThemeData(color: AppColors.greyLabel), + unselectedIconTheme: const IconThemeData( + color: AppColors.greyLabel, + ), unselectedLabelTextStyle: GoogleFonts.workSansTextTheme().headline5!.copyWith( color: AppColors.greyLabel, diff --git a/experimental/linting_tool/lib/widgets/adaptive_nav.dart b/experimental/linting_tool/lib/widgets/adaptive_nav.dart index a1da02d51..96fef4782 100644 --- a/experimental/linting_tool/lib/widgets/adaptive_nav.dart +++ b/experimental/linting_tool/lib/widgets/adaptive_nav.dart @@ -195,7 +195,6 @@ class _NavigationRailHeader extends StatelessWidget { children: [ const SizedBox(width: 6), InkWell( - key: const ValueKey('ReplyLogo'), borderRadius: const BorderRadius.all(Radius.circular(16)), onTap: () { extended.value = !extended.value!; @@ -323,7 +322,15 @@ class _NavigationRailTrailingSection extends StatelessWidget { void _onTapped(BuildContext context, String key) { switch (key) { case 'About': - showAboutDialog(context: context); + showAboutDialog( + context: context, + applicationIcon: const FlutterLogo(), + children: [ + const Text( + 'A tool that helps you manage linter rules for your Flutter projects.', + ), + ], + ); break; default: break; diff --git a/experimental/linting_tool/lib/widgets/lint_expansion_tile.dart b/experimental/linting_tool/lib/widgets/lint_expansion_tile.dart index 206fa8ac3..29b0f826a 100644 --- a/experimental/linting_tool/lib/widgets/lint_expansion_tile.dart +++ b/experimental/linting_tool/lib/widgets/lint_expansion_tile.dart @@ -177,6 +177,8 @@ class _ProfileTypeDialog extends StatelessWidget { @override Widget build(BuildContext context) { + var profilesStore = context.watch(); + return AlertDialog( actionsPadding: const EdgeInsets.only( left: 16.0, @@ -185,17 +187,18 @@ class _ProfileTypeDialog extends StatelessWidget { ), title: const Text('Select Profile Type'), actions: [ - ElevatedButton( - onPressed: () { - Navigator.pop(context, ProfileType.existingProfile); - }, - child: const Text('Existing Profile'), - ), + if (profilesStore.savedProfiles.isNotEmpty) + ElevatedButton( + onPressed: () { + Navigator.pop(context, ProfileType.existingProfile); + }, + child: const Text('Existing'), + ), TextButton( onPressed: () { Navigator.pop(context, ProfileType.newProfile); }, - child: const Text('Create new profile'), + child: const Text('New'), ), ], ); diff --git a/experimental/linting_tool/linux/flutter/generated_plugin_registrant.cc b/experimental/linting_tool/linux/flutter/generated_plugin_registrant.cc index 2609641f6..215e09436 100644 --- a/experimental/linting_tool/linux/flutter/generated_plugin_registrant.cc +++ b/experimental/linting_tool/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,7 @@ #include #include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = @@ -14,4 +15,7 @@ void fl_register_plugins(FlPluginRegistry* registry) { 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); + g_autoptr(FlPluginRegistrar) window_size_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin"); + window_size_plugin_register_with_registrar(window_size_registrar); } diff --git a/experimental/linting_tool/linux/flutter/generated_plugins.cmake b/experimental/linting_tool/linux/flutter/generated_plugins.cmake index 627fdc7f8..73c8db305 100644 --- a/experimental/linting_tool/linux/flutter/generated_plugins.cmake +++ b/experimental/linting_tool/linux/flutter/generated_plugins.cmake @@ -5,6 +5,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_linux url_launcher_linux + window_size ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/experimental/linting_tool/macos/Flutter/GeneratedPluginRegistrant.swift b/experimental/linting_tool/macos/Flutter/GeneratedPluginRegistrant.swift index 021fe488e..d2deae347 100644 --- a/experimental/linting_tool/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/experimental/linting_tool/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,9 +8,11 @@ import Foundation import file_selector_macos import path_provider_macos import url_launcher_macos +import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin")) } diff --git a/experimental/linting_tool/macos/Podfile.lock b/experimental/linting_tool/macos/Podfile.lock index 46af999c9..9936f80f1 100644 --- a/experimental/linting_tool/macos/Podfile.lock +++ b/experimental/linting_tool/macos/Podfile.lock @@ -6,12 +6,15 @@ PODS: - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS + - window_size (0.0.2): + - FlutterMacOS DEPENDENCIES: - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) EXTERNAL SOURCES: file_selector_macos: @@ -22,13 +25,16 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + window_size: + :path: Flutter/ephemeral/.symlinks/plugins/window_size/macos SPEC CHECKSUMS: file_selector_macos: ff6dc948d4ddd34e8602a1f60b7d0b4cc6051a47 FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b url_launcher_macos: 45af3d61de06997666568a7149c1be98b41c95d4 + window_size: 339dafa0b27a95a62a843042038fa6c3c48de195 PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c -COCOAPODS: 1.10.1 +COCOAPODS: 1.10.2 diff --git a/experimental/linting_tool/pubspec.lock b/experimental/linting_tool/pubspec.lock index c173b9015..40ebe368e 100644 --- a/experimental/linting_tool/pubspec.lock +++ b/experimental/linting_tool/pubspec.lock @@ -692,14 +692,14 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" vector_math: dependency: transitive description: @@ -728,6 +728,15 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.5" + window_size: + dependency: "direct main" + description: + path: "plugins/window_size" + ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81 + resolved-ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81 + url: "git://github.com/google/flutter-desktop-embedding.git" + source: git + version: "0.1.0" xdg_directories: dependency: transitive description: diff --git a/experimental/linting_tool/pubspec.yaml b/experimental/linting_tool/pubspec.yaml index 403fc2615..a960a125e 100644 --- a/experimental/linting_tool/pubspec.yaml +++ b/experimental/linting_tool/pubspec.yaml @@ -3,6 +3,8 @@ description: A new Flutter project. version: 1.0.0+1 +publish_to: 'none' + environment: sdk: ">=2.12.0 <3.0.0" @@ -28,6 +30,11 @@ dependencies: provider: ^5.0.0 yaml: ^3.1.0 context_menus: ^0.1.0+5 + window_size: + git: + url: git://github.com/google/flutter-desktop-embedding.git + path: plugins/window_size + ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81 dev_dependencies: flutter_test: diff --git a/experimental/linting_tool/windows/flutter/generated_plugin_registrant.cc b/experimental/linting_tool/windows/flutter/generated_plugin_registrant.cc index 7133e517d..66c947041 100644 --- a/experimental/linting_tool/windows/flutter/generated_plugin_registrant.cc +++ b/experimental/linting_tool/windows/flutter/generated_plugin_registrant.cc @@ -5,11 +5,14 @@ #include "generated_plugin_registrant.h" #include -#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorPlugin")); - UrlLauncherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WindowSizePluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowSizePlugin")); } diff --git a/experimental/linting_tool/windows/flutter/generated_plugins.cmake b/experimental/linting_tool/windows/flutter/generated_plugins.cmake index b944b21a8..f3f27e476 100644 --- a/experimental/linting_tool/windows/flutter/generated_plugins.cmake +++ b/experimental/linting_tool/windows/flutter/generated_plugins.cmake @@ -5,6 +5,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows url_launcher_windows + window_size ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/platform_channels/pubspec.lock b/platform_channels/pubspec.lock index 0dd2532a0..29526b6b5 100644 --- a/platform_channels/pubspec.lock +++ b/platform_channels/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -113,7 +113,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -148,7 +148,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: