From 926210f74fd7265a0d2257d750f61465796019df Mon Sep 17 00:00:00 2001 From: "snehalathad@aissel.com" Date: Mon, 9 Dec 2024 14:35:56 +0530 Subject: [PATCH] session notes crud,insights client specific ,updates --- assets/interactionform.json | 1 + assets/medicalinsightform.json | 2 + .../model/interaction_data.dart | 7 + .../interactionform/new_dynamicform.dart | 1 + .../viewinteractionprovider.dart | 2 +- lib/model/affiliationsmodel.dart | 76 +-- lib/model/allsessionnotesmodel.dart | 96 +++ lib/model/events_details.dart | 29 +- lib/model/hive_api_constants.dart | 12 + lib/model/sessionstopics_model.dart | 15 +- lib/model/specialtymodel.dart | 10 +- lib/model/topics_cloud_model.dart | 28 + lib/utils/apicall.dart | 298 +++++---- lib/utils/constants.dart | 18 +- lib/utils/hivetypeids.dart | 1 + lib/view/eventslist.dart | 56 +- lib/view/home.dart | 46 +- lib/view/insights.dart | 575 ++++++++++-------- lib/view/login.dart | 198 +++--- lib/view/login_components/intropaging.dart | 4 +- lib/view/profileview.dart | 355 ++++++++--- lib/viewmodel/eventsprovider.dart | 76 ++- lib/viewmodel/hcpprofprovider.dart | 59 +- lib/widgets/chartline.dart | 10 +- lib/widgets/snackbar.dart | 9 +- pubspec.lock | 8 + pubspec.yaml | 1 + 27 files changed, 1325 insertions(+), 668 deletions(-) create mode 100644 lib/model/allsessionnotesmodel.dart create mode 100644 lib/model/hive_api_constants.dart diff --git a/assets/interactionform.json b/assets/interactionform.json index dde4f61..07943d0 100644 --- a/assets/interactionform.json +++ b/assets/interactionform.json @@ -3,6 +3,7 @@ { "id": "Form1", "name": "Interaction Form", + "form-fields": [ { "sectionName": "Interaction Details", diff --git a/assets/medicalinsightform.json b/assets/medicalinsightform.json index 76af1c9..cca501e 100644 --- a/assets/medicalinsightform.json +++ b/assets/medicalinsightform.json @@ -3,7 +3,9 @@ { "id": "MedInsight", "name": "Medical Insights Form", + "form-fields": [ + { "sectionName": "Medical Insight", "multiple": false, diff --git a/lib/contacts_module/ui_screen/interactionform/model/interaction_data.dart b/lib/contacts_module/ui_screen/interactionform/model/interaction_data.dart index 3e1140c..d2baad3 100644 --- a/lib/contacts_module/ui_screen/interactionform/model/interaction_data.dart +++ b/lib/contacts_module/ui_screen/interactionform/model/interaction_data.dart @@ -6,6 +6,8 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; +import 'package:konectar_events/widgets/eventdetailscontainer.dart'; +import 'package:konectar_events/widgets/gridview.dart'; part 'interaction_data.g.dart'; // InteractionResultData welcomeFromJson(String str) => @@ -43,6 +45,11 @@ class InteractionResultData { String id; @HiveField(2) String name; + + //For MEd Insight required fields to send for syncing this data + //eventid,speakerid,session name,... + //For Int required fields to send for syncing this data + //hcpid,medin id ,/..... InteractionResultData( {required this.result, required this.id, required this.name}); diff --git a/lib/contacts_module/ui_screen/interactionform/new_dynamicform.dart b/lib/contacts_module/ui_screen/interactionform/new_dynamicform.dart index 0f28f25..f379d97 100644 --- a/lib/contacts_module/ui_screen/interactionform/new_dynamicform.dart +++ b/lib/contacts_module/ui_screen/interactionform/new_dynamicform.dart @@ -36,6 +36,7 @@ class InteractionScreen1 extends StatefulWidget { int index; String form; String? title; + dynamic formdata; InteractionScreen1( {super.key, required this.index, required this.form, this.title}); diff --git a/lib/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart b/lib/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart index 8f71e9c..ef0861f 100644 --- a/lib/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart +++ b/lib/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart @@ -853,7 +853,7 @@ class ViewInteractionProvider extends ChangeNotifier { await getRecords(saveInteraction.form!); // box.close(); - // await MockApiCall().postFormData(data); + /// await MockApiCall().postFormData(data); } Future deleteRecord(SaveInteraction saveInteraction) async { diff --git a/lib/model/affiliationsmodel.dart b/lib/model/affiliationsmodel.dart index b590f60..5f5f2a0 100644 --- a/lib/model/affiliationsmodel.dart +++ b/lib/model/affiliationsmodel.dart @@ -47,54 +47,54 @@ class AffiliationsResp { }; } -List affiliationsFromJson(String str) => List.from( - json.decode(str).map((x) => Affiliations.fromJson(x))); +Affiliations affiliationsResponseFromJson(String str) => + Affiliations.fromJson(json.decode(str)); -String affiliationsToJson(List data) => - json.encode(List.from(data.map((x) => x.toJson()))); - -class Affiliations { - String? id; - String? orgCount; - String? orgName; - - Affiliations({ - this.id, - this.orgCount, - this.orgName, - }); - - factory Affiliations.fromJson(Map json) => Affiliations( - id: json["id"], - orgCount: json["org_count"], - orgName: json["org_name"], - ); - - Map toJson() => { - "id": id, - "org_count": orgCount, - "org_name": orgName, - }; -} +String affiliationsResponseToJson(Affiliations data) => + json.encode(data.toJson()); // class Affiliations { -// List affiliationNames; -// List affiliationCount; +// String? id; +// String? orgCount; +// String? orgName; // Affiliations({ -// required this.affiliationNames, -// required this.affiliationCount, +// this.id, +// this.orgCount, +// this.orgName, // }); // factory Affiliations.fromJson(Map json) => Affiliations( -// affiliationNames: -// List.from(json["affiliationNames"].map((x) => x)), -// affiliationCount: -// List.from(json["affiliationCount"].map((x) => x)), +// id: json["id"], +// orgCount: json["org_count"], +// orgName: json["org_name"], // ); // Map toJson() => { -// "affiliationNames": List.from(affiliationNames.map((x) => x)), -// "affiliationCount": List.from(affiliationCount.map((x) => x)), +// "id": id, +// "org_count": orgCount, +// "org_name": orgName, // }; // } + +class Affiliations { + List affiliationNames; + List affiliationCount; + + Affiliations({ + required this.affiliationNames, + required this.affiliationCount, + }); + + factory Affiliations.fromJson(Map json) => Affiliations( + affiliationNames: + List.from(json["affiliationNames"].map((x) => x)), + affiliationCount: + List.from(json["affiliationCount"].map((x) => x)), + ); + + Map toJson() => { + "affiliationNames": List.from(affiliationNames.map((x) => x)), + "affiliationCount": List.from(affiliationCount.map((x) => x)), + }; +} diff --git a/lib/model/allsessionnotesmodel.dart b/lib/model/allsessionnotesmodel.dart new file mode 100644 index 0000000..2815f87 --- /dev/null +++ b/lib/model/allsessionnotesmodel.dart @@ -0,0 +1,96 @@ +// To parse this JSON data, do +// +// final allSessionNotesResponse = allSessionNotesResponseFromJson(jsonString); + +import 'dart:convert'; + +String allSessionNotesResponseToJson(List data) => + json.encode(List.from(data.map((x) => x.toJson()))); + +List AllSessionNotesResponseFromJson(String str) { + final jsonData = json.decode(str); + return new List.from( + jsonData.map((x) => AllSessionNotesResponse.fromJson(x))); +} + +class AllSessionNotesResponse { + List>? eventTopicNotesId; + String? note; + String? sessionName; + String? eventTopics; + String? userName; + String? users; + List? notes; + List? createdOn; + String? firstName; + String? middleName; + String? lastName; + DateTime? notesCreatedOn; + List? addedBy; + + AllSessionNotesResponse({ + this.eventTopicNotesId, + this.note, + this.sessionName, + this.eventTopics, + this.userName, + this.users, + this.notes, + this.createdOn, + this.firstName, + this.middleName, + this.lastName, + this.notesCreatedOn, + this.addedBy, + }); + + factory AllSessionNotesResponse.fromJson(Map json) => + AllSessionNotesResponse( + eventTopicNotesId: json["event_topic_notes_id"] == null + ? [] + : List>.from(json["event_topic_notes_id"]! + .map((x) => List.from(x.map((x) => x)))), + note: json["note"], + sessionName: json["session_name"], + eventTopics: json["event_topics"], + userName: json["user_name"]!, + users: json["users"], + notes: json["notes"] == null + ? [] + : List.from(json["notes"]!.map((x) => x)), + createdOn: json["created_on"] == null + ? [] + : List.from(json["created_on"]!.map((x) => x)), + firstName: json["first_name"], + middleName: json["middle_name"], + lastName: json["last_name"], + notesCreatedOn: json["notes_created_on"] == null + ? null + : DateTime.parse(json["notes_created_on"]), + addedBy: json["added_by"] == null + ? [] + : List.from(json["added_by"]!.map((x) => x)), + ); + + Map toJson() => { + "event_topic_notes_id": eventTopicNotesId == null + ? [] + : List.from(eventTopicNotesId! + .map((x) => List.from(x.map((x) => x)))), + "note": note, + "session_name": sessionName, + "event_topics": eventTopics, + "user_name": userName, + "users": users, + "notes": notes == null ? [] : List.from(notes!.map((x) => x)), + "created_on": createdOn == null + ? [] + : List.from(createdOn!.map((x) => x)), + "first_name": firstName, + "middle_name": middleName, + "last_name": lastName, + "notes_created_on": notesCreatedOn?.toIso8601String(), + "added_by": + addedBy == null ? [] : List.from(addedBy!.map((x) => x)), + }; +} diff --git a/lib/model/events_details.dart b/lib/model/events_details.dart index 9667a3e..144e1ce 100644 --- a/lib/model/events_details.dart +++ b/lib/model/events_details.dart @@ -40,7 +40,7 @@ class EventsOverviewData { String? eventFor; String? eventId; List? topSpeakers; - dynamic eventTopics; + List? eventTopics; List? eventSponsers; bool? eventUserAttendee; bool? eventUserInterest; @@ -73,8 +73,11 @@ class EventsOverviewData { ? [] : List.from( json["eventData"]!.map((x) => TopSpeakers.fromJson(x))), - eventTopics: json["eventTopics"], - eventSponsers: json["eventSponsers"] == null + eventTopics: json["eventTopics"] == null + ? [] + : List.from( + json["eventTopics"]!.map((x) => EventTopic.fromJson(x))), + eventSponsers: json["eventTopics"] == null ? [] : List.from( json["eventSponsers"]!.map((x) => EventSponser.fromJson(x))), @@ -297,6 +300,26 @@ class ArrEvent { }; } +class EventTopic { + String? numTopics; + String? eventTopics; + + EventTopic({ + this.numTopics, + this.eventTopics, + }); + + factory EventTopic.fromJson(Map json) => EventTopic( + numTopics: json["num_topics"], + eventTopics: json["event_topics"], + ); + + Map toJson() => { + "num_topics": numTopics, + "event_topics": eventTopics, + }; +} + @HiveType(typeId: HiveTypeIdConstants.topspeakersHiveId) class TopSpeakers { @HiveField(0) diff --git a/lib/model/hive_api_constants.dart b/lib/model/hive_api_constants.dart new file mode 100644 index 0000000..37abcc6 --- /dev/null +++ b/lib/model/hive_api_constants.dart @@ -0,0 +1,12 @@ +import 'package:hive_flutter/hive_flutter.dart'; +import 'package:konectar_events/utils/hivetypeids.dart'; + +@HiveType(typeId: HiveTypeIdConstants.hiveApiConstantsId) +class HiveApiConstants { + @HiveField(0) + String? functionName; + @HiveField(1) + int? interval; + + HiveApiConstants({this.functionName, this.interval}); +} diff --git a/lib/model/sessionstopics_model.dart b/lib/model/sessionstopics_model.dart index cd9dc33..7cd4846 100644 --- a/lib/model/sessionstopics_model.dart +++ b/lib/model/sessionstopics_model.dart @@ -10,6 +10,19 @@ SessionTopicsResponse sessionTopicsResponseFromJson(String str) => String sessionTopicsResponseToJson(SessionTopicsResponse data) => json.encode(data.toJson()); +List showSessionNotesResponseFromJson(String str) => + List.from( + json.decode(str).map((x) => SessionsTopicsData.fromJson(x))); + +String showSessionNotesResponseToJson(List data) => + json.encode(List.from(data.map((x) => x.toJson()))); + +List SessionsTopicsDataFromJson(String str) { + final jsonData = json.decode(str); + return new List.from( + jsonData.map((x) => SessionsTopicsData.fromJson(x))); +} + class SessionTopicsResponse { List? data; @@ -44,7 +57,7 @@ class SessionsTopicsData { bool? canEditNotes; bool? canAddNotes; String? noteCount; - String? projKolId; + dynamic projKolId; bool? canAddInsights; bool? canEditInsights; diff --git a/lib/model/specialtymodel.dart b/lib/model/specialtymodel.dart index 8034a6f..4a6b34e 100644 --- a/lib/model/specialtymodel.dart +++ b/lib/model/specialtymodel.dart @@ -46,12 +46,18 @@ class Specialtyresp { }; } -List specialtyFromJson(String str) => - List.from(json.decode(str).map((x) => Specialty.fromJson(x))); +// List specialtyFromJson(String str) => +// List.from(json.decode(str).map((x) => Specialty.fromJson(x))); +// List.from(json.decode(str).map((x) => AllSessionNotesResponse.fromJson(x))); String specialtyToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); +List specialtyFromJson(String str) { + final jsonData = json.decode(str); + return new List.from(jsonData.map((x) => Specialty.fromJson(x))); +} + class Specialty { String? specialtyCount; String? specialtyName; diff --git a/lib/model/topics_cloud_model.dart b/lib/model/topics_cloud_model.dart index 2848079..e6decf1 100644 --- a/lib/model/topics_cloud_model.dart +++ b/lib/model/topics_cloud_model.dart @@ -61,6 +61,34 @@ List topicsCloudDataFromJson(String str) => String topicsCloudDataToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); +TopicCloudResponse topicCloudResponseFromJson(String str) => + TopicCloudResponse.fromJson(json.decode(str)); + +String topicCloudResponseToJson(TopicCloudResponse data) => + json.encode(data.toJson()); + +class TopicCloudResponse { + List? resultData; + + TopicCloudResponse({ + this.resultData, + }); + + factory TopicCloudResponse.fromJson(Map json) => + TopicCloudResponse( + resultData: json["resultData"] == null + ? [] + : List.from( + json["resultData"]!.map((x) => TopicsCloudData.fromJson(x))), + ); + + Map toJson() => { + "resultData": resultData == null + ? [] + : List.from(resultData!.map((x) => x.toJson())), + }; +} + class TopicsCloudData { String? total; String? topic; diff --git a/lib/utils/apicall.dart b/lib/utils/apicall.dart index e2cef62..0c5f2cb 100644 --- a/lib/utils/apicall.dart +++ b/lib/utils/apicall.dart @@ -1,10 +1,12 @@ import 'dart:convert'; +import 'dart:ffi'; import 'dart:io'; import 'package:dio/dio.dart'; import 'package:dio/io.dart'; import 'package:flutter/services.dart'; import 'package:konectar_events/model/affiliationsmodel.dart'; +import 'package:konectar_events/model/allsessionnotesmodel.dart'; import 'package:konectar_events/model/events_details.dart'; import 'package:konectar_events/model/events_list_resp_2.dart'; import 'package:konectar_events/model/events_speakers_k1.dart'; @@ -104,7 +106,7 @@ class ApiCall { return keywordList; } - Future> getEventsFromK1({String? type}) async { + Future> getEventsFromK1({int? type}) async { Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -115,24 +117,24 @@ class ApiCall { Response response; var formData = FormData.fromMap({ "user_email": "vinodh@aissel.com", - "project_id": "", - "start": DateTime(2024, 10, 14).toIso8601String(), - "end": DateTime(2024, 12, 14).toIso8601String(), - "order_by": 7, - "type": type ?? 1 + "start": "2024-12-05", + "end": "2024-12-31", + "order_by": 8, + 'type': type ?? 1 }); - response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.eventslistapi}', - options: Options(), - // queryParameters: { - // "user_email": "vinodh@aissel.com", - // "project_id": "", - // "start": 2024 - 11 - 22, - // "end": "", - // "order_by": 7, - // "type": 1, - // }, - data: formData); + // "end": DateTime(2024, 12, 14).toIso8601String(), + response = + await dio.post('${EventsConstants.url}${EventsConstants.eventslistapi}', + options: Options(), + // queryParameters: { + // "user_email": "vinodh@aissel.com", + // "project_id": "", + // "start": 2024 - 11 - 22, + // "end": "", + // "order_by": 7, + // "type": 1, + // }, + data: formData); print("response user eventssssss here!!!!!!!!!!!!!!!!!!!!! "); print(response.data.toString()); Map jsondata = json.decode(response.data); @@ -154,7 +156,7 @@ class ApiCall { var formData = FormData.fromMap( {"user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag}); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.followUnfollowEvent}', + '${EventsConstants.url}${EventsConstants.followUnfollowEvent}', options: Options(), queryParameters: { "user_email": "vinodh@aissel.com", @@ -180,7 +182,7 @@ class ApiCall { var formData = FormData.fromMap( {"user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag}); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.attendNotAttendEvent}', + '${EventsConstants.url}${EventsConstants.attendNotAttendEvent}', options: Options(), queryParameters: { "user_email": "vinodh@aissel.com", @@ -198,8 +200,10 @@ class ApiCall { required String eventid, required String startDate, required String endDate, + required bool client, }) async { - print("CHECK_DATE $startDate $endDate $eventid"); + print( + "FORMAT_CHECK_DATE $startDate $endDate $eventid ${DateTime(2024, 12, 03).toIso8601String()}"); Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -209,39 +213,48 @@ class ApiCall { }; Response response; //ventId=4937&type='1'&sd=2024-07-30&ed=2024-08-03&user_email=vinodh@aissel.com - var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": startDate, - "ed": endDate, - "type": 1, - }); + var formData; + if (client) { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + "type": 1, + "chart_type": "client" + }); + } else { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + }); + } + print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.specialtyOfSpeakers}', + '${EventsConstants.url}${EventsConstants.specialtyOfSpeakers}', options: Options(), - queryParameters: { - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": "\"$startDate\"", - "ed": "\"$endDate\"", - "type": "\"1\"", - }, data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); + // Map jsondata = json.decode(response.data); // Specialtyresp resp = Specialtyresp.fromJson(jsondata); - List data = specialtyFromJson(response.data); - return data; + List sdata = []; + if (response.data != "null") { + print(response.data.toString()); + sdata = specialtyFromJson(response.data.toString()); + } + return sdata; } - Future> insightsTopicsCloud({ - required String eventid, - required String startDate, - required String endDate, - }) async { + Future> insightsTopicsCloud( + {required String eventid, + required String startDate, + required String endDate, + required bool client}) async { Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -250,39 +263,50 @@ class ApiCall { return client; }; Response response; - var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": "\"$startDate\"", - "ed": "\"$endDate\"", - "type": "\"1\"", - }); + var formData; + if (client) { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + "type": 1, + "chart_type": "client" + }); + } else { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + }); + } + print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.insightsTopicsCloud}', + '${EventsConstants.url}${EventsConstants.insightsTopicsCloud}', options: Options(), - queryParameters: { - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": "\"$startDate\"", - "ed": "\"$endDate\"", - "type": "\"1\"", - }, data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); + // Map jsondata = json.decode(response.data); // Specialtyresp resp = Specialtyresp.fromJson(jsondata); - List data = topicsCloudDataFromJson(response.data); + List data = []; + if (response.data != "null") { + print(response.data.toString()); + TopicCloudResponse topicCloudResponse = + topicCloudResponseFromJson(response.data); + data = topicCloudResponse.resultData!; + } return data; } - Future> insightsBarChart({ - required String eventid, - required String startDate, - required String endDate, - }) async { + Future insightsBarChart( + {required String eventid, + required String startDate, + required String endDate, + required bool client}) async { Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -291,31 +315,41 @@ class ApiCall { return client; }; Response response; - var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": "\"$startDate\"", - "ed": "\"$endDate\"", - "type": "\"1\"", - }); + var formData; + if (client) { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + "type": 1, + "chart_type": "client" + }); + } else { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "eventId": eventid, + "sd": startDate, + "ed": endDate, + }); + } + print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.insightsBarChart}', + '${EventsConstants.url}${EventsConstants.insightsBarChart}', options: Options(), - queryParameters: { - "user_email": "vinodh@aissel.com", - "eventId": eventid, - "sd": "\"$startDate\"", - "ed": "\"$endDate\"", - "type": "\"1\"", - }, data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); + // Map jsondata = json.decode(response.data); // Specialtyresp resp = Specialtyresp.fromJson(jsondata); - List data = affiliationsFromJson(response.data); + Affiliations data = + Affiliations(affiliationCount: [], affiliationNames: []); + if (response.data != "null") { + print(response.data.toString()); + data = affiliationsResponseFromJson(response.data); + } return data; } @@ -334,7 +368,7 @@ class ApiCall { "event_id": eventid, }); response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.eventdetailsapi}', + '${EventsConstants.url}${EventsConstants.eventdetailsapi}', options: Options(), queryParameters: { "user_email": "vinodh@aissel.com", @@ -363,11 +397,12 @@ class ApiCall { var formData = FormData.fromMap({ "user_email": "vinodh@aissel.com", "event_id": eventid, - "sd": "2024-07-30", - "ed": "2024-08-03", + "project_id": 1, }); + // "sd": "2024-07-30", + // "ed": "2024-08-03", response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.speakerslistapi}', + '${EventsConstants.url}${EventsConstants.speakerslistapi}', options: Options(), queryParameters: { "user_email": "vinodh@aissel.com", @@ -396,13 +431,13 @@ class ApiCall { print("formdata : eventid:$eventid kolid:$kolid kid:$kid"); var formData = FormData.fromMap({ "user_email": "vinodh@aissel.com", - "event_id": "eventid", + "event_id": eventid, "kol_id": kolid, "k_id": kid, - "proj_kol_id": 0, }); + // "proj_kol_id": 0, response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.showEventsTopicsAndSession}', + '${EventsConstants.url}${EventsConstants.showEventsTopicsAndSession}', options: Options(), queryParameters: { "user_email": "vinodh@aissel.com", @@ -411,16 +446,24 @@ class ApiCall { data: formData); print("response user SESSIONTOPICS here!!!!!!!!!!!!!!!!!!!!! "); print(response.data.toString()); - Map jsondata = json.decode(response.data); - SessionTopicsResponse sessionTopicsResponse = - SessionTopicsResponse.fromJson(jsondata); - List data = sessionTopicsResponse.data!; + // Map jsondata = json.decode(response.data)[0]; + // SessionTopicsResponse sessionTopicsResponse = + // SessionTopicsResponse.fromJson(jsondata); + List data = + SessionsTopicsDataFromJson(response.data.toString()); return data; } - Future addSessionNotes(String eventid, String kolid, - String event_attendees_id, String kid, String notes) async { + Future addSessionNotes( + String eventid, + String kolid, + String event_attendees_id, + String kid, + String notes, + String? filepath, + String? filename, + String? noteId) async { Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -428,16 +471,32 @@ class ApiCall { (X509Certificate cert, String host, int port) => true; return client; }; + var formData; Response response; - var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", - "kol_events_id": eventid, - "kol_id": kolid, - "event_attendees_id": event_attendees_id, - "notes": notes, - }); + if (filename != "") { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "kol_events_id": eventid, + "kol_id": kolid, + "event_attendees_id": event_attendees_id, + "note": notes, + "file": MultipartFile.fromFileSync(filepath!, filename: filename), + "id": noteId ?? "", + }); + } else { + formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "kol_events_id": eventid, + "kol_id": kolid, + "event_attendees_id": event_attendees_id, + "note": notes, + "id": noteId ?? "", + }); + } + // "/Users/aissel/Library/Developer/CoreSimulator/Devices/1E435121-7E65-45C6-9E0B-411C8B9915F5/data/Containers/Data/Application/3CBC1CFF-79AD-49FA-A6E0-13D0AA2959D2/tmp/Flutter Questionaire.pdf", + response = await dio.post( - '${EventsConstants.devUrl}${EventsConstants.showEventsTopicsAndSession}', + '${EventsConstants.url}${EventsConstants.saveEventsTopicNote}', options: Options(), data: formData); print("response user ADDSESSION here!!!!!!!!!!!!!!!!!!!!! "); @@ -450,6 +509,37 @@ class ApiCall { return jsondata; } + Future> getAllSessionNotes( + String eventid) async { + Dio dio = Dio(); + (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = + (HttpClient client) { + client.badCertificateCallback = + (X509Certificate cert, String host, int port) => true; + return client; + }; + Response response; + + var formData = FormData.fromMap({ + "user_email": "vinodh@aissel.com", + "kol_events_id": eventid, + }); + // "proj_kol_id": 0, + response = await dio.post( + '${EventsConstants.url}${EventsConstants.eventUserAnalytics}', + options: Options(), + data: formData); + print("response user ALLSESSIONNOTES here!!!!!!!!!!!!!!!!!!!!! "); + List data = []; + if (response.data != "null") { + print(response.data.toString()); + // Map jsondata = json.decode(response.data)[0]; + // SessionTopicsResponse sessionTopicsResponse = + // SessionTopicsResponse.fromJson(jsondata); + data = AllSessionNotesResponseFromJson(response.data.toString()); + } + return data; + } //************ K2 API CALLS *********************************************************************************************************************************** Future> getEventsFromK2(int page, String search, diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index c859ef1..f8f24fc 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -22,7 +22,9 @@ class EventsConstants { // 192.168.2.109:8007 - office //K1 API~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static const String stagingUrl = - "https://cardio-staging.konectar.io/reports/"; + "https://cardio-staging.konectar.io/eventapis/"; + static const String url = stagingUrl; + static const String devUrl = "http://192.168.2.130/konectar-sandbox/eventapis/"; static const String eventslistapi = "loadFutureEvents/"; @@ -38,6 +40,20 @@ class EventsConstants { static const String saveEventsTopicNote = "saveEventsTopicNote"; static const String eventUserAnalytics = "eventUserAnalytics"; +//Hive +/* +{ +{ +name:"loadFutureEvents", +interval:5, +method:POST, +} +"saveUserInterestedEvent", +"getSpecialitiesDonutChart", + + +} +*/ //K1 API END~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static const String eventslistapifromk2 = "http://192.168.2.130:8888/api/kolevents/v1/en/fetch"; diff --git a/lib/utils/hivetypeids.dart b/lib/utils/hivetypeids.dart index 8994e0a..2a727b1 100644 --- a/lib/utils/hivetypeids.dart +++ b/lib/utils/hivetypeids.dart @@ -2,4 +2,5 @@ class HiveTypeIdConstants { static const int topspeakersHiveId = 103; static const int topSponsorsHiveId = 104; static const int topTopicsHiveId = 105; + static const int hiveApiConstantsId = 106; } diff --git a/lib/view/eventslist.dart b/lib/view/eventslist.dart index d62b30e..1d9769a 100644 --- a/lib/view/eventslist.dart +++ b/lib/view/eventslist.dart @@ -1,3 +1,4 @@ +import 'package:expandable/expandable.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -39,7 +40,7 @@ class EventsListingScreen extends StatefulWidget { class _EventsListingScreenState extends State with TickerProviderStateMixin { - late final TabController _tabController; + late final TabController tabController; int itemcount = 3; bool isExtended = false; bool isExtendedInterested = false; @@ -49,14 +50,17 @@ class _EventsListingScreenState extends State static const _pageSize = 20; int lastIndex = 0; String searchSpeaker = ""; + bool isClientOverview = false; + bool isLoading = true; @override void initState() { super.initState(); - _tabController = TabController(length: 2, vsync: this); + tabController = TabController(length: 2, vsync: this); final provider = Provider.of(context, listen: false); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { init(); + isLoading = false; }); pagingController.addPageRequestListener((pageKey) { _fetchPages(pageKey, provider); @@ -108,7 +112,7 @@ class _EventsListingScreenState extends State Future _fetchPages(int pageKey, EventsProvider provider) async { List list = await provider - .getInitialSpeakersDetails("47336", searchkey: searchSpeaker); + .getInitialSpeakersDetails(widget.event.id!, searchkey: searchSpeaker); print("CHECK LENGTH ${list.length}"); final isLastPage = pageKey + _pageSize >= list.length; final nextItems = @@ -137,24 +141,32 @@ class _EventsListingScreenState extends State // await Provider.of(context, listen: false) // .getTopicsCloud(widget.event); print("FIRST INITIAL"); - await Provider.of(context, listen: false) - .getInitialSpeakersDetails(widget.event.id!, searchkey: searchSpeaker); - Provider.of(context, listen: false).getSessionCount(); await Provider.of(context, listen: false) .getOverviewData(widget.event.id!, start, end); + await Provider.of(context, listen: false) + .getInitialSpeakersDetails(widget.event.id!, searchkey: searchSpeaker); + await Provider.of(context, listen: false).getSessionCount(); + await Provider.of(context, listen: false) + .getTopicsCloud(widget.event); await Provider.of(context, listen: false) .getSpecialtyData(widget.event); await Provider.of(context, listen: false) .getAffiliations(widget.event); - + await Provider.of(context, listen: false) + .getAllSessionNotesFromApi(widget.event.id!); + Provider.of(context, listen: false).isLoadingInsights = + false; setState(() {}); } @override void dispose() { - _tabController.dispose(); + tabController.dispose(); pagingController.dispose(); + Provider.of(context, listen: false).allSessionNotes.clear(); + widget.event = EventsList(); + super.dispose(); } @@ -771,18 +783,31 @@ class _EventsListingScreenState extends State children: [ expandableDetails(provider), speakersList(context, provider), + EventsInsights( + eid: widget.event.id!, + eventsdetail: widget.event, eventid: widget.event.eventId!, kFlutterHashtags: provider.kFlutterHashtags, specialtyList: provider.specialtyList, affiliations: provider.affiliations, + allSessionNotes: provider.allSessionNotes, ), + // medicalInsights(), //SocialMedia(), ], ), ), ), + Visibility( + visible: isLoading, + child: Center( + child: CircularProgressIndicator( + backgroundColor: EventsConstants.blueColor, + ), + ), + ), ], ), ), @@ -1512,13 +1537,18 @@ class _EventsListingScreenState extends State List topSponsors = []; List topTopics = []; - if (provider.overviewData!.topSpeakers!.length != 0) { - for (var obj in provider.overviewData!.topSpeakers!) { - topSpeakers.add(obj.firstName!); + if (provider.overviewData.eventTopics!.length != 0) { + for (var obj in provider.overviewData.eventTopics!) { + topTopics.add(obj.eventTopics ?? "-"); } } - if (provider.overviewData!.eventSponsers!.length != 0) { - for (var obj in provider.overviewData!.eventSponsers!) { + if (provider.overviewData.topSpeakers!.length != 0) { + for (var obj in provider.overviewData.topSpeakers!) { + topSpeakers.add(obj.firstName ?? "-"); + } + } + if (provider.overviewData.eventSponsers!.length != 0) { + for (var obj in provider.overviewData.eventSponsers!) { topSponsors.add(obj.sessionSponsor!); } } diff --git a/lib/view/home.dart b/lib/view/home.dart index b9b759e..aa4846b 100644 --- a/lib/view/home.dart +++ b/lib/view/home.dart @@ -1517,10 +1517,10 @@ class _HomeScreenState extends State with TickerProviderStateMixin { )); }, child: Card( - elevation: 4, - //color: EventsConstants.homeCardBackgound, - surfaceTintColor: Colors.white, - //surfaceTintColor: EventsConstants.homeCardBackgound, + //elevation: 4, + color: EventsConstants.homeCardBackgound, + //surfaceTintColor: Colors.white, + surfaceTintColor: EventsConstants.homeCardBackgound, // shadowColor: Constants.bgcolor, child: buildCardView(context, eventsList, provider), ), @@ -1571,12 +1571,20 @@ class _HomeScreenState extends State with TickerProviderStateMixin { // Build each card in the grid view. return InkWell( onTap: () { - Navigator.of(context, rootNavigator: true) - .push(MaterialPageRoute( - builder: (context) => EventsTab( - event: provider.eventList[index], - ), - )); + if (provider.eventList[index].sessionName != "") { + Navigator.of(context, rootNavigator: true) + .push(MaterialPageRoute( + builder: (context) => EventsTab( + event: provider.eventList[index], + ), + )); + } else { + //Alert + Alert( + data: "Data for the ", + onPressed: () {}, + ); + } // Navigator.of(context).push(new MaterialPageRoute( // builder: (BuildContext context) { // return new EventsTab(); @@ -1599,8 +1607,8 @@ class _HomeScreenState extends State with TickerProviderStateMixin { buildCardView( BuildContext context, EventsList event, EventsProvider provider) { - print( - "CHECK EVENT INTERESTED : ${provider.checkIfUserInterested(event.eventId!)}}"); + // print( + // "CHECK EVENT INTERESTED : ${provider.checkIfUserInterested(event.eventId ?? "")}}"); double height = isTablet ? MediaQuery.of(context).size.height * 0.35 : MediaQuery.of(context).size.height * 0.65; @@ -1610,14 +1618,14 @@ class _HomeScreenState extends State with TickerProviderStateMixin { decoration: BoxDecoration( // color: Color.fromARGB(179, 248, 238, 238), - color: Colors.white, - // color: EventsConstants.homeCardBackgound, + // color: Colors.white, + color: EventsConstants.homeCardBackgound, borderRadius: BorderRadius.all(Radius.circular(20))), // height: MediaQuery.of(context).size.height * 0.2, // height: 136, // height: double.minPositive, padding: isTablet - ? EdgeInsets.symmetric(horizontal: 8.0, vertical: 2.0) + ? EdgeInsets.symmetric(horizontal: 12.0, vertical: 12.0) : EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0), child: // Column( @@ -1657,7 +1665,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { // decorationColor: Colors.blue, color: Colors.black, fontWeight: FontWeight.bold, - fontSize: isTablet ? 22 : 16, + fontSize: isTablet ? 18 : 16, // fontFamily: "SourceSerif", ), @@ -1695,7 +1703,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { style: TextStyle( color: Colors.black, //fontStyle: FontStyle.italic, - fontSize: isTablet ? 20 : 12), + fontSize: isTablet ? 16 : 12), ), ], ), @@ -1717,7 +1725,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { color: Colors.black, //fontStyle: FontStyle.italic, - fontSize: isTablet ? 20 : 12), + fontSize: isTablet ? 16 : 12), ), ], ), @@ -1733,7 +1741,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - provider.ifOfflineExists(event.eventId!) + provider.ifOfflineExists(event.eventId ?? "") ? Padding( padding: EdgeInsets.only(right: 10), child: Icon(Icons.bookmark, diff --git a/lib/view/insights.dart b/lib/view/insights.dart index 13b763a..009c1fe 100644 --- a/lib/view/insights.dart +++ b/lib/view/insights.dart @@ -1,28 +1,39 @@ import 'dart:math'; import 'package:fl_chart/fl_chart.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_scatter/flutter_scatter.dart'; import 'package:konectar_events/model/affiliationsmodel.dart'; +import 'package:konectar_events/model/allsessionnotesmodel.dart'; +import 'package:konectar_events/model/neweventsmodel.dart'; import 'package:konectar_events/model/specialtymodel.dart'; import 'package:konectar_events/utils/constants.dart'; +import 'package:konectar_events/viewmodel/eventsprovider.dart'; import 'package:konectar_events/viewmodel/hcpprofprovider.dart'; import 'package:konectar_events/widgets/chartline.dart'; import 'package:konectar_events/widgets/piechart.dart'; import 'package:konectar_events/widgets/word_cloud.dart'; import 'package:provider/provider.dart'; +import 'package:zoom_widget/zoom_widget.dart'; class EventsInsights extends StatefulWidget { - //EventsList eventsdetail; + EventsList eventsdetail; String eventid; + String eid; + List kFlutterHashtags = []; List specialtyList = []; - List affiliations; + List allSessionNotes = []; + Affiliations affiliations; EventsInsights( {super.key, + required this.eventsdetail, + required this.eid, required this.eventid, required this.kFlutterHashtags, required this.affiliations, + required this.allSessionNotes, required this.specialtyList}); @override @@ -34,6 +45,8 @@ class _EventsInsightsState extends State { int count = 0; String wordstring = ''; + bool isClientOverview = false; + Matrix4 matrix = Matrix4.identity(); @override void initState() { @@ -45,26 +58,22 @@ class _EventsInsightsState extends State { } init() async { - await Provider.of(context, listen: false) - .getAllSessionNotesList(widget.eventid); - + // await Provider.of(context, listen: false) + // .getAllSessionNotesFromApi(widget.eid); setState(() {}); } + @override + void dispose() { + super.dispose(); + Provider.of(context, listen: false).allSessionNotes = []; + } + @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; final ratio = screenSize.width / (screenSize.height / 2); - List affCountList = []; - int maximum = 0; - if (widget.affiliations.isNotEmpty) { - for (var obj in widget.affiliations) { - affCountList.add(int.parse(obj.orgCount!)); - } - maximum = affCountList.reduce(max); - } - - return Consumer( + return Consumer( builder: (BuildContext context, provider, Widget? child) { List widgets = []; for (var i = 0; i < widget.kFlutterHashtags.length; i++) { @@ -78,258 +87,210 @@ class _EventsInsightsState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Text( - // '2024 Hematology/Oncology Pharmacy Association Annual Conference (HOPA)', - // style: TextStyle( - // color: Colors.blue, - // fontWeight: FontWeight.bold, - // fontSize: 17, - // ), - // maxLines: 2, - // softWrap: true, - // overflow: TextOverflow.ellipsis, - // ), - // Container( - // decoration: BoxDecoration( - // // color: Colors.white, - // border: Border.all(color: Colors.blueAccent)), - // width: 180, - // child: DropdownButton( - // items: ["All Events Insights", "My Events Insights"] - // .map((String value) { - // return DropdownMenuItem( - // value: value, - // child: Text(value), - // ); - // }).toList(), - // value: _value, - // onChanged: (value) { - // setState(() { - // _value = value!; - // }); - // }, - // ), - // ), - // SizedBox( - // height: 20, - // ), - labelWidget("Topics Discussed"), - widgets.isNotEmpty - ? Card( - surfaceTintColor: Colors.white, - child: Container( - padding: EdgeInsets.all(2.0), - margin: EdgeInsets.all(2.0), - height: screenSize.height / 2, - width: screenSize.width, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(20))), - child: Center( - child: FittedBox( - child: Scatter( - fillGaps: true, - delegate: ArchimedeanSpiralScatterDelegate( - ratio: ratio), - children: widgets, - ), - ), - ), + Container( + child: Wrap( + children: [ + Padding( + padding: const EdgeInsets.only( + right: 2.0, bottom: 30, top: 10.0), + child: CupertinoSwitch( + activeColor: Color.fromARGB(255, 0, 71, 132), + value: isClientOverview, + onChanged: (value) async { + isClientOverview = value; + if (isClientOverview) { + provider.isLoadingInsights = true; + await provider.callInsightsDataForClientSpecific( + widget.eventsdetail, true); + + setState(() {}); + } else { + await provider.callInsightsDataForClientSpecific( + widget.eventsdetail, false); + setState(() {}); + } + setState(() {}); + }, ), + ), + Padding( + padding: const EdgeInsets.only( + right: 8.0, top: 20.0, bottom: 20), + child: !isClientOverview + ? const Text( + 'Client Overview', + style: + TextStyle(fontSize: 15, color: Colors.grey), + ) + : const Text( + 'Client Overview', + style: TextStyle( + fontSize: 15, + ), + ), ) - : SizedBox.shrink(), - SizedBox( - height: 20, - ), - labelWidget("Specialty of speakers"), - Card( - surfaceTintColor: Colors.white, - child: Container( - padding: EdgeInsets.all(2.0), - margin: EdgeInsets.all(5.0), - height: screenSize.height / 2, - width: screenSize.width, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20)), - color: Colors.white, - ), - child: CustomPieChart( - specialtyList: widget.specialtyList, - ), - // child: PieChartWidget([ - // Sector( - // value: 35.0, - // color: Colors.purple, - // title: "35% Engineering"), - // Sector( - // value: 40, color: Colors.amber, title: "40% Development"), - // Sector(value: 55, color: Colors.green, title: "55% Social"), - // Sector(value: 70, color: Colors.orange, title: "70% Live"), - // ]), + ], ), ), - SizedBox( - height: 20, - ), - labelWidget("Speaker counts by providers"), - widget.affiliations.isNotEmpty - ? Card( + provider.isLoadingInsights + ? Center( + child: CircularProgressIndicator( + color: EventsConstants.blueColor, + ), + ) + : _buildCharts(provider, widgets), + widget.allSessionNotes.isNotEmpty + ? labelWidget("Session Notes") + : SizedBox.shrink(), + widget.allSessionNotes.isEmpty + ? SizedBox.shrink() + : Card( surfaceTintColor: Colors.white, child: Container( - padding: EdgeInsets.all(12.0), - // margin: EdgeInsets.all(10.0), + padding: EdgeInsets.all(4.0), + margin: EdgeInsets.all(4.0), // height: screenSize.height / 3, width: screenSize.width, + constraints: BoxConstraints( + maxHeight: widget.allSessionNotes.length > 3 + ? screenSize.height + : 400, + minHeight: 400), + // height: double.minPositive, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(20)), color: Colors.white, ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: List.generate( - widget.affiliations.length, (index) { - return ChartLine( - title: widget.affiliations[index].orgName!, - number: int.parse( - widget.affiliations[index].orgCount!), - rate: int.parse(widget.affiliations[index] - .orgCount!) == - maximum - ? 1 - : int.parse(widget.affiliations[index] - .orgCount!) / - maximum); - }), - )), - ) - : SizedBox.shrink(), - SizedBox( - height: 20, - ), - labelWidget("Session Notes"), - Card( - surfaceTintColor: Colors.white, - child: Container( - padding: EdgeInsets.all(4.0), - margin: EdgeInsets.all(4.0), - // height: screenSize.height / 3, - width: screenSize.width, - constraints: BoxConstraints( - maxHeight: provider.allSessionNotesList.length > 3 - ? screenSize.height - : 400, - minHeight: 400), - // height: double.minPositive, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20)), - color: Colors.white, - ), - child: provider.allSessionNotesList.isNotEmpty - ? ListView.separated( - padding: EdgeInsets.zero, - itemCount: provider.allSessionNotesList.length, - itemBuilder: (context, index) { - return ExpansionTile( - initiallyExpanded: true, - shape: Border(), - expandedCrossAxisAlignment: - CrossAxisAlignment.start, - expandedAlignment: Alignment.topLeft, - childrenPadding: EdgeInsets.all(8.0), - title: Text( - "\"${provider.allSessionNotesList[index].notes}\"", - style: TextStyle( - fontSize: 15, - fontStyle: FontStyle.italic)), - subtitle: Padding( - padding: const EdgeInsets.symmetric( - vertical: 8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - "Added by: ${provider.allSessionNotesList[index].addedBy}", - style: TextStyle( - color: Colors.grey[900], - fontSize: 12), - ), - Text( - "On: ${provider.allSessionNotesList[index].addedDate}", - style: TextStyle( - color: Colors.grey[900], - fontSize: 12), - ), - ], - ), - ), - children: [ - Container( - padding: EdgeInsets.all(8.0), - // width: isTablet - // ? MediaQuery.of(context).size.width * 0.25 - // : MediaQuery.of(context).size.width * 0.5, - child: Column( - crossAxisAlignment: + child: widget.allSessionNotes.isNotEmpty + ? ListView.separated( + padding: EdgeInsets.zero, + itemCount: widget.allSessionNotes.length, + itemBuilder: (context, index) { + return ExpansionTile( + initiallyExpanded: false, + shape: Border(), + expandedCrossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Session: ${provider.allSessionNotesList[index].selectedSession}", - maxLines: 3, + expandedAlignment: Alignment.topLeft, + childrenPadding: EdgeInsets.all(8.0), + title: Text( + "Session: ${widget.allSessionNotes[index].sessionName}", + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + )), + subtitle: Padding( + padding: + const EdgeInsets.only(top: 8.0), + child: Text( + "Speaker: ${widget.allSessionNotes[index].firstName}", + // maxLines: 3, style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, - //fontFamily: "SourceSerif", - color: Colors.grey[700], + // //fontFamily: "SourceSerif", + //color: Colors.grey[700], - //fontStyle: FontStyle.italic, + //fontWeight: FontWeight.bold, fontSize: 14), ), - SizedBox( - height: 5, - ), - Text( - "Speaker: ${provider.allSessionNotesList[index].hcpname}", - maxLines: 3, - style: TextStyle( - // decoration: TextDecoration.underline, - // decorationColor: Colors.blue, - //fontFamily: "SourceSerif", - color: Colors.grey[700], + ), + children: List.generate( + widget.allSessionNotes[index] + .addedBy!.length, (i) { + return Container( + padding: EdgeInsets.all(8.0), + // width: isTablet + // ? MediaQuery.of(context).size.width * 0.25 + // : MediaQuery.of(context).size.width * 0.5, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "\"${widget.allSessionNotes[index].notes![i]}\"", + maxLines: 3, + style: TextStyle( + // decoration: TextDecoration.underline, + // decorationColor: Colors.blue, + //fontFamily: "SourceSerif", + color: Colors.grey[900], + fontStyle: + FontStyle.italic, + fontSize: 14), + ), + SizedBox( + height: 5, + ), + Padding( + padding: const EdgeInsets + .symmetric(vertical: 8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Text( + "Added by ${widget.allSessionNotes[index].addedBy![i]}", + style: TextStyle( + color: Colors + .grey[900], + fontSize: 13), + ), + Text( + " On ${widget.allSessionNotes[index].createdOn![i]}", + style: TextStyle( + color: Colors + .grey[900], + fontSize: 13), + ), + ], + ), + ), + widget.allSessionNotes[index] + .addedBy!.length > + 1 + ? (i + 1) != + widget + .allSessionNotes[ + index] + .addedBy! + .length + ? Divider( + //color: Colors.grey[900], + ) + : SizedBox.shrink() + : SizedBox.shrink(), + ], + ), + ); + }), + //), + // Text( + // "Notes : ${sessionNotesList[index]}", + // maxLines: 3, + // style: TextStyle( + // // decoration: TextDecoration.underline, + // // decorationColor: Colors.blue, + // fontFamily: "SourceSerif", + // color: Colors.grey[700], - //fontStyle: FontStyle.italic, - fontSize: 14), - ), - ], - ), - ), - // Text( - // "Notes : ${sessionNotesList[index]}", - // maxLines: 3, - // style: TextStyle( - // // decoration: TextDecoration.underline, - // // decorationColor: Colors.blue, - // fontFamily: "SourceSerif", - // color: Colors.grey[700], - - // //fontStyle: FontStyle.italic, - // fontSize: 14), - // ), - ], - ); - }, - separatorBuilder: - (BuildContext context, int index) { - return Divider(); - }, - // separatorBuilder: (context, index) { - // return Divider(); - // }, - ) - : Center(child: Text("No added session notes"))), - ), + // //fontStyle: FontStyle.italic, + // fontSize: 14), + // ), + ); + }, + separatorBuilder: + (BuildContext context, int index) { + return Divider(); + }, + // separatorBuilder: (context, index) { + // return Divider(); + // }, + ) + : Center( + child: Text("No added session notes"))), + ), ], ), ), @@ -338,6 +299,128 @@ class _EventsInsightsState extends State { }); } + Widget _buildCharts(EventsProvider provider, List widgets) { + final screenSize = MediaQuery.of(context).size; + final ratio = screenSize.width / (screenSize.height / 2); + List affCountList = []; + int maximum = 0; + if (widget.affiliations.affiliationCount.isNotEmpty) { + for (var obj in widget.affiliations.affiliationCount) { + affCountList.add(int.parse(obj)); + } + maximum = affCountList.reduce(max); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + widgets.isNotEmpty + ? labelWidget("Topics Discussed") + : SizedBox.shrink(), + widgets.isNotEmpty + ? Card( + surfaceTintColor: Colors.white, + child: Container( + padding: EdgeInsets.all(2.0), + margin: EdgeInsets.all(2.0), + height: screenSize.height / 2, + width: screenSize.width, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(20))), + child: Center( + // child: Zoom( + // backgroundColor: Colors.white, + // initTotalZoomOut: true, + // centerOnScale: false, + // scrollWeight: 5, + child: FittedBox( + child: Scatter( + fillGaps: true, + delegate: + ArchimedeanSpiralScatterDelegate(ratio: ratio), + children: widgets, + // ), + ), + ), + ), + ), + ) + : SizedBox.shrink(), + provider.specialtyList.isEmpty + ? SizedBox.shrink() + : SizedBox( + height: 20, + ), + provider.specialtyList.isNotEmpty + ? labelWidget("Specialty of speakers") + : SizedBox.shrink(), + provider.specialtyList.isNotEmpty + ? Card( + surfaceTintColor: Colors.white, + child: Container( + padding: EdgeInsets.all(2.0), + margin: EdgeInsets.all(5.0), + height: screenSize.height / 2, + width: screenSize.width, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20)), + color: Colors.white, + ), + child: CustomPieChart( + specialtyList: widget.specialtyList, + ), + ), + ) + : SizedBox.shrink(), + provider.specialtyList.isEmpty + ? SizedBox.shrink() + : SizedBox( + height: 20, + ), + provider.affiliations.affiliationCount.isNotEmpty + ? labelWidget("Speaker counts by providers") + : SizedBox.shrink(), + provider.affiliations.affiliationCount.isNotEmpty + ? Card( + surfaceTintColor: Colors.white, + child: Container( + padding: EdgeInsets.all(12.0), + // margin: EdgeInsets.all(10.0), + // height: screenSize.height / 3, + width: screenSize.width, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20)), + color: Colors.white, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List.generate( + widget.affiliations.affiliationCount.length, (index) { + return ChartLine( + title: widget.affiliations.affiliationNames[index], + number: int.parse( + widget.affiliations.affiliationCount[index]), + rate: int.parse(widget.affiliations + .affiliationCount[index]) == + maximum + ? 1 + : int.parse(widget + .affiliations.affiliationCount[index]) / + maximum); + }), + )), + ) + : SizedBox.shrink(), + provider.specialtyList.isEmpty + ? SizedBox.shrink() + : SizedBox( + height: 20, + ) + ], + ); + } + Widget labelWidget(String title) { return Text( title, diff --git a/lib/view/login.dart b/lib/view/login.dart index 81589f6..dc888f8 100644 --- a/lib/view/login.dart +++ b/lib/view/login.dart @@ -285,109 +285,115 @@ class _LoginScreenState extends State { Center( child: CustomButton( backgroundColor: EventsConstants.onboardButtonColor, - onPressed: () async { - setState(() { - print("loading"); - provider.loading = true; - }); + // onPressed: () async { + // setState(() { + // print("loading"); + // provider.loading = true; + // }); - if (textFieldsValidation(provider).isEmpty) { - print("email:${emailTextController.text}"); - // if (await _logout) { - // print("LOGOUT"); - // provider.code = secretKeyTextConrtroller.text; - // Map resp = await provider.verifyCode( - // emailTextController.text, secretKeyTextConrtroller.text); - // if (resp["code"] == "1200") { - // provider.loading = false; - // provider.showCodeField = false; - // provider.showMessage = true; - // _displaySnackBar("You have logged in successfully"); - // _saveprefs(resp["token"], emailTextController.text, - // secretKeyTextConrtroller.text, true) - // .then((value) { - // Navigator.of(context).pushReplacement( - // MaterialPageRoute( - // builder: (context) => NavigationHomeScreen()), - // ); - // }); - // } else { - // provider.message = resp["message"]; - // } - // } else { - print("FIRST LOGIN"); - if (!provider.showCodeField) { - provider.email = emailTextController.text; - String encoded = - base64.encode(utf8.encode(provider.deviceId)); + // if (textFieldsValidation(provider).isEmpty) { + // print("email:${emailTextController.text}"); + // // if (await _logout) { + // // print("LOGOUT"); + // // provider.code = secretKeyTextConrtroller.text; + // // Map resp = await provider.verifyCode( + // // emailTextController.text, secretKeyTextConrtroller.text); + // // if (resp["code"] == "1200") { + // // provider.loading = false; + // // provider.showCodeField = false; + // // provider.showMessage = true; + // // _displaySnackBar("You have logged in successfully"); + // // _saveprefs(resp["token"], emailTextController.text, + // // secretKeyTextConrtroller.text, true) + // // .then((value) { + // // Navigator.of(context).pushReplacement( + // // MaterialPageRoute( + // // builder: (context) => NavigationHomeScreen()), + // // ); + // // }); + // // } else { + // // provider.message = resp["message"]; + // // } + // // } else { + // print("FIRST LOGIN"); + // if (!provider.showCodeField) { + // provider.email = emailTextController.text; + // String encoded = + // base64.encode(utf8.encode(provider.deviceId)); - Map resp = await provider.verifyEmail( - emailTextController.text, encoded, platform); - print("resp:${resp["code"]}"); - if (resp.isEmpty) { - print("isEmplty"); - } + // Map resp = await provider.verifyEmail( + // emailTextController.text, encoded, platform); + // print("resp:${resp["code"]}"); + // if (resp.isEmpty) { + // print("isEmplty"); + // } - if (resp["code"] == "1200") { - provider.loading = false; - provider.showCodeField = true; - provider.showMessage = true; - } else { - provider.loading = false; - provider.showCodeField = false; - provider.showMessage = true; - } + // if (resp["code"] == "1200") { + // provider.loading = false; + // provider.showCodeField = true; + // provider.showMessage = true; + // } else { + // provider.loading = false; + // provider.showCodeField = false; + // provider.showMessage = true; + // } - provider.message = resp["message"]; - setState(() { - emailTextController.text = provider.email!; - }); - } else { - provider.code = secretKeyTextConrtroller.text; - Map resp = await provider.verifyCode( - emailTextController.text, - secretKeyTextConrtroller.text); - if (resp["code"] == "1200") { - provider.loading = false; - provider.showCodeField = false; - provider.showMessage = true; - _displaySnackBar("You have logged in successfully"); - _saveprefs(resp["token"], emailTextController.text, - secretKeyTextConrtroller.text, true) - .then((value) { - Navigator.of(context).pushReplacement( - MaterialPageRoute( - builder: (context) => NavigationHomeScreen()), - ); - }); - } else { - provider.message = resp["message"]; - } - setState(() { - emailTextController.text = provider.email!; - secretKeyTextConrtroller.text = provider.code!; - }); - } - // } + // provider.message = resp["message"]; + // setState(() { + // emailTextController.text = provider.email!; + // }); + // } else { + // provider.code = secretKeyTextConrtroller.text; + // Map resp = await provider.verifyCode( + // emailTextController.text, + // secretKeyTextConrtroller.text); + // if (resp["code"] == "1200") { + // provider.loading = false; + // provider.showCodeField = false; + // provider.showMessage = true; + // _displaySnackBar("You have logged in successfully"); + // _saveprefs(resp["token"], emailTextController.text, + // secretKeyTextConrtroller.text, true) + // .then((value) { + // Navigator.of(context).pushReplacement( + // MaterialPageRoute( + // builder: (context) => NavigationHomeScreen()), + // ); + // }); + // } else { + // provider.message = resp["message"]; + // } + // setState(() { + // emailTextController.text = provider.email!; + // secretKeyTextConrtroller.text = provider.code!; + // }); + // } + // // } - //_joinMeeting(roomText.text, "demo meet2"); - // _saveprefs( + // //_joinMeeting(roomText.text, "demo meet2"); + // // _saveprefs( - // emailTextController.text, + // // emailTextController.text, - // true) - // .then((value) { - // Navigator.of(context).pushReplacement( - // MaterialPageRoute( - // builder: (context) => FirebaseExample( - // title: secretKeyTextConrtroller.text, - // )), - // ); - // } - // ); - } else { - _displaySnackBar(textFieldsValidation(provider)); - } + // // true) + // // .then((value) { + // // Navigator.of(context).pushReplacement( + // // MaterialPageRoute( + // // builder: (context) => FirebaseExample( + // // title: secretKeyTextConrtroller.text, + // // )), + // // ); + // // } + // // ); + // } else { + // _displaySnackBar(textFieldsValidation(provider)); + // } + // }, + onPressed: () { + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (context) => NavigationHomeScreen()), + ); }, textColor: Colors.white, fontsize: isTablet ? 22 : 18, diff --git a/lib/view/login_components/intropaging.dart b/lib/view/login_components/intropaging.dart index bba5479..2c70888 100644 --- a/lib/view/login_components/intropaging.dart +++ b/lib/view/login_components/intropaging.dart @@ -96,7 +96,7 @@ class _IntroductionAnimationScreenState } void _onSkipClick() { - _animationController?.animateTo(0.8, + _animationController?.animateTo(0.6, duration: Duration(milliseconds: 1200)); } @@ -143,7 +143,7 @@ class _IntroductionAnimationScreenState void _signUpClick() { Navigator.of(context).pushReplacement( - MaterialPageRoute(builder: (context) => NavigationHomeScreen()), + MaterialPageRoute(builder: (context) => LoginScreen()), ); } } diff --git a/lib/view/profileview.dart b/lib/view/profileview.dart index 2b039a6..eb80acc 100644 --- a/lib/view/profileview.dart +++ b/lib/view/profileview.dart @@ -18,6 +18,7 @@ import 'package:konectar_events/contacts_module/ui_screen/interactionform/new_dy 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'; @@ -29,6 +30,7 @@ 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'; @@ -61,6 +63,9 @@ class _HCPProfileScreenState extends State { bool isExtended = false; List sessionList = []; String attachedFileName = ''; + String attachedFilePath = ''; + bool isLoading = false; + String btnText = "Add Notes"; final List _fruits = ['Events', 'Sessions']; final List topics = [ " Admin. & Managemente", @@ -70,6 +75,7 @@ class _HCPProfileScreenState extends State { "Program Committee", "Practical Application of CDK 4/6 Inhibitor" ]; + final ValueNotifier> valueList = ValueNotifier>([]); TextEditingController notesController = TextEditingController(text: ""); List sessionNotesList = []; Future dialogBuilder(BuildContext context, Eventsdetail eventsdetail, @@ -161,9 +167,14 @@ class _HCPProfileScreenState extends State { setState(() { _selectedFruit = newValue!.sessionName; sessionsTopicsData = newValue; + notesController.text = newValue.note ?? ""; + if (newValue.note != "" && notesController.text.length != 0) { + btnText = "Update"; + } + setState(() {}); }); }, - hint: Text("Select Session", style: hintStyle), + hint: Text("Select Session *", style: hintStyle), items: provider.sessionTopics .map((session) => DropdownMenuItem( value: session, child: Text(session.sessionName!))) @@ -171,6 +182,7 @@ class _HCPProfileScreenState extends State { @override void initState() { + valueList.value = [0, 0, 0]; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { init(); }); @@ -183,8 +195,7 @@ class _HCPProfileScreenState extends State { .getSessionData(); await Provider.of(context, listen: false) .getSessionTopics(widget.eventsdetail); - // await Provider.of(context, listen: false) - // .getCounts(widget.eventsdetail); + Provider.of(context, listen: false).getCounts(); await Provider.of(context, listen: false) .initConfigData(); @@ -197,6 +208,12 @@ class _HCPProfileScreenState extends State { await Provider.of(context, listen: false) .getRecords(formname, hcp: widget.kolFullName); + 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; setState(() {}); } @@ -337,6 +354,7 @@ class _HCPProfileScreenState extends State { buildprofile( BuildContext context, EventSpeakersData eventsdetail, String title) { MediaQuery.of(context).size.height * 0.35; + print("ORG:${eventsdetail.orgName}"); return Container( //color: Colors.yellowAccent, @@ -379,16 +397,69 @@ class _HCPProfileScreenState extends State { // color: Colors.white, // // fontFamily: "SourceSerif", // )), - Text( - "${eventsdetail.orgName ?? ""} ${eventsdetail.country ?? ""} ${eventsdetail.city ?? ""}", - softWrap: true, - maxLines: 2, + + RichText( textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - // fontFamily: "SourceSerif", - fontSize: 14, - )), + text: TextSpan(children: [ + TextSpan( + text: eventsdetail.orgName != null || + eventsdetail.orgName!.trim() != "" + ? '${eventsdetail.orgName}' + : "", + 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, + // )), ], ), ), @@ -563,11 +634,14 @@ class _HCPProfileScreenState extends State { ), // const Spacer(), Center( - child: _ProfileInfoRow(items: [ - ProfileInfoItem("Topic(s)", widget.topics.length), - ProfileInfoItem("Session(s)", widget.sessionNames.length), - ProfileInfoItem("Note(s)", provider.totalNotes), - ])), + 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, // ), @@ -583,9 +657,10 @@ class _HCPProfileScreenState extends State { return Container( color: EventsConstants.bgcolor, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: const EdgeInsets.all(15.0), + padding: const EdgeInsets.only(left: 15.0, top: 15, right: 15), // decoration: BoxDecoration( // border: Border.all(color: Colors.grey), // borderRadius: BorderRadius.circular(8.0)), @@ -608,6 +683,9 @@ class _HCPProfileScreenState extends State { TextFormField( controller: notesController, maxLines: 3, + inputFormatters: [ + LengthLimitingTextInputFormatter(1000), + ], validator: (value) { // add email validation if (value == null || value.isEmpty) { @@ -624,13 +702,17 @@ class _HCPProfileScreenState extends State { return null; }, decoration: const InputDecoration( - labelText: 'Notes', - hintText: 'Notes', + labelText: 'Notes *', + // hintText: 'Notes', // prefixIcon: Icon(Icons.note), border: OutlineInputBorder(), focusedBorder: OutlineInputBorder(), ), ), + Text( + 'Maximum Characters: 1000', + style: TextStyle(fontSize: 12), + ), SizedBox( height: 10, ), @@ -647,7 +729,13 @@ class _HCPProfileScreenState extends State { // sectionItem.selectedValue = []; // sectionItem.extension = []; // sectionItem.fileName = []; - await getEncodedFile(); + if (_selectedFruit != null) { + await getEncodedFile(); + } else { + SnackBarWidget.displaySnackBar( + "Please select a session", context, + error: true); + } setState(() {}); }, @@ -655,7 +743,7 @@ class _HCPProfileScreenState extends State { height: 40, fontsize: 12, textColor: Colors.black, - title: "Upload file"), + title: "Attach file"), SizedBox( width: 5, ), @@ -672,53 +760,95 @@ class _HCPProfileScreenState extends State { )), Align( alignment: Alignment.center, - child: SizedBox( - height: 45, - child: FloatingActionButton.extended( - // backgroundColor: const Color.fromARGB(255, 222, 237, 247), - backgroundColor: Colors.green, - onPressed: () async { - //"Program Committee Admin. & Management" - //setState(() { - print("ADD : ${_selectedFruit} ${notesController.text}"); - if (notesController.text.length != 0 || - notesController.text != "") { - sessionNotesList - .add("${_selectedFruit} \n\n ${notesController.text}"); - // }); - print(" eventid:${widget.eventid},hcp:${widget.eventid}"); + child: Stack( + children: [ + Align( + alignment: Alignment.center, + child: SizedBox( + height: 45, + child: FloatingActionButton.extended( + // backgroundColor: const Color.fromARGB(255, 222, 237, 247), + backgroundColor: Colors.green, + onPressed: () async { + //"Program Committee Admin. & Management" + //setState(() { + isLoading = true; - await provider.submitSessionNotes(eventsdetail, - sessionsTopicsData!, notesController.text); + 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}"); - SessionNotesModel notesModel = SessionNotesModel( - notes: notesController.text, - addedBy: "user", - addedDate: CustomDateFormatter().formatDate(), - eventid: widget.eventid, - hcpid: widget.eventid, - selectedSession: _selectedFruit); - print( - "${notesModel.addedBy},${notesModel.notes},${notesModel.addedDate},${notesModel.eventid},${notesModel.hcpid},${notesModel.selectedSession}"); - await provider.addSessionNotes(notesModel); - _selectedFruit = null; - sessionsTopicsData = null; - notesController.clear(); - } else { - print("something went wrong"); - } - }, - heroTag: 'addnotes', - elevation: 0, - label: const Text( - "Submit", - style: TextStyle(color: Colors.white), + await provider.submitSessionNotes( + eventsdetail, + sessionsTopicsData!, + notesController.text, + attachedFileName != '' ? attachedFilePath : "", + attachedFileName != '' ? attachedFileName : "", + ); + //HIVESTORE + + SessionNotesModel notesModel = SessionNotesModel( + notes: notesController.text, + addedBy: "user", + addedDate: CustomDateFormatter().formatDate(), + eventid: widget.eventid, + hcpid: widget.eventid, + selectedSession: _selectedFruit); + print( + "${notesModel.addedBy},${notesModel.notes},${notesModel.addedDate},${notesModel.eventid},${notesModel.hcpid},${notesModel.selectedSession}"); + await provider.addSessionNotes(notesModel); + _selectedFruit = null; + isLoading = false; + sessionsTopicsData = null; + attachedFileName = ""; + notesController.clear(); + isLoading = false; + 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, + // ), + ), + ), ), - // icon: const Icon( - // Icons.add, - // color: Colors.black, - // ), - ), + Visibility( + visible: isLoading, + child: Center( + child: CircularProgressIndicator( + color: EventsConstants.blueColor, + )), + ), + ], + ), + ), + Divider(), + Padding( + padding: const EdgeInsets.only(left: 15.0), + child: Text( + "My Notes", + style: TextStyle(fontSize: 16), ), ), Divider(), @@ -726,8 +856,8 @@ class _HCPProfileScreenState extends State { //height: 200, child: ListView.separated( padding: EdgeInsets.all(2.0), - itemCount: provider - .getSessionNotesList(widget.eventid, widget.eventsdetail) + itemCount: provider.sessionTopics + .where((element) => element.canEditNotes == true) .length, itemBuilder: (context, index) { return SizedBox( @@ -736,7 +866,7 @@ class _HCPProfileScreenState extends State { : MediaQuery.of(context).size.width * 0.5, child: ListTile( title: Text( - "\"${provider.sessionNotesList[index].notes}\"", + "\"${provider.sessionTopics[index].note}\"", // maxLines: 3, style: TextStyle( // decoration: TextDecoration.underline, @@ -754,7 +884,7 @@ class _HCPProfileScreenState extends State { height: 10, ), Text( - "Session: ${provider.sessionNotesList[index].selectedSession}", + "Session: ${provider.sessionTopics[index].sessionName}", // maxLines: 3, style: TextStyle( // decoration: TextDecoration.underline, @@ -765,38 +895,59 @@ class _HCPProfileScreenState extends State { //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"; + } + + setState(() {}); + }, + width: 80, + height: 30, + fontsize: 12, + textColor: Colors.black, + title: "Edit"), SizedBox( height: 5, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Added By: ${provider.sessionNotesList[index].addedBy}", - // maxLines: 3, - style: TextStyle( - // decoration: TextDecoration.underline, - // decorationColor: Colors.blue, - //fontFamily: "SourceSerif", - color: const Color.fromARGB(255, 66, 65, 65), + // 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), + // ), + // 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), - ), - ], - ), + // //fontStyle: FontStyle.italic, + // fontSize: 12), + // ), + // ], + // ), ], ), ), @@ -819,7 +970,7 @@ class _HCPProfileScreenState extends State { : await Permission.storage.status; if (status.isGranted) { FilePickerResult? result = - await FilePicker.platform.pickFiles(allowMultiple: true); + await FilePicker.platform.pickFiles(allowMultiple: false); if (result != null) { print(result.files.first.path); @@ -850,6 +1001,10 @@ class _HCPProfileScreenState extends State { 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); @@ -1214,6 +1369,10 @@ 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( diff --git a/lib/viewmodel/eventsprovider.dart b/lib/viewmodel/eventsprovider.dart index c63a832..7604b77 100644 --- a/lib/viewmodel/eventsprovider.dart +++ b/lib/viewmodel/eventsprovider.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:konectar_events/contacts_module/model_class/k2_api_model/kol_event_k2.dart'; import 'package:konectar_events/model/affiliationsmodel.dart'; +import 'package:konectar_events/model/allsessionnotesmodel.dart'; import 'package:konectar_events/model/events_details.dart'; import 'package:konectar_events/model/events_list_resp_2.dart'; import 'package:konectar_events/model/events_speakers_k1.dart'; @@ -54,11 +55,13 @@ class EventsProvider extends ChangeNotifier { List kFlutterHashtags = []; List topics = []; List specialtyList = []; - EventsOverviewData? overviewData; - List affiliations = []; - + EventsOverviewData overviewData = EventsOverviewData( + arrEvents: [], topSpeakers: [], eventSponsers: [], eventTopics: []); + Affiliations affiliations = + Affiliations(affiliationCount: [], affiliationNames: []); + List allSessionNotes = []; late StreamSubscription> connectivitySubscription; - + bool isLoadingInsights = true; Future onSelectAll(int page) async { isFavSeleted = false; isAllSelected = !isAllSelected; @@ -236,13 +239,13 @@ class EventsProvider extends ChangeNotifier { offlineEvents = await getOfflineMyEvents(); eventList = isFavSeleted - ? await ApiCall().getEventsFromK1(type: "2") + ? await ApiCall().getEventsFromK1(type: 2) : await ApiCall().getEventsFromK1(); print("see the list : $neweventList"); if (eventList.isEmpty) { // eventList = (await ApiCall().getEvents())!; eventList = isFavSeleted - ? await ApiCall().getEventsFromK1(type: "2") + ? await ApiCall().getEventsFromK1(type: 2) : await ApiCall().getEventsFromK1(); //eventList = (await ApiCall().getStagingEvents())!; for (var events in eventList) { @@ -268,11 +271,11 @@ class EventsProvider extends ChangeNotifier { Future> getMyEvents(int page) async { // eventList = await getAllEventsData(); - myEvents = await ApiCall().getEventsFromK1(type: "2"); + myEvents = await ApiCall().getEventsFromK1(type: 2); print("see the list : $myEvents"); if (myEvents.isEmpty) { // eventList = (await ApiCall().getEvents())!; - myEvents = await ApiCall().getEventsFromK1(type: "2"); + myEvents = await ApiCall().getEventsFromK1(type: 2); //eventList = (await ApiCall().getStagingEvents())!; } for (var events in myEvents) { @@ -309,7 +312,7 @@ class EventsProvider extends ChangeNotifier { Future> getInitialSpeakersDetails(String eventid, {required String searchkey}) async { - speakersList = (await ApiCall().getEventsSpeakersFromK1(eventid)); + speakersList = await ApiCall().getEventsSpeakersFromK1(eventid); getSessionCount(); if (searchkey.length != 0) { List searchspeakers = speakersList @@ -481,37 +484,52 @@ class EventsProvider extends ChangeNotifier { notifyListeners(); } - FutureOr getTopicsCloud(EventsList event) async { - List topics = (await ApiCall().insightsTopicsCloud( - eventid: event.eventId!, startDate: event.start!, endDate: event.end!)); + FutureOr getTopicsCloud(EventsList event, {bool? client}) async { + List topics = await ApiCall().insightsTopicsCloud( + eventid: event.eventId!, + startDate: CustomDateFormatter().formatYearDate( + CustomDateFormatter().convertStringToDate(event.start!)), + endDate: CustomDateFormatter().formatYearDate( + CustomDateFormatter().convertStringToDate(event.end!)), + client: client ?? false); // for (var events in eventList) { // await saveEventsData(events); // } //notifyListeners(); kFlutterHashtags = []; for (var topic in topics) { - kFlutterHashtags - .add(FlutterHashtag(topic.topic!, int.parse(topic.total!), false)); + kFlutterHashtags.add( + FlutterHashtag(topic.topic!, int.parse(topic.total!) + 500, false)); } notifyListeners(); } - FutureOr getSpecialtyData(EventsList event) async { - specialtyList = (await ApiCall().specialtyOfSpeakers( + FutureOr getSpecialtyData(EventsList event, {bool? client}) async { + String date = CustomDateFormatter().formatYearDate( + CustomDateFormatter().convertStringToDate(event.start!)); + print("Formatted_DATE :$date"); + specialtyList = await ApiCall().specialtyOfSpeakers( eventid: event.eventId!, startDate: CustomDateFormatter().formatYearDate( CustomDateFormatter().convertStringToDate(event.start!)), endDate: CustomDateFormatter().formatYearDate( - CustomDateFormatter().convertStringToDate(event.end!)))); - + CustomDateFormatter().convertStringToDate(event.end!)), + client: client ?? false); + //isLoadingInsights = false; notifyListeners(); } - FutureOr getAffiliations(EventsList event) async { - affiliations = (await ApiCall().insightsBarChart( - eventid: event.eventId!, startDate: event.start!, endDate: event.end!)); - + FutureOr getAffiliations(EventsList event, {bool? client}) async { + // isLoadingInsights = true; + affiliations = await ApiCall().insightsBarChart( + eventid: event.eventId!, + startDate: CustomDateFormatter().formatYearDate( + CustomDateFormatter().convertStringToDate(event.start!)), + endDate: CustomDateFormatter().formatYearDate( + CustomDateFormatter().convertStringToDate(event.end!)), + client: client ?? false); + //isLoadingInsights = false; notifyListeners(); } @@ -523,5 +541,19 @@ class EventsProvider extends ChangeNotifier { notifyListeners(); } + FutureOr getAllSessionNotesFromApi(String eid) async { + print("Check hcp id"); + // print("$eid,$hcpid"); + allSessionNotes = await ApiCall().getAllSessionNotes(eid); + notifyListeners(); + } + + FutureOr callInsightsDataForClientSpecific( + EventsList event, bool client) async { + await getTopicsCloud(event, client: client); + await getSpecialtyData(event, client: client); + await getAffiliations(event, client: client); + isLoadingInsights = false; + } //INTERNET CONNECTIVITY } diff --git a/lib/viewmodel/hcpprofprovider.dart b/lib/viewmodel/hcpprofprovider.dart index 2c6aedf..630b71b 100644 --- a/lib/viewmodel/hcpprofprovider.dart +++ b/lib/viewmodel/hcpprofprovider.dart @@ -4,6 +4,7 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:hive_flutter/hive_flutter.dart'; +import 'package:konectar_events/model/allsessionnotesmodel.dart'; import 'package:konectar_events/model/events_speakers_k1.dart'; import 'package:konectar_events/model/eventsdetailmodel.dart'; import 'package:konectar_events/model/eventspeakers.dart'; @@ -15,37 +16,65 @@ import 'package:konectar_events/widgets/word_cloud.dart'; class HcpProfileProvider extends ChangeNotifier { List sessionNotesList = []; - List allSessionNotesList = []; + List allSessionNotesHiveList = []; int totalTopics = 0; int totalSessions = 0; int totalNotes = 0; List sessionTopics = []; + List allSessionNotes = []; late Box box; Future getSessionTopics(EventSpeakersData detail) async { sessionTopics = await ApiCall().getSessionsTopics(detail.eid!, detail.kolId == "0" ? detail.hcpPinAlias! : detail.kolId!, detail.kId!); totalSessions = sessionTopics.length; + getCounts(); notifyListeners(); } - Future submitSessionNotes(EventSpeakersData detail, - SessionsTopicsData sessionsTopicsData, String notes) async { - var data = await ApiCall().addSessionNotes( - sessionsTopicsData.kolEventsId!, - detail.kolId == "0" ? detail.hcpPinAlias! : detail.kolId!, - detail.eventAttendeesId!, - detail.kId!, - notes); + Future submitSessionNotes( + EventSpeakersData detail, + SessionsTopicsData sessionsTopicsData, + String notes, + String? selectedfilepath, + String? selectedfilename) async { + var data = await ApiCall() + .addSessionNotes( + sessionsTopicsData.kolEventsId!, + sessionsTopicsData.kolId!, + sessionsTopicsData.eventAttendeesId!, + detail.kId!, + notes, + selectedfilepath, + selectedfilename, + sessionsTopicsData.id ?? "", + ) + .then( + (value) { + getSessionTopics(detail); + }, + ); return data; } - getCounts(Eventsdetail eventsdetail) { - List topics = eventsdetail.eventTopics!.split("|"); - totalTopics = topics.length; + getCounts() { + // List topics = eventsdetail.eventTopics!.split("|"); + // totalTopics = topics.length; - totalSessions = int.parse(eventsdetail.numSess ?? "1"); - totalNotes = sessionNotesList.length; + // totalSessions = int.parse(eventsdetail.numSess ?? "1"); + // totalNotes = sessionNotesList.length; + int total = 0; + int totalT = 0; + if (sessionTopics.isNotEmpty) { + for (var obj in sessionTopics) { + print("Notes_count : ${obj.noteCount}"); + total = total + int.parse(obj.noteCount ?? "0"); + totalT = totalT + obj.eventTopics!.split("|").length ?? 0; + } + } + totalNotes = total; + totalTopics = totalT; + totalSessions = sessionTopics.length; notifyListeners(); } @@ -87,7 +116,7 @@ class HcpProfileProvider extends ChangeNotifier { print("Check hcp id"); // print("$eid,$hcpid"); await getSessionData(); - allSessionNotesList = + allSessionNotesHiveList = sessionNotesList.where((element) => element.eventid == eid).toList(); notifyListeners(); } diff --git a/lib/widgets/chartline.dart b/lib/widgets/chartline.dart index 1f82e67..b5d084d 100644 --- a/lib/widgets/chartline.dart +++ b/lib/widgets/chartline.dart @@ -27,16 +27,18 @@ class ChartLine extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - //constraints: BoxConstraints(minWidth: lineWidget), - child: IntrinsicWidth( + constraints: BoxConstraints( + minWidth: lineWidget, minHeight: constraints.minHeight), + child: Expanded( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + //mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( title, + maxLines: 2, style: TextStyle( fontSize: 14, - overflow: TextOverflow.ellipsis, + overflow: TextOverflow.clip, ), ), ], diff --git a/lib/widgets/snackbar.dart b/lib/widgets/snackbar.dart index 4021b91..c01343d 100644 --- a/lib/widgets/snackbar.dart +++ b/lib/widgets/snackbar.dart @@ -2,14 +2,17 @@ import 'package:flutter/material.dart'; import 'package:konectar_events/utils/constants.dart'; class SnackBarWidget { - static displaySnackBar(String msg, BuildContext context) { + static displaySnackBar(String msg, BuildContext context, + {bool error = false}) { final snackBar = SnackBar( content: Text( msg, style: TextStyle(color: Colors.black), ), - backgroundColor: EventsConstants.oldbgcolor, - duration: Durations.long1, + backgroundColor: error + ? Color.fromARGB(255, 235, 110, 76) + : EventsConstants.oldbgcolor, + duration: error ? Durations.long3 : Durations.long1, ); ScaffoldMessenger.of(context).showSnackBar(snackBar); //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); diff --git a/pubspec.lock b/pubspec.lock index 42f78e6..4449f0f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1685,6 +1685,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.2" + zoom_widget: + dependency: "direct main" + description: + name: zoom_widget + sha256: "50fbaa460ffc938ca14c0077f8c9e5968c437897242d7f552dacff1bf3270225" + url: "https://pub.dev" + source: hosted + version: "2.0.1" sdks: dart: ">=3.3.0 <4.0.0" flutter: ">=3.19.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7b3b702..f0d4e5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -94,6 +94,7 @@ dependencies: animations: ^2.0.11 overlay_support: ^2.1.0 flutter_svg_provider: ^1.0.7 + zoom_widget: ^2.0.1 dev_dependencies: -- 2.34.1