149 lines
4.4 KiB
Dart
149 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../../core/theme/design_tokens.dart';
|
|
import '../../../../core/l10n/l10n.dart';
|
|
import '../../../../shared/widgets/app_button.dart';
|
|
|
|
class MessageActionSheet extends StatelessWidget {
|
|
final String title;
|
|
final String? description;
|
|
final String? statusText;
|
|
final bool isReadOnly;
|
|
final VoidCallback? onAccept;
|
|
final VoidCallback? onDecline;
|
|
final IconData? icon;
|
|
final Color? iconColor;
|
|
final String? primaryActionText;
|
|
final VoidCallback? onPrimaryAction;
|
|
|
|
const MessageActionSheet({
|
|
super.key,
|
|
required this.title,
|
|
this.description,
|
|
this.statusText,
|
|
this.isReadOnly = false,
|
|
this.onAccept,
|
|
this.onDecline,
|
|
this.icon,
|
|
this.iconColor,
|
|
this.primaryActionText,
|
|
this.onPrimaryAction,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
final resolvedIconColor = iconColor ?? colorScheme.primary;
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.fromLTRB(24, 20, 24, 0),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.outlineVariant,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
if (icon != null) ...[
|
|
Container(
|
|
width: 72,
|
|
height: 72,
|
|
decoration: BoxDecoration(
|
|
color: resolvedIconColor.withValues(alpha: 0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(icon, size: 32, color: resolvedIconColor),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w600,
|
|
color: colorScheme.onSurface,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
if (description != null && description!.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
description!,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
if (statusText != null) ...[
|
|
const SizedBox(height: 16),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surfaceContainerHigh,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Text(
|
|
statusText!,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
const SizedBox(height: 24),
|
|
if (!isReadOnly) ...[
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: AppButton(
|
|
text: context.l10n.messagesReject,
|
|
isOutlined: true,
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onDecline?.call();
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
Expanded(
|
|
child: AppButton(
|
|
text: context.l10n.messagesAccept,
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onAccept?.call();
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
] else if (primaryActionText != null && onPrimaryAction != null) ...[
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: AppButton(
|
|
text: primaryActionText!,
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
onPrimaryAction?.call();
|
|
},
|
|
),
|
|
),
|
|
],
|
|
SizedBox(height: MediaQuery.of(context).padding.bottom + 12),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|