fix(bb): download url

This commit is contained in:
Rongjian Zhang 2020-02-02 23:02:58 +08:00
parent 76a2f4b960
commit f9fa142702
3 changed files with 7 additions and 3 deletions

View File

@ -70,6 +70,7 @@ class BbTree {
String type;
String path;
int size;
Map<String, dynamic> links;
BbTree();
factory BbTree.fromJson(Map<String, dynamic> json) => _$BbTreeFromJson(json);
}

View File

@ -122,11 +122,13 @@ BbTree _$BbTreeFromJson(Map<String, dynamic> json) {
return BbTree()
..type = json['type'] as String
..path = json['path'] as String
..size = json['size'] as int;
..size = json['size'] as int
..links = json['links'] as Map<String, dynamic>;
}
Map<String, dynamic> _$BbTreeToJson(BbTree instance) => <String, dynamic>{
'type': instance.type,
'path': instance.path,
'size': instance.size,
'links': instance.links,
};

View File

@ -21,10 +21,11 @@ class BbObjectScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthModel>(context);
return RefreshStatefulScaffold(
title: AppBarTitle(path ?? 'Files'),
fetchData: () async {
final res = await Provider.of<AuthModel>(context)
final res = await auth
.fetchBb('/repositories/$owner/$name/src/$ref/${path ?? ''}');
if (res.headers[HttpHeaders.contentTypeHeader] == 'text/plain') {
return res.body;
@ -58,7 +59,7 @@ class BbObjectScreen extends StatelessWidget {
size: v.type == 'commit_file' ? v.size : null,
url:
'/bitbucket/$owner/$name/src/$ref?path=${v.path.urlencode}',
downloadUrl: null,
downloadUrl: v.links['self']['href'] as String,
),
]);
} else {