Skip to content

Commit

Permalink
Merge branch 'main' into Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
devsdocs authored Feb 7, 2024
2 parents 9514f73 + a4f3f38 commit 8bb703c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
23 changes: 6 additions & 17 deletions lib/src/utilities/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ extension StringExt on String {
ExcelColor get excelColor => this == 'none'
? ExcelColor.none
: _assertHexString(this)

? ExcelColor.valuesAsMap[this] ?? ExcelColor._(this)

: ExcelColor.black;
}

/// Copying from Flutter Material Color
class ExcelColor extends Equatable {

const ExcelColor._(this._color, [this._name, this._type]);

final String _color;
Expand All @@ -101,6 +104,7 @@ class ExcelColor extends Equatable {

String? get name => _name;


/// Warning! Highly unsafe method.
/// Can break your excel file if you do not know what you are doing
factory ExcelColor.fromInt(int colorIntValue) =>
Expand All @@ -111,8 +115,10 @@ class ExcelColor extends Equatable {
factory ExcelColor.fromHexString(String colorHexValue) =>
ExcelColor._(colorHexValue);


static const none = ExcelColor._('none');


static const black = ExcelColor._('FF000000', 'black', ColorType.color);
static const black12 = ExcelColor._('1F000000', 'black12', ColorType.color);
static const black26 = ExcelColor._('42000000', 'black26', ColorType.color);
Expand Down Expand Up @@ -187,112 +193,96 @@ class ExcelColor extends Equatable {
ExcelColor._('FF607D8B', 'blueGrey', ColorType.material);
static const redAccent100 =
ExcelColor._('FFFF8A80', 'redAccent100', ColorType.materialAccent);

static const redAccent400 =
ExcelColor._('FFFF1744', 'redAccent400', ColorType.materialAccent);
static const redAccent700 =
ExcelColor._('FFD50000', 'redAccent700', ColorType.materialAccent);
static const pinkAccent100 =
ExcelColor._('FFFF80AB', 'pinkAccent100', ColorType.materialAccent);

static const pinkAccent400 =
ExcelColor._('FFF50057', 'pinkAccent400', ColorType.materialAccent);
static const pinkAccent700 =
ExcelColor._('FFC51162', 'pinkAccent700', ColorType.materialAccent);
static const purpleAccent100 =
ExcelColor._('FFEA80FC', 'purpleAccent100', ColorType.materialAccent);

static const purpleAccent400 =
ExcelColor._('FFD500F9', 'purpleAccent400', ColorType.materialAccent);
static const purpleAccent700 =
ExcelColor._('FFAA00FF', 'purpleAccent700', ColorType.materialAccent);
static const deepPurpleAccent100 =
ExcelColor._('FFB388FF', 'deepPurpleAccent100', ColorType.materialAccent);

static const deepPurpleAccent400 =
ExcelColor._('FF651FFF', 'deepPurpleAccent400', ColorType.materialAccent);
static const deepPurpleAccent700 =
ExcelColor._('FF6200EA', 'deepPurpleAccent700', ColorType.materialAccent);
static const indigoAccent100 =
ExcelColor._('FF8C9EFF', 'indigoAccent100', ColorType.materialAccent);

static const indigoAccent400 =
ExcelColor._('FF3D5AFE', 'indigoAccent400', ColorType.materialAccent);
static const indigoAccent700 =
ExcelColor._('FF304FFE', 'indigoAccent700', ColorType.materialAccent);
static const blueAccent100 =
ExcelColor._('FF82B1FF', 'blueAccent100', ColorType.materialAccent);

static const blueAccent400 =
ExcelColor._('FF2979FF', 'blueAccent400', ColorType.materialAccent);
static const blueAccent700 =
ExcelColor._('FF2962FF', 'blueAccent700', ColorType.materialAccent);
static const lightBlueAccent100 =
ExcelColor._('FF80D8FF', 'lightBlueAccent100', ColorType.materialAccent);

static const lightBlueAccent400 =
ExcelColor._('FF00B0FF', 'lightBlueAccent400', ColorType.materialAccent);
static const lightBlueAccent700 =
ExcelColor._('FF0091EA', 'lightBlueAccent700', ColorType.materialAccent);
static const cyanAccent100 =
ExcelColor._('FF84FFFF', 'cyanAccent100', ColorType.materialAccent);

static const cyanAccent400 =
ExcelColor._('FF00E5FF', 'cyanAccent400', ColorType.materialAccent);
static const cyanAccent700 =
ExcelColor._('FF00B8D4', 'cyanAccent700', ColorType.materialAccent);
static const tealAccent100 =
ExcelColor._('FFA7FFEB', 'tealAccent100', ColorType.materialAccent);

static const tealAccent400 =
ExcelColor._('FF1DE9B6', 'tealAccent400', ColorType.materialAccent);
static const tealAccent700 =
ExcelColor._('FF00BFA5', 'tealAccent700', ColorType.materialAccent);
static const greenAccent100 =
ExcelColor._('FFB9F6CA', 'greenAccent100', ColorType.materialAccent);

static const greenAccent400 =
ExcelColor._('FF00E676', 'greenAccent400', ColorType.materialAccent);
static const greenAccent700 =
ExcelColor._('FF00C853', 'greenAccent700', ColorType.materialAccent);
static const lightGreenAccent100 =
ExcelColor._('FFCCFF90', 'lightGreenAccent100', ColorType.materialAccent);

static const lightGreenAccent400 =
ExcelColor._('FF76FF03', 'lightGreenAccent400', ColorType.materialAccent);
static const lightGreenAccent700 =
ExcelColor._('FF64DD17', 'lightGreenAccent700', ColorType.materialAccent);
static const limeAccent100 =
ExcelColor._('FFF4FF81', 'limeAccent100', ColorType.materialAccent);

static const limeAccent400 =
ExcelColor._('FFC6FF00', 'limeAccent400', ColorType.materialAccent);
static const limeAccent700 =
ExcelColor._('FFAEEA00', 'limeAccent700', ColorType.materialAccent);
static const yellowAccent100 =
ExcelColor._('FFFFFF8D', 'yellowAccent100', ColorType.materialAccent);

static const yellowAccent400 =
ExcelColor._('FFFFEA00', 'yellowAccent400', ColorType.materialAccent);
static const yellowAccent700 =
ExcelColor._('FFFFD600', 'yellowAccent700', ColorType.materialAccent);
static const amberAccent100 =
ExcelColor._('FFFFE57F', 'amberAccent100', ColorType.materialAccent);

static const amberAccent400 =
ExcelColor._('FFFFC400', 'amberAccent400', ColorType.materialAccent);
static const amberAccent700 =
ExcelColor._('FFFFAB00', 'amberAccent700', ColorType.materialAccent);
static const orangeAccent100 =
ExcelColor._('FFFFD180', 'orangeAccent100', ColorType.materialAccent);

static const orangeAccent400 =
ExcelColor._('FFFF9100', 'orangeAccent400', ColorType.materialAccent);
static const orangeAccent700 =
ExcelColor._('FFFF6D00', 'orangeAccent700', ColorType.materialAccent);
static const deepOrangeAccent100 =
ExcelColor._('FFFF9E80', 'deepOrangeAccent100', ColorType.materialAccent);

static const deepOrangeAccent400 =
ExcelColor._('FFFF3D00', 'deepOrangeAccent400', ColorType.materialAccent);
static const deepOrangeAccent700 =
Expand Down Expand Up @@ -906,7 +896,6 @@ class ExcelColor extends Equatable {

static Map<String, ExcelColor> get valuesAsMap =>
values.asMap().map((_, v) => MapEntry(v.colorHex, v));

@override
List<Object?> get props => [
_name,
Expand Down
5 changes: 5 additions & 0 deletions test/excel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ void main() {
final List<List<int>> data = List<List<int>>.generate(
5, (x) => List<int>.generate(5, (i) => (x + 1) * (i + 1)));


const newName = 'Sheet1Replacement';

const defaultSheetName = 'Sheet1';
Expand All @@ -799,14 +800,17 @@ void main() {
.where((e) => e.type == ColorType.materialAccent)
.toList();


excelFiles.forEach((element) {
expect(element.getDefaultSheet()!, defaultSheetName);
for (var row = 0; row < data.length; row++) {
for (var column = 0; column < data[row].length; column++) {

final border = Border(
borderColorHex: borderColor[column],
borderStyle: BorderStyle.Thin,
);

element.updateCell(
element.getDefaultSheet()!,
CellIndex.indexByColumnRow(columnIndex: column, rowIndex: row),
Expand All @@ -818,6 +822,7 @@ void main() {
..rightBorder = border
..backgroundColor = backgroundColor[row]
..fontColor = fontColor[column],

);
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8bb703c

Please sign in to comment.