// ignore_for_file: use_build_context_synchronously

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sis_flutter/themes/themes.dart';
import 'package:sis_flutter/views/home/home_view.dart';
import 'package:sis_flutter/views/profile/profile_screen.dart';
import 'package:sis_flutter/widgets/app_drawer.dart';
import 'package:sis_flutter/widgets/custom_bottom_navigation_bar.dart';

class HomeScreen extends StatefulWidget {
  static const String route = '/home';

  const HomeScreen({super.key});

  @override
  Formulario createState() => Formulario();
}

class Formulario extends State<HomeScreen> with SingleTickerProviderStateMixin {
  late TabController _tabController;
  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppTheme.progressBackground,
      appBar: AppBar(
        backgroundColor: Colors.white,
      ),
      drawerScrimColor:
          const Color.fromARGB(255, 119, 119, 119).withOpacity(0.5),
      drawer: AppDrawer(),
      body: TabBarView(
        controller: _tabController,
        children: <Widget>[
          const HomeBody(),
          const ProfileScreen(),
        ],
      ),
      bottomNavigationBar: CustomBottomNavigationBar(
          indexValue: _tabController.index,
          onIndexSelected: (index) {
            setState(() {
              _tabController.index = index;
            });
          }),
    );
  }
}
