Skip to content

Commit

Permalink
Fixing stringifyArea and adding test. #1
Browse files Browse the repository at this point in the history
  • Loading branch information
caduandrade committed Sep 26, 2023
1 parent 602378f commit 6df0f7d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/src/layout/layout_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ class LayoutParser {
String stringifyArea({required DockingArea area}) {
List<String> data = [];
// WEIGHT
data.add('${area.minimalWeight?.toString()}');
final String weight = area.weight != null ? area.weight.toString() : '';
data.add(weight);
// MINIMAL_SIZE
data.add('${area.minimalWeight?.toString()}');
final String minimalWeight =
area.minimalWeight != null ? area.minimalWeight.toString() : '';
data.add(minimalWeight);
// MINIMAL_SIZE
data.add('${area.minimalSize?.toString()}');
final String minimalSize =
area.minimalSize != null ? area.minimalSize!.toStringAsFixed(0) : '';
data.add(minimalSize);

return data.join(';');
}
Expand Down
24 changes: 24 additions & 0 deletions test/layout_stringify_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:docking/docking.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

import 'exceptions.dart';
Expand Down Expand Up @@ -31,5 +32,28 @@ void main() {
expect(parser.stringifyParent(parent: row), '4,5');
expect(parser.stringifyParent(parent: tabs), '7,8');
});
test('stringifyArea', () {
DockingItem itemA = DockingItem(widget: Container());
DockingItem itemB = DockingItem(widget: Container(), weight: .2);
DockingItem itemC = DockingItem(widget: Container(), minimalSize: 100);
DockingItem itemD = DockingItem(widget: Container(), minimalWeight: .2);
DockingItem itemE =
DockingItem(widget: Container(), weight: .3, minimalWeight: .2);
DockingRow row = DockingRow([itemB, itemC], weight: .4);
DockingTabs tabs = DockingTabs([itemD, itemE], minimalSize: 200);
DockingColumn column =
DockingColumn([itemA, row, tabs], minimalWeight: .5);

DockingLayout(root: column);

expect(parser.stringifyArea(area: column), ';0.5;');
expect(parser.stringifyArea(area: row), '0.4;;');
expect(parser.stringifyArea(area: tabs), ';;200');
expect(parser.stringifyArea(area: itemA), ';;');
expect(parser.stringifyArea(area: itemB), '0.2;;');
expect(parser.stringifyArea(area: itemC), ';;100');
expect(parser.stringifyArea(area: itemD), ';0.2;');
expect(parser.stringifyArea(area: itemE), '0.3;0.2;');
});
});
}

0 comments on commit 6df0f7d

Please sign in to comment.