Skip to content

Commit

Permalink
refactor: drop support for the 'call' operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Oct 19, 2021
1 parent 471efd7 commit 14ba6cf
Show file tree
Hide file tree
Showing 46 changed files with 22 additions and 178 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- stricter lint rules.
- improvements in README.

### Removed

- The overloading of the function call operator —
[109](https://github.com/dartoos-dev/eo_color/issues/109) **BREAKIN CHANGE**.

## [1.1.9] - 2021-08-06

### Changed
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Likewise, there are commands for retrieving lighter and darker shades.
- shades of grey darker than the primary shade: `Grey.bitDarker()`,
`Grey.darker()`, `Grey.dark()`, or `Grey.veryDark()` for the darkest shade.

With the exception of the colors black and white, the same command patterns (light,
lighter, dark, very dark, etc.) also apply to all other colors.
With the exception of the colors black and white, the same command patterns
(light, lighter, dark, very dark, etc.) also apply to all other colors.

## Getting Started

Expand All @@ -67,11 +67,13 @@ three main interfaces are `Palette`, `Swatch`, and `Gradient`.
It represents color palettes from which a color can be selected.

Typically, subclasses of the _Palette_ interface provide named constructors by
which the desired color is selected — to be retrieved later via the `color` property.
which the desired color is selected — to be retrieved later via the `color`
property.

For instance, the command `Blue()` retrieves the primary shade of blue and is equivalent
to the Flutter command `Colors.blue.shade500`. Similarly, `Blue.veryLight()` is equivalent
to `Colors.blue.shade50`; `Blue.veryDark()`, to `Colors.grey.shade900`; and so on.
For instance, the command `Blue()` retrieves the primary shade of blue and is
equivalent to the Flutter command `Colors.blue.shade500`. Similarly,
`Blue.veryLight()` is equivalent to `Colors.blue.shade50`; `Blue.veryDark()`, to
`Colors.grey.shade900`; and so on.

The code snippet below demonstrates how to build a bluish Flutter Container
widget using the `Blue` color class.
Expand Down Expand Up @@ -104,8 +106,8 @@ The table below contains the relationship between the Material Design indexes
such as _Amber_, _Green_, _Red_, etc.
- On the other hande, the **"Accent"** column refers to classes that represent
accent colors such as _AmberAccent_, _GreenAccent_, _RedAccent_, and so on.
- Finally, **"()"** refers to the default constructor, which in turn represents
the primary shade of the color class it belongs to.
- Finally, **"()"** refers to the default constructor, which in turn
represents the primary shade of the color class it belongs to.

| Index | Normal | Accent |
| :---- | ---------- | :----- |
Expand Down Expand Up @@ -206,8 +208,8 @@ For a complete list of gradients:
## Demo application

The demo application provides a fully working example, focused on demonstrating
exactly three color palettes in action: BlueGrey, Grey, and Brown. You can take
the code in this demo and experiment with it.
exactly three color palettes in action: **BlueGrey**, **Grey**, and **Brown**.
You can take the code in this demo and experiment with it.

To run the demo application:

Expand Down
4 changes: 0 additions & 4 deletions lib/src/gradient_immu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ abstract class GradientImmu extends SwatchBase implements Gradient {
/// An **immutable list** of position-dependent colors — a color gradient.
@override
List<Color> get colors => List.unmodifiable(super.colors);

/// Forwards to [colors].
@override
List<Color> call() => colors;
}
3 changes: 0 additions & 3 deletions lib/src/palette_rgb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ abstract class PaletteRGB implements Palette {
/// The rgb color.
@override
Color get color => Color(_value);

/// Convenience overloading; forwards to [color].
Color call() => color;
}
3 changes: 0 additions & 3 deletions lib/src/swatch_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ abstract class SwatchBase implements Swatch {
/// A new lazy [Iterable] of [Color].
@override
Iterable<Color> get colors => _palettes.map((palette) => palette.color);

/// Forwards to [colors].
Iterable<Color> call() => colors;
}
1 change: 0 additions & 1 deletion test/gradient_immu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void main() {
test('single', () {
const singleElem = GradTest.single();
expect(singleElem.colors.length, 1);
expect(singleElem().first, aGrey.first.color);
});
test('many', () {
const manyElems = GradTest.many();
Expand Down
4 changes: 0 additions & 4 deletions test/material/amber/amber_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const AmberAccent.dark().color, Colors.amberAccent.shade700);
});
test('call method', () {
const amberAccent = AmberAccent();
expect(amberAccent(), amberAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/amber/amber_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Amber.veryDark().color, Colors.amber.shade900);
});
test('call method', () {
const amber = Amber();
expect(amber(), amber.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/black/black_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ void main() {
test('12% opacity', () {
expect(const Black.opacity12().color, Colors.black12);
});
test('call method', () {
const black = Black();
expect(black(), black.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/blue/blue_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const BlueAccent.dark().color, Colors.blueAccent.shade700);
});
test('call method', () {
const blueAccent = BlueAccent();
expect(blueAccent(), blueAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/blue/blue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Blue.veryDark().color, Colors.blue.shade900);
});
test('call method', () {
const blue = Blue();
expect(blue(), blue.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/blue_grey/blue_grey_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const BlueGrey.veryDark().color, Colors.blueGrey.shade900);
});
test('call method', () {
const blueGrey = BlueGrey();
expect(blueGrey(), blueGrey.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/brown/brown_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Brown.veryDark().color, Colors.brown.shade900);
});
test('call method', () {
const brown = Brown();
expect(brown(), brown.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/cyan/cyan_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const CyanAccent.dark().color, Colors.cyanAccent.shade700);
});
test('call method', () {
const cyanAccent = CyanAccent();
expect(cyanAccent(), cyanAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/cyan/cyan_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Cyan.veryDark().color, Colors.cyan.shade900);
});
test('call method', () {
const cyan = Cyan();
expect(cyan(), cyan.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/deep_orange/deep_orange_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ void main() {
Colors.deepOrangeAccent.shade700,
);
});
test('call method', () {
const deepOrangeAccent = DeepOrangeAccent();
expect(deepOrangeAccent(), deepOrangeAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/deep_orange/deep_orange_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const DeepOrange.veryDark().color, Colors.deepOrange.shade900);
});
test('call method', () {
const deepOrange = DeepOrange();
expect(deepOrange(), deepOrange.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/deep_purple/deep_purple_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ void main() {
Colors.deepPurpleAccent.shade700,
);
});
test('call method', () {
const deepPurpleAccent = DeepPurpleAccent();
expect(deepPurpleAccent(), deepPurpleAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/deep_purple/deep_purple_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const DeepPurple.veryDark().color, Colors.deepPurple.shade900);
});
test('call method', () {
const deepPurple = DeepPurple();
expect(deepPurple(), deepPurple.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/green/green_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const GreenAccent.dark().color, Colors.greenAccent.shade700);
});
test('call method', () {
const greenAccent = GreenAccent();
expect(greenAccent(), greenAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/green/green_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Green.veryDark().color, Colors.green.shade900);
});
test('call method', () {
const green = Green();
expect(green(), green.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/grey/grey_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,5 @@ void main() {
test('very dark', () {
expect(const Grey.veryDark().color, Colors.grey.shade900);
});
test('call method', () {
const grey = Grey();
expect(grey(), grey.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/indigo/indigo_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const IndigoAccent.dark().color, Colors.indigoAccent.shade700);
});
test('call method', () {
const indigoAccent = IndigoAccent();
expect(indigoAccent(), indigoAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/indigo/indigo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Indigo.veryDark().color, Colors.indigo.shade900);
});
test('call method', () {
const indigo = Indigo();
expect(indigo(), indigo.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/light_blue/light_blue_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ void main() {
Colors.lightBlueAccent.shade700,
);
});
test('call method', () {
const lightBlueAccent = LightBlueAccent();
expect(lightBlueAccent(), lightBlueAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/light_blue/light_blue_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const LightBlue.veryDark().color, Colors.lightBlue.shade900);
});
test('call method', () {
const lightBlue = LightBlue();
expect(lightBlue(), lightBlue.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/light_green/light_green_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ void main() {
Colors.lightGreenAccent.shade700,
);
});
test('call method', () {
const lightGreenAccent = LightGreenAccent();
expect(lightGreenAccent(), lightGreenAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/light_green/light_green_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const LightGreen.veryDark().color, Colors.lightGreen.shade900);
});
test('call method', () {
const lightGreen = LightGreen();
expect(lightGreen(), lightGreen.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/lime/lime_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const LimeAccent.dark().color, Colors.limeAccent.shade700);
});
test('call method', () {
const limeAccent = LimeAccent();
expect(limeAccent(), limeAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/lime/lime_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Lime.veryDark().color, Colors.lime.shade900);
});
test('call method', () {
const lime = Lime();
expect(lime(), lime.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/orange/orange_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const OrangeAccent.dark().color, Colors.orangeAccent.shade700);
});
test('call method', () {
const orangeAccent = OrangeAccent();
expect(orangeAccent(), orangeAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/orange/orange_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Orange.veryDark().color, Colors.orange.shade900);
});
test('call method', () {
const orange = Orange();
expect(orange(), orange.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/pink/pink_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const PinkAccent.dark().color, Colors.pinkAccent.shade700);
});
test('call method', () {
const pinkAccent = PinkAccent();
expect(pinkAccent(), pinkAccent.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/pink/pink_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,5 @@ void main() {
test('very dark', () {
expect(const Pink.veryDark().color, Colors.pink.shade900);
});
test('call method', () {
const pink = Pink();
expect(pink(), pink.color);
});
});
}
4 changes: 0 additions & 4 deletions test/material/purple/purple_accent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ void main() {
test('dark', () {
expect(const PurpleAccent.dark().color, Colors.purpleAccent.shade700);
});
test('call method', () {
const purpleAccent = PurpleAccent();
expect(purpleAccent(), purpleAccent.color);
});
});
}
Loading

0 comments on commit 14ba6cf

Please sign in to comment.