import 'package:flutter/material.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/interactionprovider.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/new_dynamicform.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_contacts.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_editinteraction.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_viewinteraction.dart'; import 'package:konectar_events/utils/app_theme.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/utils/dateformater.dart'; import 'package:konectar_events/view/helpdesk.dart'; import 'package:konectar_events/view/home.dart'; import 'package:konectar_events/viewmodel/hive_repository.dart'; import 'package:konectar_events/widgets/drawerusercontroller.dart'; import 'package:konectar_events/widgets/home_drawer.dart'; import 'package:provider/provider.dart'; import '../contacts_module/ui_screen/interactionform/configprovider.dart'; class NavigationHomeScreen extends StatefulWidget { @override _NavigationHomeScreenState createState() => _NavigationHomeScreenState(); } class _NavigationHomeScreenState extends State { Widget? screenView; DrawerIndex? drawerIndex; @override void initState() { drawerIndex = DrawerIndex.HOME; screenView = const HomeScreen(); super.initState(); } @override Widget build(BuildContext context) { return Container( color: Colors.white, child: SafeArea( top: false, bottom: false, child: Scaffold( backgroundColor: Colors.white, body: DrawerUserController( screenIndex: drawerIndex, drawerWidth: MediaQuery.of(context).size.width * 0.75, onDrawerCall: (DrawerIndex drawerIndexdata) async { bool checkContacts = await HiveOperations.checkIfApiExists( EventsConstants.contactsListapi, EventsConstants.moduleName); if (!checkContacts && drawerIndexdata.name == "Contacts") { } else { changeIndex(drawerIndexdata); } //callback from drawer for replace screen as user need with passing DrawerIndex(Enum index) }, screenView: screenView, //we replace screen view as we need on navigate starting screens like MyHomePage, HelpScreen, FeedbackScreen, etc... ), ), ), ); } Widget medicalInsights() { return Consumer( builder: (BuildContext context, provider, Widget? child) { return Container( color: EventsConstants.bgcolor, child: Column( children: [ SizedBox( height: 20, ), Center( child: FloatingActionButton.extended( backgroundColor: Colors.green, onPressed: () async { final ConfigDataProvider configDataProvider = ConfigDataProvider(); await configDataProvider.initConfigUIDataMediccalInsight(); await Provider.of(context, listen: false) .initConfigData(); Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => InteractionScreen1( index: 0, form: Provider.of(context, listen: false) .intConfigDataList[0] .name, title: "Hope Neuman", ))); // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => const InteractionListScreen())); }, heroTag: 'medicalinsights', elevation: 0, label: const Text("Add Medical Insights", style: TextStyle( color: Colors.white, )), icon: const Icon( Icons.add, color: Colors.white, ), ), ), SizedBox( height: 20, ), provider.savedList.isEmpty ? SizedBox.shrink() : ListView.builder( itemCount: provider.savedList.length, shrinkWrap: true, cacheExtent: double.parse(provider.savedList.length.toString()), itemBuilder: (context, index) { return Column( children: [ ListTile( subtitle: Text( 'Updated on ${CustomDateFormatter().convertDateTimeToDate(provider.savedList[index].updatedTime!)}', //style: TextStyle(fontStyle: FontStyle.italic), ), title: Text( provider.savedList[index].id, ), trailing: SizedBox( width: 100, child: Row(children: [ IconButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => ViewInteractionScreen1( saveInteraction: provider.savedList[index], ))); }, icon: const Icon( Icons.info_outline, size: 24, color: Color.fromARGB(255, 8, 39, 92), ), ), IconButton( onPressed: () async { await provider.initConfigData().then({ // Navigator.push( // context, // MaterialPageRoute( // builder: (BuildContext context) => // EditInteractionScreen( // saveInteraction: provider // .savedList[index], // ))) Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => EditInteractionScreen1( saveInteraction: provider .savedList[index], ))) }); }, icon: const Icon( Icons.edit, size: 24, color: Color.fromARGB(255, 8, 39, 92), ), ), // IconButton( // onPressed: () { // showDeleteRecordAlertDialog( // context, // provider.savedList[index].id, // provider.savedList[index]); // }, // icon: const Icon( // Icons.delete, // size: 24, // color: Color.fromARGB(255, 8, 39, 92), // ), // ), ]), ), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => ViewInteractionScreen1( saveInteraction: provider.savedList[index], ))); }, ), const Divider(), ], ); }), ], ), ); }); } void changeIndex(DrawerIndex drawerIndexdata) { if (drawerIndex != drawerIndexdata) { drawerIndex = drawerIndexdata; switch (drawerIndex) { case DrawerIndex.HOME: setState(() { screenView = const HomeScreen(); }); break; case DrawerIndex.Contacts: setState(() { screenView = Contacts1(); }); break; case DrawerIndex.FeedBack: setState(() { screenView = HelpDeskScreen(); }); break; case DrawerIndex.Invite: setState(() { screenView = medicalInsights(); }); break; default: break; } } } }