import 'package:conalep_pos/themes/themes.dart';
import 'package:conalep_pos/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../viewmodels/login_view_model.dart';
import '../../viewmodels/viewmodels.dart';
import '../pedido/pedido_sync.dart';

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

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

class Formulario extends State<HomeScreen> {
  @override
  void initState() {
    super.initState();
    // Future(() async {
    //   await Provider.of<LoginViewModel>(context, listen: false).setValores();
    // });
    PedidoSync()
        .startSync(Provider.of<PedidoViewModel>(context, listen: false));

    WidgetsBinding.instance.addPostFrameCallback((_) {
      Provider.of<ProductoViewModel>(context, listen: false)
          .sincronizarProductosYCategorias();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey.shade200,
      drawer: AppDrawer(),
      appBar: AppBar(
        title: Text(
          'Inicio',
          style: TextStyle(color: AppTheme.secondary),
        ),
        iconTheme: IconThemeData(color: AppTheme.secondary),
      ),
      body: const Center(
        child: Image(
          image: AssetImage('assets/icono.png'),
          height: 200,
        ),
      ),
    );
  }
}
