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

Commit

Permalink
Merge branch 'release/0.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Teifun2 committed Jan 3, 2021
2 parents 46e07a3 + 6bb4a4c commit 5344bd4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/src/models/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class Category extends Equatable {
static List<Category> parseCategories(String responseBody) {
final parsed = json.decode(responseBody).cast<Map<String, dynamic>>();

return parsed.map<Category>((json) => Category.fromJson(json)).toList();
return parsed
.map<Category>((json) => Category.fromJson(json))
.where((Category c) => c.recipeCount > 0)
.toList();
}
}
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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5344bd4

Please sign in to comment.