Files
iiEsaywebUIapp/lib/shared/widgets/chat_action_button.dart

87 lines
2.8 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:conduit/shared/theme/theme_extensions.dart';
import 'package:conduit/core/services/platform_service.dart';
import 'package:conduit/core/services/settings_service.dart';
class ChatActionButton extends ConsumerStatefulWidget {
final IconData icon;
final String label;
final VoidCallback? onTap;
final EdgeInsetsGeometry padding;
final BorderRadius? borderRadius;
const ChatActionButton({
super.key,
required this.icon,
required this.label,
this.onTap,
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
this.borderRadius,
});
@override
ConsumerState<ChatActionButton> createState() => _ChatActionButtonState();
}
class _ChatActionButtonState extends ConsumerState<ChatActionButton> {
bool _pressed = false;
@override
Widget build(BuildContext context) {
final theme = context.conduitTheme;
final hapticEnabled = ref.read(hapticEnabledProvider);
2025-09-26 00:10:43 +05:30
final radius = BorderRadius.circular(AppBorderRadius.circular);
final overlay = theme.buttonPrimary.withValues(alpha: 0.08);
return Tooltip(
message: widget.label,
waitDuration: const Duration(milliseconds: 600),
child: Semantics(
button: true,
label: widget.label,
child: AnimatedScale(
2025-09-26 00:10:43 +05:30
scale: _pressed ? 0.95 : 1.0,
duration: const Duration(milliseconds: 120),
curve: Curves.easeOutCubic,
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: radius,
splashColor: overlay,
highlightColor: theme.textPrimary.withValues(alpha: 0.06),
onHighlightChanged: (v) => setState(() => _pressed = v),
onTap: widget.onTap == null
? null
: () {
PlatformService.hapticFeedbackWithSettings(
type: HapticType.selection,
hapticEnabled: hapticEnabled,
);
widget.onTap!();
},
child: Ink(
2025-09-26 00:10:43 +05:30
width: 32,
height: 32,
decoration: BoxDecoration(
color: theme.textPrimary.withValues(alpha: 0.04),
borderRadius: radius,
border: Border.all(
color: theme.textPrimary.withValues(alpha: 0.08),
width: BorderWidth.regular,
),
),
2025-09-26 00:10:43 +05:30
child: Icon(
widget.icon,
size: IconSize.sm,
color: theme.textPrimary.withValues(alpha: 0.8),
),
),
),
),
),
),
);
}
}