import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:fhub/src/CustomWidgets.dart';
import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    kickstartAnimations();
  }

  void kickstartAnimations() async {
    await Future.delayed(const Duration(milliseconds: 500));

    setState(() {
      op1 = 1;
      op2 = 1;
      op3 = 1;
    });
  }

  int selectedPageId = 0;
  String TitleText = "Home";
  @override
  Widget build(BuildContext context) {
    final screenHeight = MediaQuery.of(context).size.height;
    final screenWidth = MediaQuery.of(context).size.width;

    return Scaffold(
      backgroundColor: Colors.black,
      extendBody: true,
      body: SafeArea(
          child: CustomBody(
        context: context,
        onAnimEnd: () {
          setState(() {});
        },
        bottomNav: [
          BottomNavBarItem(
            icon: Icons.home,
            active: selectedPageId == 0,
            onPressed: () {
              setState(() {
                TitleText = "Home";
                selectedPageId = 0;
              });
            },
          ),
          BottomNavBarItem(
              icon: Icons.wallet,
              active: selectedPageId == 1,
              onPressed: () {
                setState(() {
                  TitleText = "Wallet";
                  selectedPageId = 1;
                });
              }),
          BottomNavBarItem(
              icon: Icons.settings,
              active: selectedPageId == 2,
              onPressed: () {
                setState(() {
                  TitleText = "Settings";
                  selectedPageId = 2;
                });
              }),
        ],
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(children: [
            Center(
                child:
                AnimatedSwitcher(
                  duration: Duration(milliseconds: 300),
                  transitionBuilder:
                      (Widget child, Animation<double> animation) {
                    return FadeTransition(child: child,opacity: Tween<double>(begin: 0, end: 1).animate(animation));
                  },
                  child:
                  GradientText(key: ValueKey<String>(TitleText),text: TitleText,gradient: LinearGradient(colors: [Colors.deepPurpleAccent, Colors.purple,Colors.purpleAccent]),style: TextStyle(fontSize: 45,fontWeight: FontWeight.bold),),
                ))
          ]),
        ),
      )),
    );
  }
}
