import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loader_overlay/loader_overlay.dart';

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

class BSChooseSortMethod extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<FilterController>(
      // init: FilterController(),
      builder: (cc) => BottomSheetScaffold(
        title: Text('sort'.tr, style: AppTheme.bottomSheetHeaderStyle),
        body: SingleChildScrollView(
          child: LoaderOverlay(
            useDefaultLoading: false,
            overlayColor: Colors.transparent,
            overlayWidget: CustomLoader(),
            child: Column(
              children: cc.state.sortModels
                  .map(
                    (sortModel) => Column(
                      children: [
                        RadioListTile(
                          activeColor: ThemeColor.mainColor,
                          contentPadding: EdgeInsets.zero,
                          value: sortModel.id,
                          groupValue: cc.state.selectedSortModelId,
                          onChanged: (_) => cc.onSortMethodChange(sortModel, context),
                          title: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Expanded(
                                flex: 3,
                                child: Text(
                                  sortModel.label,
                                  style: AppTheme.radioListTxtStyle,
                                ),
                              ),
                            ],
                          ),
                        ),
                        // AppTheme.appColorDivider,
                      ],
                    ),
                  )
                  .toList(),
            ),
          ),
        ),
      ),
    );
  }
}
