mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
[linting_tool] Prepare for release (#880)
This commit is contained in:
committed by
GitHub
parent
0aad30fc5b
commit
410e43fbc1
@@ -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<void> 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<RulesProfile>('rules_profile');
|
||||
|
||||
setWindowMinSize(const Size(600, 600));
|
||||
|
||||
runApp(const LintingTool());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<ProfilesStore>(
|
||||
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<ProfilesStore>()
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -177,6 +177,8 @@ class _ProfileTypeDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var profilesStore = context.watch<ProfilesStore>();
|
||||
|
||||
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'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user