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

import '../../app/constant.dart';

// ignore: non_constant_identifier_names
Future<String?> DialogPrint(BuildContext context, String noAntrian,
    Function funcPrintTicket, String serviceName) {
  return showDialog<String>(
    context: context,
    builder: (BuildContext context) => Dialog(
      child: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: Text(
                textAlign: TextAlign.center,
                'CETAK TIKET ANTRIAN',
                style: Constant.subTitle(context: context),
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            SizedBox(
                width: Constant.getActualX(context: context, x: 700),
                child: const Divider()),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: Text(
                textAlign: TextAlign.center,
                serviceName,
                style: Constant.subTitle(context: context),
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: Text(
                textAlign: TextAlign.center,
                noAntrian,
                style: Constant.subTitle(context: context),
              ),
            ),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: QrImageView(
                data: noAntrian,
                version: QrVersions.auto,
                size: 290,
                // embeddedImage: AssetImage('assets/images/logo-westerindo.png'),
                // embeddedImageStyle: ,
                gapless: false,
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: ElevatedButton(
                onPressed: () {
                  funcPrintTicket(noAntrian);
                },
                style: ElevatedButton.styleFrom(
                    elevation: 5, backgroundColor: Colors.blue),
                child: Text(
                  'Cetak Tiket',
                  style: Constant.label(context: context)
                      .copyWith(color: Colors.white),
                ),
              ),
            ),
            SizedBox(
              height: 10,
            ),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: Text(
                textAlign: TextAlign.center,
                "Scan qr code atau tekan tombol 'cetak tiket' untuk mendapatkan tiket",
                style: Constant.label(context: context),
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            Container(
              width: Constant.getActualX(context: context, x: 700),
              alignment: Alignment.center,
              child: Text(
                textAlign: TextAlign.center,
                "Tutup dialog setelah mendapatkan tiket",
                style: Constant.label(context: context),
              ),
            ),
            SizedBox(
                width: Constant.getActualX(context: context, x: 700),
                child: const Divider()),
            const SizedBox(
              height: 10,
            ),
            SizedBox(
              width: Constant.getActualX(context: context, x: 700),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: const Text('Tutup'),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  );
}
