activityTile method

Widget activityTile(
  1. BuildContext context,
  2. HttpActivity activity,
  3. int index
)

Implementation

Widget activityTile(
  BuildContext context,
  HttpActivity activity,
  int index,
) {
  return ListTile(
    onTap: () {
      var provider = context.read<ActivityProvider>();
      provider.goToDetailActivity(activity);
    },
    title: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Expanded(
          flex: 1,
          child: Text(
            '${activity.request?.method} '
            '${activity.request?.path ?? '-'}',
            overflow: TextOverflow.ellipsis,
            style: Theme.of(context).textTheme.bodyLarge,
          ),
        ),
        ContainerLabel(
          text: '${activity.response?.responseStatusCode ?? 'N/A'}',
          color: NetworkInspectorValue.containerColor(
            activity.response?.responseStatusCode ?? 0,
          ),
          textColor: Colors.white,
        ),
      ],
    ),
    subtitle: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Visibility(
              visible: activity.request?.baseUrl?.isSecure ?? false,
              replacement: const Icon(
                Icons.lock_open,
                size: 18,
                color: Colors.grey,
              ),
              child: const Icon(
                Icons.lock,
                size: 18,
                color: Colors.green,
              ),
            ),
            const SizedBox(width: 4),
            Expanded(
              flex: 1,
              child: Text(
                activity.request?.baseUrl ?? '-',
                overflow: TextOverflow.ellipsis,
                style: Theme.of(context).textTheme.bodyMedium,
              ),
            )
          ],
        ),
        const SizedBox(height: 4),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              activity.request?.createdAt?.convertToYmdHms ?? '-',
              style: Theme.of(context).textTheme.bodySmall,
            ),
            Text(
              _byteUtil.totalTransferSize(
                activity.request?.requestSize,
                activity.response?.responseSize,
                false,
              ),
              style: Theme.of(context).textTheme.bodySmall,
            ),
            Text(
              _dateTimeUtil.milliSecondDifference(
                activity.request?.createdAt,
                activity.response?.createdAt,
              ),
              style: Theme.of(context).textTheme.bodySmall,
            ),
          ],
        ),
      ],
    ),
  );
}