import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class AtualizarScreen extends StatefulWidget {
  final String? linkLoja;
  AtualizarScreen({this.linkLoja});
  @override
  _AtualizarScreenState createState() => _AtualizarScreenState();
}

class _AtualizarScreenState extends State<AtualizarScreen> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('Aplicativos'),
      // ),
      body: Container(
        padding: const EdgeInsets.all(8.0),
        width: double.maxFinite,
        color: Colors.white70,
        child: Stack(
          //fit: StackFit.loose,
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Container(
                  height: MediaQuery.of(context).size.height * 0.4,
                  child: Image.asset('assets/images/foguete.png',fit: BoxFit.contain,),
                ),
                SizedBox(height: 25.0,),
                Text('Atualização necessária',style: TextStyle(fontSize: 18.0,fontWeight: FontWeight.bold,color: Colors.grey.shade800),),
                SizedBox(height: 25.0,),
                Text('A versão atual deste aplicativo não é mais suportada.  Por favor atualize o app.',textAlign: TextAlign.center,style: TextStyle(fontWeight: FontWeight.w300,color: Colors.grey.shade800)),
                Expanded(
                  child: SafeArea(
                    bottom: true,
                    minimum: const EdgeInsets.only(bottom: 30.0),
                    child: Flex(
                      direction: Axis.vertical,
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        MaterialButton(
                          color: Theme.of(context).primaryColor,
                          minWidth: MediaQuery.of(context).size.width * 0.6,
                          child: Text('ATUALIZAR AGORA'),
                          textColor: Colors.white,
                          //minWidth: MediaQuery.of(context).size.width * 0.5,
                          elevation: 0,
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(10.0)
                          ),
                          onPressed: (){
                            launch(widget.linkLoja!);
                          }
                        ),
                      ],
                    ),
                  ),
                )
              ],
            ),   
          ],
        )
      ),
    );
  }
}