import 'package:flutter/material.dart'; import '../../core/l10n/l10n.dart'; import '../../core/theme/design_tokens.dart'; import 'app_button.dart'; class AppSelectionItem { const AppSelectionItem({required this.value, required this.label}); final T value; final String label; } Future showAppSelectionSheet( BuildContext context, { required String title, required List> items, required T? selectedValue, }) async { final result = await showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0), builder: (sheetContext) { final colorScheme = Theme.of(sheetContext).colorScheme; return SafeArea( top: false, child: Container( margin: const EdgeInsets.fromLTRB( AppSpacing.md, AppSpacing.none, AppSpacing.md, AppSpacing.md, ), padding: const EdgeInsets.symmetric(vertical: AppSpacing.lg), decoration: BoxDecoration( color: colorScheme.surface, borderRadius: BorderRadius.circular(AppRadius.xl), border: Border.all(color: colorScheme.outlineVariant), ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg), child: Text( title, textAlign: TextAlign.center, style: TextStyle( fontSize: 17, fontWeight: FontWeight.w700, color: colorScheme.onSurface, ), ), ), const SizedBox(height: AppSpacing.md), ...items.map((item) { final isSelected = item.value == selectedValue; return _buildItem( sheetContext, item: item, isSelected: isSelected, ); }), SizedBox(height: AppSpacing.sm), Divider(height: 1, color: colorScheme.outlineVariant), SizedBox(height: AppSpacing.sm), Padding( padding: const EdgeInsets.symmetric(horizontal: AppSpacing.lg), child: SizedBox( height: 48, child: AppButton( text: context.l10n.commonCancel, isOutlined: true, onPressed: () => Navigator.of(sheetContext).pop(), ), ), ), ], ), ), ); }, ); return result; } Widget _buildItem( BuildContext sheetContext, { required AppSelectionItem item, required bool isSelected, }) { final colorScheme = Theme.of(sheetContext).colorScheme; return InkWell( onTap: () => Navigator.of(sheetContext).pop(item.value), child: Container( padding: const EdgeInsets.symmetric( horizontal: AppSpacing.lg, vertical: AppSpacing.md, ), child: Row( children: [ Expanded( child: Text( item.label, style: TextStyle( fontSize: 15, fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500, color: isSelected ? colorScheme.primary : colorScheme.onSurfaceVariant, ), ), ), if (isSelected) Icon(Icons.check, size: 20, color: colorScheme.primary), ], ), ), ); }