Skip to content

Commit 1a0949b

Browse files
rafamizesrultor
authored andcommitted
feat: Instagram and Google gradients
Closes #79
1 parent 7c24f9c commit 1a0949b

File tree

14 files changed

+163
-61
lines changed

14 files changed

+163
-61
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Instagram and Google gradient classes GoogleGrad and InstagramGrad —
13+
[79](https://github.com/dartoos-dev/flutter_brand_palettes/issues/79).
14+
1015
## [0.3.5] - 2021-06-25
1116

1217
### Changed

example/lib/main.dart

Lines changed: 28 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_brand_palettes/palettes.dart';
2+
import 'package:flutter_brand_palettes/flutter_brand_palettes.dart';
33
import 'package:eo_color/eo_color.dart';
44

5-
void main() {
6-
runApp(MyApp());
7-
}
5+
void main() => runApp(MyApp());
86

97
class MyApp extends StatelessWidget {
108
@override
@@ -23,53 +21,30 @@ class InstagramPalettePage extends StatelessWidget {
2321
super(key: key);
2422

2523
final String _title;
26-
27-
/// The 'late' modifier ensures the lazy initialization of [_gradient]. In
28-
/// other words, the _gradient's initializer expression runs only the first
29-
/// time the variable is used.
30-
static late final _gradient = _toGradient();
31-
32-
// Application's bar backgroud color.
33-
static const _bgAppBar = Grey.veryLight();
34-
35-
/// Builds the Instagram's gradient color scheme.
36-
static List<Color> _toGradient() {
37-
return const [
38-
Instagram.lightYellow(),
39-
Instagram.yellow(),
40-
Instagram.orange(),
41-
Instagram.darkOrange(),
42-
Instagram.red(),
43-
Instagram.purpleRed(),
44-
Instagram.darkPink(),
45-
Instagram.purple(),
46-
Instagram.blue(),
47-
Instagram.royalBlue(),
48-
].map((picked) => picked.color).toList(growable: false);
49-
}
24+
static final _gradient = const InstagramGrad().colors;
5025

5126
@override
5227
Widget build(BuildContext context) {
5328
return Scaffold(
5429
appBar: AppBar(
55-
backgroundColor: _bgAppBar.color,
30+
backgroundColor: const Grey.veryLight().color,
5631
elevation: 2.0,
5732
title: GradientTitle(_title, _gradient),
5833
),
5934
body: ListView(
60-
padding: const EdgeInsets.all(12),
35+
padding: const EdgeInsets.all(16),
6136
children: [
6237
_ColorItem.gradient('Gradient', colors: _gradient),
63-
_ColorItem('Light Yellow', _gradient[0]),
64-
_ColorItem('Yellow', _gradient[1]),
65-
_ColorItem('Orange', _gradient[2]),
66-
_ColorItem('Dark Orange', _gradient[3]),
67-
_ColorItem('Red', _gradient[4]),
68-
_ColorItem('Purple-Red', _gradient[5]),
69-
_ColorItem('Dark Pink', _gradient[6]),
70-
_ColorItem('Purple', _gradient[7]),
71-
_ColorItem('Blue', _gradient[8]),
72-
_ColorItem('Royal Blue', _gradient[9]),
38+
_ColorItem('Light Yellow', _gradient[9]),
39+
_ColorItem('Yellow', _gradient[8]),
40+
_ColorItem('Orange', _gradient[7]),
41+
_ColorItem('Dark Orange', _gradient[6]),
42+
_ColorItem('Red', _gradient[5]),
43+
_ColorItem('Purple-Red', _gradient[4]),
44+
_ColorItem('Dark Pink', _gradient[3]),
45+
_ColorItem('Purple', _gradient[2]),
46+
_ColorItem('Blue', _gradient[1]),
47+
_ColorItem('Royal Blue', _gradient[0]),
7348
],
7449
),
7550
);
@@ -92,6 +67,8 @@ class GradientTitle extends StatelessWidget {
9267
fontStyle: FontStyle.italic,
9368
foreground: Paint()
9469
..shader = LinearGradient(
70+
begin: Alignment.topRight,
71+
end: Alignment.bottomLeft,
9572
colors: _colors,
9673
).createShader(const Rect.fromLTRB(0.0, 0.0, 200.0, 70.0)),
9774
),
@@ -101,29 +78,27 @@ class GradientTitle extends StatelessWidget {
10178
}
10279

10380
class _ColorItem extends StatelessWidget {
104-
/// Ctor. Color rectangle.
81+
/// A rectangle filled with a solid color.
10582
_ColorItem(String label, Color color)
106-
: this.decoration(label, () => BoxDecoration(color: color));
83+
: this.deco(label, () => BoxDecoration(color: color));
10784

108-
/// Ctor. Gradient rectangle.
85+
/// A rectangle with linear gradient background.
10986
_ColorItem.gradient(String label, {required List<Color> colors})
110-
: this.decoration(
87+
: this.deco(
11188
label,
11289
() => BoxDecoration(
11390
gradient: LinearGradient(
114-
// begin: Alignment.topRight,
115-
// end: Alignment.bottomLeft,
91+
begin: Alignment.topRight,
92+
end: Alignment.bottomLeft,
11693
colors: colors,
11794
),
11895
),
11996
);
120-
const _ColorItem.decoration(this._label, this._boxDecoration);
12197

122-
final String _label;
123-
final BoxDecoration Function() _boxDecoration;
98+
const _ColorItem.deco(this._label, this._deco);
12499

125-
// Normal font color.
126-
static const _normal = Grey.dark();
100+
final String _label;
101+
final BoxDecoration Function() _deco;
127102

128103
@override
129104
Widget build(BuildContext context) {
@@ -134,16 +109,12 @@ class _ColorItem extends StatelessWidget {
134109
child: Text(
135110
_label,
136111
textAlign: TextAlign.center,
137-
style: TextStyle(
138-
color: _normal(), // or _normal.color
139-
fontWeight: FontWeight.bold,
140-
),
112+
style: TextStyle(color: const Grey.veryDark().color),
141113
),
142114
),
143115
Expanded(
144116
flex: 5,
145-
child: Container(
146-
height: kToolbarHeight / 1.5, decoration: _boxDecoration()),
117+
child: Container(height: kToolbarHeight / 1.5, decoration: _deco()),
147118
),
148119
],
149120
),

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ packages:
6868
path: ".."
6969
relative: true
7070
source: path
71-
version: "0.3.3"
71+
version: "0.3.5"
7272
flutter_test:
7373
dependency: "direct dev"
7474
description: flutter

lib/flutter_brand_palettes.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
/// Defined by David Ogilvy as “the intangible sum of a product’s attributes”, a
2+
/// brand is the customers’ perception of a product, service, or company.
3+
/// Multiple visual elements can help with brand recognition, more specifically
4+
/// logos, shapes, graphics and colors.
5+
///
6+
/// [usbrandcolors](https://usbrandcolors.com/)
7+
library flutter_brand_palettes;
8+
9+
export 'gradients.dart';
110
export 'palettes.dart';

lib/gradients.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// Brand gradients.
2+
library gradients;
3+
4+
export 'src/brands/google/google_grad.dart';
5+
export 'src/brands/instagram/instagram_grad.dart';

lib/palettes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export 'src/brands/bitcoin.dart';
66
export 'src/brands/facebook.dart';
77
export 'src/brands/fedex.dart';
88
export 'src/brands/flutter.dart';
9-
export 'src/brands/google.dart';
9+
export 'src/brands/google/google.dart';
1010
export 'src/brands/ibm.dart';
11-
export 'src/brands/instagram.dart';
11+
export 'src/brands/instagram/instagram.dart';
1212
export 'src/brands/iphones/devices.dart';
1313
export 'src/brands/kotlin.dart';
1414
export 'src/brands/linkedin.dart';
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'dart:ui';
2+
3+
import 'package:eo_color/swatches.dart';
4+
5+
import 'google.dart';
6+
7+
/// Google gradient.
8+
class GoogleGrad extends SwatchBase {
9+
/// Google's official color sequence
10+
///
11+
/// There are 4 valid indexes
12+
/// - 0, blue
13+
/// - 1, red
14+
/// - 2, yellow
15+
/// - 3, green
16+
///
17+
/// [google-color-sequence](https://www.behance.net/gallery/9028077/Google-Visual-Assets-Guidelines-Part-1)
18+
const GoogleGrad()
19+
: super(const [
20+
Google.blue(),
21+
Google.red(),
22+
Google.yellow(),
23+
Google.green(),
24+
]);
25+
26+
@override
27+
List<Color> get colors => List.unmodifiable(super.colors);
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'dart:ui';
2+
3+
import 'package:eo_color/swatches.dart';
4+
5+
import 'instagram.dart';
6+
7+
/// Instagram gradient.
8+
class InstagramGrad extends SwatchBase {
9+
/// Instagram's official color sequence
10+
///
11+
/// There are 10 valid indexes
12+
/// - 0, royal blue
13+
/// - 1, blue
14+
/// - 2, purple
15+
/// - 3, dark pink
16+
/// - 4, purple-red
17+
/// - 5, red
18+
/// - 6, dark orange
19+
/// - 7, orange
20+
/// - 8, yellow
21+
/// - 9, light yellow
22+
///
23+
/// [instagram-colors](https://usbrandcolors.com/instagram-colors/)
24+
const InstagramGrad()
25+
: super(const [
26+
Instagram.royalBlue(),
27+
Instagram.blue(),
28+
Instagram.purple(),
29+
Instagram.darkPink(),
30+
Instagram.purpleRed(),
31+
Instagram.red(),
32+
Instagram.darkOrange(),
33+
Instagram.orange(),
34+
Instagram.yellow(),
35+
Instagram.lightYellow(),
36+
]);
37+
38+
@override
39+
List<Color> get colors => List.unmodifiable(super.colors);
40+
}

0 commit comments

Comments
 (0)