2026-03-12 16:41:45 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import '../../core/theme/design_tokens.dart';
|
|
|
|
|
|
|
|
|
|
class LinkButton extends StatelessWidget {
|
|
|
|
|
const LinkButton({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.text,
|
|
|
|
|
required this.onTap,
|
|
|
|
|
this.enabled = true,
|
|
|
|
|
this.textAlign = TextAlign.center,
|
2026-03-12 18:26:10 +08:00
|
|
|
this.foregroundColor,
|
2026-03-12 16:41:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final String text;
|
|
|
|
|
final VoidCallback? onTap;
|
|
|
|
|
final bool enabled;
|
|
|
|
|
final TextAlign textAlign;
|
2026-03-12 18:26:10 +08:00
|
|
|
final Color? foregroundColor;
|
2026-03-12 16:41:45 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-27 19:07:39 +08:00
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-13 14:10:13 +08:00
|
|
|
final color = enabled
|
2026-03-27 19:07:39 +08:00
|
|
|
? (foregroundColor ?? colorScheme.primary)
|
|
|
|
|
: colorScheme.outline;
|
2026-03-12 18:26:10 +08:00
|
|
|
|
2026-03-13 14:10:13 +08:00
|
|
|
return TextButton(
|
|
|
|
|
onPressed: enabled ? onTap : null,
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
minimumSize: const Size(0, 40),
|
|
|
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
foregroundColor: color,
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: AppSpacing.md,
|
|
|
|
|
vertical: AppSpacing.sm,
|
2026-03-12 16:41:45 +08:00
|
|
|
),
|
2026-03-13 14:10:13 +08:00
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
2026-03-12 16:41:45 +08:00
|
|
|
),
|
|
|
|
|
),
|
2026-03-13 14:10:13 +08:00
|
|
|
child: Text(
|
|
|
|
|
text,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
color: color,
|
|
|
|
|
),
|
|
|
|
|
textAlign: textAlign,
|
|
|
|
|
),
|
2026-03-12 16:41:45 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|