Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
Fix image loading with subUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Teifun2 committed Jan 3, 2021
1 parent 54bbb5b commit 330f10b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/src/widget/authentication_cached_network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,39 @@ import 'package:nextcloud_cookbook_flutter/src/models/app_authentication.dart';
import 'package:nextcloud_cookbook_flutter/src/services/user_repository.dart';

class AuthenticationCachedNetworkImage extends StatelessWidget {
final RegExp exp = new RegExp(r'recipes/(\d*?)/image\?(.*?)$');
String imageId;
String imageSettings;
final String imagePath;
final double width;
final double height;
final BoxFit boxFit;

const AuthenticationCachedNetworkImage(
{@required this.imagePath, this.width, this.height, this.boxFit});
AuthenticationCachedNetworkImage({
@required this.imagePath,
this.width,
this.height,
this.boxFit,
}) {
RegExpMatch match = exp.firstMatch(imagePath);
this.imageId = match.group(1);
this.imageSettings = match.group(2);
}

@override
Widget build(BuildContext context) {
AppAuthentication appAuthentication =
UserRepository().getCurrentAppAuthentication();

print(
'${appAuthentication.server}/apps/cookbook/recipes/$imageId/image?$imageSettings');

return CachedNetworkImage(
width: width,
height: height,
fit: boxFit,
imageUrl: '${appAuthentication.server}$imagePath',
imageUrl:
'${appAuthentication.server}/apps/cookbook/recipes/$imageId/image?$imageSettings',
httpHeaders: {
"authorization": appAuthentication.basicAuth,
},
Expand Down

0 comments on commit 330f10b

Please sign in to comment.