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

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

class BSPriceFilter extends StatelessWidget {
  final String title;

  const BSPriceFilter({Key? key, required this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // final oCcy = NumberFormat('#,##0.00', 'en_US');
    return GetBuilder<FilterController>(
      init: FilterController({}),
      builder: (cc) => BottomSheetScaffold(
        title: Text(title, style: AppTheme.bottomSheetHeaderStyle),
        body: SingleChildScrollView(
          child: Column(
            children: [
              /* Row(
                children: [
                  Container(
                    width: 0.38.sw,
                    child: MyTextFormField(
                      controller: cc.state.startPrice,
                      label: 'low_price'.tr,
                      keyboardType: TextInputType.number,
                      suffix: Text('m.  '),
                      inputFormatters: [
                        CurrencyTextInputFormatter(
                          customPattern: '#,##0.00',
                          locale: 'en',
                          decimalDigits: 2,
                          symbol: '',
                        ),
                      ],
                    ),
                  ),
                  // Spacer(),
                  SizedBox(
                    width: 38.w,
                    child: Center(
                      child: Text(
                        '-',
                        style: TextStyle(
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                    ),
                  ),
                  Container(
                    width: 0.35.sw,
                    child: MyTextFormField(
                      controller: cc.state.endPrice,
                      label: 'top_price'.tr,
                      keyboardType: TextInputType.number,
                      suffix: Text('m.  '),
                      inputFormatters: [
                        CurrencyTextInputFormatter(
                          customPattern: '#,##0.00',
                          locale: 'en',
                          decimalDigits: 2,
                          symbol: '',
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              AppTheme.appColorDivider,
              */
              ...cc.state.priceModels
                  .map(
                    (model) => Column(
                      children: [
                        RadioListTile(
                          activeColor: ThemeColor.mainColor,
                          contentPadding: EdgeInsets.zero,
                          value: model.id,
                          toggleable: true,
                          groupValue: cc.state.selectedPriceFilterModelId,
                          onChanged: (_) => cc.onPriceMethodChange(model, context),
                          title: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Expanded(
                                flex: 3,
                                child: Text(
                                  model.label,
                                  style: AppTheme.radioListTxtStyle,
                                ),
                              ),
                            ],
                          ),
                        ),
                        // AppTheme.appDivider,
                      ],
                    ),
                  )
                  .toList(),
            ],
          ),
        ),
      ),
    );
  }
}
