import 'package:betting/commom/utils/color_utils.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class CustomToast {
  FToast fToast = FToast();

  showToast(BuildContext context, String type, bool isFavourite) {
    String msg = '';
    if(type.toLowerCase().compareTo('competitions') == 0) {
      msg = (isFavourite == true)
          ? 'Added to Favourites'
          : 'Removed from Favourites';
    } else {
      msg = (isFavourite == true)
          ? '$type favourited & notification on'
          : '$type unfavourited & notification off';
    }
    Widget toast = Container(
      padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(25.0),
        color: Colors.white,
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          (isFavourite == true)
              ? const Icon(
                  Icons.star_rounded,
                  color: ColorUtils.PRIMARY_COLOR,
                )
              : const Icon(Icons.star_outline_rounded),
          const SizedBox(
            width: 12.0,
          ),
          Text(
            msg,
            style: TextStyle(
                color: Colors.black.withOpacity(0.6),
                fontWeight: FontWeight.bold),
          ),
        ],
      ),
    );

    fToast.init(context).showToast(
      child: toast,
      gravity: ToastGravity.BOTTOM,
      toastDuration: const Duration(seconds: 2),
    );
  }
}
