import 'package:flutter/material.dart';

import '../../app_style/sizing.dart';

class RequestInfoRow extends StatelessWidget {
  final String? title;
  final String? info;
  final String? content;
  final Widget? contentWidget;
  final Widget? infoWidget;

  const RequestInfoRow({
    Key? key,
    this.title,
    this.info,
    this.content,
    this.contentWidget,
    this.infoWidget,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    if (info != null && info!.isEmpty) {
      return const SizedBox.shrink();
    }
    if (content != null && content!.isEmpty) {
      return const SizedBox.shrink();
    }
    return Column(
      children: [
        Row(
          children: [
            Text(
              "$title :  ",
              style: Theme.of(context).textTheme.titleSmall?.copyWith(
                  //fontSize: 12
                  ),
              textScaleFactor: AppStyle.getScaleFactor(context),
            ),
            if (info != null)
              Expanded(
                child: Text(
                  info ?? '',
                  style: Theme.of(context).textTheme.bodyMedium,
                  textAlign: TextAlign.right,
                  textScaleFactor: AppStyle.getScaleFactor(context),
                ),
              ),
            if (infoWidget != null)
              Expanded(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    infoWidget ?? const SizedBox(),
                  ],
                ),
              ),
          ],
        ),
        if (content != null)
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 8),
            child: Row(
              children: [
                Expanded(
                  child: Text(
                    content ?? 'No data found',
                    style: Theme.of(context).textTheme.bodyMedium,
                    textAlign: TextAlign.center,
                    textScaleFactor: AppStyle.getScaleFactor(context),
                  ),
                ),
              ],
            ),
          ),
        if (contentWidget != null) contentWidget!,
        Divider(
          color: Theme.of(context).primaryColor,
        ),
      ],
    );
  }
}
