import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '/app/constant.dart';
import '/widget/open_pdf_widget.dart';
import '/widget/rpt_date.dart';
import 'package:url_launcher/url_launcher.dart';

class InformationRptCard extends HookConsumerWidget {
  final String courierID;
  const InformationRptCard(this.courierID, {super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    // final Uri url = Uri.parse("http://devone.aplikasi.web.id/");
    // final Uri url = Uri.parse("https://www.google.com/");
    final Uri url = Uri.parse(
        "${Constant.baseBirtUrl}app-birt/run?__report=report/one/rekap/rpt_total_order_kurir.rptdesign&__format=pdf&courierID=40");
    Future<void> _launchUrl() async {
      print(url);
      if (!await launchUrl(url)) {
        throw Exception('Could not launch $url');
      }
    }

    return Container(
      // padding: EdgeInsets.fromLTRB(
      //     Constant.getActualY(context: context, y: 30),
      //     Constant.getActualX(context: context, x: 24),
      //     Constant.getActualX(context: context, x: 10),
      //     Constant.getActualY(context: context, y: 30)),
      height: Constant.getActualY(context: context, y: 180),
      decoration: BoxDecoration(
          image: DecorationImage(image: AssetImage("assets/kurir_bg_card.png")),
          borderRadius: BorderRadius.circular(20)),
      child: Row(
        children: [
          Expanded(
              flex: 5,
              child: Padding(
                padding: EdgeInsets.fromLTRB(
                    Constant.getActualY(context: context, y: 30),
                    Constant.getActualX(context: context, x: 24),
                    0,
                    Constant.getActualY(context: context, y: 30)),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      "Status Total Pekerjaan",
                      style: Constant.body1(context: context).copyWith(
                          fontWeight: FontWeight.w700, color: Colors.white),
                    ),
                    ElevatedButton(
                        onPressed: () {
                          // Navigator.push(
                          //     context,
                          //     MaterialPageRoute(
                          //       builder: (context) =>
                          //           PdfViewerPage(courierID: courierID),
                          //     ));

                          // _launchUrl();
                          RptDate(context, ref, courierID);
                        },
                        child: Text(
                          "Lihat RPT",
                          style: Constant.caption1(context: context).copyWith(
                              fontWeight: FontWeight.w700,
                              color: Color(0xff3366FF)),
                        ),
                        style: ElevatedButton.styleFrom(
                            shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(12)),
                            elevation: 0,
                            backgroundColor: Colors.white)),
                  ],
                ),
              )),
          Expanded(
              flex: 7,
              child: Container(
                  // color: Colors.red,
                  child: Image.asset("assets/kurir_icon_card.png")))
        ],
      ),
    );
  }
}
