import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/shared/utils/limited_text_size.dart';

import '../../flutter_flow/flutter_flow_theme.dart';

class SnackBarUtil {
  static void showSnackBar(BuildContext context, String text,
      {bool isError = false}) {
    double limitedBodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context);
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        content: Text(
          text,
          overflow: TextOverflow.clip,
          style: TextStyle(
              color: FlutterFlowTheme.of(context).info,
              fontSize: limitedBodyFontSize),
        ),
        backgroundColor: isError
            ? FlutterFlowTheme.of(context).error
            : FlutterFlowTheme.of(context).success,
        duration: const Duration(seconds: 3),
        behavior: SnackBarBehavior.floating,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(30),
        ),
      ),
    );
  }

  static void showNoMoreDataSnackbar(BuildContext context) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        content: Text(
          FFLocalizations.of(context).getVariableText(
              ptText: "Não há mais dados.", enText: "No more data."),
          style: TextStyle(
            color: Colors.white,
            fontSize: LimitedFontSizeUtil.getBodyFontSize(context),
          ),
        ),
        duration: const Duration(seconds: 3),
        backgroundColor: FlutterFlowTheme.of(context).primary,
      ),
    );
  }
}
