import 'dart:convert'; import 'dart:io'; import 'dart:math'; import 'package:avatar_stack/avatar_stack.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:intl/intl.dart'; import 'package:konectar_events/contacts_module/model_class/speaker.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/configprovider.dart'; import 'package:konectar_events/contacts_module/ui_screen/interactionform/interactionlistscreen.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/interactionform/widget/custombutton.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_editinteraction.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_new_profile.dart'; import 'package:konectar_events/contacts_module/ui_screen/new_viewinteraction.dart'; import 'package:konectar_events/model/events_speakers_k1.dart'; import 'package:konectar_events/model/eventsdetailmodel.dart'; import 'package:konectar_events/model/eventspeakers.dart'; import 'package:konectar_events/model/sessionnotesmodel.dart'; import 'package:konectar_events/model/sessionstopics_model.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/utils/dateformater.dart'; import 'package:konectar_events/utils/util.dart'; import 'package:konectar_events/viewmodel/hcpprofprovider.dart'; import 'package:konectar_events/widgets/customdropdown.dart'; import 'package:konectar_events/widgets/snackbar.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:path/path.dart' as p; class HCPProfileScreen extends StatefulWidget { EventSpeakersData eventsdetail; String eventid; String title; List sessionNames; List topics; String kolFullName; HCPProfileScreen( {super.key, required this.eventsdetail, required this.eventid, required this.kolFullName, required this.sessionNames, required this.topics, required this.title}); @override State createState() => _HCPProfileScreenState(); } class _HCPProfileScreenState extends State { String? _selectedFruit; SessionsTopicsData? sessionsTopicsData; bool isExtended = false; List sessionList = []; String attachedFileName = ''; String attachedFilePath = ''; bool isLoading = false; bool enableCancel = false; String btnText = "Add Notes"; final List _fruits = ['Events', 'Sessions']; final List topics = [ " Admin. & Managemente", "Cyclin-Dependent Kinase 4 | Cyclin-Dependent Kinase 6 | Breast Neoplasms" ]; final List sessions = [ "Program Committee", "Practical Application of CDK 4/6 Inhibitor" ]; final ValueNotifier> valueList = ValueNotifier>([0, 0, 0]); TextEditingController notesController = TextEditingController(text: ""); List sessionNotesList = []; Future dialogBuilder(BuildContext context, Eventsdetail eventsdetail, HcpProfileProvider provider) { return showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: const Text('Session Notes'), content: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( border: Border.all(color: Colors.grey), borderRadius: BorderRadius.circular(8.0)), child: dropDown(underline: Container(), provider: provider)), TextFormField( validator: (value) { // add email validation if (value == null || value.isEmpty) { return 'Please enter some text'; } // bool emailValid = RegExp( // r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") // .hasMatch(value); // if (!emailValid) { // return 'Please enter a valid email'; // } return null; }, decoration: const InputDecoration( labelText: 'Notes', hintText: 'Notes', prefixIcon: Icon(Icons.email_outlined), border: OutlineInputBorder(), ), ), ], ), actions: [ TextButton( style: TextButton.styleFrom( textStyle: Theme.of(context).textTheme.labelLarge, ), child: const Text('Submit'), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( style: TextButton.styleFrom( textStyle: Theme.of(context).textTheme.labelLarge, ), child: const Text('Cancel'), onPressed: () { Navigator.of(context).pop(); }, ), ], ); }, ); } Widget dropDown( {Widget? underline, Widget? icon, TextStyle? style, TextStyle? hintStyle, Color? dropdownColor, required HcpProfileProvider provider}) => DropdownButton( value: sessionsTopicsData, underline: underline, icon: Align(alignment: Alignment.centerRight, child: icon), dropdownColor: dropdownColor, isExpanded: true, style: TextStyle( //fontFamily: "SourceSerif", color: Colors.black, fontSize: 14.0, ), // iconEnabledColor: iconEnabledColor, onChanged: (SessionsTopicsData? newValue) { setState(() { _selectedFruit = newValue!.sessionName; sessionsTopicsData = newValue; notesController.text = newValue.note ?? ""; if (newValue.note != "" && notesController.text.length != 0) { btnText = "Update"; enableCancel = true; } setState(() {}); }); }, hint: Text("Select Session *", style: hintStyle), items: provider.sessionTopics .map((session) => DropdownMenuItem( value: session, child: Text(session.sessionName!))) .toList()); @override void initState() { //valueList.value = [0, 0, 0]; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { init(); }); super.initState(); } init() async { // await Provider.of(context, listen: false) // .initConfigModules(); await Provider.of(context, listen: false) .getSessionData(); await Provider.of(context, listen: false) .getSessionTopics(widget.eventsdetail) .then( (value) { valueList.value[0] = Provider.of(context, listen: false).totalNotes; valueList.value[1] = Provider.of(context, listen: false) .totalSessions; valueList.value[2] = Provider.of(context, listen: false).totalTopics; }, ); Provider.of(context, listen: false).getCounts(); await Provider.of(context, listen: false) .initConfigData(); await Provider.of(context, listen: false).getRecords(); String formname = Provider.of(context, listen: false) .intConfigDataList[0] .name; await Provider.of(context, listen: false) .getRecords(formname, hcp: widget.kolFullName); setState(() {}); } Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, provider, Widget? child) { return DefaultTabController( length: provider.tabs.length, child: Scaffold( backgroundColor: EventsConstants.bgcolor, appBar: AppBar( // title: Text(""), automaticallyImplyLeading: false, backgroundColor: EventsConstants.blueColor, centerTitle: false, flexibleSpace: FlexibleSpaceBar( background: Padding( padding: const EdgeInsets.only(top: 2.0, right: 2.0), child: Row( // alignment: Alignment.center, // fit: StackFit.expand, crossAxisAlignment: CrossAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center, children: [ IconButton( icon: Icon( Icons.arrow_back_ios, size: 18, color: Colors.white, ), onPressed: () { Navigator.pop(context); }, ), // SizedBox( // width: 40, // ), Expanded( child: Text( "${widget.title}", //maxLines: 4, //softWrap: true, style: TextStyle( overflow: TextOverflow.ellipsis, // decoration: TextDecoration.underline, // decorationColor: Colors.blue, color: Colors.white, //fontWeight: FontWeight.bold, fontSize: isTablet ? 22 : 14, ), ), ), ], ), ), ), ), body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( expandedHeight: 280.0, // expandedHeight: MediaQuery.of(context).size.height * 0.25, backgroundColor: EventsConstants.bgcolor, //backgroundColor: Colors.white, automaticallyImplyLeading: false, floating: false, pinned: false, stretch: true, flexibleSpace: FlexibleSpaceBar( centerTitle: true, collapseMode: CollapseMode.parallax, // title: Text("", // style: TextStyle( // color: Colors.black, // fontSize: 16.0, // )), title: SizedBox.shrink(), background: buildCardView( context, widget.eventsdetail, provider) // Image.network( // "https://images.pexels.com/photos/417173/pexels-photo-417173.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", // fit: BoxFit.cover, // ) ), ), SliverPersistentHeader( pinned: true, floating: true, delegate: _SliverAppBarDelegate( TabBar( isScrollable: false, indicatorSize: TabBarIndicatorSize.tab, tabAlignment: TabAlignment.fill, labelColor: Colors.black, indicatorColor: EventsConstants.blueColor, labelStyle: TextStyle( fontWeight: FontWeight.bold, ), labelPadding: EdgeInsets.all(2), indicatorWeight: 2.0, //Color.fromARGB(255, 5, 36, 62) unselectedLabelColor: Colors.grey, tabs: provider.tabs, ), ), ), ]; }, body: provider.tabs.length == 0 ? Container() : TabBarView(children: returnTabWidget(provider) // _tabs // .map((e) => Center( // child: FloatingActionButton.extended( // backgroundColor: // const Color.fromARGB(255, 222, 237, 247), // onPressed: () {}, // heroTag: 'follow', // elevation: 0, // label: const Text("Add Notes"), // icon: const Icon(Icons.add), // ), // // Text("${e.text}", textAlign: TextAlign.center), // )) // .toList()), ), ), )); }); } List returnTabWidget(HcpProfileProvider provider) { List widgets = []; for (var tabs in provider.tabs) { if (tabs.text == "Sessions") { widgets.add(topicsTab(widget.eventsdetail, provider)); } if (tabs.text == "Notes") { widgets.add(sessionNotes(context, widget.eventsdetail, provider)); } if (tabs.text == "Medical Insights") { widgets.add(medicalInsights()); } } return widgets; } buildprofile(BuildContext context, EventSpeakersData eventsdetail, String title, HcpProfileProvider provider) { MediaQuery.of(context).size.height * 0.35; print("ORG:${eventsdetail.orgName}"); return Container( //color: Colors.yellowAccent, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, //mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Stack(clipBehavior: Clip.none, alignment: Alignment.center, children: [ Container( width: MediaQuery.of(context).size.width, // Adjust width as needed height: 140, // Adjust height as needed decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ EventsConstants.blueColor, EventsConstants.blueColor, EventsConstants.blueColor, // const Color.fromARGB(255, 222, 237, 247), // const Color.fromARGB(255, 222, 237, 247), // Color(0xff006df1) ]), ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: 15, ), Text(eventsdetail.kolFullName!, style: TextStyle( fontSize: 20, // fontFamily: "SourceSerif", color: Colors.white, fontWeight: FontWeight.bold)), // Text("Hematology/Oncology", // style: TextStyle( // color: Colors.white, // // fontFamily: "SourceSerif", // )), RichText( textAlign: TextAlign.center, text: TextSpan(children: [ TextSpan( text: provider.getUserLoc(eventsdetail), style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, color: Colors.white, fontSize: 14, // fontFamily: "SourceSerif", ), // maxLines: isTablet ? 4 : 4, // softWrap: true, // overflow: TextOverflow.ellipsis, ), // TextSpan( // text: eventsdetail.country != null // ? '${eventsdetail.country},' // : "", // style: TextStyle( // // decoration: TextDecoration.underline, // // decorationColor: Colors.blue, // color: Colors.white, // fontSize: 14, // // fontFamily: "SourceSerif", // ), // ), // TextSpan( // text: eventsdetail.city != null // ? '${eventsdetail.city}' // : "", // style: TextStyle( // // decoration: TextDecoration.underline, // // decorationColor: Colors.blue, // color: Colors.white, // fontSize: 14, // // fontFamily: "SourceSerif", // ), // ) ])), // Text( // "${eventsdetail.orgName ?? ""},${eventsdetail.country ?? ""},${eventsdetail.city ?? ""}", // softWrap: true, // maxLines: 2, // textAlign: TextAlign.center, // style: TextStyle( // color: Colors.white, // // fontFamily: "SourceSerif", // fontSize: 14, // )), ], ), ), // Column( // mainAxisAlignment: MainAxisAlignment.start, // children: [ // Text1( // title: "Dr " + widget.text!["name"], // txtcolor: Colors.white, // fontweight: FontWeight.normal, // txtfont: 22.0), // Text1( // title: widget.text!["speciality"], // txtcolor: Colors.white, // fontweight: FontWeight.normal, // txtfont: 15.0), // ], // ), Positioned( bottom: -45, child: Container( // child: widget.text["img_path"] == null // ? ProfilePicture( // name: widget.text!["name"], // radius: 38, // fontsize: 21, // ) child: ClipOval( child: SizedBox.fromSize( size: Size.fromRadius(48), child: SizedBox( width: 120, height: 120, child: BorderedCircleAvatar( // radius: 24, backgroundColor: Colors.grey, border: BorderSide(color: Colors.white), // child: Icon( // Icons.person, // size: 18, // color: Colors.white, // ), child: Text( title[0], style: TextStyle( fontWeight: FontWeight.bold, fontSize: 34, color: Colors.white), ), ), ), ), ), ), ), // SizedBox( // height: 55.0, // ), ]), ], )); } Widget buildCardView(BuildContext context, EventSpeakersData eventsdetail, HcpProfileProvider provider) { return Container( // color: Constants.bgcolor, child: Column( children: [ // _TopPortion( // title: eventsdetail.kolFullName!, // eventsdetail: eventsdetail, // ), buildprofile( context, eventsdetail, eventsdetail.kolFullName!, provider), // Padding( // padding: const EdgeInsets.all(8.0), // child: Column( // children: [ // Text(eventsdetail.kolFullName!, // style: TextStyle( // fontSize: 20, // // fontFamily: "SourceSerif", // fontWeight: FontWeight.bold)), // Text("Hematology/Oncology", // style: TextStyle( // // fontFamily: "SourceSerif", // )), // Text( // "${eventsdetail.orgName ?? ""} ${eventsdetail.country ?? ""} ${eventsdetail.city ?? ""}", // softWrap: true, // maxLines: 2, // textAlign: TextAlign.center, // style: TextStyle( // // fontFamily: "SourceSerif", // fontSize: 12, // )), // const SizedBox(height: 20), // Row( // mainAxisAlignment: MainAxisAlignment.center, // children: [ // SizedBox( // height: 45, // child: FloatingActionButton.extended( // elevation: 1, // // backgroundColor: Color.fromARGB(255, 166, 217, 250), // backgroundColor: Colors.grey, // onPressed: () { // setState(() { // isExtended = !isExtended; // }); // }, // label: AnimatedSwitcher( // duration: Duration(seconds: 1), // transitionBuilder: (Widget child, // Animation animation) => // FadeTransition( // opacity: animation, // child: SizeTransition( // child: child, // sizeFactor: animation, // axis: Axis.horizontal, // ), // ), // child: isExtended // ? Row( // children: [ // Padding( // padding: const EdgeInsets.only( // right: 4.0), // child: Icon(Icons.check), // ), // Text("Added to Contacts") // ], // ) // : Row( // children: [ // Padding( // padding: const EdgeInsets.only( // right: 4.0), // child: Icon(Icons.add, // color: Colors.white), // ), // Text( // "Add to Contacts", // style: // TextStyle(color: Colors.white), // ) // ], // ))), // ), // const SizedBox(width: 16.0), // FloatingActionButton.extended( // onPressed: () {}, // heroTag: 'mesage', // elevation: 0, // backgroundColor: Colors.red, // label: const Text("Message"), // icon: const Icon(Icons.message_rounded), // ), // ], // ), // const SizedBox(height: 15), // const SizedBox(height: 5), // ], // ), // ), SizedBox( height: 60, ), // const Spacer(), Center( child: ValueListenableBuilder>( valueListenable: valueList, builder: (context, value, child) => _ProfileInfoRow(items: [ ProfileInfoItem("Topic(s)", value[2]), ProfileInfoItem("Session(s)", value[1]), ProfileInfoItem("Note(s)", value[0]), ]), )), // SizedBox( // height: 20, // ), ], ), ); } Widget sessionNotes(BuildContext context, EventSpeakersData eventsdetail, HcpProfileProvider provider) { // sessionList = eventsdetail.sessionName!.split(','); sessionList = widget.sessionNames; return Container( color: EventsConstants.bgcolor, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.only(left: 15.0, top: 15, right: 15), // decoration: BoxDecoration( // border: Border.all(color: Colors.grey), // borderRadius: BorderRadius.circular(8.0)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.all(4.0), // height: 40, width: double.infinity, decoration: BoxDecoration( border: Border.all(color: Colors.grey), borderRadius: BorderRadius.circular(4.0)), child: dropDown(underline: Container(), provider: provider)), SizedBox( height: 15, ), TextFormField( controller: notesController, maxLines: 3, inputFormatters: [ LengthLimitingTextInputFormatter(1000), ], validator: (value) { // add email validation if (value == null || value.isEmpty) { return 'Please enter some text'; } // bool emailValid = RegExp( // r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") // .hasMatch(value); // if (!emailValid) { // return 'Please enter a valid email'; // } return null; }, decoration: const InputDecoration( labelText: 'Notes *', // hintText: 'Notes', // prefixIcon: Icon(Icons.note), border: OutlineInputBorder(), focusedBorder: OutlineInputBorder(), ), ), Text( 'Maximum Characters: 1000', style: TextStyle(fontSize: 12), ), SizedBox( height: 10, ), Row( children: [ // Text("Attach a file :"), // SizedBox( // width: 10, // ), // SizedBox( // width: 140, // height: 30, // child: OutlinedButton( // onPressed: () { // enableCancel = false; // notesController.clear(); // sessionsTopicsData = null; // _selectedFruit = ""; // btnText = "Add Notes"; // setState(() {}); // }, // style: ButtonStyle( // shape: MaterialStateProperty.all(CircleBorder()), // ), // child: Icon(Icons.attach_file)), // ), CustomButton( backgroundColor: const Color.fromARGB(255, 233, 229, 229), onPressed: () async { // sectionItem.selectedValue = []; // sectionItem.extension = []; // sectionItem.fileName = []; if (_selectedFruit != null) { await getEncodedFile(); } else { SnackBarWidget.displaySnackBar( "Please select a session", context, error: true); } setState(() {}); }, width: 120, height: 35, fontsize: 12, textColor: Colors.black, title: "Attach file"), SizedBox( width: 5, ), Text( attachedFileName != "" ? attachedFileName : "", style: TextStyle( color: attachedFileName != "" ? Colors.green : Colors.red), ), ], ), ], )), const SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( alignment: Alignment.center, child: Stack( children: [ Align( alignment: Alignment.center, child: SizedBox( height: 40, child: // CustomButton( // backgroundColor: EventsConstants.btnGreenColor, // onPressed: () async { // isLoading = true; // if (notesController.text.isNotEmpty && // sessionsTopicsData != null) { // print("ADD : ${_selectedFruit}"); // sessionNotesList.add( // "${_selectedFruit} \n\n ${notesController.text}"); // // }); // print( // " eventid:${widget.eventid},hcp:${widget.eventid} session: ${sessionsTopicsData}"); // await provider.submitSessionNotes( // eventsdetail, // sessionsTopicsData!, // notesController.text, // attachedFileName != '' // ? attachedFilePath // : "", // attachedFileName != '' // ? attachedFileName // : "", // ); // //HIVESTORE // SessionNotesModel notesModel = // SessionNotesModel( // notes: notesController.text, // addedBy: "user", // addedDate: // CustomDateFormatter().formatDate(), // eventid: // sessionsTopicsData!.kolEventsId, // hcpid: widget.eventid, // kolid: sessionsTopicsData!.kolId, // event_attendees_id: sessionsTopicsData! // .eventAttendeesId, // kid: eventsdetail.kId, // filepath: attachedFileName != '' // ? attachedFilePath // : "", // filename: attachedFileName != '' // ? attachedFileName // : "", // selectedSession: _selectedFruit); // await provider.addSessionNotes(notesModel); // _selectedFruit = null; // isLoading = false; // sessionsTopicsData = null; // attachedFileName = ""; // notesController.clear(); // isLoading = false; // enableCancel = false; // btnText = "Add Notes"; // setState(() {}); // SnackBarWidget.displaySnackBar( // "Notes added", // context, // ); // } else { // isLoading = false; // SnackBarWidget.displaySnackBar( // "Session/Notes cannot be empty", context, // error: true); // } // }, // width: 100, // height: 35, // fontsize: 12, // textColor: Colors.white, // title: btnText), FloatingActionButton.extended( // backgroundColor: const Color.fromARGB(255, 222, 237, 247), backgroundColor: Colors.green, onPressed: () async { //"Program Committee Admin. & Management" //setState(() { isLoading = true; if (notesController.text.isNotEmpty && sessionsTopicsData != null) { print("ADD : ${_selectedFruit}"); sessionNotesList.add( "${_selectedFruit} \n\n ${notesController.text}"); // }); print( " eventid:${widget.eventid},hcp:${widget.eventid} session: ${sessionsTopicsData}"); await provider.submitSessionNotes( eventsdetail, sessionsTopicsData!, notesController.text, attachedFileName != '' ? attachedFilePath : "", attachedFileName != '' ? attachedFileName : "", ); //HIVESTORE SessionNotesModel notesModel = SessionNotesModel( notes: notesController.text, addedBy: "user", addedDate: CustomDateFormatter().formatDate(), eventid: sessionsTopicsData!.kolEventsId, hcpid: widget.eventid, kolid: sessionsTopicsData!.kolId, event_attendees_id: sessionsTopicsData!.eventAttendeesId, kid: eventsdetail.kId, filepath: attachedFileName != '' ? attachedFilePath : "", filename: attachedFileName != '' ? attachedFileName : "", selectedSession: _selectedFruit); await provider.addSessionNotes(notesModel); _selectedFruit = null; isLoading = false; sessionsTopicsData = null; attachedFileName = ""; notesController.clear(); isLoading = false; enableCancel = false; btnText = "Add Notes"; setState(() {}); SnackBarWidget.displaySnackBar( "Notes added", context, ); } else { isLoading = false; SnackBarWidget.displaySnackBar( "Session/Notes cannot be empty", context, error: true); } }, heroTag: 'addnotes', elevation: 0, label: Text( btnText, style: TextStyle(color: Colors.white), ), // icon: const Icon( // Icons.add, // color: Colors.black, // ), ), ), ), Visibility( visible: isLoading, child: Center( child: CircularProgressIndicator( color: EventsConstants.blueColor, )), ), ], ), ), Padding( padding: const EdgeInsets.only(left: 15.0), child: Visibility( visible: enableCancel, // child: Padding( // padding: EdgeInsets.all(4.0), // child: Text('Cancel', // style: TextStyle( // fontSize: 14, color: EventsConstants.blueColor)), // ), child: OutlinedButton( onPressed: () { enableCancel = false; notesController.clear(); sessionsTopicsData = null; _selectedFruit = ""; btnText = "Add Notes"; setState(() {}); }, style: ButtonStyle( shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0))), ), child: const Text( "Cancel", style: TextStyle(color: Colors.black), ), ), // child: CustomButton( // backgroundColor: Colors.transparent, // onPressed: () async { // enableCancel = false; // notesController.clear(); // sessionsTopicsData = null; // _selectedFruit = ""; // btnText = "Add Notes"; // setState(() {}); // }, // width: 100, // height: 40, // fontsize: 12, // textColor: Colors.black, // title: "Cancel"), // child: TextButton( // style: TextButton.styleFrom( // textStyle: Theme.of(context).textTheme.labelLarge, // ), // child: const Text('Cancel', // style: TextStyle( // fontSize: 14, color: EventsConstants.blueColor)), // onPressed: () { // enableCancel = false; // notesController.clear(); // sessionsTopicsData = null; // _selectedFruit = ""; // btnText = "Add Notes"; // setState(() {}); // }, // ), ), ), ], ), Divider(), Padding( padding: const EdgeInsets.only(left: 15.0), child: Text( "My Notes", style: TextStyle(fontSize: 16), ), ), Divider(), Expanded( //height: 200, child: ListView.separated( padding: EdgeInsets.all(2.0), itemCount: provider.sessionTopics .where((element) => element.canEditNotes == true) .length, itemBuilder: (context, index) { return SizedBox( width: isTablet ? MediaQuery.of(context).size.width * 0.25 : MediaQuery.of(context).size.width * 0.5, child: ListTile( title: Text( "\"${provider.sessionTopics[index].note}\"", // maxLines: 3, style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, //fontFamily: "SourceSerif", color: Colors.black, fontStyle: FontStyle.italic, fontSize: 15), ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( height: 10, ), Text( "Session: ${provider.sessionTopics[index].sessionName}", // maxLines: 3, style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, //fontFamily: "SourceSerif", color: const Color.fromARGB(255, 66, 65, 65), //fontStyle: FontStyle.italic, fontSize: 14), ), CustomButton( backgroundColor: const Color.fromARGB(255, 233, 229, 229), onPressed: () { sessionsTopicsData = provider.sessionTopics[index]; _selectedFruit = provider.sessionTopics[index].sessionName; notesController.text = provider.sessionTopics[index].note ?? ""; if (notesController.text.length != 0) { btnText = "Update"; } enableCancel = true; setState(() {}); }, width: 80, height: 30, fontsize: 12, textColor: Colors.black, title: "Edit"), SizedBox( height: 5, ), // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // Text( // "Added By:me", // // maxLines: 3, // style: TextStyle( // // decoration: TextDecoration.underline, // // decorationColor: Colors.blue, // //fontFamily: "SourceSerif", // color: const Color.fromARGB(255, 66, 65, 65), // //fontStyle: FontStyle.italic, // fontSize: 12), // ), // Text( // "On: ${provider.sessionNotesList[index].addedDate}", // // maxLines: 3, // style: TextStyle( // // decoration: TextDecoration.underline, // // decorationColor: Colors.blue, // //fontFamily: "SourceSerif", // color: const Color.fromARGB(255, 66, 65, 65), // //fontStyle: FontStyle.italic, // fontSize: 12), // ), // ], // ), ], ), ), ); }, separatorBuilder: (context, index) { return Divider(); }, ), ) ], ), ); } Future getEncodedFile() async { String base64Image = ''; var status = Platform.isAndroid ? await Permission.manageExternalStorage.status : await Permission.storage.status; if (status.isGranted) { FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: false); if (result != null) { print(result.files.first.path); print(result.files.last.path); for (var files in result.files) { File file = File(files.path!); print("check file path : ${file.path}"); var fileName = file.path.split('/').last; // Get the application folder directory Directory? directory = Platform.isAndroid ? await getExternalStorageDirectory() //FOR ANDROID : await getApplicationDocumentsDirectory(); String newPath = ""; //FOR ios String convertedDirectoryPath = (directory?.path).toString(); print("see the converted directory path $convertedDirectoryPath"); newPath = "$convertedDirectoryPath/konectar/files"; print("new path :$newPath"); directory = Directory(newPath); if (!await directory.exists()) { await directory.create(recursive: true); } File newFile = await file.copy('${directory.path}/$fileName'); print("new path is ${newFile.path}"); final extension = p.extension(newFile.path); List imageBytes = await newFile.readAsBytes(); Uint8List imageUint8List = Uint8List.fromList(imageBytes); base64Image = base64Encode(imageUint8List); attachedFileName = fileName; attachedFilePath = newFile.path; if (notesController.text == "") { notesController.text = "This attachment is loaded by Vinod Hangal"; } // sectionItem.selectedValue!.add(base64Image); // sectionItem.extension!.add(extension); // sectionItem.fileName!.add(fileName); } } } else { print("not permitted"); await requestPermission(Platform.isAndroid ? Permission.manageExternalStorage : Permission.storage); } } Future requestPermission(Permission permission) async { final status = await permission.request(); setState(() { print(status); // _permissionStatus = status; // print(_permissionStatus); }); } Widget topicsTab( EventSpeakersData eventsdetail, HcpProfileProvider provider) { //print("${eventsdetail.sessionName!.join(",").length} @@@lengtg"); // List sessions = eventsdetail.sessionName!.split(","); return Container( width: double.maxFinite, padding: EdgeInsets.only(left: 8), decoration: BoxDecoration( // color: Color.fromARGB(179, 248, 238, 238), color: EventsConstants.bgcolor, ), child: ListView.separated( padding: EdgeInsets.only(top: 10.0, left: 4.0), itemCount: provider.sessionTopics.length, itemBuilder: (context, index) { List topics = provider.sessionTopics[index].eventTopics!.split('|'); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // Text( // "", // style: TextStyle( // //fontFamily: "SourceSerif", // fontSize: 16, // fontWeight: FontWeight.bold, // ), // //softWrap: true, // overflow: TextOverflow.ellipsis, // ), Text( "${index + 1}.${provider.sessionTopics[index].sessionName}", style: TextStyle( // fontFamily: "SourceSerif", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, ), maxLines: 3, //softWrap: true, ), SizedBox( height: 10, ), SizedBox( width: isTablet ? MediaQuery.of(context).size.width * 0.25 : MediaQuery.of(context).size.width * 0.5, child: Text( "Topics", style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, fontSize: 14, // fontWeight: FontWeight.bold, color: Colors.grey[900], //fontStyle: FontStyle.italic, ), ), ), buildTopicsCard(topics), // SizedBox( // width: isTablet // ? MediaQuery.of(context).size.width * 0.25 // : MediaQuery.of(context).size.width * 0.5, // child: Text( // "${topics.join(" \n ")}", // // maxLines: 3, // style: TextStyle( // // decoration: TextDecoration.underline, // // decorationColor: Colors.blue, // //fontFamily: "SourceSerif", // color: Colors.grey[700], // //fontStyle: FontStyle.italic, // fontSize: 16), // ), // ), ], ); }, separatorBuilder: (context, index) { return Divider(); }, )); } Widget buildTopicsCard(List tags) { return Container( child: Padding( padding: const EdgeInsets.only( top: 8, bottom: 8, ), child: Wrap( runSpacing: 12.0, spacing: 12.0, children: tags.map((String tag) { return Container( constraints: BoxConstraints( // minWidth: MediaQuery.of(context).size.width * 0.34, maxWidth: MediaQuery.of(context).size.width), decoration: BoxDecoration( color: EventsConstants.bgtopic, border: Border.all(color: Colors.grey), borderRadius: BorderRadius.all( Radius.circular(10.0), ), // color: Colors.grey ), margin: const EdgeInsets.symmetric(horizontal: 3.0), padding: const EdgeInsets.symmetric(horizontal: 1.6, vertical: 5.0), child: Text( '$tag', // overflow: TextOverflow.ellipsis, //textWidthBasis: TextWidthBasis.longestLine, // softWrap: false, maxLines: 2, style: TextStyle( overflow: TextOverflow.clip, color: EventsConstants.fonttopic, fontSize: isTablet ? 16 : 14), ), ); }).toList()), ), ); } 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: "${widget.kolFullName}", ))); // 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(), ], ); }), ], ), ); }); } } const _tabs = [ Tab(text: "Sessions"), Tab(text: "Notes"), Tab(text: "Medical Insights"), // Tab(text: "Survey"), ]; class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { _SliverAppBarDelegate(this._tabBar); final TabBar _tabBar; @override double get minExtent => _tabBar.preferredSize.height; @override double get maxExtent => _tabBar.preferredSize.height; @override Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { return Container( color: Colors.white, // decoration: BoxDecoration( // gradient: LinearGradient( // begin: Alignment.bottomCenter, // end: Alignment.topCenter, // colors: [ // // Constants.blueColor, // EventsConstants.tabbgColor, // EventsConstants.blueColor, // // Constants.tabbgColor, // // const Color.fromARGB(255, 222, 237, 247), // // const Color.fromARGB(255, 222, 237, 247), // // Color(0xff006df1) // ]), // ), // color: Colors.white, //249, 103, 49 // color: const Color.fromARGB(255, 239, 71, 49), child: _tabBar); } @override bool shouldRebuild(_SliverAppBarDelegate oldDelegate) { return true; } } class _ProfileInfoRow extends StatelessWidget { List items; _ProfileInfoRow({Key? key, required this.items}) : super(key: key); bool shouldRebuild(_ProfileInfoRow delegate) { return true; } @override Widget build(BuildContext context) { return Container( height: 60, constraints: const BoxConstraints(maxWidth: 400), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: items .map((item) => Expanded( child: Row( children: [ if (items.indexOf(item) != 0) const VerticalDivider(), Expanded(child: _singleItem(context, item)), ], ))) .toList(), ), ), ); } Widget _singleItem(BuildContext context, ProfileInfoItem item) => Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( item.value.toString(), style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 14, ), ), ), Text( item.title, style: Theme.of(context).textTheme.bodyLarge, ) ], ); } class ProfileInfoItem { final String title; final int value; const ProfileInfoItem( this.title, this.value, ); } class _TopPortion extends StatelessWidget { final String title; final Eventsdetail eventsdetail; const _TopPortion({Key? key, required this.title, required this.eventsdetail}) : super(key: key); @override Widget build(BuildContext context) { return Stack( //fit: StackFit.expand, // alignment: Alignment.center, children: [ Align( alignment: Alignment.topCenter, child: Container( margin: const EdgeInsets.only(bottom: 30), decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.bottomCenter, end: Alignment.topCenter, colors: [ EventsConstants.blueColor, EventsConstants.blueColor, EventsConstants.blueColor, // const Color.fromARGB(255, 222, 237, 247), // const Color.fromARGB(255, 222, 237, 247), // Color(0xff006df1) ]), // borderRadius: BorderRadius.only( // bottomLeft: Radius.circular(20), // bottomRight: Radius.circular(20), // ) ), child: Align( alignment: Alignment.topCenter, child: Column( children: [ SizedBox( height: 15, ), Text(eventsdetail.kolFullName!, style: TextStyle( fontSize: 20, // fontFamily: "SourceSerif", color: Colors.white, fontWeight: FontWeight.bold)), Text("Hematology/Oncology", style: TextStyle( color: Colors.white, // fontFamily: "SourceSerif", )), Text( "${eventsdetail.orgName ?? ""} ${eventsdetail.country ?? ""} ${eventsdetail.city ?? ""}", softWrap: true, maxLines: 2, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, // fontFamily: "SourceSerif", fontSize: 12, )), ], ), ), ), ), Positioned( bottom: -30, child: CircleAvatar( radius: 20, backgroundColor: Theme.of(context).scaffoldBackgroundColor, child: Container( margin: const EdgeInsets.all(8.0), decoration: const BoxDecoration( color: Colors.green, shape: BoxShape.circle), ), ), ), // Align( // alignment: Alignment.bottomCenter, // child: SizedBox( // width: 120, // height: 120, // child: Stack( // fit: StackFit.expand, // children: [ // BorderedCircleAvatar( // // radius: 24, // backgroundColor: Colors.grey, // border: BorderSide(color: Colors.white), // // child: Icon( // // Icons.person, // // size: 18, // // color: Colors.white, // // ), // child: Text( // title[0], // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 34, // color: Colors.white), // ), // ), // Container( // decoration: const BoxDecoration( // color: Colors.black, // shape: BoxShape.circle, // image: DecorationImage( // fit: BoxFit.cover, // image: NetworkImage( // 'https://cardio-staging.konectar.io/images/kol_images/resized/1093755944.jpeg')), // // 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80')), // ), // ), // Positioned( // bottom: 0, // right: 0, // child: CircleAvatar( // radius: 20, // backgroundColor: Theme.of(context).scaffoldBackgroundColor, // child: Container( // margin: const EdgeInsets.all(8.0), // decoration: const BoxDecoration( // color: Colors.green, shape: BoxShape.circle), // ), // ), // ), // ], // ), //), // ) ], ); } }