import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:satu/core/redux/state/sell_state.dart';
import 'package:satu/core/redux/store.dart';
import 'package:satu/shared/app_colors.dart';
import 'package:satu/widgets/bar/products_app_bar.dart';
import 'package:satu/widgets/bar/products_header_bar.dart';
import 'package:satu/widgets/bar/products_title_bar.dart';
import 'package:satu/views/work/tabs/utils/ProductUtils.dart';
import 'package:satu/widgets/buttons/busy_button.dart';

class PaymentView extends StatefulWidget {
  @override
  _PaymentViewState createState() => _PaymentViewState();
}

class _PaymentViewState extends State<PaymentView> {
  bool combine = false;

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, SellState>(
        converter: (store) => store.state.sellState!,
        builder: (_, state) {
          return Scaffold(
            appBar: ProductsAppBar(
              title: 'Способ оплаты',
              backgroundColor: backgroundColor,
              childHeight: 60,
              child: ProductHeaderBar(
                count: state.items!.length,
                sum: sumProducts(state.items!),
              ),
            ),
            body: ListView(
              physics: const BouncingScrollPhysics(),
              children: [
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 15.w),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        'Способ оплаты',
                        style: TextStyle(
                            fontSize: 16.sp, color: placeholderColor),
                      ),
                      Row(
                        children: [
                      Text(
                        'Комбинированный',
                        style: TextStyle(fontSize: 14.sp, color: placeholderColor),
                      ),
                      Switch(
                        value: combine,
                        onChanged: (vl) {
                          setState(() {
                            combine = !combine;
                          });
                        },
                      ),
                        ],
                      )
                    ],
                  ),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 45.0),
                  child: BusyButton(title: 'ОПЛАТА', onPressed: () {}),
                ),
              ],
            ),
          );
        });
  }
}
