Skip to content

Commit f32849a

Browse files
committed
conflict merge
2 parents 383e2a4 + a852cd6 commit f32849a

File tree

22 files changed

+284
-348
lines changed

22 files changed

+284
-348
lines changed

README.md

Lines changed: 37 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ class FontFamily {
384384

385385
### Colors
386386

387+
[FlutterGen] supports generating colors from [XML](example/assets/color/colors.xml) format files.
387388
_Ignore duplicated._
388389

389390
```yaml
@@ -392,27 +393,15 @@ flutter_gen:
392393
colors:
393394
inputs:
394395
- assets/color/colors.xml
395-
- assets/color/colors2.json
396-
- assets/color/colors3.xml
396+
- assets/color/colors2.xml
397397
```
398398

399-
[FlutterGen] supports the following input file formats:
400-
401-
- a [XML file](example/assets/color/colors.xml), the same format as the Android colors.xml files, containing tags
399+
[FlutterGen] generates [MaterialColor](https://api.flutter.dev/flutter/material/MaterialColor-class.html) class
400+
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.
402401

403402
```xml
404403
<color name="milk_tea">#F5CB84</color>
405-
<color name="cinnamon">#955E1C</color>
406-
<color name="black_50">#80000000</color>
407-
```
408-
409-
- a [JSON file](example/assets/color/colors2.json), representing a dictionary of names -> values, each value being the hex representation of the color
410-
411-
```json
412-
{
413-
"disabled": "#666666",
414-
"accent_red": "#FF4D4D"
415-
}
404+
<color name="cinnamon" type="material">#955E1C</color>
416405
```
417406

418407
These configurations will generate **`colors.gen.dart`** under the **`lib/gen/`** directory by default.
@@ -437,68 +426,45 @@ Text(
437426
/// *****************************************************
438427
439428
import 'package:flutter/painting.dart';
429+
import 'package:flutter/material.dart';
440430
441431
class ColorName {
442432
ColorName._();
443433
444434
static const Color white = Color(0xFFFFFFFF);
435+
static const Color black = Color(0xFF000000);
445436
static const Color gray70 = Color(0xFFEEEEEE);
446-
static const Color gray150 = Color(0xFFD8D8D8);
447437
static const Color gray410 = Color(0xFF979797);
448-
static const Color gray470 = Color(0xFF878787);
449-
static const Color gray550 = Color(0xFF737373);
450-
static const Color gray600 = Color(0xFF666666);
451-
static const Color gray620 = Color(0xFF606060);
452-
static const Color gray680 = Color(0xFF525252);
453-
static const Color gray770 = Color(0xFF37373D);
454-
static const Color gray800 = Color(0xFF333333);
455-
static const Color gray860 = Color(0xFF222226);
456-
static const Color gray880 = Color(0xFF1D1D22);
457-
static const Color gray900 = Color(0xFF18181C);
458-
static const Color gray910 = Color(0xFF141418);
459-
static const Color black = Color(0xFF000000);
460-
static const Color seaPink = Color(0xFFEB9798);
461-
static const Color coral = Color(0xFFFE6363);
462-
static const Color strawberry = Color(0xFFFF4D4D);
463-
static const Color crimsonRed = Color(0xFFCF2A2A);
464-
static const Color rustRed = Color(0xFF421E21);
465-
static const Color milkTea = Color(0xFFF5CB84);
466-
static const Color cornBrond = Color(0xFFF5CB84);
467-
static const Color yellowOcher = Color(0xFFDF9527);
468-
static const Color cinnamon = Color(0xFF955E1C);
469-
static const Color tulipTree = Color(0xFFE6A53A);
470-
static const Color gullGray = Color(0xFFA1B3BC);
471-
static const Color fleryOrange = Color(0xFFB36111);
472-
static const Color denim = Color(0xFF127DB8);
473-
static const Color forestGreen = Color(0xFF238833);
474-
static const Color amazon = Color(0xFF367A62);
475-
static const Color copperCanyon = Color(0xFF8A4213);
476-
static const Color russet = Color(0xFF7B5A19);
477-
static const Color bronzetone = Color(0xFF533C10);
478-
static const Color bush = Color(0xFF0F3A2B);
479-
static const Color bronze = Color(0xFF421F0A);
480-
static const Color highEmphasis = Color(0xFFEEEEEE);
481-
static const Color mediumEmphasis = Color(0xFF979797);
482-
static const Color disabled = Color(0xFF666666);
483-
static const Color accentRed = Color(0xFFFF4D4D);
484-
static const Color accentYellow = Color(0xFFF2B756);
485-
static const Color highEmphasis30 = Color(0x4DEEEEEE);
486-
static const Color white00016 = Color(0x29FFFFFF);
487-
static const Color white00020 = Color(0x33FFFFFF);
488-
static const Color white00030 = Color(0x4DFFFFFF);
489-
static const Color white00032 = Color(0x52FFFFFF);
490-
static const Color white00040 = Color(0x66FFFFFF);
491-
static const Color white00060 = Color(0x99FFFFFF);
492-
static const Color gray91000 = Color(0x00141418);
493-
static const Color gray91030 = Color(0x4D141418);
494-
static const Color gray91070 = Color(0xB3141418);
495-
static const Color gray910100 = Color(0xFF141418);
496-
static const Color colorAccentDark15 = Color(0x26CF2B2B);
497-
static const Color colorAccentDark20 = Color(0x33CF2B2B);
498-
static const Color black30 = Color(0x4D000000);
499-
static const Color black40 = Color(0x66000000);
500-
static const Color black50 = Color(0x80000000);
501-
static const Color black60 = Color(0x99000000);
438+
static const MaterialColor crimsonRed = MaterialColor(
439+
0xFFCF2A2A,
440+
<int, Color>{
441+
50: Color(0xFFF9E5E5),
442+
100: Color(0xFFF1BFBF),
443+
200: Color(0xFFE79595),
444+
300: Color(0xFFDD6A6A),
445+
400: Color(0xFFD64A4A),
446+
500: Color(0xFFCF2A2A),
447+
600: Color(0xFFCA2525),
448+
700: Color(0xFFC31F1F),
449+
800: Color(0xFFBD1919),
450+
900: Color(0xFFB20F0F),
451+
},
452+
);
453+
static const MaterialColor yellowOcher = MaterialColor(
454+
0xFFDF9527,
455+
<int, Color>{
456+
50: Color(0xFFFBF2E5),
457+
100: Color(0xFFF5DFBE),
458+
200: Color(0xFFEFCA93),
459+
300: Color(0xFFE9B568),
460+
400: Color(0xFFE4A547),
461+
500: Color(0xFFDF9527),
462+
600: Color(0xFFDB8D23),
463+
700: Color(0xFFD7821D),
464+
800: Color(0xFFD27817),
465+
900: Color(0xFFCA670E),
466+
},
467+
);
502468
}
503469
```
504470

example/assets/color/colors.xml

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<!-- Color Pallet -->
43
<color name="white">#FFFFFF</color>
4+
<color name="black">#000000</color>
55
<color name="gray_70">#EEEEEE</color>
6-
<color name="gray_150">#D8D8D8</color>
76
<color name="gray_410">#979797</color>
8-
<color name="gray_470">#878787</color>
9-
<color name="gray_550">#737373</color>
10-
<color name="gray_600">#666666</color>
11-
<color name="gray_620">#606060</color>
12-
<color name="gray_680">#525252</color>
13-
<color name="gray_770">#37373D</color>
14-
<color name="gray_800">#333333</color>
15-
<color name="gray_860">#222226</color>
16-
<color name="gray_880">#1D1D22</color>
17-
<color name="gray_900">#18181C</color>
18-
<color name="gray_910">#141418</color>
19-
<color name="black">#000000</color>
20-
21-
<color name="sea_pink">#EB9798</color>
22-
<color name="coral">#FE6363</color>
23-
<color name="strawberry">#FF4D4D</color>
24-
<color name="crimson_red">#CF2A2A</color>
25-
<color name="rust_red">#421E21</color>
26-
27-
<color name="milk_tea">#F5CB84</color>
28-
<color name="corn_brond">#F5CB84</color>
29-
<color name="yellow_ocher">#DF9527</color>
30-
<color name="cinnamon">#955E1C</color>
31-
32-
<color name="tulip_tree">#E6A53A</color>
33-
<color name="gull_gray">#A1B3BC</color>
34-
<color name="flery_orange">#B36111</color>
35-
<color name="denim">#127DB8</color>
36-
<color name="forest_green">#238833</color>
37-
38-
<color name="amazon">#367A62</color>
39-
<color name="copper_canyon">#8A4213</color>
40-
<color name="russet">#7B5A19</color>
41-
<color name="bronzetone">#533C10</color>
42-
<color name="bush">#0F3A2B</color>
43-
<color name="bronze">#421F0A</color>
44-
</resources>
7+
<color name="crimson_red" type="material">#CF2A2A</color>
8+
<color name="yellow_ocher" type="material">#DF9527</color>
9+
</resources>

example/assets/color/colors2.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/assets/color/colors2.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="black_30">#4D000000</color>
4+
<color name="black_40">#66000000</color>
5+
<color name="black_50">#80000000</color>
6+
<color name="black_60">#99000000</color>
7+
</resources>

example/assets/color/colors3.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

example/lib/gen/colors.gen.dart

Lines changed: 32 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ void main() {
1010
theme: ThemeData(
1111
// Auto generated font from FlutterGen.
1212
fontFamily: FontFamily.raleway,
13+
primarySwatch: ColorName.crimsonRed,
1314
),
1415
home: Scaffold(
16+
appBar: AppBar(
17+
title: const Text('FlutterGen'),
18+
),
1519
body: Center(
1620
child: SingleChildScrollView(
1721
child: Column(
@@ -34,7 +38,7 @@ void main() {
3438
'Hi there, I\'m FlutterGen',
3539
style: TextStyle(
3640
// Auto generated color from FlutterGen.
37-
color: ColorName.denim,
41+
color: ColorName.black60,
3842

3943
// Auto generated font from FlutterGen.
4044
fontFamily: FontFamily.robotoMono,

0 commit comments

Comments
 (0)