import 'package:flutter/material.dart';
import 'package:top_snackbar_flutter/custom_snack_bar.dart';
import 'package:top_snackbar_flutter/top_snack_bar.dart';

enum snackbarType { error, info, success, warning }

SanckbarWidget(BuildContext context, String msg, snackbarType tipe) {
  switch (tipe) {
    case snackbarType.error:
      return showTopSnackBar(
        animationDuration: Duration(milliseconds: 900),
        displayDuration: Duration(seconds: 1),
        dismissType: DismissType.onTap,
        Overlay.of(context),
        CustomSnackBar.error(
          message: msg,
        ),
      );
      break;
    case snackbarType.success:
      return showTopSnackBar(
        animationDuration: Duration(milliseconds: 900),
        displayDuration: Duration(seconds: 1),
        dismissType: DismissType.onTap,
        Overlay.of(context),
        CustomSnackBar.success(
          message: msg,
        ),
      );
      break;
    case snackbarType.info:
      return showTopSnackBar(
        animationDuration: Duration(milliseconds: 900),
        displayDuration: Duration(seconds: 1),
        dismissType: DismissType.onTap,
        Overlay.of(context),
        CustomSnackBar.info(
          message: msg,
        ),
      );
      break;
    case snackbarType.warning:
      return showTopSnackBar(
        animationDuration: Duration(milliseconds: 900),
        displayDuration: Duration(seconds: 1),
        dismissType: DismissType.onTap,
        Overlay.of(context),
        CustomSnackBar.info(
          backgroundColor: Colors.orangeAccent,
          message: msg,
        ),
      );
      break;
    default:
      return showTopSnackBar(
        animationDuration: Duration(milliseconds: 900),
        displayDuration: Duration(seconds: 1),
        dismissType: DismissType.onTap,
        Overlay.of(context),
        CustomSnackBar.info(
          message: msg,
        ),
      );
  }
}
