|
|
|
@ -1,12 +1,9 @@
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/service_locator.dart';
|
|
|
|
import '../../core/service_locator.dart';
|
|
|
|
import '../../core/logger.dart';
|
|
|
|
import '../../core/logger.dart';
|
|
|
|
import '../../data/recipes/recipe_service.dart';
|
|
|
|
import '../../data/recipes/recipe_service.dart';
|
|
|
|
import '../../data/recipes/models/bookmark_category_model.dart';
|
|
|
|
import '../../data/recipes/models/bookmark_category_model.dart';
|
|
|
|
import '../../data/recipes/models/recipe_model.dart';
|
|
|
|
import '../../data/recipes/models/recipe_model.dart';
|
|
|
|
import '../add_recipe/add_recipe_screen.dart';
|
|
|
|
|
|
|
|
import '../photo_gallery/photo_gallery_screen.dart';
|
|
|
|
|
|
|
|
import '../navigation/main_navigation_scaffold.dart';
|
|
|
|
import '../navigation/main_navigation_scaffold.dart';
|
|
|
|
import 'bookmark_category_recipes_screen.dart';
|
|
|
|
import 'bookmark_category_recipes_screen.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -291,21 +288,6 @@ class _BookmarksScreenState extends State<BookmarksScreen> with SingleTickerProv
|
|
|
|
}).toList();
|
|
|
|
}).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _viewRecipe(RecipeModel recipe) {
|
|
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
|
|
context,
|
|
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
|
|
builder: (context) => AddRecipeScreen(
|
|
|
|
|
|
|
|
recipe: recipe,
|
|
|
|
|
|
|
|
viewMode: true,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).then((_) {
|
|
|
|
|
|
|
|
// Reload bookmarks when returning from recipe view
|
|
|
|
|
|
|
|
_loadBookmarks();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _openCategory(BookmarkCategory category) {
|
|
|
|
void _openCategory(BookmarkCategory category) {
|
|
|
|
Navigator.push(
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
@ -850,224 +832,3 @@ class _CategoryCard extends StatelessWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Widget for displaying a recipe item in a bookmark category.
|
|
|
|
|
|
|
|
class _BookmarkRecipeItem extends StatelessWidget {
|
|
|
|
|
|
|
|
final RecipeModel recipe;
|
|
|
|
|
|
|
|
final VoidCallback onTap;
|
|
|
|
|
|
|
|
final ValueChanged<int> onPhotoTap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const _BookmarkRecipeItem({
|
|
|
|
|
|
|
|
required this.recipe,
|
|
|
|
|
|
|
|
required this.onTap,
|
|
|
|
|
|
|
|
required this.onPhotoTap,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Builds an image widget using ImmichService for authenticated access.
|
|
|
|
|
|
|
|
Widget _buildRecipeImage(String imageUrl) {
|
|
|
|
|
|
|
|
final mediaService = ServiceLocator.instance.mediaService;
|
|
|
|
|
|
|
|
if (mediaService == null) {
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
width: 60,
|
|
|
|
|
|
|
|
height: 60,
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
child: const Icon(Icons.image, size: 32),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Try to extract asset ID from Immich URL (format: .../api/assets/{id}/original)
|
|
|
|
|
|
|
|
final assetIdMatch = RegExp(r'/api/assets/([^/]+)/').firstMatch(imageUrl);
|
|
|
|
|
|
|
|
String? assetId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (assetIdMatch != null) {
|
|
|
|
|
|
|
|
assetId = assetIdMatch.group(1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// For Blossom URLs, use the full URL
|
|
|
|
|
|
|
|
assetId = imageUrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (assetId != null) {
|
|
|
|
|
|
|
|
return FutureBuilder<Uint8List?>(
|
|
|
|
|
|
|
|
future: mediaService.fetchImageBytes(assetId, isThumbnail: true),
|
|
|
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
child: const Center(
|
|
|
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (snapshot.hasError || !snapshot.hasData || snapshot.data == null) {
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
child: const Icon(Icons.broken_image, size: 32),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Image.memory(
|
|
|
|
|
|
|
|
snapshot.data!,
|
|
|
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Image.network(
|
|
|
|
|
|
|
|
imageUrl,
|
|
|
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
|
|
|
errorBuilder: (context, error, stackTrace) {
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
child: const Icon(Icons.broken_image, size: 32),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
loadingBuilder: (context, child, loadingProgress) {
|
|
|
|
|
|
|
|
if (loadingProgress == null) return child;
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
child: Center(
|
|
|
|
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
|
|
|
|
value: loadingProgress.expectedTotalBytes != null
|
|
|
|
|
|
|
|
? loadingProgress.cumulativeBytesLoaded /
|
|
|
|
|
|
|
|
loadingProgress.expectedTotalBytes!
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Color _getRatingColor(double rating) {
|
|
|
|
|
|
|
|
if (rating >= 4.5) return Colors.green;
|
|
|
|
|
|
|
|
if (rating >= 3.5) return Colors.orange;
|
|
|
|
|
|
|
|
if (rating >= 2.5) return Colors.amber;
|
|
|
|
|
|
|
|
return Colors.red;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
// Recipe image
|
|
|
|
|
|
|
|
recipe.imageUrls.isNotEmpty
|
|
|
|
|
|
|
|
? GestureDetector(
|
|
|
|
|
|
|
|
onTap: () => onPhotoTap(0),
|
|
|
|
|
|
|
|
child: ClipRRect(
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
width: 80,
|
|
|
|
|
|
|
|
height: 80,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: _buildRecipeImage(recipe.imageUrls.first),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: Container(
|
|
|
|
|
|
|
|
width: 80,
|
|
|
|
|
|
|
|
height: 80,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
|
|
Icons.restaurant_menu,
|
|
|
|
|
|
|
|
color: Colors.grey.shade400,
|
|
|
|
|
|
|
|
size: 32,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
|
|
|
// Recipe info
|
|
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
recipe.title,
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (recipe.description != null && recipe.description!.isNotEmpty) ...[
|
|
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
recipe.description!,
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
|
|
|
|
|
|
color: Colors.grey.shade600,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
// Rating badge
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
|
|
horizontal: 8,
|
|
|
|
|
|
|
|
vertical: 4,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: _getRatingColor(recipe.rating.toDouble()).withOpacity(0.15),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
const Icon(
|
|
|
|
|
|
|
|
Icons.star,
|
|
|
|
|
|
|
|
size: 14,
|
|
|
|
|
|
|
|
color: Colors.amber,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
recipe.rating.toString(),
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
|
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
|
|
color: _getRatingColor(recipe.rating.toDouble()),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (recipe.isFavourite) ...[
|
|
|
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.favorite,
|
|
|
|
|
|
|
|
size: 16,
|
|
|
|
|
|
|
|
color: Colors.red.shade400,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
// Chevron icon
|
|
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
|
|
Icons.chevron_right,
|
|
|
|
|
|
|
|
color: Colors.grey.shade400,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|