import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mitra_corporate/screen/dashboard/dashboard_screen.dart';
import 'package:mitra_corporate/screen/registrasi/registrasi_pasien_screen.dart';
import 'package:mitra_corporate/screen/result/detail_result_screen.dart';
import 'package:mitra_corporate/screen/result/result_screen.dart';
import 'package:mitra_corporate/screen/surat_jalan/surat_jalan_detail_screen.dart';
import 'package:mitra_corporate/screen/surat_jalan/surat_jalan_screen.dart';
import 'package:mitra_corporate/widgets/side_menu.dart';

import '../../provider/menu_provider.dart';
import '../order/order_screen.dart';

class HomeScreen extends HookConsumerWidget {
  const HomeScreen({super.key});
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final currentMenu = ref.watch(currentMenuProvider);
    // getPref() async {
    //   final SharedPreferences prefs = await SharedPreferences.getInstance();
    //   final String? getData = prefs.getString(Constant.tokenName);
    //   // print(getData);
    //   if (getData == null) {
    //     Timer(Duration(seconds: 1), () {
    //       Navigator.pushNamed(context, loginRoute);
    //     });
    //   }
    // }

    // useEffect(() {
    //   WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
    //     getPref();
    //   });
    //   return () {};
    // }, []);
    return Scaffold(
      body: Container(
        child: Row(
          children: [
            SideMenu(),
            if (currentMenu == 1) Expanded(child: DashboardScreen()),
            if (currentMenu == 2) Expanded(child: RegistrasiPasienScreen()),
            if (currentMenu == 3) Expanded(child: SuratJalanScreen()),
            if (currentMenu == 4) Expanded(child: ResultScreen()),
            if (currentMenu == 5) Expanded(child: SuratJalanDetailScreen()),
            if (currentMenu == 6) Expanded(child: OrderScreen()),
            if (currentMenu == 7) Expanded(child: DetailResultScreen()),

            // Container(
            //   child: Text("a"),
            // )
          ],
        ),
      ),
    );
  }
}
