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

import '../../../app.dart';

import 'widgets/b_s_choose_sort.dart';

class SortWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<FilterController>(
      builder: (hc) => Material(
        color: Colors.transparent,
        child: InkWell(
          splashColor: Theme.of(context).splashColor,
          borderRadius: BorderRadius.circular(8),
          onTap: () {
            debugPrint('on sortWidget tapped');
            showMaterialModalBottomSheet(
              shape: AppTheme.bottomSheetBorder,
              context: context,
              builder: (_) => hc.state.isSortLoading.value
                  ? BottomSheetScaffold(
                      title: Text('loading'.tr, style: AppTheme.bottomSheetHeaderStyle),
                      body: Container(
                        height: 0.15.sh,
                        child: Center(child: CustomLoader()),
                      ),
                    )
                  : BSChooseSortMethod(),
            );
          },
          child: Container(
            padding: const EdgeInsets.only(left: 2, right: 8, top: 2, bottom: 2),
            decoration: new BoxDecoration(
              borderRadius: BorderRadius.circular(8),
            ),
            child: Row(
              children: [
                SvgPicture.asset(
                  'assets/icons/sort_icon.svg',
                  height: 14.h,
                  width: 14.w,
                ),
                SizedBox(width: 4.w),
                Text(
                  'Sort',
                  style: AppTheme.sortFilterTxtStyle,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
