Merge branch 'claude/nostalgic-wright-acfc25': inline offer photos

Market offers carry a small base64 data-URI thumbnail embedded in the Nostr
event (no media server); full photo stays in the encrypted inventory. Blossom
alternative parked on branch parked/offer-photos-blossom.

# Conflicts:
#	apps/app_seeds/lib/i18n/strings.g.dart
This commit is contained in:
vjrj 2026-07-10 21:43:35 +02:00
commit 2c8869ea0d
20 changed files with 520 additions and 16 deletions

View file

@ -6,6 +6,7 @@ import 'package:tane/i18n/strings.g.dart';
import 'package:tane/services/social_service.dart';
import 'package:tane/services/social_settings.dart';
import 'package:tane/ui/market_offer_detail_screen.dart';
import 'package:tane/ui/market_widgets.dart';
import '../support/test_support.dart';
@ -25,7 +26,7 @@ Widget _wrap(MarketOfferDetailScreen screen) {
);
}
Offer _offer({bool organic = false}) => Offer(
Offer _offer({bool organic = false, String? imageUrl}) => Offer(
id: 'lot-1',
authorPubkeyHex: 'ab' * 32,
summary: 'Tomate rosa de Barbastro',
@ -33,6 +34,7 @@ Offer _offer({bool organic = false}) => Offer(
category: 'Solanaceae',
approxGeohash: 'sp3e9',
isOrganic: organic,
imageUrl: imageUrl,
);
void main() {
@ -70,4 +72,34 @@ void main() {
expect(find.byKey(const Key('offerDetail.contact')), findsNothing);
});
testWidgets('shows a hero image when the offer has a photo', (tester) async {
final social = await SocialService.fromRootSeedHex('00' * 32);
final settings = SocialSettings(InMemorySecretStore());
await settings.setRelayUrls(const []);
await tester.pumpWidget(_wrap(MarketOfferDetailScreen(
offer: _offer(imageUrl: 'https://media.example/abc.jpg'),
social: social,
settings: settings,
)));
await tester.pumpAndSettle();
expect(find.byType(OfferHeroImage), findsOneWidget);
});
testWidgets('shows no hero image when the offer has none', (tester) async {
final social = await SocialService.fromRootSeedHex('00' * 32);
final settings = SocialSettings(InMemorySecretStore());
await settings.setRelayUrls(const []);
await tester.pumpWidget(_wrap(MarketOfferDetailScreen(
offer: _offer(),
social: social,
settings: settings,
)));
await tester.pumpAndSettle();
expect(find.byType(OfferHeroImage), findsNothing);
});
}

View file

@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tane/ui/market_widgets.dart';
Widget _wrap(Widget child) => MaterialApp(home: Scaffold(body: Center(child: child)));
/// A 1×1 PNG as an inline data URI the shape offers actually publish.
const _dataUri =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lE'
'QVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
void main() {
testWidgets('OfferThumbnail renders an inline data-URI from memory',
(tester) async {
await tester.pumpWidget(
_wrap(const OfferThumbnail(url: _dataUri, semanticLabel: 'Photo')),
);
await tester.pump();
expect(find.byType(Image), findsOneWidget);
// Decoded fine no broken-image placeholder.
expect(find.byIcon(Icons.image_not_supported_outlined), findsNothing);
});
testWidgets('OfferThumbnail builds a network image', (tester) async {
await tester.pumpWidget(
_wrap(const OfferThumbnail(
url: 'https://media.example/abc.jpg',
semanticLabel: 'Photo',
)),
);
// The image widget is present; its loadingBuilder/errorBuilder handle the
// remote fetch, so we only assert the widget is wired (no network in tests).
expect(find.byType(Image), findsOneWidget);
});
testWidgets('OfferThumbnail falls back to a placeholder when the load fails',
(tester) async {
await tester.pumpWidget(
_wrap(const OfferThumbnail(
url: 'https://media.example/missing.jpg',
semanticLabel: 'Photo',
)),
);
// Let the (failed) network fetch resolve; the errorBuilder then shows a
// neutral icon instead of a broken image.
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(find.byIcon(Icons.image_not_supported_outlined), findsOneWidget);
});
testWidgets('OfferHeroImage builds a network image', (tester) async {
await tester.pumpWidget(
_wrap(const OfferHeroImage(
url: 'https://media.example/abc.jpg',
semanticLabel: 'Photo',
)),
);
expect(find.byType(Image), findsOneWidget);
});
}