KonectarApp/lib/view/navigation_home_screen.dart

249 lines
10 KiB
Dart
Raw Permalink Normal View History

2024-10-07 12:45:45 +00:00
import 'package:flutter/material.dart';
2024-12-03 05:59:45 +00:00
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';
2024-10-08 12:01:59 +00:00
import 'package:konectar_events/contacts_module/ui_screen/new_contacts.dart';
2024-12-03 05:59:45 +00:00
import 'package:konectar_events/contacts_module/ui_screen/new_editinteraction.dart';
import 'package:konectar_events/contacts_module/ui_screen/new_viewinteraction.dart';
2024-10-07 12:45:45 +00:00
import 'package:konectar_events/utils/app_theme.dart';
2024-12-19 05:21:33 +00:00
import 'package:konectar_events/utils/appcolors.dart';
2024-12-03 05:59:45 +00:00
import 'package:konectar_events/utils/constants.dart';
import 'package:konectar_events/utils/dateformater.dart';
2024-11-19 12:57:30 +00:00
import 'package:konectar_events/view/helpdesk.dart';
2024-10-07 12:45:45 +00:00
import 'package:konectar_events/view/home.dart';
2024-12-10 09:36:43 +00:00
import 'package:konectar_events/viewmodel/hive_repository.dart';
2024-10-07 12:45:45 +00:00
import 'package:konectar_events/widgets/drawerusercontroller.dart';
import 'package:konectar_events/widgets/home_drawer.dart';
2024-12-03 05:59:45 +00:00
import 'package:provider/provider.dart';
import '../contacts_module/ui_screen/interactionform/configprovider.dart';
2024-10-07 12:45:45 +00:00
class NavigationHomeScreen extends StatefulWidget {
@override
_NavigationHomeScreenState createState() => _NavigationHomeScreenState();
}
class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
Widget? screenView;
DrawerIndex? drawerIndex;
@override
void initState() {
drawerIndex = DrawerIndex.HOME;
screenView = const HomeScreen();
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
2024-12-18 04:39:20 +00:00
color: Colors.white,
2024-10-07 12:45:45 +00:00
child: SafeArea(
top: false,
bottom: false,
child: Scaffold(
2024-12-18 04:39:20 +00:00
backgroundColor: Colors.white,
2024-10-07 12:45:45 +00:00
body: DrawerUserController(
screenIndex: drawerIndex,
drawerWidth: MediaQuery.of(context).size.width * 0.75,
2024-12-10 09:36:43 +00:00
onDrawerCall: (DrawerIndex drawerIndexdata) async {
bool checkContacts = await HiveOperations.checkIfApiExists(
2024-12-16 11:26:32 +00:00
EventsConstants.contactsListapi, EventsConstants.moduleName);
2024-12-19 05:21:33 +00:00
// if (!checkContacts && drawerIndexdata.name == "Contacts") {
// } else {
changeIndex(drawerIndexdata);
// }
2024-10-07 12:45:45 +00:00
//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...
),
),
),
);
}
2024-12-03 05:59:45 +00:00
Widget medicalInsights() {
return Consumer<ViewInteractionProvider>(
builder: (BuildContext context, provider, Widget? child) {
return Container(
2024-12-19 05:21:33 +00:00
color: AppColors.bgcolor,
2024-12-03 05:59:45 +00:00
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<InteractionProvider>(context, listen: false)
.initConfigData();
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => InteractionScreen1(
index: 0,
form: Provider.of<InteractionProvider>(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(),
],
);
}),
],
),
);
});
}
2024-10-07 12:45:45 +00:00
void changeIndex(DrawerIndex drawerIndexdata) {
if (drawerIndex != drawerIndexdata) {
drawerIndex = drawerIndexdata;
switch (drawerIndex) {
case DrawerIndex.HOME:
setState(() {
screenView = const HomeScreen();
});
break;
2024-12-10 09:36:43 +00:00
case DrawerIndex.Contacts:
2024-10-07 12:45:45 +00:00
setState(() {
2024-10-08 12:01:59 +00:00
screenView = Contacts1();
2024-10-07 12:45:45 +00:00
});
break;
case DrawerIndex.FeedBack:
setState(() {
2024-11-19 12:57:30 +00:00
screenView = HelpDeskScreen();
2024-10-07 12:45:45 +00:00
});
break;
case DrawerIndex.Invite:
setState(() {
2024-12-03 05:59:45 +00:00
screenView = medicalInsights();
2024-10-07 12:45:45 +00:00
});
break;
default:
break;
}
}
}
}