import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mitra_corporate/app/constant.dart';
import 'package:webview_flutter/webview_flutter.dart';

class DialogPrint extends HookConsumerWidget {
  const DialogPrint({super.key, required this.url});
  final String url;
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    late WebViewController controller;

    controller = WebViewController()
      ..loadRequest(
        Uri.parse(url),
      );
    return Padding(
      padding: EdgeInsets.all(40),
      child: Material(
        borderRadius: BorderRadius.circular(8),
        child: Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(8),
          ),
          child: Column(
            children: [
              Container(
                padding: EdgeInsets.symmetric(
                    horizontal: Constant.getActualX(context: context, x: 32)),
                height: Constant.getActualY(context: context, y: 96),
                decoration: BoxDecoration(
                  color: Colors.grey,
                  borderRadius: BorderRadius.only(
                      topRight: Radius.circular(8),
                      topLeft: Radius.circular(8)),
                ),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      "Cetak Surat Jalan",
                      style: Constant.h2_600(context: context),
                    ),
                    IconButton(
                        onPressed: () {
                          Navigator.pop(context);
                        },
                        icon: Icon(
                          size: 30,
                          Icons.close_rounded,
                          color: Colors.red,
                        ))
                  ],
                ),
              ),
              SizedBox(
                // color: Colors.red,
                height: Constant.getActualY(context: context, y: 800),
                // width: Constant.getActualX(context: context, x: 1500),
                child: WebViewWidget(
                  controller: controller,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
