Skip to content

Commit

Permalink
Analysis improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Oct 6, 2022
1 parent 6bdc4f8 commit b645e99
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 251 deletions.
26 changes: 1 addition & 25 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
avoid_print: false # Uncomment to disable the `avoid_print` rule
prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
require_trailing_commas: true
use_super_parameters: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
use_super_parameters: true
2 changes: 2 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ linter:
rules:
prefer_const_constructors: false
prefer_const_literals_to_create_immutables: false
require_trailing_commas: true
use_super_parameters: true

29 changes: 16 additions & 13 deletions example/lib/example_page_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ const _lorem =

final examplePageItems = <YaruPageItem>[
YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('YaruTile'),
iconData: YaruIcons.format_unordered_list,
builder: (_) => YaruPage(children: [TileList()]),
itemWidget: SizedBox(
height: 20,
child: YaruCircularProgressIndicator(strokeWidth: 2),
)),
titleBuilder: (context) => YaruPageItemTitle.text('YaruTile'),
iconData: YaruIcons.format_unordered_list,
builder: (_) => YaruPage(children: [TileList()]),
itemWidget: SizedBox(
height: 20,
child: YaruCircularProgressIndicator(strokeWidth: 2),
),
),
YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('YaruProgressIndicator'),
iconData: YaruIcons.download,
Expand Down Expand Up @@ -69,13 +70,15 @@ final examplePageItems = <YaruPageItem>[
builder: (_) => SectionPage(),
),
YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('YaruTabbedPage'),
builder: (_) => TabbedPagePage(),
iconData: YaruIcons.tab_new),
titleBuilder: (context) => YaruPageItemTitle.text('YaruTabbedPage'),
builder: (_) => TabbedPagePage(),
iconData: YaruIcons.tab_new,
),
YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('YaruCarousel'),
builder: (_) => CarouselPage(),
iconData: YaruIcons.refresh),
titleBuilder: (context) => YaruPageItemTitle.text('YaruCarousel'),
builder: (_) => CarouselPage(),
iconData: YaruIcons.refresh,
),
YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('YaruColorDisk'),
builder: (context) => ColorDiskPage(),
Expand Down
82 changes: 42 additions & 40 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import 'package:yaru_widgets_example/example_page_items.dart';
import 'package:yaru_widgets_example/theme.dart';

void main() {
runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => LightTheme(yaruLight)),
ChangeNotifierProvider(create: (_) => DarkTheme(yaruDark)),
],
child: Home(),
));
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => LightTheme(yaruLight)),
ChangeNotifierProvider(create: (_) => DarkTheme(yaruDark)),
],
child: Home(),
),
);
}

class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
const Home({super.key});

