import 'package:ambito/src/extensions/extensions.dart';
import 'package:flutter/material.dart';

import '../../packages/ambito_theme/ambito_theme.dart';

class TextButtonElement extends StatelessWidget {
  const TextButtonElement(
      {super.key, required this.title, required this.onPressed});

  final String title;
  final VoidCallback onPressed;

  @override
  Widget build(BuildContext context) {
    final AmbitoTheme theme = getTheme(context);

    return TextButton(
      style: ButtonStyle(
        backgroundColor:
            WidgetStateProperty.all(theme.currentColorScheme.secondary),
        padding: WidgetStateProperty.all<EdgeInsets>(
          const EdgeInsets.all(16),
        ),
        shape: WidgetStateProperty.all<RoundedRectangleBorder>(
          RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(
              8.0,
            ),
          ),
        ),
      ),
      onPressed: onPressed,
      child: Text(
        context.translate(title),
        style: theme.bodyLarge.copyWith(
          fontWeight: FontWeight.bold,
          color: theme.currentColorScheme.onPrimary,
        ),
      ),
    );
  }
}
