import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:satu/core/models/settings/printer_setting.dart';
import 'package:satu/core/redux/actions/setting_actions.dart';
import 'package:satu/core/redux/store.dart';
import 'package:satu/widgets/bar/products_app_bar.dart';
import 'package:satu/widgets/bar/products_title_bar.dart';
import 'package:satu/widgets/fields/line_checkbox.dart';

class PrinterPaperSizeView extends StatelessWidget {
  const PrinterPaperSizeView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const ProductsAppBar(
        title: 'Размер чека',
      ),
      body: StoreConnector<AppState,PrinterSetting>(
        converter: (store) => store.state.settingState!.printer!,
        builder: (context, printer) {
          return Column(children: [
            const ProductsTitleBarBar(title: 'Выберите размер чека'),
            LineCheckBox(
              PrinterConst.paperSize58mm,
              value: printer.paperSize == PrinterConst.paperSize58mm,
              onTap: () => {
                Redux.store!.dispatch(
                  setPaperSize(PrinterConst.paperSize58mm),
                )
              },
            ),
            const Divider(height: 1,),
            LineCheckBox(
              PrinterConst.paperSize80mm,
              value: printer.paperSize == PrinterConst.paperSize80mm,
              onTap: () => {
                Redux.store!.dispatch(
                  setPaperSize(PrinterConst.paperSize80mm),
                )
              },
            ),
          ]);
        }
      ),
    );
  }
}
