tane/apps/app_seeds/lib/ui/app_drawer.dart
vjrj be5977d688 fix(ux): filter clear pinned, no-match text, instant avatar save, market avatar, favourites, WoT drawer
Six reported UX issues:
- Inventory 'clear filters' is now pinned outside the horizontal scroll,
  always visible — you no longer have to scroll past every chip to find it.
- Empty result now reads 'No seeds match your filters' (not 'no seeds
  yet') when a SEARCH or the 'this month' filter hid everything — the
  'filtered' flag was missing query + sowThisMonthOnly. Guarded by a test.
- Profile avatar saves + publishes the instant you pick it, so it no
  longer looks saved when it wasn't (the Save button sits below the fold).
- Market offer detail shows the author's real avatar (photo/illustration)
  instead of a generic person icon — resolves + caches their kind:0 picture.
- 'Wishlist' renamed to Favourites/Favoritos (en/es/pt/ast).
- The drawer 'following' item now opens the web-of-trust 'your people'
  screen when the social layer is on (was a dead item).

analyze clean; inventory/market/home + overflow suites green.
2026-07-12 02:56:08 +02:00

260 lines
8.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:material_symbols_icons/symbols.dart';
import '../i18n/strings.g.dart';
import 'seed_glyph.dart';
import 'theme.dart';
import 'unread_badge.dart';
/// The app's navigation drawer (redesign screen 05). A white sheet: Inventory is
/// the live destination (green seed glyph), the social items (market, profile,
/// chat…) belong to Block 2 and are greyed with a "soon" tag, and Settings sits
/// pinned at the bottom.
class AppDrawer extends StatelessWidget {
const AppDrawer({this.marketEnabled = false, super.key});
/// When the Block 2 social layer is wired, the Market becomes a live drawer
/// destination; other social items stay "soon" until they're built.
final bool marketEnabled;
@override
Widget build(BuildContext context) {
final t = context.t;
return Drawer(
child: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const _DrawerHeader(),
// The destinations scroll; the header above and the utility footer
// below stay pinned, so Settings/About are always reachable even on
// a short screen (drawer used to overflow once Calendar was added).
Expanded(
child: ListView(
padding: EdgeInsets.zero,
children: [
_DrawerItem(
icon: const SeedGlyph(SeedGlyphs.jars, size: 23),
label: t.menu.inventory,
onTap: () {
Navigator.of(context).pop();
context.push('/inventory');
},
),
// Local, works offline — a reproduction-commitment ledger.
_DrawerItem(
icon: const Icon(Icons.volunteer_activism_outlined),
label: t.menu.plantares,
onTap: () {
Navigator.of(context).pop();
context.push('/plantares');
},
),
// Local sales ledger — also offline.
_DrawerItem(
icon: const Icon(Icons.sell_outlined),
label: t.menu.sales,
onTap: () {
Navigator.of(context).pop();
context.push('/sales');
},
),
// "What's due this month" — the aggregate crop calendar.
_DrawerItem(
icon: const Icon(Icons.calendar_month),
label: t.menu.calendar,
onTap: () {
Navigator.of(context).pop();
context.push('/calendar');
},
),
_DrawerItem(
icon: const Icon(Symbols.storefront),
label: t.menu.market,
divider: true,
onTap: marketEnabled
? () {
Navigator.of(context).pop();
context.push('/market');
}
: null,
),
_DrawerItem(
icon: const Icon(Icons.person),
label: t.menu.profile,
onTap: marketEnabled
? () {
Navigator.of(context).pop();
context.push('/profile');
}
: null,
),
_DrawerItem(
icon: const UnreadBadge(child: Icon(Icons.chat_bubble)),
label: t.menu.chat,
onTap: marketEnabled
? () {
Navigator.of(context).pop();
context.push('/messages');
}
: null,
),
_DrawerItem(
icon: const Icon(Icons.favorite),
label: t.menu.wishlist,
),
// The ego-centric web of trust ("your people") — live once the
// social layer is on.
_DrawerItem(
icon: const Icon(Icons.group),
label: t.menu.following,
onTap: marketEnabled
? () {
Navigator.of(context).pop();
context.push('/your-people');
}
: null,
),
],
),
),
const Divider(height: 1),
_DrawerItem(
icon: const Icon(Icons.auto_stories_outlined),
label: t.intro.menuEntry,
onTap: () {
Navigator.of(context).pop();
context.push('/intro');
},
),
_DrawerItem(
icon: const Icon(Icons.settings),
label: t.menu.settings,
onTap: () {
Navigator.of(context).pop();
context.push('/settings');
},
),
_DrawerItem(
icon: const Icon(Icons.info_outline),
label: t.about.title,
onTap: () {
Navigator.of(context).pop();
context.push('/about');
},
),
],
),
),
);
}
}
/// The drawer's brand header. Tapping it closes the drawer and returns to the
/// home screen.
class _DrawerHeader extends StatelessWidget {
const _DrawerHeader();
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
Navigator.of(context).pop();
context.go('/');
},
child: Container(
padding: const EdgeInsets.fromLTRB(22, 18, 22, 16),
decoration: const BoxDecoration(
border: Border(bottom: BorderSide(color: seedDivider)),
),
child: Row(
children: [
Image.asset('assets/logo.png', height: 34),
const SizedBox(width: 12),
Text(
context.t.app.title,
style: const TextStyle(
color: seedGreen,
fontSize: 22,
fontWeight: FontWeight.w700,
letterSpacing: -0.2,
),
),
],
),
),
);
}
}
/// A 52-tall drawer row. A live destination has an [onTap] (dark text, green
/// icon); a disabled Block-2 destination is greyed with a "soon" tag. [divider]
/// draws a hairline under the row (separating live from upcoming items).
class _DrawerItem extends StatelessWidget {
const _DrawerItem({
required this.icon,
required this.label,
this.onTap,
this.divider = false,
});
final Widget icon;
final String label;
final VoidCallback? onTap;
final bool divider;
@override
Widget build(BuildContext context) {
final enabled = onTap != null;
final fg = enabled ? seedOnSurface : const Color(0xFF9AA88F);
final iconColor = enabled ? seedGreen : const Color(0xFF9AA88F);
final row = InkWell(
onTap: onTap,
child: Container(
height: 52,
padding: const EdgeInsets.symmetric(horizontal: 22),
decoration: divider
? const BoxDecoration(
border: Border(bottom: BorderSide(color: seedDivider)),
)
: null,
child: Row(
children: [
SizedBox(
width: 24,
child: Center(
child: IconTheme.merge(
data: IconThemeData(size: 23, color: iconColor),
child: icon,
),
),
),
const SizedBox(width: 18),
Expanded(
child: Text(
label,
style: TextStyle(
color: fg,
fontSize: 15,
fontWeight: enabled ? FontWeight.w500 : FontWeight.w400,
),
),
),
if (!enabled)
Text(
context.t.common.comingSoon.toUpperCase(),
style: const TextStyle(
color: Color(0xFFB3BDA8),
fontSize: 11,
fontWeight: FontWeight.w500,
letterSpacing: 0.5,
),
),
],
),
),
);
return row;
}
}