import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';
import 'notificacoes_controller.dart';

class NotificacaoDetail extends StatelessWidget {
  final NotificacoesController c = Get.find();
  
  @override
  Widget build(BuildContext context) {
    
    return Scaffold(
      appBar: AppBar(
        //
        //title: Obx(() => Text(c.notificacaoDetail.value.result.titulo ?? 'Notificação')),
      ),
      body: Obx(() =>  c.loadingDetail.value ? Center(child: CircularProgressIndicator(),) : c.notificacaoDetail.value.errorCode != 0 ? Center(child: Text(c.notificacaoDetail.value.errorMessage!),)  : ListView(
          children: <Widget>[
            Visibility(
              visible: GetUtils.isNullOrBlank(c.notificacaoDetail.value.result!.imageUrl) == false,
              child: Container(
                color: Colors.black38,
                height: 250,
                child: Padding(
                  padding: const EdgeInsets.all(70.0),
                  child: Image.network(
                    c.notificacaoDetail.value.result!.imageUrl ?? '',
                    fit: BoxFit.contain,
                  ),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(20.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    c.notificacaoDetail.value.result!.titulo!,
                    style: TextStyle(fontSize: 30.0,),
                  ),
                  const SizedBox(height: 10),
                  Html(
                    data: c.notificacaoDetail.value.result!.conteudo,
                    // onLinkTap: (url){
                    //   launch(url);
                    // },
                    onLinkTap: (url,ctx,mp,element){
                      launch(url!);
                    },
                    // style: Theme.of(context).textTheme.bodyText2.copyWith(
                    //       color: Colors.black54,
                    //       height: 1.5,
                    //       fontSize: 16.0,
                    //     ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}