Skip to content

Commit

Permalink
Add common lint rules (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Jun 29, 2022
1 parent 41c8619 commit 0346af4
Show file tree
Hide file tree
Showing 21 changed files with 452 additions and 314 deletions.
3 changes: 2 additions & 1 deletion analysis_options.yaml
@@ -1,6 +1,7 @@
include: package:lints/recommended.yaml
include: package:flutter_lints/flutter.yaml

linter:
rules:
prefer_const_constructors: true
prefer_const_declarations: true
require_trailing_commas: true
7 changes: 7 additions & 0 deletions example/analysis_options.yaml
@@ -0,0 +1,7 @@
include: package:flutter_lints/flutter.yaml

linter:
rules:
prefer_const_constructors: true
prefer_const_declarations: true
require_trailing_commas: true
12 changes: 9 additions & 3 deletions example/lib/main.dart
Expand Up @@ -3,17 +3,19 @@ import 'package:yaru/yaru.dart';
import 'package:yaru_example/view/home_page.dart';

void main() {
runApp(MyApp());
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(
builder: (context) => YaruTheme(
data: AppTheme.of(context),
child: HomePage(),
child: const HomePage(),
),
),
debugShowCheckedModeBanner: false,
Expand All @@ -23,7 +25,11 @@ class MyApp extends StatelessWidget {

class AppTheme {
static YaruThemeData of(BuildContext context) {
return SharedAppData.getValue(context, 'theme', () => YaruThemeData());
return SharedAppData.getValue(
context,
'theme',
() => const YaruThemeData(),
);
}

static void apply(
Expand Down
26 changes: 15 additions & 11 deletions example/lib/view/color_disk.dart
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';

class ColorDisk extends StatelessWidget {
const ColorDisk(
{Key? key,
required this.onPressed,
required this.color,
required this.selected})
: super(key: key);
const ColorDisk({
Key? key,
required this.onPressed,
required this.color,
required this.selected,
}) : super(key: key);

final VoidCallback onPressed;
final Color color;
Expand All @@ -22,18 +22,22 @@ class ColorDisk extends StatelessWidget {
style: TextButton.styleFrom(
padding: const EdgeInsets.all(0),
shape: CircleBorder(
side: BorderSide(
color: selected
? Theme.of(context).primaryColor
: Colors.transparent)),
side: BorderSide(
color: selected
? Theme.of(context).primaryColor
: Colors.transparent,
),
),
),
onPressed: onPressed,
child: SizedBox(
height: 20,
width: 20,
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100), color: color),
borderRadius: BorderRadius.circular(100),
color: color,
),
),
),
),
Expand Down
148 changes: 81 additions & 67 deletions example/lib/view/colors_view.dart
@@ -1,54 +1,61 @@
import 'package:flutter/material.dart';

import 'package:yaru_colors/yaru_colors.dart';

class ColorsView extends StatelessWidget {
const ColorsView({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return ListView(
padding: EdgeInsets.all(15.0),
padding: const EdgeInsets.all(15.0),
children: <Widget>[
Text('Accent Colors', style: Theme.of(context).textTheme.headline4),
const SizedBox(height: 15.0),
Row(
children: [
Expanded(child: colorPaletteExample('orange', YaruColors.orange)),
SizedBox(width: 25.0),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('olive', YaruColors.olive)),
SizedBox(width: 25.0),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('bark', YaruColors.bark)),
],
),
Divider(height: 50.0),
const Divider(height: 50.0),
Row(
children: [
Expanded(
child: colorPaletteExample('viridian', YaruColors.viridian)),
SizedBox(width: 25.0),
child: colorPaletteExample('viridian', YaruColors.viridian),
),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('purple', YaruColors.purple)),
SizedBox(width: 25.0),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('red', YaruColors.red)),
],
),
Divider(height: 50.0),
const Divider(height: 50.0),
Row(
children: [
Expanded(child: colorPaletteExample('blue', YaruColors.blue)),
SizedBox(width: 25.0),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('magenta', YaruColors.magenta)),
SizedBox(width: 25.0),
const SizedBox(width: 25.0),
Expanded(child: colorPaletteExample('sage', YaruColors.sage)),
],
),
Divider(height: 50.0),
const Divider(height: 50.0),
Row(
children: [
Expanded(
child: colorPaletteExample(
'prussianGreen', YaruColors.prussianGreen)),
SizedBox(width: 25.0),
Spacer(),
SizedBox(width: 25.0),
Spacer(),
child: colorPaletteExample(
'prussianGreen',
YaruColors.prussianGreen,
),
),
const SizedBox(width: 25.0),
const Spacer(),
const SizedBox(width: 25.0),
const Spacer(),
],
),
const SizedBox(height: 15.0),
Expand All @@ -57,83 +64,90 @@ class ColorsView extends StatelessWidget {
Row(
children: [
Expanded(
child:
colorPaletteExample('kubuntuBlue', YaruColors.kubuntuBlue)),
SizedBox(width: 25.0),
child: colorPaletteExample('kubuntuBlue', YaruColors.kubuntuBlue),
),
const SizedBox(width: 25.0),
Expanded(
child:
colorPaletteExample('lubuntuBlue', YaruColors.lubuntuBlue)),
SizedBox(width: 25.0),
child: colorPaletteExample('lubuntuBlue', YaruColors.lubuntuBlue),
),
const SizedBox(width: 25.0),
Expanded(
child: colorPaletteExample(
'ubuntuBudgieBlue', YaruColors.ubuntuBudgieBlue)),
child: colorPaletteExample(
'ubuntuBudgieBlue',
YaruColors.ubuntuBudgieBlue,
),
),
],
),
Divider(height: 50.0),
const Divider(height: 50.0),
Row(
children: [
Expanded(
child: colorPaletteExample(
'ubuntuMateGreen', YaruColors.ubuntuMateGreen)),
SizedBox(width: 25.0),
child: colorPaletteExample(
'ubuntuMateGreen',
YaruColors.ubuntuMateGreen,
),
),
const SizedBox(width: 25.0),
Expanded(
child: colorPaletteExample(
'ubuntuStudioBlue', YaruColors.ubuntuStudioBlue)),
SizedBox(width: 25.0),
child: colorPaletteExample(
'ubuntuStudioBlue',
YaruColors.ubuntuStudioBlue,
),
),
const SizedBox(width: 25.0),
Expanded(
child:
colorPaletteExample('xubuntuBlue', YaruColors.xubuntuBlue)),
child: colorPaletteExample('xubuntuBlue', YaruColors.xubuntuBlue),
),
],
),
],
);
}

