import 'package:flutter/material.dart';
import 'package:school_management_system/components/default_values.dart';
import 'package:school_management_system/screens/main/main_screen.dart';
import 'package:school_management_system/screens/welcome/components/welcome_image.dart';
import 'package:school_management_system/screens/welcome/components/welcome_login.dart';

class WelcomeScreen extends StatefulWidget {
  const WelcomeScreen({super.key});

  @override
  State<WelcomeScreen> createState() => _WelcomeScreenState();
}

class _WelcomeScreenState extends State<WelcomeScreen> {
  @override
  void initState() {

    super.initState();
    setSharedPref('authkey', '');
    setSharedPref('isLogin', false);
    setSharedPref('tokenValidity', '');
  }

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SingleChildScrollView(
            child: Responsive(
              desktop: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Expanded(
                    child: WelcomeImage(),
                  ),
                  Expanded(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        SizedBox(
                          width: 350,
                          child: LoginButton(),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              mobile: MobileWelcomeScreen(),
            ),
          ),
        ],
      ),
    );
  }
}

class MobileWelcomeScreen extends StatelessWidget {
  const MobileWelcomeScreen({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return const Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        WelcomeImage(),
        Row(
          children: [
            Spacer(),
            Expanded(
              flex: 3,
              child: LoginButton(),
            ),
            Spacer(),
          ],
        ),
      ],
    );
  }
}
