import 'package:flutter/material.dart';
import 'package:initial_folder/providers/theme_provider.dart';
import 'package:initial_folder/screens/certificate/all_certificate.dart';
import 'package:initial_folder/screens/certificate/certificatecheck/certificate_check.dart';
import 'package:initial_folder/screens/splash/splash_screen_login.dart';
import 'package:initial_folder/widgets/custom_navigator.dart';
import 'package:provider/provider.dart';

import '../../size_config.dart';
import '../../theme.dart';

class Certificate extends StatelessWidget {
  const Certificate({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final themeProvider = Provider.of<ThemeProvider>(context);
    return Scaffold(
      appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.background,
          centerTitle: true,
          title: Text(
            'Cek Status Sertifikat',
            style: secondaryTextStyle.copyWith(
                letterSpacing: 1,
                fontWeight: semiBold,
                fontSize: getProportionateScreenWidth(16)),
          )),
      body: Padding(
        padding: EdgeInsets.all(15),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.asset(
                "assets/images/undraw_certificate.png",
                scale: getProportionateScreenHeight(2),
              ),
              SizedBox(height: 10),
              Text(
                "Cek keaslian sertifikat atau cek sertifikat dari kursus yang anda miliki",
                style: TextStyle(
                    fontSize: getProportionateScreenHeight(12),
                    fontWeight: reguler),
                textAlign: TextAlign.center,
              ),
              SizedBox(height: getProportionateScreenHeight(38)),
              Padding(
                padding: EdgeInsets.symmetric(
                    horizontal: getProportionateScreenWidth(10)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    SizedBox(
                      width: double.infinity,
                      child: ElevatedButton(
                        style: ElevatedButton.styleFrom(
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(5),
                            ),
                            backgroundColor:  themeProvider.themeData == ThemeClass.darkmode
                              ?primaryColor : primaryColorligtmode,
                            padding: EdgeInsets.symmetric(
                                vertical: 5,
                                horizontal: getProportionateScreenWidth(5))),
                        onPressed: () {
                          Navigator.push(
                            context,
                            CustomNavigator(
                              child: CertificateCheck(),
                            ),
                          );
                        },
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Text(
                              "Verifikasi Sertifikat",
                              style: thirdTextStyle.copyWith(
                                fontSize: getProportionateScreenWidth(12),
                                color: baruTextutih,
                                fontWeight: reguler,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                    SizedBox(height: getProportionateScreenHeight(12)),
                    SizedBox(
                      width: double.infinity,
                      child: ElevatedButton(
                        style: ElevatedButton.styleFrom(
                          elevation: 0.0,
                          foregroundColor: primaryColor,
                          backgroundColor:
                              Theme.of(context).colorScheme.background,
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(5),
                            side: BorderSide(
                               color: themeProvider.themeData == ThemeClass.darkmode
                              ?primaryColor : primaryColorligtmode,
                              width: getProportionateScreenWidth(1.5),
                            ),
                          ),
                          padding: EdgeInsets.symmetric(
                            vertical: 5,
                            horizontal: getProportionateScreenWidth(5),
                          ),
                        ),
                        onPressed: (!Condition.loginEmail &&
                                !Condition.loginFirebase)
                            ? () {
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                    builder: (context) => AllCertificate(
                                      isLogin: false,
                                    ),
                                  ),
                                );
                              }
                            : () {
                                Navigator.of(context, rootNavigator: true).push(
                                  CustomNavigator(
                                    child: AllCertificate(),
                                  ),
                                );
                              },
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Text(
                              "Sertifikat Saya",
                              style: thirdTextStyle.copyWith(
                                fontSize: getProportionateScreenWidth(12),
                                 color: themeProvider.themeData == ThemeClass.darkmode
                              ?primaryColor : primaryColorligtmode,
                                fontWeight: bold,
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