Widget colorPaletteExample(String colorName, MaterialColor color) {
Map<String, MaterialColor> _color = {colorName: color};
int _shade = 50;
TextStyle _textStyle(int _shade) => TextStyle(
color: (_color.values.first[_shade]!.computeLuminance() > 0.4)
Map<String, MaterialColor> colorEntry = {colorName: color};
int shade = 50;
TextStyle textStyle(int shade) => TextStyle(
color: (colorEntry.values.first[shade]!.computeLuminance() > 0.4)
? Colors.black
: Colors.white,
fontSize: 9.0,
);
List<Widget> _colorItem = [];
List<Widget> colorItem = [];
for (int i = 1; i <= 10; i++) {
_colorItem.add(Container(
height: 40.0,
color: _color.values.first[_shade],
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 10,
child: Text(
_color.keys.first + '[$_shade]',
style: _textStyle(_shade),
colorItem.add(
Container(
height: 40.0,
color: colorEntry.values.first[shade],
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
flex: 10,
child: Text(
'${colorEntry.keys.first}[$shade]',
style: textStyle(shade),
),
),
),
Expanded(
flex: 4,
child: Text(
'#' +
_color.values.first[_shade]!.value
.toRadixString(16)
.substring(2)
.toUpperCase(),
style: _textStyle(_shade),
Expanded(
flex: 4,
child: Text(
'#${colorEntry.values.first[shade]!.value.toRadixString(16).substring(2).toUpperCase()}',
style: textStyle(shade),
),
),
),
],
],
),
),
),
));
_shade = i * 100;
);
shade = i * 100;
}
return Column(
children: _colorItem,
children: colorItem,
);
}
}

0 comments on commit 0346af4

Please sign in to comment.