import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/sizing.dart';

class ReportIssueItem extends StatelessWidget {
  final bool isSelected;
  final String? issueInfo;
  final Function(String?, bool) onChange;

  const ReportIssueItem({Key? key, this.isSelected = false, this.issueInfo, required this.onChange}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialButton(
      // splashColor: AColors.secondaryColor.withOpacity(.5),
      padding: const EdgeInsets.symmetric(vertical: 4),
      onPressed: () {
        onChange(issueInfo, !isSelected);
      },
      child: Column(
        children: [
          Row(
            children: [
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8),
                  child: Text(
                    issueInfo ?? "",
                    style: Theme.of(context).textTheme.titleSmall,
                    textScaleFactor: AppStyle.getScaleFactor(context),
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
                child: Checkbox(
                  value: isSelected,
                  onChanged: (value) {
                    onChange(issueInfo, value!);
                  },
                ),
              ),
            ],
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 16),
            child: Divider(),
          ),
        ],
      ),
    );
  }
}
