diet-guard/app/lib/widgets/pickers/picker_frame.dart
Krzysztof kuhy Rudnicki 49144a2c49 Move the app to material_ui for Flutter 3.50
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation
infos failed flutter analyze --fatal-infos, and four Dart pins were
behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2,
github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages
now sit on material_ui, so the app has to as well or their widgets lose
MaterialLocalizations.

Imports swap one-for-one and dart fix re-sorted the directives; no
behaviour change. analyze is clean and all six test shards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:25:34 +01:00

76 lines
2.4 KiB
Dart

/// The shared dialog around every picker: a centred, width-capped [Dialog]
/// with a close icon (cancel) and a check icon (confirm), no words.
library;
import 'package:diet_guard_app/ui/theme.dart';
import 'package:flutter/services.dart';
import 'package:material_ui/material_ui.dart';
/// Picker chrome. Outside tap and Esc cancel (the dialog route's own
/// dismiss); Enter confirms when [canConfirm].
///
/// The icons carry spoken-only `semanticLabel`s and no `tooltip:`, which
/// would paint the word on long-press.
class PickerFrame extends StatelessWidget {
/// Creates a [PickerFrame].
const PickerFrame({
required this.child,
required this.canConfirm,
required this.onConfirm,
super.key,
});
/// The picker body.
final Widget child;
/// Whether the check is enabled (a half-chosen range is not).
final bool canConfirm;
/// Pops the dialog with the chosen value.
final VoidCallback onConfirm;
void _enter() {
if (canConfirm) onConfirm();
}
@override
Widget build(BuildContext context) => Dialog(
insetPadding: const EdgeInsets.all(AppSpacing.md),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: AppWidth.picker),
child: SingleChildScrollView(
padding: const EdgeInsets.all(AppSpacing.md),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Around the body only: Enter on a focused close icon must
// reach that button (cancel), not bubble up into a confirm.
CallbackShortcuts(
bindings: {
const SingleActivator(LogicalKeyboardKey.enter): _enter,
const SingleActivator(LogicalKeyboardKey.numpadEnter): _enter,
},
child: child,
),
const SizedBox(height: AppSpacing.sm),
Row(
mainAxisAlignment: MainAxisAlignment.end,
spacing: AppSpacing.sm,
children: [
IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.close, semanticLabel: 'Cancel'),
),
IconButton.filled(
onPressed: canConfirm ? onConfirm : null,
icon: const Icon(Icons.check, semanticLabel: 'Confirm'),
),
],
),
],
),
),
),
);
}