Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Flutter support and flutter_lints #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
# flutter_nord_theme

## 3.0.0

- Increased Flutter compatibility
- Increased Flutter minimum support to >=2.0.0
- Updated themes to Material 3

## 2.1.0
* New theme properties:
* Theme for FloatingActionButon.
* Each theme is now based on a ColorScheme.
* Meta:
* Update package description.
* The documentation now covers all the elements of the public API.

- New theme properties:
- Theme for FloatingActionButton.
- Each theme is now based on a ColorScheme.
- Meta:
- Update package description.
- The documentation now covers all the elements of the public API.

## 2.0.2
* Fixes
* Label color for navigation theme
* Card background color for light theme
* Divider color for light theme

- Fixes
- Label color for navigation theme
- Card background color for light theme
- Divider color for light theme

## 2.0.1
* Added a theme for NavigationRail

- Added a theme for NavigationRail

## 2.0.0
* Migrating to null safety.

- Migrating to null safety.

## 1.0.0
* First working version, usable in development: a light theme and a dark theme, not customizables.

- First working version, usable in development: a light theme and a dark theme, not customizables.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
26 changes: 13 additions & 13 deletions example/full_example/lib/buttons.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter_nord_theme/flutter_nord_theme.dart';

final List<Widget> buttons = [
final buttons = <Widget>[
TextButton(
child: Text('TextButton'),
onPressed: () => null,
child: const Text('TextButton'),
onPressed: () {},
),
ElevatedButton(
child: Text('ElevatedButton'),
onPressed: () => null,
child: const Text('ElevatedButton'),
onPressed: () {},
),
OutlinedButton(
child: Text('OutlinedButton'),
onPressed: () => null,
child: const Text('OutlinedButton'),
onPressed: () {},
),
ElevatedButton(
child: Text('Custom button'),
style: ElevatedButton.styleFrom(
primary: NordColors.aurora.red,
backgroundColor: NordColors.aurora.red,
),
onPressed: () => null,
onPressed: () {},
child: const Text('Custom button'),
),
TextButton(child: Text('TextButton'), onPressed: null),
ElevatedButton(child: Text('ElevatedButton'), onPressed: null),
OutlinedButton(child: Text('OutlinedButton'), onPressed: null),
const TextButton(onPressed: null, child: Text('TextButton')),
const ElevatedButton(onPressed: null, child: Text('ElevatedButton')),
const OutlinedButton(onPressed: null, child: Text('OutlinedButton')),
];
17 changes: 9 additions & 8 deletions example/full_example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import 'package:flutter/material.dart';

import 'theme.dart';
import 'theme_switch_list_tile.dart';

import 'texts.dart';
import 'buttons.dart';
import 'switches.dart';
import 'texts.dart';
import 'theme.dart';
import 'theme_switch_list_tile.dart';

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

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

@override
_MyAppState createState() => _MyAppState();
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
Expand All @@ -30,8 +31,8 @@ class _MyAppState extends State<MyApp> {
debugShowCheckedModeBanner: false,
theme: theme.currentThemeData(),
home: Scaffold(
appBar: AppBar(title: Text('Demo app')),
drawer: Drawer(child: ThemeSwitchListTile()),
appBar: AppBar(title: const Text('Demo app')),
drawer: const Drawer(child: ThemeSwitchListTile()),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Wrap(
Expand Down
10 changes: 6 additions & 4 deletions example/full_example/lib/switches.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import 'package:flutter/material.dart';

final List<Widget> switches = [
ToggleableSwitch(),
Switch(value: false, onChanged: (_) => null),
Switch(value: false, onChanged: null),
const ToggleableSwitch(),
Switch(value: false, onChanged: (_) {}),
const Switch(value: false, onChanged: null),
];

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

@override
_ToggleableSwitchState createState() => _ToggleableSwitchState();
State<ToggleableSwitch> createState() => _ToggleableSwitchState();
}

class _ToggleableSwitchState extends State<ToggleableSwitch> {
Expand Down
2 changes: 1 addition & 1 deletion example/full_example/lib/texts.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

final texts = [
const texts = <Widget>[
Text('Example text.'),
SelectableText('Selectable text.'),
];
6 changes: 4 additions & 2 deletions example/full_example/lib/theme_switch_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import 'package:flutter_nord_theme/flutter_nord_theme.dart';
import 'theme.dart';

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

@override
_ThemeSwitchListTileState createState() => _ThemeSwitchListTileState();
State<ThemeSwitchListTile> createState() => _ThemeSwitchListTileState();
}

class _ThemeSwitchListTileState extends State<ThemeSwitchListTile> {
@override
Widget build(BuildContext context) {
final value = theme.currentMode() == ThemeMode.dark;
return SwitchListTile(
title: Text('Switch theme'),
title: const Text('Switch theme'),
value: value,
secondary: Icon(
value ? Icons.palette : Icons.palette_outlined,
Expand Down
8 changes: 5 additions & 3 deletions example/simple_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import 'package:flutter/material.dart';
import 'package:flutter_nord_theme/flutter_nord_theme.dart';

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

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

@override
Widget build(BuildContext context) => MaterialApp(
themeMode: ThemeMode.light, // Or [ThemeMode.dark]
theme: NordTheme.light(),
darkTheme: NordTheme.dark(),
home: Scaffold(
appBar: AppBar(title: Text('Title')),
body: Center(child: Text('Example text.')),
appBar: AppBar(title: const Text('Title')),
body: const Center(child: Text('Example text.')),
),
);
}
2 changes: 1 addition & 1 deletion lib/flutter_nord_theme.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// An arctic, north-bluish theme for Flutter, based on the Nord theme.
library flutter_nord_theme;

export 'src/themes/theme.dart' show NordTheme;
export 'src/colors/colors.dart' show NordColors;
export 'src/themes/theme.dart' show NordTheme;
32 changes: 16 additions & 16 deletions lib/src/colors/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,51 @@ abstract class NordColors {
static const aurora = NordAurora();

/// The origin color of the Polar Night palette.
static const $0 = const Color(NordColorCodes.$0);
static const $0 = Color(NordColorCodes.$0);

/// A brighter shade color based on [$0].
static const $1 = const Color(NordColorCodes.$1);
static const $1 = Color(NordColorCodes.$1);

/// An even more brighter shade color of [$0]].
static const $2 = const Color(NordColorCodes.$2);
static const $2 = Color(NordColorCodes.$2);

/// The brightest shade color based on [$0].
static const $3 = const Color(NordColorCodes.$3);
static const $3 = Color(NordColorCodes.$3);

/// The origin color or the Snow Storm palette.
static const $4 = const Color(NordColorCodes.$4);
static const $4 = Color(NordColorCodes.$4);

/// A brighter shade color of [$4].
static const $5 = const Color(NordColorCodes.$5);
static const $5 = Color(NordColorCodes.$5);

/// The brightest shade color based on [$4].
static const $6 = const Color(NordColorCodes.$6);
static const $6 = Color(NordColorCodes.$6);

/// A calm and highly contrasted color reminiscent of frozen polar water.
static const $7 = const Color(NordColorCodes.$7);
static const $7 = Color(NordColorCodes.$7);

/// The bright and shiny primary accent color reminiscent of pure and clear
/// ice.
static const $8 = const Color(NordColorCodes.$8);
static const $8 = Color(NordColorCodes.$8);

/// A more darkened and less saturated color reminiscent of arctic waters.
static const $9 = const Color(NordColorCodes.$9);
static const $9 = Color(NordColorCodes.$9);

/// A dark and intensive color reminiscent of the deep arctic ocean.
static const $10 = const Color(NordColorCodes.$10);
static const $10 = Color(NordColorCodes.$10);

/// A vermilion, yet soothing color.
static const $11 = const Color(NordColorCodes.$11);
static const $11 = Color(NordColorCodes.$11);

/// A saturated, imposing orange color.
static const $12 = const Color(NordColorCodes.$12);
static const $12 = Color(NordColorCodes.$12);

/// A calming yellow color.
static const $13 = const Color(NordColorCodes.$13);
static const $13 = Color(NordColorCodes.$13);

/// A nice, neither too bright nor too dark, green color.
static const $14 = const Color(NordColorCodes.$14);
static const $14 = Color(NordColorCodes.$14);

/// A dark, dull violet color.
static const $15 = const Color(NordColorCodes.$15);
static const $15 = Color(NordColorCodes.$15);
}
2 changes: 1 addition & 1 deletion lib/src/themes/roles/dark.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import 'package:flutter_nord_theme/flutter_nord_theme.dart';

import 'roles.dart';

class NordDarkColorRoles extends NordColorRoles {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/themes/roles/light.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import 'package:flutter_nord_theme/flutter_nord_theme.dart';

import 'roles.dart';

class NordLightColorRoles extends NordColorRoles {
Expand Down
15 changes: 8 additions & 7 deletions lib/src/themes/roles/roles.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

import 'package:flutter_nord_theme/flutter_nord_theme.dart';

import 'light.dart';

/// This class describes the role of each color.
Expand All @@ -22,9 +22,9 @@ abstract class NordColorRoles {
/// in theory, all the other [ThemeData] properties are just overrides.
ColorScheme get colorScheme => ColorScheme(
primary: primary,
primaryVariant: primary,
primaryContainer: primary,
secondary: secondary,
secondaryVariant: secondary,
secondaryContainer: secondary,
surface: card,
background: background,
error: error,
Expand Down Expand Up @@ -70,7 +70,7 @@ abstract class NordColorRoles {
Color get splash;

/// The color of shadows (e.g. for [Card] widgets).
final Color shadow = Color(0x590f1115);
Color get shadow => const Color(0x590f1115);

/// A color that contrasts with [primary], e.g. used as the remaining part of
/// a progress bar.
Expand Down Expand Up @@ -141,8 +141,9 @@ abstract class NordColorRoles {
}),
backgroundColor: MaterialStateProperty.all<Color>(Colors.transparent),
overlayColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.hovered))
if (states.contains(MaterialState.hovered)) {
return button.withOpacity(0.04);
}
if (states.contains(MaterialState.focused) ||
states.contains(MaterialState.pressed)) {
return button.withOpacity(0.12);
Expand Down Expand Up @@ -192,12 +193,12 @@ abstract class NordColorRoles {
NavigationRailThemeData? get navigationRail {
return NavigationRailThemeData(
backgroundColor: bottomAppBar,
unselectedLabelTextStyle: TextStyle(fontSize: 10),
unselectedLabelTextStyle: const TextStyle(fontSize: 10),
selectedLabelTextStyle: TextStyle(
fontSize: 10,
color: primary,
),
unselectedIconTheme: IconThemeData(),
unselectedIconTheme: const IconThemeData(),
selectedIconTheme: IconThemeData(color: primary),
);
}
Expand Down
Loading