@override
State<Home> createState() => _HomeState();
Expand All @@ -33,37 +35,39 @@ class _HomeState extends State<Home> {
Widget build(BuildContext context) {
final configItem = YaruPageItem(
titleBuilder: (context) => YaruPageItemTitle.text('Layout'),
builder: (_) => YaruPage(children: [
YaruTile(
title: Text('Compact mode'),
trailing: Switch(
value: _compactMode,
onChanged: (v) => setState(() => _compactMode = v),
),
),
if (_compactMode)
builder: (_) => YaruPage(
children: [
YaruTile(
title: Text('YaruPageItem amount'),
trailing: Row(
children: [
TextButton(
onPressed: () {
if (_amount >= examplePageItems.length) return;
setState(() => _amount++);
},
child: Icon(YaruIcons.plus),
),
TextButton(
onPressed: () {
if (_amount <= 2) return;
setState(() => _amount--);
},
child: Icon(YaruIcons.minus),
),
],
title: Text('Compact mode'),
trailing: Switch(
value: _compactMode,
onChanged: (v) => setState(() => _compactMode = v),
),
)
]),
),
if (_compactMode)
YaruTile(
title: Text('YaruPageItem amount'),
trailing: Row(
children: [
TextButton(
onPressed: () {
if (_amount >= examplePageItems.length) return;
setState(() => _amount++);
},
child: Icon(YaruIcons.plus),
),
TextButton(
onPressed: () {
if (_amount <= 2) return;
setState(() => _amount--);
},
child: Icon(YaruIcons.minus),
),
],
),
)
],
),
iconData: YaruIcons.settings,
);

Expand Down Expand Up @@ -91,11 +95,9 @@ class _HomeState extends State<Home> {

class _CompactPage extends StatelessWidget {
const _CompactPage({
Key? key,
required this.configItem,
required int amount,
}) : _amount = amount,
super(key: key);
}) : _amount = amount;

final YaruPageItem configItem;
final int _amount;
Expand Down
97 changes: 56 additions & 41 deletions example/lib/pages/carousel_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:yaru_icons/yaru_icons.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

class CarouselPage extends StatefulWidget {
const CarouselPage({Key? key}) : super(key: key);
const CarouselPage({super.key});

@override
_CarouselPageState createState() => _CarouselPageState();
Expand All @@ -14,48 +14,60 @@ class _CarouselPageState extends State<CarouselPage> {

@override
Widget build(BuildContext context) {
return YaruPage(children: [
YaruSection(headline: 'Auto scroll: off', width: 700, children: [
YaruCarousel(
controller: YaruCarouselController(
pagesLength: _getCarouselChildren().length,
),
children: _getCarouselChildren(),
height: 400,
navigationControls: true,
previousIcon: Icon(YaruIcons.go_previous),
nextIcon: Icon(YaruIcons.go_next),
return YaruPage(
children: [
YaruSection(
headline: 'Auto scroll: off',
width: 700,
children: [
YaruCarousel(
controller: YaruCarouselController(
pagesLength: _getCarouselChildren().length,
),
children: _getCarouselChildren(),
height: 400,
navigationControls: true,
previousIcon: Icon(YaruIcons.go_previous),
nextIcon: Icon(YaruIcons.go_next),
),
],
),
]),
YaruSection(headline: 'Auto scroll: on', width: 700, children: [
YaruCarousel(
controller: YaruCarouselController(
autoScroll: true,
pagesLength: _getCarouselChildren().length,
),
children: _getCarouselChildren(),
height: 400,
YaruSection(
headline: 'Auto scroll: on',
width: 700,
children: [
YaruCarousel(
controller: YaruCarouselController(
autoScroll: true,
pagesLength: _getCarouselChildren().length,
),
children: _getCarouselChildren(),
height: 400,
),
],
),
]),
ButtonBar(
buttonPadding: EdgeInsets.zero,
children: [
YaruOptionButton(
ButtonBar(
buttonPadding: EdgeInsets.zero,
children: [
YaruOptionButton(
onPressed: () => setState(() {
length++;
}),
child: Icon(YaruIcons.plus)),
SizedBox(
width: 10,
),
YaruOptionButton(
length++;
}),
child: Icon(YaruIcons.plus),
),
SizedBox(
width: 10,
),
YaruOptionButton(
onPressed: () => setState(() {
length >= 2 ? length-- : length = length;
}),
child: Icon(YaruIcons.minus))
],
)
]);
length >= 2 ? length-- : length = length;
}),
child: Icon(YaruIcons.minus),
)
],
)
],
);
}

List<Widget> _getCarouselChildren() {
Expand All @@ -65,9 +77,12 @@ class _CarouselPageState extends State<CarouselPage> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1)),
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.1),
),
image: DecorationImage(
fit: BoxFit.contain, image: AssetImage('assets/ubuntuhero.jpg')),
fit: BoxFit.contain,
image: AssetImage('assets/ubuntuhero.jpg'),
),
),
),
);
Expand Down
42 changes: 22 additions & 20 deletions example/lib/pages/color_disk_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:yaru_widgets/yaru_widgets.dart';
import 'package:yaru_widgets_example/theme.dart';

class ColorDiskPage extends StatefulWidget {
const ColorDiskPage({Key? key}) : super(key: key);
const ColorDiskPage({super.key});

@override
State<ColorDiskPage> createState() => _ColorDiskPageState();
Expand All @@ -16,25 +16,27 @@ class _ColorDiskPageState extends State<ColorDiskPage> {
Widget build(BuildContext context) {
final lightTheme = context.read<LightTheme>();
final darkTheme = context.read<DarkTheme>();
return YaruPage(children: [
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
for (var theme in themeList)
YaruColorDisk(
onPressed: () {
lightTheme.value = theme.theme;
darkTheme.value = theme.darkTheme;
},
color: theme.color,
selected: Theme.of(context).primaryColor == theme.color,
),
],
),
)
]);
return YaruPage(
children: [
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
for (var theme in themeList)
YaruColorDisk(
onPressed: () {
lightTheme.value = theme.theme;
darkTheme.value = theme.darkTheme;
},
color: theme.color,
selected: Theme.of(context).primaryColor == theme.color,
),
],
),
)
],
);
}
}

Expand Down
Loading

0 comments on commit b645e99

Please sign in to comment.