fix(github): binary files

related: #21
This commit is contained in:
Rongjian Zhang 2020-01-31 13:50:09 +08:00
parent c3cf25bcf3
commit 89c311c410
1 changed files with 14 additions and 2 deletions

View File

@ -74,11 +74,23 @@ class ObjectScreen extends StatelessWidget {
return ObjectTree(
items: (data as GhObjectTree).entries.map((v) {
// if (item.type == 'commit') return null;
String url;
var ext = p.extension(v.name);
if (ext.startsWith('.')) ext = ext.substring(1);
if (['pdf', 'docx', 'doc', 'pptx', 'ppt', 'xlsx', 'xls']
.contains(ext)) {
// Let system browser handle these files
url =
'https://raw.githubusercontent.com/$owner/$name/$branch/$path';
} else {
url =
'/$owner/$name/blob/$branch?path=${p.join(_pathNotNull, v.name).urlencode}';
}
return ObjectTreeItem(
name: v.name,
type: v.type,
url:
'/$owner/$name/blob/$branch?path=${p.join(_pathNotNull, v.name).urlencode}',
url: url,
size: v.object.resolveType == 'Blob'
? (v.object as GhObjectBlob).byteSize
: null,