diff --git a/lib/src/models/category.dart b/lib/src/models/category.dart index 977b4328..614cf68f 100644 --- a/lib/src/models/category.dart +++ b/lib/src/models/category.dart @@ -21,6 +21,9 @@ class Category extends Equatable { static List parseCategories(String responseBody) { final parsed = json.decode(responseBody).cast>(); - return parsed.map((json) => Category.fromJson(json)).toList(); + return parsed + .map((json) => Category.fromJson(json)) + .where((Category c) => c.recipeCount > 0) + .toList(); } } diff --git a/lib/src/widget/authentication_cached_network_image.dart b/lib/src/widget/authentication_cached_network_image.dart index d366b2a5..e14e76da 100644 --- a/lib/src/widget/authentication_cached_network_image.dart +++ b/lib/src/widget/authentication_cached_network_image.dart @@ -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, }, diff --git a/pubspec.yaml b/pubspec.yaml index 3f99d5e2..15f83d4d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A new Flutter application. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.3.5+11 +version: 0.3.6+12 environment: sdk: ">=2.6.0 <3.0.0"