chore: dartfmt Dart code in the repo

This commit is contained in:
Kevin Moore
2015-05-08 19:51:19 -07:00
parent a5638a940c
commit 7844e3a275
27 changed files with 252 additions and 332 deletions

View File

@ -5,9 +5,7 @@ import 'dart:html';
import 'package:angular/angular.dart';
import 'package:angular2/src/test_lib/benchmark_util.dart';
@Component(
selector: 'scroll-app',
template: '''
@Component(selector: 'scroll-app', template: '''
<div>
<div style="display: flex">
<scroll-area scroll-top="scrollTop"></scroll-area>
@ -29,7 +27,7 @@ class App implements ShadowRootAware {
int appSize = getIntParameter('appSize');
iterationCount = getIntParameter('iterationCount');
scrollIncrement = getIntParameter('scrollIncrement');
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
scrollAreas = new List.generate(appSize, (i) => i);
}

View File

@ -3,43 +3,25 @@ library cells;
import 'package:angular/angular.dart';
import 'common.dart';
@Component(
selector: 'company-name',
template: '''
@Component(selector: 'company-name', template: '''
<div style="width: {{width}}">{{company.name}}</div>
''',
map: const {
'company': '=>company',
'cell-width': '=>width',
})
''', map: const {'company': '=>company', 'cell-width': '=>width',})
class CompanyNameComponent {
String width;
Company company;
}
@Component(
selector: 'opportunity-name',
template: '''
@Component(selector: 'opportunity-name', template: '''
<div style="width: {{width}}">{{opportunity.name}}</div>
''',
map: const {
'opportunity': '=>opportunity',
'cell-width': '=>width',
})
''', map: const {'opportunity': '=>opportunity', 'cell-width': '=>width',})
class OpportunityNameComponent {
String width;
Opportunity opportunity;
}
@Component(
selector: 'offering-name',
template: '''
@Component(selector: 'offering-name', template: '''
<div style="width: {{width}}">{{offering.name}}</div>
''',
map: const {
'offering': '=>offering',
'cell-width': '=>width',
})
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
class OfferingNameComponent {
String width;
Offering offering;
@ -52,15 +34,11 @@ class Stage {
Function apply;
String get styleString => style != null
? style.keys
.map((prop) => '$prop: ${style[prop]}')
.join(';')
: '';
? style.keys.map((prop) => '$prop: ${style[prop]}').join(';')
: '';
}
@Component(
selector: 'stage-buttons',
template: '''
@Component(selector: 'stage-buttons', template: '''
<div style="width: {{width}}">
<button ng-repeat="stage in stages"
ng-disabled="stage.isDisabled"
@ -69,11 +47,7 @@ class Stage {
{{stage.name}}
</button>
</div>
''',
map: const {
'offering': '=>offering',
'cell-width': '=>width',
})
''', map: const {'offering': '=>offering', 'cell-width': '=>width',})
class StageButtonsComponent {
Offering _offering;
List<Stage> stages;
@ -92,42 +66,30 @@ class StageButtonsComponent {
_computeStageButtons() {
bool disabled = true;
stages = STATUS_LIST
.map((String status) {
stages = STATUS_LIST.map((String status) {
bool isCurrent = offering.status == status;
var stage = new Stage();
stage
..name = status
..isDisabled = disabled
..style = {
'background-color': disabled
? '#DDD'
: isCurrent
? '#DDF'
: '#FDD'
};
'background-color': disabled ? '#DDD' : isCurrent ? '#DDF' : '#FDD'
};
if (isCurrent) {
disabled = false;
}
return stage;
})
.toList();
}).toList();
}
}
@Component(
selector: 'account-cell',
template: '''
@Component(selector: 'account-cell', template: '''
<div style="width: {{width}}">
<a href="/account/{{account.accountId}}">
{{account.accountId}}
</a>
</div>
''',
map: const {
'account': '=>account',
'cell-width': '=>width',
})
''', map: const {'account': '=>account', 'cell-width': '=>width',})
class AccountCellComponent {
Account account;
String width;
@ -136,10 +98,7 @@ class AccountCellComponent {
@Component(
selector: 'formatted-cell',
template: '''<div style="width: {{width}}">{{formattedValue}}</div>''',
map: const {
'value': '=>value',
'cell-width': '=>width',
})
map: const {'value': '=>value', 'cell-width': '=>width',})
class FormattedCellComponent {
String formattedValue;
String width;

View File

@ -23,32 +23,25 @@ const DUE_DATE_WIDTH = 100;
const END_DATE_WIDTH = 100;
const AAT_STATUS_WIDTH = 100;
const ROW_WIDTH = COMPANY_NAME_WIDTH +
OPPORTUNITY_NAME_WIDTH +
OFFERING_NAME_WIDTH +
ACCOUNT_CELL_WIDTH +
BASE_POINTS_WIDTH +
KICKER_POINTS_WIDTH +
STAGE_BUTTONS_WIDTH +
BUNDLES_WIDTH +
DUE_DATE_WIDTH +
END_DATE_WIDTH +
AAT_STATUS_WIDTH;
OPPORTUNITY_NAME_WIDTH +
OFFERING_NAME_WIDTH +
ACCOUNT_CELL_WIDTH +
BASE_POINTS_WIDTH +
KICKER_POINTS_WIDTH +
STAGE_BUTTONS_WIDTH +
BUNDLES_WIDTH +
DUE_DATE_WIDTH +
END_DATE_WIDTH +
AAT_STATUS_WIDTH;
const STATUS_LIST = const [
'Planned', 'Pitched', 'Won', 'Lost'
];
const STATUS_LIST = const ['Planned', 'Pitched', 'Won', 'Lost'];
const AAT_STATUS_LIST = const [
'Active', 'Passive', 'Abandoned'
];
const AAT_STATUS_LIST = const ['Active', 'Passive', 'Abandoned'];
// Imitate Streamy entities.
class RawEntity
extends Object
with MapMixin<String, dynamic>
implements ObservableMap<String, dynamic> {
class RawEntity extends Object with MapMixin<String, dynamic>
implements ObservableMap<String, dynamic> {
ObservableMap _data = new ObservableMap();
@override
@ -60,7 +53,7 @@ implements ObservableMap<String, dynamic> {
}
@override
operator[](String key) {
operator [](String key) {
if (!key.contains('.')) {
return _data[key];
}
@ -74,7 +67,7 @@ implements ObservableMap<String, dynamic> {
}
@override
operator[]=(String key, value) {
operator []=(String key, value) {
if (!key.contains('.')) {
_data[key] = value;
return;
@ -115,7 +108,7 @@ implements ObservableMap<String, dynamic> {
bool deliverChanges() => _data.deliverChanges();
@override
notifyPropertyChange(Symbol field, Object oldValue, Object newValue) =>
_data.notifyPropertyChange(field, oldValue, newValue);
_data.notifyPropertyChange(field, oldValue, newValue);
@override
void notifyChange(ChangeRecord record) {
_data.notifyChange(record);
@ -199,7 +192,6 @@ class Opportunity extends RawEntity {
set name(String val) {
this['name'] = val;
}
}
class Account extends RawEntity {

View File

@ -9,7 +9,8 @@ import 'cells.dart';
class MyAppModule extends Module {
MyAppModule() {
bind(ResourceResolverConfig, toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
bind(ResourceResolverConfig,
toValue: new ResourceResolverConfig.resolveRelativeUrls(false));
bind(App);
bind(ScrollAreaComponent);
bind(ScrollItemComponent);
@ -23,7 +24,5 @@ class MyAppModule extends Module {
}
void main() {
applicationFactory()
.addModule(new MyAppModule())
.run();
applicationFactory().addModule(new MyAppModule()).run();
}

View File

@ -3,7 +3,7 @@ library random_data;
import 'common.dart';
List<Offering> generateOfferings(int count) =>
new List.generate(count, generateOffering);
new List.generate(count, generateOffering);
Offering generateOffering(int seed) {
final res = new Offering();
@ -22,24 +22,32 @@ Offering generateOffering(int seed) {
}
Company generateCompany(int seed) {
return new Company()
..name = generateName(seed);
return new Company()..name = generateName(seed);
}
Opportunity generateOpportunity(int seed) {
return new Opportunity()
..name = generateName(seed);
return new Opportunity()..name = generateName(seed);
}
Account generateAccount(int seed) {
return new Account()
..accountId = seed;
return new Account()..accountId = seed;
}
String generateName(int seed) {
const names = const [
'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh',
'Xyzzy', 'Thud', 'Cruft', 'Stuff'
'Foo',
'Bar',
'Baz',
'Qux',
'Quux',
'Garply',
'Waldo',
'Fred',
'Plugh',
'Xyzzy',
'Thud',
'Cruft',
'Stuff'
];
return names[seed % names.length];
}
@ -49,13 +57,17 @@ DateTime randomDate(int seed, {DateTime minDate}) {
minDate = new DateTime.now();
}
const offsets = const[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const offsets = const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
return minDate.add(new Duration(days: offsets[seed % offsets.length]));
}
String randomString(int seed) {
return new String.fromCharCodes(new List.generate(
const[5, 7, 9, 11, 13][seed % 5],
(i) => 'a'.codeUnitAt(0) + const[0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i
));
return new String.fromCharCodes(new List.generate(const [
5,
7,
9,
11,
13
][seed % 5], (i) =>
'a'.codeUnitAt(0) + const [0, 1, 2, 3, 4, 5, 6, 7, 8][seed % 9] + i));
}

View File

@ -9,9 +9,7 @@ import 'random_data.dart';
@Component(
selector: 'scroll-area',
templateUrl: 'scroll_area.html',
map: const {
'scroll-top': '=>scrollTop',
})
map: const {'scroll-top': '=>scrollTop',})
class ScrollAreaComponent implements ShadowRootAware {
Element scrollDiv;
List<Offering> _fullList;
@ -32,10 +30,10 @@ class ScrollAreaComponent implements ShadowRootAware {
scrollDiv = shadowRoot.querySelector('#scrollDiv');
onScroll();
scrollDivStyle.addAll({
'height': '${VIEW_PORT_HEIGHT}px',
'width': '1000px',
'border': '1px solid #000',
'overflow': 'scroll',
'height': '${VIEW_PORT_HEIGHT}px',
'width': '1000px',
'border': '1px solid #000',
'overflow': 'scroll',
});
innerStyle['width'] = '${ROW_WIDTH}px';
}
@ -52,7 +50,8 @@ class ScrollAreaComponent implements ShadowRootAware {
int padding = iStart * ITEM_HEIGHT;
innerStyle['height'] = '${HEIGHT - padding}px';
paddingStyle['height'] = '${padding}px';
visibleItems..clear()..addAll(_fullList.getRange(iStart, iEnd));
visibleItems
..clear()
..addAll(_fullList.getRange(iStart, iEnd));
}
}

View File

@ -6,36 +6,33 @@ import 'common.dart';
@Component(
selector: 'scroll-item',
templateUrl: 'scroll_item.html',
map: const {
'offering': '=>offering',
})
map: const {'offering': '=>offering',})
class ScrollItemComponent implements ShadowRootAware {
Offering offering;
Offering offering;
// Init empty maps and populate later. There seems to be a bug in Angular
// that makes it choke on pre-populated style maps.
Map itemStyle = {};
// Init empty maps and populate later. There seems to be a bug in Angular
// that makes it choke on pre-populated style maps.
Map itemStyle = {};
@override
void onShadowRoot(_) {
itemStyle.addAll({
'height': '${ITEM_HEIGHT}px',
'line-height': '${ITEM_HEIGHT}px',
'font-size': '18px',
'display': 'flex',
'justify-content': 'space-between',
});
}
get companyNameWidth => '${COMPANY_NAME_WIDTH}px';
get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px';
get offeringNameWidth => '${OFFERING_NAME_WIDTH}px';
get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px';
get basePointsWidth => '${BASE_POINTS_WIDTH}px';
get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px';
get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px';
get bundlesWidth => '${BUNDLES_WIDTH}px';
get dueDateWidth => '${DUE_DATE_WIDTH}px';
get endDateWidth => '${END_DATE_WIDTH}px';
get aatStatusWidth => '${AAT_STATUS_WIDTH}px';
@override
void onShadowRoot(_) {
itemStyle.addAll({
'height': '${ITEM_HEIGHT}px',
'line-height': '${ITEM_HEIGHT}px',
'font-size': '18px',
'display': 'flex',
'justify-content': 'space-between',
});
}
get companyNameWidth => '${COMPANY_NAME_WIDTH}px';
get opportunityNameWidth => '${OPPORTUNITY_NAME_WIDTH}px';
get offeringNameWidth => '${OFFERING_NAME_WIDTH}px';
get accountCellWidth => '${ACCOUNT_CELL_WIDTH}px';
get basePointsWidth => '${BASE_POINTS_WIDTH}px';
get kickerPointsWidth => '${KICKER_POINTS_WIDTH}px';
get stageButtonsWidth => '${STAGE_BUTTONS_WIDTH}px';
get bundlesWidth => '${BUNDLES_WIDTH}px';
get dueDateWidth => '${DUE_DATE_WIDTH}px';
get endDateWidth => '${END_DATE_WIDTH}px';
get aatStatusWidth => '${AAT_STATUS_WIDTH}px';
}