| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'github_services.dart'; | |
| 6 | |
| 7 import 'package:immi/dart/immi.dart'; | |
| 8 import 'package:immi/dart/image.dart'; | |
| 9 | |
| 10 import 'package:immi_samples/sequenced_presenter.dart'; | |
| 11 | |
| 12 // Export generated code for nodes in commit_presenter.immi | |
| 13 import 'package:immi/dart/commit_presenter.dart'; | |
| 14 export 'package:immi/dart/commit_presenter.dart'; | |
| 15 | |
| 16 class CommitPresenter extends SequencedPresenter<CommitNode> { | |
| 17 Repository _repository; | |
| 18 Set<int> selectedIndices = new Set<int>(); | |
| 19 | |
| 20 CommitPresenter(this._repository); | |
| 21 | |
| 22 void toggleAt(int index) { | |
| 23 if (selectedIndices.contains(index)) { | |
| 24 selectedIndices.remove(index); | |
| 25 } else { | |
| 26 selectedIndices.add(index); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 CommitNode presentAt(int index) { | |
| 31 Map<String, dynamic> json = _repository.getCommitAt(index); | |
| 32 if (json == null) return null; | |
| 33 | |
| 34 String imageUrl = json['author'] == null | |
| 35 ? "" | |
| 36 : json['author']['avatar_url']; | |
| 37 | |
| 38 return new CommitNode( | |
| 39 author: json['commit']['author']['name'], | |
| 40 message: json['commit']['message'], | |
| 41 selected: selectedIndices.contains(index), | |
| 42 image: new ImageNode(url: imageUrl)); | |
| 43 } | |
| 44 } | |
| OLD | NEW |