From 0aad30fc5b3b4655b8aee1df0876d9a034a72487 Mon Sep 17 00:00:00 2001 From: Abdullah Deshmukh Date: Mon, 16 Aug 2021 18:50:14 -0700 Subject: [PATCH] Add new DefaultRulesPage (#875) --- .../lib/pages/default_lints_page.dart | 4 +- .../lib/pages/default_rules_page.dart | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 experimental/linting_tool/lib/pages/default_rules_page.dart diff --git a/experimental/linting_tool/lib/pages/default_lints_page.dart b/experimental/linting_tool/lib/pages/default_lints_page.dart index 65ac1d742..043198b88 100644 --- a/experimental/linting_tool/lib/pages/default_lints_page.dart +++ b/experimental/linting_tool/lib/pages/default_lints_page.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:linting_tool/layout/adaptive.dart'; import 'package:linting_tool/model/rules_store.dart'; -import 'package:linting_tool/pages/rules_page.dart'; +import 'package:linting_tool/pages/default_rules_page.dart'; import 'package:linting_tool/theme/colors.dart'; import 'package:provider/provider.dart'; @@ -55,7 +55,7 @@ class DefaultLintsPage extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => RulesPage(profile: profile), + builder: (context) => DefaultRulesPage(profile: profile), ), ); }, diff --git a/experimental/linting_tool/lib/pages/default_rules_page.dart b/experimental/linting_tool/lib/pages/default_rules_page.dart new file mode 100644 index 000000000..f0b20768a --- /dev/null +++ b/experimental/linting_tool/lib/pages/default_rules_page.dart @@ -0,0 +1,74 @@ +// Copyright 2021 The Flutter team. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:linting_tool/layout/adaptive.dart'; +import 'package:linting_tool/model/profile.dart'; +import 'package:linting_tool/widgets/lint_expansion_tile.dart'; + +class DefaultRulesPage extends StatelessWidget { + final RulesProfile profile; + + const DefaultRulesPage({ + required this.profile, + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final isDesktop = isDisplayLarge(context); + final isTablet = isDisplayMedium(context); + var textTheme = Theme.of(context).textTheme; + final startPadding = isTablet + ? 60.0 + : isDesktop + ? 120.0 + : 4.0; + final endPadding = isTablet + ? 60.0 + : isDesktop + ? 120.0 + : 4.0; + return Scaffold( + appBar: AppBar( + title: Text( + profile.name, + style: textTheme.subtitle2!.copyWith( + color: textTheme.bodyText1!.color, + ), + ), + leading: Padding( + padding: const EdgeInsets.only(left: 80.0), + child: TextButton.icon( + onPressed: () { + Navigator.pop(context); + }, + icon: const Icon(Icons.arrow_back_ios_new), + label: const Text('Back'), + ), + ), + leadingWidth: 160.0, + toolbarHeight: 38.0, + backgroundColor: Colors.white, + brightness: Brightness.light, + ), + body: ListView.separated( + padding: EdgeInsetsDirectional.only( + start: startPadding, + end: endPadding, + top: isDesktop ? 28 : 0, + bottom: isDesktop ? kToolbarHeight : 0, + ), + itemCount: profile.rules.length, + cacheExtent: 5, + itemBuilder: (context, index) { + return LintExpansionTile( + rule: profile.rules[index], + ); + }, + separatorBuilder: (context, index) => const SizedBox(height: 4), + ), + ); + } +}