import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';

import '../../../../library/library.dart';
import '../../../app.dart';
import '../filter/widgets/b_s_choose_sort.dart';

class SortWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<FilterController>(
      // init: FilterController(),
      builder: (fc) => Material(
        color: Colors.transparent,
        child: InkWell(
          splashColor: Theme.of(context).splashColor,
          borderRadius: BorderRadius.circular(8),
          onTap: () {
            debugPrint('Sort widget');
            showMaterialModalBottomSheet(
              shape: AppTheme.bottomSheetBorder,
              context: context,
              builder: (_) => fc.state.isSortLoading.value
                  ? BottomSheetScaffold(
                      title: Text('loading'.tr, style: AppTheme.bottomSheetHeaderStyle),
                      body: Container(
                        height: 0.15.sh,
                        child: Center(child: CustomLoader()),
                      ),
                    )
                  : BSChooseSortMethod(),
            );
          },
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Icon(
              CustomIcons.sort,
              size: 19.sp,
              color: ThemeColor.greyTxtColor,
            ),
          ),
        ),
      ),
    );
  }
}
