import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:satu/core/models/inventarization/inventarization_response.dart';
import 'package:satu/shared/app_colors.dart';

class InventarizationListTile extends StatefulWidget {
  const InventarizationListTile({required this.item, Key? key})
      : super(key: key);

  final InventarizationResponse item;

  @override
  State<InventarizationListTile> createState() =>
      _InventarizationListTileState();
}

class _InventarizationListTileState extends State<InventarizationListTile> {
  final DateFormat formatterDay = DateFormat('dd.MM.yyyy');

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(color: whiteColor),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Expanded(
            flex: 2,
            child: InventarizationCellTile(
                value: widget.item.docNumber.toString()),
          ),
          Expanded(
            flex: 2,
            child: InventarizationCellTile(
              value: formatterDay.format(widget.item.createdAt),
            ),
          ),
          Expanded(
            flex: 1,
            child: InventarizationCellButton(
              value: formatterDay.format(widget.item.createdAt),
            ),
          ),
        ],
      ),
    );
  }
}

class InventarizationCellTile extends StatelessWidget {
  const InventarizationCellTile({
    required this.value,
    Key? key,
  }) : super(key: key);

  final String value;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(15.0),
      child: Text(
        value,
        style: TextStyle(fontSize: 12),
      ),
    );
  }
}

class InventarizationCellButton extends StatelessWidget {
  const InventarizationCellButton({
    required this.value,
    Key? key,
  }) : super(key: key);

  final String value;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only( right: 15.0),
      child: OutlinedButton(
        onPressed: () {},
        child: Text(
          'Акт',
          style: TextStyle(fontSize: 12, color: whiteColor),
        ),
        style: OutlinedButton.styleFrom(
          backgroundColor: blueColor,
        ),
      ),
    );
  }
}
