diff --git a/README.md b/README.md index 0a82e71e7..27faafea1 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,7 @@ class FontFamily { ### Colors +[FlutterGen] supports generating colors from [XML](example/assets/color/colors.xml) format files. _Ignore duplicated._ ```yaml @@ -392,27 +393,15 @@ flutter_gen: colors: inputs: - assets/color/colors.xml - - assets/color/colors2.json - - assets/color/colors3.xml + - assets/color/colors2.xml ``` -[FlutterGen] supports the following input file formats: - -- a [XML file](example/assets/color/colors.xml), the same format as the Android colors.xml files, containing tags +[FlutterGen] generates [MaterialColor](https://api.flutter.dev/flutter/material/MaterialColor-class.html) class +if the element has the attribute `type="material"`, otherwise a normal [Color](https://api.flutter.dev/flutter/material/Colors-class.html) class will be generated. ```xml #F5CB84 -#955E1C -#80000000 -``` - -- a [JSON file](example/assets/color/colors2.json), representing a dictionary of names -> values, each value being the hex representation of the color - -```json -{ - "disabled": "#666666", - "accent_red": "#FF4D4D" -} +#955E1C ``` These configurations will generate **`colors.gen.dart`** under the **`lib/gen/`** directory by default. @@ -437,68 +426,45 @@ Text( /// ***************************************************** import 'package:flutter/painting.dart'; +import 'package:flutter/material.dart'; class ColorName { ColorName._(); static const Color white = Color(0xFFFFFFFF); + static const Color black = Color(0xFF000000); static const Color gray70 = Color(0xFFEEEEEE); - static const Color gray150 = Color(0xFFD8D8D8); static const Color gray410 = Color(0xFF979797); - static const Color gray470 = Color(0xFF878787); - static const Color gray550 = Color(0xFF737373); - static const Color gray600 = Color(0xFF666666); - static const Color gray620 = Color(0xFF606060); - static const Color gray680 = Color(0xFF525252); - static const Color gray770 = Color(0xFF37373D); - static const Color gray800 = Color(0xFF333333); - static const Color gray860 = Color(0xFF222226); - static const Color gray880 = Color(0xFF1D1D22); - static const Color gray900 = Color(0xFF18181C); - static const Color gray910 = Color(0xFF141418); - static const Color black = Color(0xFF000000); - static const Color seaPink = Color(0xFFEB9798); - static const Color coral = Color(0xFFFE6363); - static const Color strawberry = Color(0xFFFF4D4D); - static const Color crimsonRed = Color(0xFFCF2A2A); - static const Color rustRed = Color(0xFF421E21); - static const Color milkTea = Color(0xFFF5CB84); - static const Color cornBrond = Color(0xFFF5CB84); - static const Color yellowOcher = Color(0xFFDF9527); - static const Color cinnamon = Color(0xFF955E1C); - static const Color tulipTree = Color(0xFFE6A53A); - static const Color gullGray = Color(0xFFA1B3BC); - static const Color fleryOrange = Color(0xFFB36111); - static const Color denim = Color(0xFF127DB8); - static const Color forestGreen = Color(0xFF238833); - static const Color amazon = Color(0xFF367A62); - static const Color copperCanyon = Color(0xFF8A4213); - static const Color russet = Color(0xFF7B5A19); - static const Color bronzetone = Color(0xFF533C10); - static const Color bush = Color(0xFF0F3A2B); - static const Color bronze = Color(0xFF421F0A); - static const Color highEmphasis = Color(0xFFEEEEEE); - static const Color mediumEmphasis = Color(0xFF979797); - static const Color disabled = Color(0xFF666666); - static const Color accentRed = Color(0xFFFF4D4D); - static const Color accentYellow = Color(0xFFF2B756); - static const Color highEmphasis30 = Color(0x4DEEEEEE); - static const Color white00016 = Color(0x29FFFFFF); - static const Color white00020 = Color(0x33FFFFFF); - static const Color white00030 = Color(0x4DFFFFFF); - static const Color white00032 = Color(0x52FFFFFF); - static const Color white00040 = Color(0x66FFFFFF); - static const Color white00060 = Color(0x99FFFFFF); - static const Color gray91000 = Color(0x00141418); - static const Color gray91030 = Color(0x4D141418); - static const Color gray91070 = Color(0xB3141418); - static const Color gray910100 = Color(0xFF141418); - static const Color colorAccentDark15 = Color(0x26CF2B2B); - static const Color colorAccentDark20 = Color(0x33CF2B2B); - static const Color black30 = Color(0x4D000000); - static const Color black40 = Color(0x66000000); - static const Color black50 = Color(0x80000000); - static const Color black60 = Color(0x99000000); + static const MaterialColor crimsonRed = MaterialColor( + 0xFFCF2A2A, + { + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }, + ); + static const MaterialColor yellowOcher = MaterialColor( + 0xFFDF9527, + { + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }, + ); } ``` diff --git a/example/assets/color/colors.xml b/example/assets/color/colors.xml index 7e8d15603..3ece98f53 100644 --- a/example/assets/color/colors.xml +++ b/example/assets/color/colors.xml @@ -1,44 +1,9 @@ - #FFFFFF + #000000 #EEEEEE - #D8D8D8 #979797 - #878787 - #737373 - #666666 - #606060 - #525252 - #37373D - #333333 - #222226 - #1D1D22 - #18181C - #141418 - #000000 - - #EB9798 - #FE6363 - #FF4D4D - #CF2A2A - #421E21 - - #F5CB84 - #F5CB84 - #DF9527 - #955E1C - - #E6A53A - #A1B3BC - #B36111 - #127DB8 - #238833 - - #367A62 - #8A4213 - #7B5A19 - #533C10 - #0F3A2B - #421F0A - \ No newline at end of file + #CF2A2A + #DF9527 + diff --git a/example/assets/color/colors2.json b/example/assets/color/colors2.json deleted file mode 100644 index 0a8d8e724..000000000 --- a/example/assets/color/colors2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "high_emphasis": "#EEEEEE", - "medium_emphasis": "#979797", - "disabled": "#666666", - "accent_red": "#FF4D4D", - "accent_yellow": "#F2B756" -} \ No newline at end of file diff --git a/example/assets/color/colors2.xml b/example/assets/color/colors2.xml new file mode 100644 index 000000000..3b101bb1e --- /dev/null +++ b/example/assets/color/colors2.xml @@ -0,0 +1,7 @@ + + + #4D000000 + #66000000 + #80000000 + #99000000 + diff --git a/example/assets/color/colors3.xml b/example/assets/color/colors3.xml deleted file mode 100644 index fc2208452..000000000 --- a/example/assets/color/colors3.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - #4DEEEEEE - #29FFFFFF - #33FFFFFF - #4DFFFFFF - #52FFFFFF - #66FFFFFF - #99FFFFFF - #00141418 - #4D141418 - #B3141418 - #FF141418 - #26CF2B2B - #33CF2B2B - #4D000000 - #66000000 - #80000000 - #99000000 - \ No newline at end of file diff --git a/example/lib/gen/colors.gen.dart b/example/lib/gen/colors.gen.dart index da60f4ab1..68ef4ebb6 100644 --- a/example/lib/gen/colors.gen.dart +++ b/example/lib/gen/colors.gen.dart @@ -4,64 +4,45 @@ /// ***************************************************** import 'package:flutter/painting.dart'; +import 'package:flutter/material.dart'; class ColorName { ColorName._(); static const Color white = Color(0xFFFFFFFF); + static const Color black = Color(0xFF000000); static const Color gray70 = Color(0xFFEEEEEE); - static const Color gray150 = Color(0xFFD8D8D8); static const Color gray410 = Color(0xFF979797); - static const Color gray470 = Color(0xFF878787); - static const Color gray550 = Color(0xFF737373); - static const Color gray600 = Color(0xFF666666); - static const Color gray620 = Color(0xFF606060); - static const Color gray680 = Color(0xFF525252); - static const Color gray770 = Color(0xFF37373D); - static const Color gray800 = Color(0xFF333333); - static const Color gray860 = Color(0xFF222226); - static const Color gray880 = Color(0xFF1D1D22); - static const Color gray900 = Color(0xFF18181C); - static const Color gray910 = Color(0xFF141418); - static const Color black = Color(0xFF000000); - static const Color seaPink = Color(0xFFEB9798); - static const Color coral = Color(0xFFFE6363); - static const Color strawberry = Color(0xFFFF4D4D); - static const Color crimsonRed = Color(0xFFCF2A2A); - static const Color rustRed = Color(0xFF421E21); - static const Color milkTea = Color(0xFFF5CB84); - static const Color cornBrond = Color(0xFFF5CB84); - static const Color yellowOcher = Color(0xFFDF9527); - static const Color cinnamon = Color(0xFF955E1C); - static const Color tulipTree = Color(0xFFE6A53A); - static const Color gullGray = Color(0xFFA1B3BC); - static const Color fleryOrange = Color(0xFFB36111); - static const Color denim = Color(0xFF127DB8); - static const Color forestGreen = Color(0xFF238833); - static const Color amazon = Color(0xFF367A62); - static const Color copperCanyon = Color(0xFF8A4213); - static const Color russet = Color(0xFF7B5A19); - static const Color bronzetone = Color(0xFF533C10); - static const Color bush = Color(0xFF0F3A2B); - static const Color bronze = Color(0xFF421F0A); - static const Color highEmphasis = Color(0xFFEEEEEE); - static const Color mediumEmphasis = Color(0xFF979797); - static const Color disabled = Color(0xFF666666); - static const Color accentRed = Color(0xFFFF4D4D); - static const Color accentYellow = Color(0xFFF2B756); - static const Color highEmphasis30 = Color(0x4DEEEEEE); - static const Color white00016 = Color(0x29FFFFFF); - static const Color white00020 = Color(0x33FFFFFF); - static const Color white00030 = Color(0x4DFFFFFF); - static const Color white00032 = Color(0x52FFFFFF); - static const Color white00040 = Color(0x66FFFFFF); - static const Color white00060 = Color(0x99FFFFFF); - static const Color gray91000 = Color(0x00141418); - static const Color gray91030 = Color(0x4D141418); - static const Color gray91070 = Color(0xB3141418); - static const Color gray910100 = Color(0xFF141418); - static const Color colorAccentDark15 = Color(0x26CF2B2B); - static const Color colorAccentDark20 = Color(0x33CF2B2B); + static const MaterialColor crimsonRed = MaterialColor( + 0xFFCF2A2A, + { + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }, + ); + static const MaterialColor yellowOcher = MaterialColor( + 0xFFDF9527, + { + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }, + ); static const Color black30 = Color(0x4D000000); static const Color black40 = Color(0x66000000); static const Color black50 = Color(0x80000000); diff --git a/example/lib/main.dart b/example/lib/main.dart index efac26d9d..4845f84b4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,8 +10,12 @@ void main() { theme: ThemeData( // Auto generated font from FlutterGen. fontFamily: FontFamily.raleway, + primarySwatch: ColorName.crimsonRed, ), home: Scaffold( + appBar: AppBar( + title: const Text('FlutterGen'), + ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -27,8 +31,7 @@ void main() { 'Hi there, I\'m FlutterGen', style: TextStyle( // Auto generated color from FlutterGen. - color: ColorName.denim, - + color: ColorName.black60, // Auto generated font from FlutterGen. fontFamily: FontFamily.robotoMono, fontFamilyFallback: [FontFamily.raleway], diff --git a/example/pubspec.lock b/example/pubspec.lock index d965fd99b..8e708e011 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -169,6 +169,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.6" + dartx: + dependency: transitive + description: + name: dartx + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" fake_async: dependency: transitive description: @@ -194,7 +201,7 @@ packages: path: ".." relative: true source: path - version: "0.0.19" + version: "0.0.21" flutter_test: dependency: "direct dev" description: flutter @@ -422,6 +429,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.17" + time: + dependency: transitive + description: + name: time + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" timing: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9fd506dc7..77aa894f8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,9 +27,8 @@ flutter_gen: colors: inputs: - assets/color/colors.xml - - assets/color/colors2.json - - assets/color/colors3.xml - - assets/color/colors3.xml # duplicated + - assets/color/colors2.xml + - assets/color/colors2.xml # duplicated flutter: uses-material-design: true diff --git a/lib/src/generators/colors_generator.dart b/lib/src/generators/colors_generator.dart index 121db0fad..e61d45bfb 100644 --- a/lib/src/generators/colors_generator.dart +++ b/lib/src/generators/colors_generator.dart @@ -1,13 +1,12 @@ -import 'dart:convert'; import 'dart:io'; import 'package:dart_style/dart_style.dart'; +import 'package:dartx/dartx.dart'; import 'package:flutter_gen/src/generators/generator_helper.dart'; import 'package:flutter_gen/src/settings/color_path.dart'; import 'package:flutter_gen/src/settings/color_set.dart'; import 'package:flutter_gen/src/settings/flutterGen/flutter_gen_colors.dart'; import 'package:flutter_gen/src/utils/camel_case.dart'; -import 'package:flutter_gen/src/utils/cast.dart'; import 'package:flutter_gen/src/utils/color.dart'; import 'package:path/path.dart'; import 'package:xml/xml.dart'; @@ -22,6 +21,7 @@ String generateColors( final buffer = StringBuffer(); buffer.writeln(header()); buffer.writeln("import 'package:flutter/painting.dart';"); + buffer.writeln("import 'package:flutter/material.dart';"); buffer.writeln(); buffer.writeln('class ColorName {'); buffer.writeln(' ColorName._();'); @@ -36,23 +36,35 @@ String generateColors( if (colorFile.isXml) { colorList.addAll( XmlDocument.parse(data).findAllElements('color').map((element) { - return Color(element.getAttribute('name'), element.text); + return Color.fromXmlElement(element); })); - } else if (colorFile.isJson) { - safeCast>(jsonDecode(data)) - .cast() - .forEach((key, value) => colorList.add(Color(key, value))); } else { - throw 'Not supported file type.'; + throw 'Not supported file type ${colorFile.mime}.'; } }); - // to Set<> for remove duplicated item - for (final color in {...colorList}) { - buffer.writeln( - ' static const Color ${color.name.camelCase()} = Color(${colorFromHex(color.hex)});'); - } + colorList + .distinctBy((color) => color.hex) + .map(_colorToStatement) + .forEach(buffer.writeln); buffer.writeln('}'); return formatter.format(buffer.toString()); } + +String _colorToStatement(Color color) { + final hex = colorFromHex(color.hex); + if (color.type == 'material') { + final swatch = swatchFromPrimaryHex(hex); + return ''' + static const MaterialColor ${color.name.camelCase()} = MaterialColor( + ${swatch[500]}, + { + ${swatch.entries.map((e) => '${e.key}: Color(${e.value}),').join('\n')} + }, + );'''; + } else if (color.type == null) { + return ' static const Color ${color.name.camelCase()} = Color($hex);'; + } + throw 'Not supported color type ${color.type}.'; +} diff --git a/lib/src/settings/color_path.dart b/lib/src/settings/color_path.dart index 447c8999b..a3904699b 100644 --- a/lib/src/settings/color_path.dart +++ b/lib/src/settings/color_path.dart @@ -17,8 +17,6 @@ class ColorPath { /// https://api.flutter.dev/flutter/widgets/Image-class.html bool get isXml => mime == 'application/xml'; - bool get isJson => mime == 'application/json'; - @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) => diff --git a/lib/src/settings/color_set.dart b/lib/src/settings/color_set.dart index 9bc5fc1fa..80c34d26b 100644 --- a/lib/src/settings/color_set.dart +++ b/lib/src/settings/color_set.dart @@ -1,6 +1,19 @@ +import 'package:xml/xml.dart'; + /// https://github.com/dart-lang/mime/blob/master/lib/src/default_extension_map.dart class Color { - const Color(this._name, this._hex); + const Color( + this._name, + this._type, + this._hex, + ); + + Color.fromXmlElement(XmlElement element) + : this( + element.getAttribute('name'), + element.getAttribute('type'), + element.text, + ); final String _name; @@ -10,16 +23,7 @@ class Color { String get hex => _hex; - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - bool operator ==(Object other) => - identical(this, other) || - other is Color && - runtimeType == other.runtimeType && - _name == other._name && - _hex == other._hex; - - @override - // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => _name.hashCode ^ _hex.hashCode; + final String _type; + + String get type => _type; } diff --git a/lib/src/utils/color.dart b/lib/src/utils/color.dart index dd26e44be..ab79fd365 100644 --- a/lib/src/utils/color.dart +++ b/lib/src/utils/color.dart @@ -5,3 +5,70 @@ String colorFromHex(String hexColor) { } return '0x$hexColor'; } + +/// [Material Design Color Generator](https://github.com/mbitson/mcg) +/// Constantin logic: https://github.com/mbitson/mcg/blob/858cffea0d79ac143d590d110fbe20a1ea54d59d/scripts/controllers/ColorGeneratorCtrl.js#L238 +Map swatchFromPrimaryHex(String primaryHex) { + final primary = _Rgb.fromHex(int.parse(primaryHex)); + const baseLight = _Rgb.fromHex(0xffffff); + final baseDark = primary * primary; + return { + 50: _Rgb.mix(baseLight, primary, 12).toHexString(), + 100: _Rgb.mix(baseLight, primary, 30).toHexString(), + 200: _Rgb.mix(baseLight, primary, 50).toHexString(), + 300: _Rgb.mix(baseLight, primary, 70).toHexString(), + 400: _Rgb.mix(baseLight, primary, 85).toHexString(), + 500: _Rgb.mix(baseLight, primary, 100).toHexString(), + 600: _Rgb.mix(baseDark, primary, 87).toHexString(), + 700: _Rgb.mix(baseDark, primary, 70).toHexString(), + 800: _Rgb.mix(baseDark, primary, 54).toHexString(), + 900: _Rgb.mix(baseDark, primary, 25).toHexString(), + }; +} + +class _Rgb { + const _Rgb(int r, int g, int b) + : value = ((0xff << 24) | + ((r & 0xff) << 16) | + ((g & 0xff) << 8) | + ((b & 0xff) << 0)) & + 0xFFFFFFFF; + + const _Rgb.fromHex(int value) : value = (value | 0xFF000000) & 0xFFFFFFFF; + + final int value; + + int get r => (0x00ff0000 & value) >> 16; + + int get g => (0x0000ff00 & value) >> 8; + + int get b => (0x000000ff & value) >> 0; + + // https://github.com/mbitson/mcg/blob/858cffea0d79ac143d590d110fbe20a1ea54d59d/scripts/controllers/ColorGeneratorCtrl.js#L221 + _Rgb operator *(_Rgb other) { + return _Rgb( + (r * other.r / 255).floor(), + (g * other.g / 255).floor(), + (b * other.b / 255).floor(), + ); + } + + String toHexString() { + return '0x${value.toRadixString(16).padLeft(8, '0').toUpperCase()}'; + } + + // https://github.com/bgrins/TinyColor/blob/96592a5cacdbf4d4d16cd7d39d4d6dd28da9bd5f/tinycolor.js#L701 + static _Rgb mix( + _Rgb color1, + _Rgb color2, + int amount, + ) { + assert(amount >= 0 && amount <= 100); + final p = amount / 100; + return _Rgb( + ((color2.r - color1.r) * p + color1.r).round(), + ((color2.g - color1.g) * p + color1.g).round(), + ((color2.b - color1.b) * p + color1.b).round(), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index d2f352642..633b8c1f9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -64,6 +64,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: @@ -127,6 +134,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.6" + dartx: + dependency: "direct main" + description: + name: dartx + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" glob: dependency: transitive description: @@ -393,6 +407,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.3.11" + time: + dependency: transitive + description: + name: time + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1c008ac43..a87d8a402 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: mime: ^0.9.7 xml: ^4.2.0 dart_style: ^1.3.6 + dartx: ^0.5.0 dev_dependencies: test: diff --git a/test_resources/actual_data/colors.gen.dart b/test_resources/actual_data/colors.gen.dart index da60f4ab1..68ef4ebb6 100644 --- a/test_resources/actual_data/colors.gen.dart +++ b/test_resources/actual_data/colors.gen.dart @@ -4,64 +4,45 @@ /// ***************************************************** import 'package:flutter/painting.dart'; +import 'package:flutter/material.dart'; class ColorName { ColorName._(); static const Color white = Color(0xFFFFFFFF); + static const Color black = Color(0xFF000000); static const Color gray70 = Color(0xFFEEEEEE); - static const Color gray150 = Color(0xFFD8D8D8); static const Color gray410 = Color(0xFF979797); - static const Color gray470 = Color(0xFF878787); - static const Color gray550 = Color(0xFF737373); - static const Color gray600 = Color(0xFF666666); - static const Color gray620 = Color(0xFF606060); - static const Color gray680 = Color(0xFF525252); - static const Color gray770 = Color(0xFF37373D); - static const Color gray800 = Color(0xFF333333); - static const Color gray860 = Color(0xFF222226); - static const Color gray880 = Color(0xFF1D1D22); - static const Color gray900 = Color(0xFF18181C); - static const Color gray910 = Color(0xFF141418); - static const Color black = Color(0xFF000000); - static const Color seaPink = Color(0xFFEB9798); - static const Color coral = Color(0xFFFE6363); - static const Color strawberry = Color(0xFFFF4D4D); - static const Color crimsonRed = Color(0xFFCF2A2A); - static const Color rustRed = Color(0xFF421E21); - static const Color milkTea = Color(0xFFF5CB84); - static const Color cornBrond = Color(0xFFF5CB84); - static const Color yellowOcher = Color(0xFFDF9527); - static const Color cinnamon = Color(0xFF955E1C); - static const Color tulipTree = Color(0xFFE6A53A); - static const Color gullGray = Color(0xFFA1B3BC); - static const Color fleryOrange = Color(0xFFB36111); - static const Color denim = Color(0xFF127DB8); - static const Color forestGreen = Color(0xFF238833); - static const Color amazon = Color(0xFF367A62); - static const Color copperCanyon = Color(0xFF8A4213); - static const Color russet = Color(0xFF7B5A19); - static const Color bronzetone = Color(0xFF533C10); - static const Color bush = Color(0xFF0F3A2B); - static const Color bronze = Color(0xFF421F0A); - static const Color highEmphasis = Color(0xFFEEEEEE); - static const Color mediumEmphasis = Color(0xFF979797); - static const Color disabled = Color(0xFF666666); - static const Color accentRed = Color(0xFFFF4D4D); - static const Color accentYellow = Color(0xFFF2B756); - static const Color highEmphasis30 = Color(0x4DEEEEEE); - static const Color white00016 = Color(0x29FFFFFF); - static const Color white00020 = Color(0x33FFFFFF); - static const Color white00030 = Color(0x4DFFFFFF); - static const Color white00032 = Color(0x52FFFFFF); - static const Color white00040 = Color(0x66FFFFFF); - static const Color white00060 = Color(0x99FFFFFF); - static const Color gray91000 = Color(0x00141418); - static const Color gray91030 = Color(0x4D141418); - static const Color gray91070 = Color(0xB3141418); - static const Color gray910100 = Color(0xFF141418); - static const Color colorAccentDark15 = Color(0x26CF2B2B); - static const Color colorAccentDark20 = Color(0x33CF2B2B); + static const MaterialColor crimsonRed = MaterialColor( + 0xFFCF2A2A, + { + 50: Color(0xFFF9E5E5), + 100: Color(0xFFF1BFBF), + 200: Color(0xFFE79595), + 300: Color(0xFFDD6A6A), + 400: Color(0xFFD64A4A), + 500: Color(0xFFCF2A2A), + 600: Color(0xFFCA2525), + 700: Color(0xFFC31F1F), + 800: Color(0xFFBD1919), + 900: Color(0xFFB20F0F), + }, + ); + static const MaterialColor yellowOcher = MaterialColor( + 0xFFDF9527, + { + 50: Color(0xFFFBF2E5), + 100: Color(0xFFF5DFBE), + 200: Color(0xFFEFCA93), + 300: Color(0xFFE9B568), + 400: Color(0xFFE4A547), + 500: Color(0xFFDF9527), + 600: Color(0xFFDB8D23), + 700: Color(0xFFD7821D), + 800: Color(0xFFD27817), + 900: Color(0xFFCA670E), + }, + ); static const Color black30 = Color(0x4D000000); static const Color black40 = Color(0x66000000); static const Color black50 = Color(0x80000000); diff --git a/test_resources/assets/color/colors.xml b/test_resources/assets/color/colors.xml index 7e8d15603..3ece98f53 100644 --- a/test_resources/assets/color/colors.xml +++ b/test_resources/assets/color/colors.xml @@ -1,44 +1,9 @@ - #FFFFFF + #000000 #EEEEEE - #D8D8D8 #979797 - #878787 - #737373 - #666666 - #606060 - #525252 - #37373D - #333333 - #222226 - #1D1D22 - #18181C - #141418 - #000000 - - #EB9798 - #FE6363 - #FF4D4D - #CF2A2A - #421E21 - - #F5CB84 - #F5CB84 - #DF9527 - #955E1C - - #E6A53A - #A1B3BC - #B36111 - #127DB8 - #238833 - - #367A62 - #8A4213 - #7B5A19 - #533C10 - #0F3A2B - #421F0A - \ No newline at end of file + #CF2A2A + #DF9527 + diff --git a/test_resources/assets/color/colors2.json b/test_resources/assets/color/colors2.json deleted file mode 100644 index 0a8d8e724..000000000 --- a/test_resources/assets/color/colors2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "high_emphasis": "#EEEEEE", - "medium_emphasis": "#979797", - "disabled": "#666666", - "accent_red": "#FF4D4D", - "accent_yellow": "#F2B756" -} \ No newline at end of file diff --git a/test_resources/assets/color/colors2.xml b/test_resources/assets/color/colors2.xml new file mode 100644 index 000000000..3b101bb1e --- /dev/null +++ b/test_resources/assets/color/colors2.xml @@ -0,0 +1,7 @@ + + + #4D000000 + #66000000 + #80000000 + #99000000 + diff --git a/test_resources/assets/color/colors3.xml b/test_resources/assets/color/colors3.xml deleted file mode 100644 index fc2208452..000000000 --- a/test_resources/assets/color/colors3.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - #4DEEEEEE - #29FFFFFF - #33FFFFFF - #4DFFFFFF - #52FFFFFF - #66FFFFFF - #99FFFFFF - #00141418 - #4D141418 - #B3141418 - #FF141418 - #26CF2B2B - #33CF2B2B - #4D000000 - #66000000 - #80000000 - #99000000 - \ No newline at end of file diff --git a/test_resources/pubspec.yaml b/test_resources/pubspec.yaml index 39c37251b..4a34bff76 100644 --- a/test_resources/pubspec.yaml +++ b/test_resources/pubspec.yaml @@ -7,9 +7,8 @@ flutter_gen: colors: inputs: - assets/color/colors.xml - - assets/color/colors2.json - - assets/color/colors3.xml - - assets/color/colors3.xml # duplicated + - assets/color/colors2.xml + - assets/color/colors2.xml # duplicated flutter: uses-material-design: true diff --git a/test_resources/pubspec_colors.yaml b/test_resources/pubspec_colors.yaml index b369c3900..8aba9df9c 100644 --- a/test_resources/pubspec_colors.yaml +++ b/test_resources/pubspec_colors.yaml @@ -7,6 +7,5 @@ flutter_gen: colors: inputs: - assets/color/colors.xml - - assets/color/colors2.json - - assets/color/colors3.xml - - assets/color/colors3.xml # duplicated + - assets/color/colors2.xml + - assets/color/colors2.xml # duplicated