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

class FailedLoading extends StatelessWidget {
  final String? message;
  final VoidCallback onReload;

  const FailedLoading({Key? key, this.message,required this.onReload}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text(
            message ?? context.translation.httpError,
            style: Theme.of(context).textTheme.titleMedium,
            textScaleFactor: AppStyle.getScaleFactor(context),
          ),
          const SizedBox(
            height: 16,
          ),
          OutlinedButton(
            onPressed: onReload,
            child: Text(context.translation.tryAgain),
          )
        ],
      ),
    );
  }
}
