1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-24 23:01:18 +01:00
git-touch-android-ios-app/lib/widgets/object_tree.dart

58 lines
1.3 KiB
Dart
Raw Normal View History

2020-01-30 05:55:55 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/table_view.dart';
import 'package:primer/primer.dart';
import 'package:seti/seti.dart';
class ObjectTreeItem {
final String url;
final String name;
final String type;
ObjectTreeItem({
@required this.name,
@required this.url,
@required this.type,
});
}
class ObjectTree extends StatelessWidget {
final Iterable<ObjectTreeItem> items;
ObjectTree({@required this.items});
Widget _buildIcon(ObjectTreeItem item) {
switch (item.type) {
case 'blob':
return SetiIcon(item.name, size: 36);
case 'tree':
return Icon(
Octicons.file_directory,
color: PrimerColors.blue300,
size: 24,
);
case 'commit':
return Icon(
Octicons.file_submodule,
color: PrimerColors.blue300,
size: 24,
);
default:
throw 'object type error';
}
}
@override
Widget build(BuildContext context) {
return TableView(
hasIcon: true,
items: [
for (var item in items)
TableViewItem(
leftWidget: _buildIcon(item),
text: Text(item.name),
url: item.url,
)
],
);
}
}