Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simpler code + cleaning

  • Loading branch information...
commit c7156702f692e37a4b718556442582e87858f13c 1 parent 701d038
@MathieuLorber authored
View
15 labs/architecture-examples/dart/web/dart/TodoApp.dart
@@ -135,21 +135,21 @@ class TodoApp {
void showAll() {
setSelectedFilter(showAllElement);
for (TodoWidget todoWidget in todoWidgets) {
- setTodoElementVisibility(todoWidget, true);
+ todoWidget.setElementVisibility(true);
}
}
void showActive() {
setSelectedFilter(showActiveElement);
for (TodoWidget todoWidget in todoWidgets) {
- setTodoElementVisibility(todoWidget, !todoWidget.todo.completed);
+ todoWidget.setElementVisibility(!todoWidget.todo.completed);
}
}
void showCompleted() {
setSelectedFilter(showCompletedElement);
for (TodoWidget todoWidget in todoWidgets) {
- setTodoElementVisibility(todoWidget, todoWidget.todo.completed);
+ todoWidget.setElementVisibility(todoWidget.todo.completed);
}
}
@@ -160,16 +160,7 @@ class TodoApp {
e.classes.add('selected');
}
- void setTodoElementVisibility(TodoWidget todoWidget, bool show) {
- if (show) {
- todoWidget.showElement();
- } else {
- todoWidget.hideElement();
- }
- }
-
void save() {
- StringBuffer storage = new StringBuffer('[');
List<Todo> todos = new List<Todo>();
for (TodoWidget todoWidget in todoWidgets) {
todos.add(todoWidget.todo);
View
12 labs/architecture-examples/dart/web/dart/TodoWidget.dart
@@ -70,12 +70,12 @@ class TodoWidget {
return element;
}
- void showElement() {
- element.style.display = 'block';
- }
-
- void hideElement() {
- element.style.display = 'none';
+ void setElementVisibility(bool visible) {
@sethladd Collaborator

Could you use a setter here?

So it could just be todoWidget.visible = true | false

@MathieuLorber Owner

You're right it's better...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if(visible) {
+ element.style.display = 'block';
+ } else {
+ element.style.display = 'none';
+ }
}
void toggle() {
Please sign in to comment.
Something went wrong with that request. Please try again.