import 'package:flutter/material.dart';
import 'package:loading_indicator/loading_indicator.dart';

import 'loading.dart';

class LoadingDialog extends StatelessWidget {
  final String message;

  const LoadingDialog({Key key, this.message}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Loading.dismiss();
      },
      child: Scaffold(
        backgroundColor: Colors.transparent,
        body: Center(
          child: UnconstrainedBox(
            child: Container(
              padding: EdgeInsets.all(10),
              decoration: BoxDecoration(
                  color: Colors.transparent, borderRadius: BorderRadius.circular(8)),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    width: 40,
                    height: 40,
                    child: LoadingIndicator(
                      indicatorType: Indicator.ballSpinFadeLoader,
                      color: Colors.white,
                    ),
                  ),
                  message == null || message == ''
                      ? Container()
                      : Container(
                          margin: EdgeInsets.only(top: 8),
                          child: Text(
                            message,
                            style: TextStyle(fontSize: 14),
                          ),
                        ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
