Lower the bulk-digitization cliff with two more routes on top of the already-landed CSV import and "save and add another": - Photo-first drafts (capture now, catalogue later): burst-capture photos (camera or multi-gallery) into unnamed draft varieties, shown in a "to catalogue" tray, hidden from the main list until named. Adds Variety.isDraft (schema), addDraftVariety/watchDrafts/nameDraft, the triage sheet and the inventory banner. - On-device OCR label suggestion (Tesseract, offline, no Google): a "Suggest name from photo" button in the naming dialog behind a LabelTextExtractor interface (Tesseract on Android/iOS, no-op elsewhere). Reads the largest print via hOCR bounding boxes, drops boilerplate/low-confidence noise, preprocesses (grayscale, contrast, upscale) and sweeps rotations (0-315 deg) so tilted packets still read. Bundles tessdata_fast eng+spa; validated on-device against real packets. The photo is written to a temp file deleted immediately in a finally block (the plugin needs a path) - a bounded, documented exception to no-plaintext-at-rest. This commit also carries the co-developed schema evolution v5 to v8 that shares these files (organic flag, species viability years, crop calendar, lot provenance/abundance/preservation format, condition checks) plus their exports/migrations and i18n. Tests: CSV/draft/OCR unit + widget + migration green in isolation. Note: the full widget suite currently hangs (>10 min) - under investigation.
187 lines
5.5 KiB
Dart
187 lines
5.5 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';
|
|
|
|
/// 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({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final t = context.t;
|
|
return Drawer(
|
|
child: SafeArea(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const _DrawerHeader(),
|
|
_DrawerItem(
|
|
icon: const SeedGlyph(SeedGlyphs.jars, size: 23),
|
|
label: t.menu.inventory,
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
context.go('/inventory');
|
|
},
|
|
),
|
|
_DrawerItem(
|
|
icon: const Icon(Symbols.storefront),
|
|
label: t.menu.market,
|
|
divider: true,
|
|
),
|
|
_DrawerItem(icon: const Icon(Icons.person), label: t.menu.profile),
|
|
_DrawerItem(
|
|
icon: const Icon(Icons.chat_bubble),
|
|
label: t.menu.chat,
|
|
),
|
|
_DrawerItem(
|
|
icon: const Icon(Icons.favorite),
|
|
label: t.menu.wishlist,
|
|
),
|
|
_DrawerItem(icon: const Icon(Icons.group), label: t.menu.following),
|
|
const Spacer(),
|
|
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;
|
|
}
|
|
}
|