import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:web_panel/utils/App_color.dart';
import 'package:web_panel/utils/spacing.dart';

import '../../constants.dart';
import '../../responsive.dart';
import 'components/header.dart';
import 'components/dash_board_count.dart';
import 'components/emi_schedule.dart';
import 'components/account_setting.dart';

class DashboardScreen extends StatelessWidget {
  const DashboardScreen({super.key,required this.scaffoldKey});
  final GlobalKey<ScaffoldState> scaffoldKey;

  @override
  Widget build(BuildContext context) {
    return SafeArea(

      child: Scaffold(
        backgroundColor: AppColor.bgColor,
        body: SelectableRegion(
          focusNode: FocusNode(),
          selectionControls: materialTextSelectionControls,
          child: SingleChildScrollView(
            primary: false,

            padding: EdgeInsets.all(defaultPadding),
            child: Column(
              children: [
                Header(title: 'Dashboard',scaffoldKey: scaffoldKey,),
                SizedBox(height: defaultPadding),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Expanded(
                      flex: 5,
                      child: Column(
                        children: [
                          Container(
                            padding: EdgeInsets.symmetric(
                              horizontal: 6.sp,
                              vertical: 4.sp,
                            ),
                            decoration: BoxDecoration(
                              color: AppColor.secondaryColor,
                              border: Border.all(
                                color: AppColor.warning,
                                width: 1.5,
                              ),

                              borderRadius: BorderRadius.circular(2.sp),
                            ),
                            child: Row(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              spacing: 4.sp,
                              children: [
                                Icon(Icons.warning, color: AppColor.warning),
                                Expanded(
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,

                                    children: [
                                      Text(
                                        'Warning: Authorized Use Only',
                                        style: Theme.of(context)
                                            .textTheme
                                            .titleMedium
                                            ?.copyWith(
                                              color: AppColor.warning,
                                              fontWeight: FontWeight.w700,
                                            ),
                                      ),
                                      Spacing.height(3),
                                      Text(
                                        "This application is designed for monitoring android application and is strictly intended for use by law enforcement agencies and legal purposes only.any misuse,unauthorized access, or illegal activity using this application is strictly prohibited. If you choose to use this application for any unlawful activities, you bear full responsibility for you actions.The developer and providers of this application hols on liability for any misuse.",
                                        style: Theme.of(context).textTheme.bodySmall
                                            ?.copyWith(
                                              color: Colors.white,
                                              fontWeight: FontWeight.w500,
                                            ),
                                      ),
                                    ],
                                  ),
                                ),
                                Container(
                                  padding: EdgeInsets.symmetric(
                                    horizontal: 2.sp,
                                    vertical: 1.sp,
                                  ),
                                  decoration: BoxDecoration(
                                    color: AppColor.buttonColor,

                                    // border: Border.all(
                                    //   color: AppColor.warning,
                                    //   width: 1.5,
                                    // ),
                                    borderRadius: BorderRadius.circular(1.5.sp),
                                  ),
                                  child: Text(
                                    'Telegram',
                                    style: Theme.of(context).textTheme.titleSmall
                                        ?.copyWith(
                                          color: Colors.white,
                                          fontWeight: FontWeight.w400,
                                        ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Spacing.height(6),
                          DashBoardCount(),
                          SizedBox(height: defaultPadding),
                          EMISchedule(),
                          if (Responsive.isMobile(context))
                            SizedBox(height: defaultPadding),
                          if (Responsive.isMobile(context)) AccountSetting(),
                        ],
                      ),
                    ),
                    if (!Responsive.isMobile(context))
                      SizedBox(width: defaultPadding),
                    if (!Responsive.isMobile(context))
                      Expanded(flex: 2, child: AccountSetting()),
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
