import 'package:flutter/material.dart';
import 'package:gap/gap.dart';

class CustomStyles {
  final BuildContext context;
  final ButtonStyle primaryButtonStyle;
  final ButtonStyle secondaryButtonStyle;

  static const double gutter = 24;
  static const double smallGutter = 12;
  static const double pagePadding = 16;

  static const double snackBarMargin = 16;
  static const double snackBarBorderRadius = 8;
  static const double horizontalPadding = 24;
  static const double minimumButtonHeight = 46;
  static const double minimumButtonWidth = 92;
  static const double verticalPadding = 12;
  static const double defaultButtonCornerRadius = 6;
  static const double defaultInputFieldCornerRadius = 6;
  static const double defaultInputContentPadding = 12;
  static const double paddingLarge = 32;
  static const EdgeInsets listPadding = EdgeInsets.all(12);
  static const double defaultMarginVertical = 4;
  static const double defaultMarginHorizontal = 5;
  static const double defaultCardCornerRadius = 12;
  static const double defaultContentPaddingHorizontal = 8;
  static const double defaultContentPadding = 12;
  static const double defaultWrapSpacing = 4;
  static const double defaultCornerRadious = 8;
  static const double defaultBottomAppbarPreferedSize = 4;
  static const int defaultNumberOfAdults = 1;
  static const int defaultNumberOfMaxResults = 10;
  static const double defaultBottomPadding = 16;
  static const double defaultCardElevation = 3;
  static const double defaultAppBarElevation = 4;
  static const int defaultmaxLines = 2;
  static const double defaultlineXY = 0.23;
  static const double defaultRightPadding = 16;
  static const double defaultSizedBoxWidth = 8;
  static const double defaultMapZoom = 16;
  static const int defaultPolylineWidth = 3;
  static const double defaultCameraUpdatePadding = 100;
  static const int defaultPageControllerDuration = 300;
  static const double defaultCarouselOptionsAspectRatio = 16 / 9;
  static const double defaultPageMaxWidth = 360;
  static const double packageCoverimageHeightRatio = .18;
  static const double coverImaageHeightRatio = 0.25;
  static const double itenaryImageHeightRatio = 0.20;
  static const double nonSightseeingMapHeightRatio = 0.4;
  static const double chatCardMaxWidthRatio = 0.7;

  CustomStyles({required this.context})
      : primaryButtonStyle = ElevatedButton.styleFrom(
          backgroundColor: Theme.of(context).colorScheme.primary,
          foregroundColor: Theme.of(context).colorScheme.onPrimary,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(defaultButtonCornerRadius),
          ),
        ),
        secondaryButtonStyle = OutlinedButton.styleFrom(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(defaultButtonCornerRadius),
          ),
        );
}

void showErrorSnackBar(BuildContext context, String message) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text(message),
      backgroundColor: Colors.red,
      behavior: SnackBarBehavior.floating,
      margin: const EdgeInsets.all(CustomStyles.snackBarMargin),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(CustomStyles.snackBarBorderRadius),
      ),
    ),
  );
}

void showSuccessSnackBar(BuildContext context, String message) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text(message),
      backgroundColor: Colors.green,
      behavior: SnackBarBehavior.floating,
      margin: const EdgeInsets.all(CustomStyles.snackBarMargin),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(CustomStyles.snackBarBorderRadius),
      ),
    ),
  );
}

void showInfoSnackBar(BuildContext context, String message) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Text(message),
      backgroundColor: Colors.blue,
      behavior: SnackBarBehavior.floating,
      margin: const EdgeInsets.all(CustomStyles.snackBarMargin),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(CustomStyles.snackBarBorderRadius),
      ),
    ),
  );
}

class Gutter extends Gap {
  const Gutter({super.key}) : super(CustomStyles.gutter);
}

class SmallGutter extends Gap {
  const SmallGutter({super.key}) : super(CustomStyles.smallGutter);
}

class ListTileColor {
  static Color of(BuildContext context, int index) {
    return index.isOdd
        ? Theme.of(context).colorScheme.surface.withAlpha(255)
        : Theme.of(context).colorScheme.surface.withAlpha(125);
  }
}
