// ignore_for_file: sized_box_for_whitespace

import 'package:flutter/material.dart';

import '../../helper/helper.dart';
import '../../helper/widget/style.dart';
import '../../models/filter_menu.dart';

class MenuListUtama extends StatelessWidget {
  const MenuListUtama({
    Key? key,
    required this.categoryNonFav,
    required this.i,
  }) : super(key: key);

  final List<FilterMenu> categoryNonFav;
  final int i;

  @override
  Widget build(BuildContext context) {
    bool addCondition = false;
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        (categoryNonFav[i].type == typeCategory)
            ? defaultText(
                context,
                categoryNonFav[i].categoryName,
                maxLines: 1,
                overFlow: TextOverflow.ellipsis,
                style: categoryNameStyle(),
              )
            : const SizedBox(),
        (categoryNonFav[i].type == typeCategory)
            ? const Divider(
                thickness: 1,
                color: textColorBlack,
              )
            : const SizedBox(),
        (categoryNonFav[i].type == typeGroup)
            ? Container(
                margin: const EdgeInsets.only(
                  top: 6,
                ),
                child: defaultText(
                  context,
                  maxLines: 3,
                  overFlow: TextOverflow.ellipsis,
                  categoryNonFav[i].groupName,
                  style: subCategoryStyle(),
                ),
              )
            : const SizedBox(),
        (categoryNonFav[i].type == typeMenu)
            ? Container(
                margin: const EdgeInsets.symmetric(vertical: 19),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Container(
                      height: 125,
                      width: double.infinity,
                      child: Row(
                        children: [
                          Expanded(
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                defaultText(
                                  context,
                                  categoryNonFav[i].name,
                                  style: menuNameStyle(),
                                ),
                                const Spacer(),
                                defaultText(
                                  maxLines: 2,
                                  overFlow: TextOverflow.ellipsis,
                                  context,
                                  categoryNonFav[i].description,
                                  style: deskripsiMenuStyle(),
                                ),
                                const SizedBox(
                                  height: 4,
                                ),
                                defaultText(
                                  maxLines: 1,
                                  overFlow: TextOverflow.ellipsis,
                                  context,
                                  'Rp ${formatNumber().format(amountParseToInt(categoryNonFav[i].price))}',
                                  style: amountMenuStyle(),
                                )
                              ],
                            ),
                          ),
                          Container(
                            width: 12,
                            height: double.infinity,
                          ),
                          Container(
                            width: 125,
                            height: 125,
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(14)),
                            child: ClipRRect(
                              borderRadius: BorderRadius.circular(14),
                              child: Image(
                                image: NetworkImage(
                                  categoryNonFav[i].imageUrlMedium,
                                ),
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                    Container(
                      height: 8,
                      width: double.infinity,
                    ),
                    (addCondition)
                        ? Container(
                            height: 36,
                            width: double.infinity,
                            child: Row(
                              children: [
                                const Spacer(),
                                Container(
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(10),
                                    color: buttonColor,
                                  ),
                                  height: double.infinity,
                                  width: 125,
                                  child: Center(
                                    child: defaultText(
                                      context,
                                      'Tambah',
                                      style: addButtonMenu(),
                                    ),
                                  ),
                                )
                              ],
                            ),
                          )
                        : Container(
                            height: 36,
                            width: 125,
                            child: Row(
                              children: [
                                Container(
                                  width: 27,
                                  height: 24,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(6),
                                    color: buttonColor,
                                  ),
                                  child: const Center(
                                    child: Image(
                                      width: 13.33,
                                      height: 13.33,
                                      color: textInButton,
                                      image:
                                          AssetImage('assets/icons/note.png'),
                                    ),
                                  ),
                                ),
                                const SizedBox(
                                  width: 5,
                                ),
                                Expanded(
                                  child: Container(
                                    height: 22,
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(30),
                                      color: Colors.white,
                                    ),
                                    child: Stack(
                                      children: [
                                        Positioned(
                                          left: 0,
                                          child: Container(
                                            width: 22,
                                            height: 22,
                                            child: const Image(
                                              image: AssetImage(
                                                  'assets/icons/minus.png'),
                                            ),
                                          ),
                                        ),
                                        Positioned(
                                          right: 0,
                                          child: Container(
                                            width: 22,
                                            height: 22,
                                            child: const Image(
                                              image: AssetImage(
                                                  'assets/icons/plus.png'),
                                            ),
                                          ),
                                        ),
                                        Center(
                                          child: Container(
                                            height: 22,
                                            child: Center(
                                              child: defaultText(
                                                context,
                                                '10',
                                                style: amountGridFav(),
                                              ),
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          )
                  ],
                ),
              )
            : const SizedBox(),
      ],
    );
  }
}
