import 'package:example/console/console_button.dart';
import 'package:example/generated/assets.dart';
import 'package:example/pages/widgets/guru_demo_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:guru_widgets/guru_widgets.dart';
import '../../theme/button/custom_standard_button_theme.dart';
import 'button_controller.dart';
import 'package:guru_widgets/theme/guru_theme.dart';
import 'package:guru_widgets/appbar/guru_app_bar.dart';

class ButtonPage extends GetWidget<ButtonController> {
  const ButtonPage({Key? key}) : super(key: key);

  Widget buildStandardButtonDemoWidget(
      {bool leading = false,
      bool action = false,
      bool trailing = false,
      bool info = false,
      bool summary = false,
      bool outline = false,
      GuruButtonStyle? style,
      Size? size,
      GuruButtonSizeSpec sizeSpec = GuruButtonSizeSpec.s2}) {
    return GuruButton(
      size: size ?? controller.designSpec.buttonS2,
      action: action ? "Action" : null,
      leading: leading ? Assets.imagesIcAds : null,
      trailing: trailing ? Assets.imagesIcCoin : null,
      info: info ? "×100" : null,
      tintLeading: true,
      tintTrailing: false,
      summary: summary ? "Button Summary" : null,
      style: style,
      fillType: outline ? GuruButtonFillType.outline : GuruButtonFillType.solid,
      sizeSpec: sizeSpec,
    );
  }

  Widget buildBody() {
    const spacer = SizedSpacer(height: 16, width: 8);
    return SingleChildScrollView(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          spacer,
          Row(mainAxisAlignment: MainAxisAlignment.center, children: [
            buildStandardButtonDemoWidget(
                leading: true,
                sizeSpec: GuruButtonSizeSpec.s1,
                size: Size(80, controller.designSpec.buttonS1.height)),
            buildStandardButtonDemoWidget(
                leading: true,
                outline: true,
                sizeSpec: GuruButtonSizeSpec.s1,
                size: Size(80, controller.designSpec.buttonS1.height)),
          ]),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              outline: true,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              leading: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              leading: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              outline: true,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              summary: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              summary: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              outline: true,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              trailing: true,
              info: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              size: controller.designSpec.buttonS1),
          spacer,
          buildStandardButtonDemoWidget(
              action: true,
              trailing: true,
              info: true,
              sizeSpec: GuruButtonSizeSpec.s1,
              outline: true,
              size: controller.designSpec.buttonS1),
          spacer,
          Row(mainAxisAlignment: MainAxisAlignment.center, children: [
            buildStandardButtonDemoWidget(
                leading: true,
                size: Size(80, controller.designSpec.buttonS2.height)),
            buildStandardButtonDemoWidget(
                leading: true,
                outline: true,
                size: Size(80, controller.designSpec.buttonS2.height)),
          ]),
          spacer,
          buildStandardButtonDemoWidget(action: true),
          spacer,
          buildStandardButtonDemoWidget(action: true, outline: true),
          spacer,
          buildStandardButtonDemoWidget(action: true, leading: true),
          spacer,
          buildStandardButtonDemoWidget(
              action: true, leading: true, outline: true),
          spacer,
          buildStandardButtonDemoWidget(action: true, summary: true),
          spacer,
          buildStandardButtonDemoWidget(
              action: true, summary: true, outline: true),
          spacer,
          buildStandardButtonDemoWidget(
              action: true, trailing: true, info: true),
          spacer,
          buildStandardButtonDemoWidget(
              action: true, trailing: true, info: true, outline: true),
          spacer,
          Row(mainAxisAlignment: MainAxisAlignment.center, children: [
            buildStandardButtonDemoWidget(
                leading: true,
                size: Size(80, controller.designSpec.buttonS3.height)),
            buildStandardButtonDemoWidget(
                leading: true,
                outline: true,
                size: Size(80, controller.designSpec.buttonS3.height)),
          ]),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              outline: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              leading: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              leading: true,
              outline: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              summary: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              outline: true,
              summary: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              trailing: true,
              info: true,
              size: controller.designSpec.buttonS3),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s3,
              action: true,
              trailing: true,
              info: true,
              outline: true,
              size: controller.designSpec.buttonS3),
          spacer,
          Row(mainAxisAlignment: MainAxisAlignment.center, children: [
            buildStandardButtonDemoWidget(
                leading: true,
                sizeSpec: GuruButtonSizeSpec.s4,
                size: Size(80, controller.designSpec.buttonS4.height)),
            buildStandardButtonDemoWidget(
                leading: true,
                outline: true,
                sizeSpec: GuruButtonSizeSpec.s4,
                size: Size(80, controller.designSpec.buttonS4.height)),
          ]),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              size: Size(100, controller.designSpec.buttonS4.height)),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              outline: true,
              size: Size(100, controller.designSpec.buttonS4.height)),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              leading: true,
              size: controller.designSpec.buttonS4),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              leading: true,
              outline: true,
              size: controller.designSpec.buttonS4),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              trailing: true,
              info: true,
              size: controller.designSpec.buttonS4),
          spacer,
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s4,
              action: true,
              trailing: true,
              info: true,
              outline: true,
              size: controller.designSpec.buttonS4),
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s5,
              action: true,
              size: controller.designSpec.buttonS5),
          buildStandardButtonDemoWidget(
              sizeSpec: GuruButtonSizeSpec.s5,
              action: true,
              outline: true,
              size: controller.designSpec.buttonS5),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GuruDemoPage(
      child: Scaffold(
        backgroundColor: const Color(0xFF121212),
        appBar: const GuruAppBar(
          title: 'Guru Standard Button',
          backgroundColor: Colors.transparent,
          color: Colors.white,
          leadingType: LeadingType.back,
        ),
        body: Stack(children: [
          Align(alignment: Alignment.topCenter, child: buildBody()),
          ConsoleButton()
        ]),
      ),
    );
  }
}
