import 'dart:async';

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

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

class CustomDialogPresensiSukses extends HookConsumerWidget {
  final String messageStatus;
  final String isiPesan;
  final ValueNotifier<bool> isLoadingAddressUserLocation;

  CustomDialogPresensiSukses({
    required this.isLoadingAddressUserLocation,
    required this.messageStatus,
    required this.isiPesan,
  });

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(8.0),
      ),
      elevation: 0,
      backgroundColor: Colors.white,
      child: contentBox(context),
    );
  }

  Widget contentBox(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: <Widget>[
        Container(
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            shape: BoxShape.rectangle,
            color: Colors.white,
            borderRadius: BorderRadius.circular(8),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Padding(
                padding: EdgeInsets.only(
                  top: Constant.getActualYPhone(context: context, y: 24),
                ),
                child: Container(
                  width: Constant.getActualXPhone(context: context, x: 100),
                  height: Constant.getActualYPhone(context: context, y: 100),
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage(
                          'images/presensi_selfie_sukses.png'), // Ganti dengan path gambar Anda
                    ),
                  ),
                ),
              ),
              SizedBox(
                height: Constant.getActualYPhone(context: context, y: 36),
              ),
              Text(
                messageStatus,
                style: Constant.titleH1_700_18(context: context).copyWith(
                  color: Constant.textOrange,
                ),
                textAlign: TextAlign.center,
              ),
              SizedBox(
                height: Constant.getActualYPhone(context: context, y: 12),
              ),
              Text(
                // 'Pengajuan presensi telah berhasil diajukan, mohon menunggu approval team leader!',
                isiPesan,
                style: Constant.titleH2_400_14(context: context).copyWith(
                  color: Constant.textTrueBlack,
                ),
                textAlign: TextAlign.center,
              ),
              SizedBox(
                height: Constant.getActualYPhone(context: context, y: 36),
              ),
              ElevatedButton(
                onPressed: () {
                  Navigator.of(context).pushNamedAndRemoveUntil(
                    homeRoute,
                    (route) => false,
                  );
                },
                style: ButtonStyle(
                  backgroundColor: MaterialStateColor.resolveWith(
                      (st) => Constant.textOrange),
                  shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                    RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(8),
                      side: BorderSide(
                        color: Constant.textOrange,
                      ),
                    ),
                  ),
                  shadowColor: MaterialStateProperty.all(Color(0xffff48423d)),
                  elevation: MaterialStateProperty.all(4.0),
                ),
                child: Text(
                  'OK',
                  style: Constant.titleH2_400_14(context: context).copyWith(
                    color: Constant.textWhite,
                  ),
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
