import 'package:example/theme/button/custom_button_decoration.dart';
import 'package:flutter/material.dart';
import 'package:guru_widgets/theme/guru_theme.dart';

/// Created by Haoyi on 2023/6/1

class CustomStandardButtonTheme extends GuruButtonTheme {
  static GuruButtonDecorator positive = GuruButtonDecorator(
    active: (child) {
      return buildWidgetDecorator(GuruButtonStyle.positive, child: child);
    },
    pressed: (child) {
      return buildWidgetDecorator(GuruButtonStyle.positive, child: child, pressed: true);
    },
  );

  static GuruButtonDecorator neutral = GuruButtonDecorator(
    active: (child) {
      return buildWidgetDecorator(GuruButtonStyle.neutral, child: child);
    },
    pressed: (child) {
      return buildWidgetDecorator(GuruButtonStyle.neutral, child: child, pressed: true);
    },
  );

  static GuruButtonDecorator negative = GuruButtonDecorator(
    active: (child) {
      return buildWidgetDecorator(GuruButtonStyle.negative, child: child);
    },
    pressed: (child) {
      return buildWidgetDecorator(GuruButtonStyle.negative, child: child, pressed: true);
    },
  );

  static DecoratedBox buildWidgetDecorator(GuruButtonStyle style,
      {Widget? child, bool pressed = false}) {
    return DecoratedBox(decoration: CustomStandardButtonDecoration(style, pressed), child: child);
  }

  static GuruButtonStyle custom = const GuruButtonStyle.create('custom');

  static GuruButtonDecorator customDec = GuruButtonDecorator(
    active: (child) {
      return buildWidgetDecorator(custom, child: child);
    },
    pressed: (child) {
      return buildWidgetDecorator(custom, child: child, pressed: true);
    },
  );
  static const GuruButtonStyle collectTrophy = GuruButtonStyle.create("collect_trophy");

  static GuruButtonElevatedScheme collectTrophyScheme = const GuruButtonElevatedScheme(
    backgroundColor: Colors.white,
    contentTintColor: Color(0xFF028858),
  );

  CustomStandardButtonTheme()
      : super(decorators: {
          GuruButtonStyle.positive: positive,
          GuruButtonStyle.neutral: neutral,
          GuruButtonStyle.negative: negative,
          GuruButtonStyle.purchase: positive,
          custom: customDec,
        }, elevatedSchemes: {
          collectTrophy: collectTrophyScheme
        });
}
