import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:crcivan/pages/utils.dart'; // Importar la función global
import 'dart:math' show min;

class CustomBottomBar extends StatelessWidget {
  const CustomBottomBar({Key? key}) : super(key: key);

  Future<void> _launchURL(String url) async {
    try {
      await launch(url);
    } catch (e) {
      // Captura de la excepción
      print('An error occurred: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return BottomAppBar(
      child: Container(
        height: getResponsiveFontSize(context, 80.0), // Ajustar la altura del BottomAppBar
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            IconButton(
              icon: const Icon(Icons.call),
              color: Colors.blue,
              iconSize: getResponsiveFontSize(context, 24.0), // Ajustar el tamaño del icono
              onPressed: () {
                _launchURL('tel:+34876636138');
              },
            ),
            Expanded(
              child: Text(
                'Avenida Maella, 35 50700 Caspe (Zaragoza)',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: min(getResponsiveFontSize(context, 10.0), 10.0),
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            IconButton(
              icon: const Icon(Icons.email),
              color: Colors.blue,
              iconSize: getResponsiveFontSize(context, 24.0), // Ajustar el tamaño del icono
              onPressed: () {
                _launchURL('mailto:civan@crcivan.com');
              },
            ),
          ],
        ),
      ),
    );
  }
}

