From e46c5e3e1d409a2b7d67b5e83f8584f6296a4371 Mon Sep 17 00:00:00 2001 From: "snehalathad@aissel.com" Date: Mon, 16 Dec 2024 16:56:32 +0530 Subject: [PATCH] login auth , verfication --- assets/api_constants.json | 29 +- .../interactionform/widget/custombutton.dart | 2 +- lib/main.dart | 22 +- lib/model/allsessionnotesmodel.dart | 2 +- lib/model/verify_user_resp.dart | 63 +++ lib/utils/apicall.dart | 187 +++--- lib/utils/constants.dart | 13 +- lib/view/eventslist.dart | 486 ++++++++-------- lib/view/home.dart | 391 +++++++------ lib/view/login.dart | 275 +++++---- lib/view/login_components/care_view.dart | 12 +- lib/view/login_components/mood_diary_vew.dart | 18 +- lib/view/login_components/relax_view.dart | 12 +- lib/view/navigation_home_screen.dart | 2 +- lib/view/profileview.dart | 532 ++++++++++++------ lib/viewmodel/eventsprovider.dart | 76 ++- lib/viewmodel/hcpprofprovider.dart | 57 ++ lib/viewmodel/hive_repository.dart | 7 +- lib/viewmodel/loginprovider.dart | 17 - lib/widgets/home_drawer.dart | 13 +- 20 files changed, 1378 insertions(+), 838 deletions(-) create mode 100644 lib/model/verify_user_resp.dart diff --git a/assets/api_constants.json b/assets/api_constants.json index ab6f221..3fdbcb0 100644 --- a/assets/api_constants.json +++ b/assets/api_constants.json @@ -5,18 +5,25 @@ "method": "POST", "module": "eventapis" }, + { - "api": "saveUserInterestedEvent", - "interval": 0, - "method": "POST", - "module": "eventapis" - }, - { - "api": "saveUserAttendingEvent", - "interval": 0, - "method": "POST", - "module": "eventapis" - }, + "api": "saveUserInterestedEvent", + "interval": 0, + "method": "POST", + "module": "eventapis" + }, + { + "api": "saveUserAttendingEvent", + "interval": 0, + "method": "POST", + "module": "eventapis" + }, + { + "api": "eventOverview", + "interval": 0, + "method": "POST", + "module": "eventapis" + }, { "api": "getSpecialitiesDonutChart", "interval": 0, diff --git a/lib/contacts_module/ui_screen/interactionform/widget/custombutton.dart b/lib/contacts_module/ui_screen/interactionform/widget/custombutton.dart index d072233..0a70a27 100644 --- a/lib/contacts_module/ui_screen/interactionform/widget/custombutton.dart +++ b/lib/contacts_module/ui_screen/interactionform/widget/custombutton.dart @@ -34,7 +34,7 @@ class CustomButton extends StatelessWidget { backgroundColor: MaterialStateColor.resolveWith((states) => backgroundColor), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), // <-- Radius + borderRadius: BorderRadius.circular(20), // <-- Radius ), ), diff --git a/lib/main.dart b/lib/main.dart index 198c6e3..4fdda30 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -283,7 +283,7 @@ Future main() async { print("isLoggedIn_is : $isLoggedIn"); print("secret : $secretkey"); return isLoggedIn - ? IntroductionAnimationScreen() + ? NavigationHomeScreen() : IntroductionAnimationScreen(); } }, @@ -329,17 +329,15 @@ class _MyAppState extends State { systemNavigationBarDividerColor: Colors.transparent, systemNavigationBarIconBrightness: Brightness.dark, )); - return OverlaySupport( - child: MaterialApp( - title: 'Flutter UI', - debugShowCheckedModeBanner: false, - // theme: ThemeData( - // primarySwatch: Colors.blue, - // textTheme: AppTheme.textTheme, - // platform: TargetPlatform.iOS, - // ), - home: NavigationHomeScreen(), - ), + return MaterialApp( + title: 'Flutter UI', + debugShowCheckedModeBanner: false, + // theme: ThemeData( + // primarySwatch: Colors.blue, + // textTheme: AppTheme.textTheme, + // platform: TargetPlatform.iOS, + // ), + home: NavigationHomeScreen(), ); } diff --git a/lib/model/allsessionnotesmodel.dart b/lib/model/allsessionnotesmodel.dart index 2815f87..55dd13c 100644 --- a/lib/model/allsessionnotesmodel.dart +++ b/lib/model/allsessionnotesmodel.dart @@ -53,7 +53,7 @@ class AllSessionNotesResponse { note: json["note"], sessionName: json["session_name"], eventTopics: json["event_topics"], - userName: json["user_name"]!, + userName: json["user_name"], users: json["users"], notes: json["notes"] == null ? [] diff --git a/lib/model/verify_user_resp.dart b/lib/model/verify_user_resp.dart new file mode 100644 index 0000000..d8d2a35 --- /dev/null +++ b/lib/model/verify_user_resp.dart @@ -0,0 +1,63 @@ +// To parse this JSON data, do +// +// final verificationResponse = verificationResponseFromJson(jsonString); + +import 'dart:convert'; + +VerificationResponse verificationResponseFromJson(String str) => + VerificationResponse.fromJson(json.decode(str)); + +String verificationResponseToJson(VerificationResponse data) => + json.encode(data.toJson()); + +class VerificationResponse { + int? status; + String? message; + String? verification_code; + String? accessToken; + User? user; + + VerificationResponse({ + this.status, + this.message, + this.accessToken, + this.verification_code, + this.user, + }); + + factory VerificationResponse.fromJson(Map json) => + VerificationResponse( + status: json["status"], + message: json["message"], + verification_code: json["verification_code"], + accessToken: json["access_token"], + user: json["user"] == null ? null : User.fromJson(json["user"]), + ); + + Map toJson() => { + "status": status, + "message": message, + "access_token": accessToken, + "user": user?.toJson(), + }; +} + +class User { + String? email; + String? userFullName; + + User({ + this.email, + this.userFullName, + }); + + factory User.fromJson(Map json) => User( + email: json["email"], + userFullName: json["user_full_name"], + ); + + Map toJson() => { + "email": email, + "user_full_name": userFullName, + }; +} diff --git a/lib/utils/apicall.dart b/lib/utils/apicall.dart index 468beee..aead3c3 100644 --- a/lib/utils/apicall.dart +++ b/lib/utils/apicall.dart @@ -23,11 +23,16 @@ import 'package:konectar_events/model/sessionnotesmodel.dart'; import 'package:konectar_events/model/sessionstopics_model.dart'; import 'package:konectar_events/model/specialtymodel.dart'; import 'package:konectar_events/model/topics_cloud_model.dart'; +import 'package:konectar_events/model/verify_user_resp.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/viewmodel/hive_repository.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class ApiCall { final dio = Dio(); + final Future _prefs = SharedPreferences.getInstance(); + + late Future _token; //K1 API CALLS Future parseInfo() async { @@ -119,16 +124,21 @@ class ApiCall { }; Response response; var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "start": "2024-12-05", "end": "2024-12-31", "order_by": 8, 'type': type ?? 1 }); // "end": DateTime(2024, 12, 14).toIso8601String(), + _token = _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); + print("SAVED TOKEN :${await _token}"); response = await dio.post('${EventsConstants.url}${EventsConstants.eventslistapi}', - options: Options(), + options: Options(headers: { + "Authorization": "Bearer ${await _token}", + }), // queryParameters: { // "user_email": "vinodh@aissel.com", // "project_id": "", @@ -576,6 +586,96 @@ class ApiCall { } } + //VERIFY EMAIL K1 + Future verifyEmail( + String email, String deviceid, String platform) 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({ + "email_id": email, + "device_id": deviceid, + }); + response = await dio.post( + '${EventsConstants.loginUrl}${EventsConstants.getVerificationCode}', + options: Options(), + data: formData); + if (response.statusCode == 200) { + print("response user login!!!!!!!!!!!!!!!!!!!!! \n ${response.data} "); + Map jsondata = json.decode(response.data); + VerificationResponse verificationResponse = + verificationResponseFromJson(response.data); + return verificationResponse; + } else { + print("isEmpty"); + return null; + } + } + + //VERIFY CODE OR LOGIN + Future verifyCode(String email, String code) 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({ + "verification_code": code, + "email_id": email, + }); + response = await dio.post( + '${EventsConstants.loginUrl}${EventsConstants.login}', + options: Options(), + data: formData); + if (response.statusCode == 200) { + print("response user login!!!!!!!!!!!!!!!!!!!!! \n ${response.data} "); + Map jsondata = json.decode(response.data); + VerificationResponse verificationResponse = + verificationResponseFromJson(response.data); + return verificationResponse; + } else { + print("isEmpty"); + return null; + } + } + +//LOGOUT + Future logout(String email, String deviceid) async { + Dio dio = Dio(); + (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = + (HttpClient client) { + client.badCertificateCallback = + (X509Certificate cert, String host, int port) => true; + return client; + }; + Response response; + print("url :${EventsConstants.loginUrl}${EventsConstants.logout}"); + var formData = FormData.fromMap({ + "email_id": email, + "device_id": deviceid, + }); + response = await dio.post( + '${EventsConstants.loginUrl}${EventsConstants.logout}', + data: formData, + // queryParameters: { + // "token": token, + // }, + ); + if (response.statusCode == 200) { + print("response user LoGOUT!!!!!!!!!!!!!!!!!!!!! \n ${response.data} "); + } + print(response.data.toString()); + + return response.data; + } //************ K2 API CALLS *********************************************************************************************************************************** Future> getEventsFromK2(int page, String search, @@ -760,58 +860,6 @@ class ApiCall { //GET MY EVENTS - Future verifyCode(String email, String code) 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({ - "email": email, - }); - response = await dio.post('${EventsConstants.validateTokenApi}', - options: Options(), - queryParameters: { - "email": email, - "token": code, - }, - data: formData); - print("response user login!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); - - return response.data; - } - -//LOGOUT - Future logout(String token) async { - print("token:::::$token"); - 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({ - // "email": email, - // }); - response = await dio.post( - '${EventsConstants.logoutApi}', - options: Options(headers: {"Authorization": "Bearer $token"}), - // queryParameters: { - // "token": token, - // }, - ); - print("response user LOGOUT!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); - - return response.data; - } - //SEARCH EVENTS API FROM K2 Future> getSearchedEventsFromK2( @@ -955,37 +1003,6 @@ class ApiCall { return response.data; } - Future verifyEmail( - String email, String deviceid, String platform) 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({ - "email": email, - }); - response = await dio.post('${EventsConstants.getTokenApi}', - options: Options(), - queryParameters: { - "email": email, - "device_id": deviceid, - "platform": platform, - }, - data: formData); - if (response.statusCode == 200) { - print("response user login!!!!!!!!!!!!!!!!!!!!! "); - print(response.data.toString()); - return response.data; - } else { - print("isEmplty"); - return null; - } - } - Future?> getEvents() async { Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index f11adcf..602dc83 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -21,7 +21,8 @@ class EventsConstants { //192.0.0.2:8007 - iphone // 192.168.2.109:8007 - office jkqehjkq //K1 API~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - static const String moduleName = "eventapis"; + static const String moduleName = "apis/v1/events"; + static const String loginmodule = "apiauths"; static const String stagingUrl = "https://cardio-staging.konectar.io/$moduleName/"; @@ -30,6 +31,9 @@ class EventsConstants { static const String devUrl = "http://192.168.2.130/konectar-sandbox/$moduleName/"; + static const String loginUrl = + "https://cardio-staging.konectar.io/$loginmodule/"; + static const String eventslistapi = "loadFutureEvents"; static const String followUnfollowEvent = "saveUserInterestedEvent"; static const String attendNotAttendEvent = "saveUserAttendingEvent"; @@ -42,9 +46,16 @@ class EventsConstants { static const String getTopicNotes = "getTopicNotes"; static const String saveEventsTopicNote = "saveEventsTopicNote"; static const String eventUserAnalytics = "eventUserAnalytics"; + static const String getVerificationCode = "getVerificationCode"; + static const String login = "login"; + + static const String logout = "logout"; + + static const String medInsightApi = "medInsightApi"; //MY CONSTANTS static const String saveEventOffline = "saveEventOffline"; static const String contactsListapi = "contactslistapi"; + static const String filtersApi = "filtersApi"; //Hive /* diff --git a/lib/view/eventslist.dart b/lib/view/eventslist.dart index 1d9769a..96d0ff1 100644 --- a/lib/view/eventslist.dart +++ b/lib/view/eventslist.dart @@ -55,7 +55,7 @@ class _EventsListingScreenState extends State @override void initState() { super.initState(); - tabController = TabController(length: 2, vsync: this); + tabController = TabController(vsync: this, length: 2); final provider = Provider.of(context, listen: false); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { @@ -67,11 +67,6 @@ class _EventsListingScreenState extends State }); } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - } - Future _fetchPage(int pageKey) async { //await initConnectivity(); // if (connectionStatus.toString().contains("ConnectivityResult.none")) { @@ -174,7 +169,7 @@ class _EventsListingScreenState extends State return Consumer( builder: (BuildContext context, provider, Widget? child) { return DefaultTabController( - length: 3, + length: provider.tabs.length, //child: SafeArea( // appBar: CustomAppBar(title: "", backgroundcolor: Constants.bgcolor), //body: @@ -543,153 +538,167 @@ class _EventsListingScreenState extends State ); } showModalBottomSheet( + //constraints: BoxConstraints(maxHeight: 200, minHeight: 120), + isScrollControlled: true, context: context, builder: (BuildContext context) { - return Container( - color: EventsConstants.bgcolor, - width: MediaQuery.of(context).size.width, - height: 240, - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: Align( - // alignment: Alignment.topLeft, - // child: const Text( - // 'Actions', - // style: TextStyle(fontSize: 18), - // )), - // ),IntroductionAnimationScreen - // InkWell( - // onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => - // IntroductionAnimationScreen(), - // ), - // ); - // // Navigator.pop(context); - // }, - // child: ListTile( - // title: Text("GOTO"), - // leading: Icon( - // Icons.calendar_month, - // color: Colors.green, - // ), - // ), - // ), - InkWell( - onTap: () { - Add2Calendar.addEvent2Cal( - buildEvent(), - ); - Navigator.pop(context); - }, - child: ListTile( - title: Text("Add to my calendar"), - leading: Icon( - Icons.calendar_month, - color: Colors.green, - ), - ), - ), - InkWell( - onTap: () async { - if (provider.offlineEvents.isEmpty) { - await provider.saveEventsData(widget.event); - SnackBarWidget.displaySnackBar( - "Event Saved Offline", context); - } else { - if (!provider.offlineExists) { - await provider.saveEventsData(widget.event); - SnackBarWidget.displaySnackBar( - "Event Saved Offline", context); - } else { - await provider.delateOfflineEvent(widget.event); - provider.offlineExists = false; - SnackBarWidget.displaySnackBar( - "Removed from Offline", context); - } - } + return Wrap(children: [ + // child: - Navigator.pop(context); - }, - child: ListTile( - title: Text(provider.offlineExists - ? "Remove the event from offline" - : "Save the event offline"), - leading: Icon( - Icons.download, - color: Colors.blue, + Container( + color: EventsConstants.bgcolor, + // width: MediaQuery.of(context).size.width, + // constraints: BoxConstraints(minHeight: 120, maxHeight: 130), + //height: 240, + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Padding( + // padding: const EdgeInsets.all(8.0), + // child: Align( + // alignment: Alignment.topLeft, + // child: const Text( + // 'Actions', + // style: TextStyle(fontSize: 18), + // )), + // ),IntroductionAnimationScreen + // InkWell( + // onTap: () { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (BuildContext context) => + // IntroductionAnimationScreen(), + // ), + // ); + // // Navigator.pop(context); + // }, + // child: ListTile( + // title: Text("GOTO"), + // leading: Icon( + // Icons.calendar_month, + // color: Colors.green, + // ), + // ), + // ), + InkWell( + onTap: () { + Add2Calendar.addEvent2Cal( + buildEvent(), + ); + Navigator.pop(context); + }, + child: ListTile( + title: Text("Add to my calendar"), + leading: Icon( + Icons.calendar_month, + color: Colors.green, + ), ), ), - ), - InkWell( - onTap: () { - if (widget.event.eventUserAttendee!) { - widget.event.eventUserAttendee = false; + provider.addOffline + ? InkWell( + onTap: () async { + if (provider.offlineEvents.isEmpty) { + await provider + .saveEventsData(widget.event); + SnackBarWidget.displaySnackBar( + "Event Saved Offline", context); + } else { + if (!provider.offlineExists) { + await provider + .saveEventsData(widget.event); + SnackBarWidget.displaySnackBar( + "Event Saved Offline", context); + } else { + await provider + .delateOfflineEvent(widget.event); + provider.offlineExists = false; + SnackBarWidget.displaySnackBar( + "Removed from Offline", context); + } + } - // if (event.isAttending) { - // SnackBarWidget.displaySnackBar( - // "Attending", context); - // } else { - SnackBarWidget.displaySnackBar( - "Marked as not attending", context); - // } - setState(() {}); - Navigator.pop(context); - } else { - Navigator.pop(context); - } - }, - child: ListTile( - title: Text("Mark as not attending"), - leading: Icon( - Icons.remove_circle, - color: Colors.red, - ), - ), - ), - // Container( - // padding: EdgeInsets.symmetric(horizontal: 8.0), - // width: MediaQuery.of(context).size.width, - // child: ElevatedButton( - // child: const Text( - // 'Add to My Calendar', - // style: TextStyle(color: Colors.black), - // ), - // onPressed: () { - // Add2Calendar.addEvent2Cal( - // buildEvent(), - // ); - // Navigator.pop(context); - // }), - // ), - // Container( - // padding: EdgeInsets.symmetric(horizontal: 8.0), - // width: MediaQuery.of(context).size.width, - // Container( - // padding: EdgeInsets.symmetric(horizontal: 8.0), - // width: MediaQuery.of(context).size.width, - // child: ElevatedButton( - // child: const Text('Remove from my events', - // style: TextStyle(color: Colors.black)), - // onPressed: () => Navigator.pop(context), - // ), - // ), - // ElevatedButton( - // child: const Text('Close'), - // onPressed: () => Navigator.pop(context), - // ), - ], + Navigator.pop(context); + }, + child: ListTile( + title: Text(provider.offlineExists + ? "Remove the event from offline" + : "Save the event offline"), + leading: Icon( + Icons.download, + color: Colors.blue, + ), + ), + ) + : SizedBox.shrink(), + provider.enableAttending + ? InkWell( + onTap: () { + if (widget.event.eventUserAttendee!) { + widget.event.eventUserAttendee = false; + + // if (event.isAttending) { + // SnackBarWidget.displaySnackBar( + // "Attending", context); + // } else { + SnackBarWidget.displaySnackBar( + "Marked as not attending", context); + // } + setState(() {}); + Navigator.pop(context); + } else { + Navigator.pop(context); + } + }, + child: ListTile( + title: Text("Mark as not attending"), + leading: Icon( + Icons.remove_circle, + color: Colors.red, + ), + ), + ) + : SizedBox.shrink(), + // Container( + // padding: EdgeInsets.symmetric(horizontal: 8.0), + // width: MediaQuery.of(context).size.width, + // child: ElevatedButton( + // child: const Text( + // 'Add to My Calendar', + // style: TextStyle(color: Colors.black), + // ), + // onPressed: () { + // Add2Calendar.addEvent2Cal( + // buildEvent(), + // ); + // Navigator.pop(context); + // }), + // ), + // Container( + // padding: EdgeInsets.symmetric(horizontal: 8.0), + // width: MediaQuery.of(context).size.width, + // Container( + // padding: EdgeInsets.symmetric(horizontal: 8.0), + // width: MediaQuery.of(context).size.width, + // child: ElevatedButton( + // child: const Text('Remove from my events', + // style: TextStyle(color: Colors.black)), + // onPressed: () => Navigator.pop(context), + // ), + // ), + // ElevatedButton( + // child: const Text('Close'), + // onPressed: () => Navigator.pop(context), + // ), + ], + ), ), ), - ); + ]); }, ); }, @@ -772,32 +781,33 @@ class _EventsListingScreenState extends State pagingController.refresh(); } }, - tabs: _tabs, + tabs: provider.tabs, ), ), ), ]; }, body: TabBarView( - //controller: _tabController, - children: [ - expandableDetails(provider), - speakersList(context, provider), + // controller: tabController, + children: returnTabWidget(provider) + // [ + // 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, + // 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(), + // ], ), - - // medicalInsights(), - //SocialMedia(), - ], - ), ), ), Visibility( @@ -815,6 +825,30 @@ class _EventsListingScreenState extends State ); } + List returnTabWidget(EventsProvider provider) { + List widgets = []; + for (var tabs in provider.tabs) { + if (tabs.text == "Speakers") { + widgets.add(speakersList(context, provider)); + } + if (tabs.text == "Details") { + widgets.add(expandableDetails(provider)); + } + if (tabs.text == "Insights") { + widgets.add(EventsInsights( + eid: widget.event.id!, + eventsdetail: widget.event, + eventid: widget.event.eventId!, + kFlutterHashtags: provider.kFlutterHashtags, + specialtyList: provider.specialtyList, + affiliations: provider.affiliations, + allSessionNotes: provider.allSessionNotes, + )); + } + } + return widgets; + } + Widget getSearchBarUI() { return Padding( padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 8), @@ -1162,62 +1196,69 @@ class _EventsListingScreenState extends State ], ), ), - SizedBox( - height: 8.0, - ), - RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon( - Icons.location_on, - size: 18, - color: Colors.white, + provider.getLocationDetails(event) == "" + ? SizedBox.shrink() + : SizedBox( + height: 8.0, + ), + provider.getLocationDetails(event) == "" + ? SizedBox.shrink() + : RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.location_on, + size: 18, + color: Colors.white, + ), + ), + TextSpan( + text: ' ${provider.getLocationDetails(event)}', + style: TextStyle( + color: Colors.white, + //fontStyle: FontStyle.italic, + letterSpacing: 0.3, + fontSize: isTablet ? 20 : 14), + ), + ], ), ), - TextSpan( - text: - ' ${event.city != null && event.city != "" ? "${event.city}, " : ""}${event.region != null && event.region != "" ? "${event.region}, " : ""}${event.country != null && event.country != "" ? "${event.country}" : ""}', - style: TextStyle( - color: Colors.white, - //fontStyle: FontStyle.italic, - letterSpacing: 0.3, - fontSize: isTablet ? 20 : 14), + event.url1 == null + ? SizedBox.shrink() + : SizedBox( + height: 8.0, ), - ], - ), - ), - SizedBox( - height: 8.0, - ), - InkWell( - onTap: () async { - print("URL:${event.url1!}"); - await _launchUrl(event.url1!); - }, - child: RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon( - Icons.link, - size: 18, - color: Colors.white, + event.url1 == null + ? SizedBox.shrink() + : InkWell( + onTap: () async { + print("URL:${event.url1!}"); + await _launchUrl(event.url1!); + }, + child: RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon( + Icons.link, + size: 18, + color: Colors.white, + ), + ), + TextSpan( + text: ' Visit Website', + style: TextStyle( + decoration: TextDecoration.underline, + color: Colors.white, + // fontStyle: FontStyle.italic, + letterSpacing: 0.6, + fontSize: isTablet ? 20 : 14), + ), + ], ), ), - TextSpan( - text: ' Visit Website', - style: TextStyle( - decoration: TextDecoration.underline, - color: Colors.white, - // fontStyle: FontStyle.italic, - letterSpacing: 0.6, - fontSize: isTablet ? 20 : 14), - ), - ], - ), - ), - ), + ), Padding( padding: const EdgeInsets.only(top: 8.0, right: 8.0, left: 1), @@ -1250,9 +1291,13 @@ class _EventsListingScreenState extends State // SizedBox( // width: 15, // ), - attendingbtn(widget.event, provider), + provider.enableAttending + ? attendingbtn(widget.event, provider) + : SizedBox.shrink(), // const Spacer(), - favbtn(widget.event, provider) + provider.enableFollow + ? favbtn(widget.event, provider) + : SizedBox.shrink(), ], ), ), @@ -2031,13 +2076,6 @@ class ProfileInfoItem { ); } -const _tabs = [ - Tab(text: "Details"), - Tab(text: "Speakers"), - Tab(text: "Insights"), -// Tab(text: "Medical Insights"), -]; - class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { _SliverAppBarDelegate(this._tabBar); diff --git a/lib/view/home.dart b/lib/view/home.dart index aa4846b..0d80ddb 100644 --- a/lib/view/home.dart +++ b/lib/view/home.dart @@ -183,14 +183,21 @@ class _HomeScreenState extends State with TickerProviderStateMixin { } init() async { - await Provider.of(context, listen: false).initFiltersData(); - // await Provider.of(context, listen: false).getMyEvents(0); await Provider.of(context, listen: false) - .getAddedSessionNotes(); + .initConfigModules(); + // await Provider.of(context, listen: false).initFiltersData(); + // await Provider.of(context, listen: false).getMyEvents(0); + //await ApiCall().dummyapi(); setState(() {}); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + init(); + } + @override Widget build(BuildContext context) { return Consumer( @@ -615,50 +622,52 @@ class _HomeScreenState extends State with TickerProviderStateMixin { // ), // ), // ), - Material( - color: Colors.transparent, - child: InkWell( - focusColor: Colors.transparent, - highlightColor: Colors.transparent, - hoverColor: Colors.transparent, - splashColor: Colors.grey.withOpacity(0.2), - borderRadius: const BorderRadius.all( - Radius.circular(4.0), - ), - onTap: () { - FocusScope.of(context).requestFocus(FocusNode()); - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (BuildContext context) => - // populateDrawer(provider), - // fullscreenDialog: false), - // ); - _scaffoldKey.currentState?.openEndDrawer(); - }, - child: Padding( - padding: const EdgeInsets.only(left: 8), - child: Row( - children: [ - Text( - 'Filters', - style: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 16, + !provider.enableFilters + ? SizedBox.shrink() + : Material( + color: Colors.transparent, + child: InkWell( + focusColor: Colors.transparent, + highlightColor: Colors.transparent, + hoverColor: Colors.transparent, + splashColor: Colors.grey.withOpacity(0.2), + borderRadius: const BorderRadius.all( + Radius.circular(4.0), + ), + onTap: () { + FocusScope.of(context).requestFocus(FocusNode()); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (BuildContext context) => + // populateDrawer(provider), + // fullscreenDialog: false), + // ); + _scaffoldKey.currentState?.openEndDrawer(); + }, + child: Padding( + padding: const EdgeInsets.only(left: 8), + child: Row( + children: [ + Text( + 'Filters', + style: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 16, + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + Icons.sort, + color: Color.fromARGB(255, 0, 71, 132), + ), + ), + ], ), ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Icon( - Icons.sort, - color: Color.fromARGB(255, 0, 71, 132), - ), - ), - ], + ), ), - ), - ), - ), ], ), ), @@ -1711,143 +1720,185 @@ class _HomeScreenState extends State with TickerProviderStateMixin { SizedBox( height: 5.0, ), - RichText( - textAlign: TextAlign.justify, - text: TextSpan( - children: [ - WidgetSpan( - child: Icon(Icons.location_on, size: 16), - ), - TextSpan( - text: - ' ${event.city != null && event.city != "" ? "${event.city}, " : ""}${event.region != null && event.region != "" ? "${event.region}, " : ""}${event.country != null && event.country != "" ? "${event.country}" : ""}', - style: TextStyle( - color: Colors.black, - //fontStyle: FontStyle.italic, + provider.getLocationDetails(event).length == 0 + ? SizedBox.shrink() + : Container( + constraints: BoxConstraints( + minWidth: 100, maxWidth: double.maxFinite), + //width: MediaQuery.of(context).size.width / 2, + // padding: EdgeInsets.only(right: 13), + child: RichText( + textAlign: TextAlign.justify, + text: TextSpan( + children: [ + WidgetSpan( + child: Icon(Icons.location_on, size: 16), + ), + // WidgetSpan( + // child: Flexible( + // // width: 200, + // child: Text( + // provider.getLocationDetails(event), + // overflow: TextOverflow.fade, + // ), + // )), + TextSpan( + spellOut: true, + text: + ' ${provider.getLocationDetails(event)}', + // ' ${event.city != null && event.city != "" ? "${event.city}, " : ""}${event.region != null && event.region != "" ? "${event.region}, " : ""}${event.country != null && event.country != "" ? "${event.country}" : ""}', + style: TextStyle( + color: Colors.black, + overflow: TextOverflow.ellipsis, + //fontStyle: FontStyle.italic, - fontSize: isTablet ? 16 : 12), + fontSize: isTablet ? 16 : 12), + ), + ], + ), + ), ), - ], - ), - ), + provider.ifOfflineExists(event.eventId ?? "") + ? Padding( + padding: EdgeInsets.only(right: 10), + child: RichText( + text: TextSpan(children: [ + WidgetSpan( + child: Icon(Icons.bookmark, + color: EventsConstants.blueColor, + size: isTablet ? 14 : 16), + ), + TextSpan( + text: ' Saved', + style: TextStyle( + color: Colors.black, + //fontStyle: FontStyle.italic, + + fontSize: isTablet ? 16 : 12), + ), + ]), + )) + : SizedBox.shrink(), ], ), - Align( - alignment: FractionalOffset.bottomRight, - child: Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - provider.ifOfflineExists(event.eventId ?? "") - ? Padding( - padding: EdgeInsets.only(right: 10), - child: Icon(Icons.bookmark, - color: EventsConstants.blueColor, - size: isTablet ? 14 : 18), - ) - : SizedBox.shrink(), - SizedBox( - width: 40, - height: 30, - child: FloatingActionButton.extended( - elevation: 1, - shape: CircleBorder(), - backgroundColor: EventsConstants.bgcolor, - //backgroundColor: EventsConstants.homeCardBackgound, - onPressed: () async { - // event.isfav = !event.isfav; + provider.enableFollow + ? Align( + alignment: FractionalOffset.bottomRight, + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: 40, + height: 30, + child: FloatingActionButton.extended( + elevation: 1, + shape: CircleBorder(), + backgroundColor: + EventsConstants.bgcolor, + //backgroundColor: EventsConstants.homeCardBackgound, + onPressed: () async { + // event.isfav = !event.isfav; - if (event.eventUserInterest!) { - //If event is added to fav then unfollow - String msg = await provider - .removeEventsToFavs(event.eventId!); - SnackBarWidget.displaySnackBar( - "Removed from My Events!", context); - } else { - String msg = await provider - .addEventsToFavs(event.eventId!); - SnackBarWidget.displaySnackBar( - "Added to My Events", context); - } - pagingController.refresh(); - setState(() {}); - // if (event.isfav) { - // // await provider.favsEventsData(event); - // } else { - // // await provider.delateEventsData(event); - // } - }, - label: AnimatedSwitcher( - duration: Duration(seconds: 1), - transitionBuilder: (Widget child, - Animation animation) => - FadeTransition( - opacity: animation, - child: SizeTransition( - child: child, - sizeFactor: animation, - axis: Axis.horizontal, - ), + if (event.eventUserInterest!) { + //If event is added to fav then unfollow + String msg = await provider + .removeEventsToFavs( + event.eventId!); + SnackBarWidget.displaySnackBar( + "Removed from My Events!", + context); + } else { + String msg = + await provider.addEventsToFavs( + event.eventId!); + SnackBarWidget.displaySnackBar( + "Added to My Events", context); + } + pagingController.refresh(); + setState(() {}); + // if (event.isfav) { + // // await provider.favsEventsData(event); + // } else { + // // await provider.delateEventsData(event); + // } + }, + label: AnimatedSwitcher( + duration: Duration(seconds: 1), + transitionBuilder: (Widget child, + Animation + animation) => + FadeTransition( + opacity: animation, + child: SizeTransition( + child: child, + sizeFactor: animation, + axis: Axis.horizontal, + ), + ), + child: event.eventUserInterest! + ? Column( + children: [ + Icon( + Icons.favorite, + color: Colors.red, + size: 14, + ), + ], + ) + : Icon( + Icons.favorite, + color: Colors.grey, + size: 14, + ))), + ), + SizedBox( + height: 2, + ), + event.eventUserInterest! + ? RichText( + text: TextSpan( + children: [ + WidgetSpan( + child: Icon(Icons.check, + color: Colors.grey[600], + size: isTablet ? 14 : 10), + ), + TextSpan( + text: ' Following', + style: TextStyle( + color: Colors.grey[600], + fontSize: + isTablet ? 14 : 10), + ), + ], ), - child: event.eventUserInterest! - ? Column( + ) + : Center( + child: RichText( + text: TextSpan( children: [ - Icon( - Icons.favorite, - color: Colors.red, - size: 14, + TextSpan( + text: 'Follow ', + style: TextStyle( + color: Colors.grey[600], + fontSize: + isTablet ? 14 : 10), ), ], - ) - : Icon( - Icons.favorite, - color: Colors.grey, - size: 14, - ))), - ), - SizedBox( - height: 2, - ), - event.eventUserInterest! - ? RichText( - text: TextSpan( - children: [ - WidgetSpan( - child: Icon(Icons.check, - color: Colors.grey[600], - size: isTablet ? 14 : 10), - ), - TextSpan( - text: ' Following', - style: TextStyle( - color: Colors.grey[600], - fontSize: isTablet ? 14 : 10), - ), - ], - ), - ) - : Center( - child: RichText( - text: TextSpan( - children: [ - TextSpan( - text: 'Follow ', - style: TextStyle( - color: Colors.grey[600], - fontSize: isTablet ? 14 : 10), + ), ), - ], - ), - ), - ), - ], - ), - ], - ), - ), + ), + ], + ), + ], + ), + ) + : SizedBox.shrink(), // Align( // alignment: Alignment.bottomRight, // child: SizedBox( diff --git a/lib/view/login.dart b/lib/view/login.dart index e052df4..c69404a 100644 --- a/lib/view/login.dart +++ b/lib/view/login.dart @@ -2,10 +2,12 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_svg/svg.dart'; import 'package:konectar_events/firebaseexample.dart'; import 'package:konectar_events/model/userdata_model.dart'; +import 'package:konectar_events/model/verify_user_resp.dart'; import 'package:konectar_events/utils/apicall.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/utils/sessionmanager.dart'; @@ -19,6 +21,7 @@ import 'package:konectar_events/widgets/custombutton.dart'; import 'package:konectar_events/widgets/customtextfield.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:mobile_device_identifier/mobile_device_identifier.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @@ -40,7 +43,10 @@ class _LoginScreenState extends State { late Future _key; late Future _login; late Future _logout; + late Future _verification_code; String platform = "android"; + String? deviceId; + final _mobileDeviceIdentifierPlugin = MobileDeviceIdentifier(); var provider; @override void initState() { @@ -48,7 +54,7 @@ class _LoginScreenState extends State { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { init(); provider = Provider.of(context, listen: false); - provider.initDeviceId(); + initDeviceId(); if (Platform.isAndroid) { platform = "android"; } else if (Platform.isIOS) { @@ -77,6 +83,21 @@ class _LoginScreenState extends State { }); } + Future initDeviceId() async { + String _deviceId; + try { + _deviceId = await _mobileDeviceIdentifierPlugin.getDeviceId() ?? + 'Unknown platform version'; + } on PlatformException { + _deviceId = 'Failed to get platform version.'; + } + + if (!mounted) return; + + deviceId = _deviceId; + print("DEVICE ID########################## :$deviceId"); + } + init() async { await ApiCall().parseInfo(); } @@ -285,120 +306,140 @@ class _LoginScreenState extends State { Center( child: CustomButton( backgroundColor: EventsConstants.onboardButtonColor, - // 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)); - - // 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; - // } - - // 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( - - // // emailTextController.text, - - // // true) - // // .then((value) { - // // Navigator.of(context).pushReplacement( - // // MaterialPageRoute( - // // builder: (context) => FirebaseExample( - // // title: secretKeyTextConrtroller.text, - // // )), - // // ); - // // } - // // ); - // } else { - // _displaySnackBar(textFieldsValidation(provider)); - // } - // }, onPressed: () async { - await ApiCall().fetchApiConstants().then( - (value) { - Navigator.of(context).pushReplacement( - MaterialPageRoute( - builder: (context) => NavigationHomeScreen()), - ); - }, - ); + 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(deviceId)); + + VerificationResponse resp = await provider.verifyEmail( + emailTextController.text, deviceId!, platform); + print("resp:${resp.status}"); + + if (resp.status == 1200 && + resp.verification_code != null) { + provider.loading = false; + provider.showCodeField = true; + provider.showMessage = true; + } else if (resp.status == 1200 && + resp.accessToken != "") { + provider.loading = false; + provider.showCodeField = false; + provider.showMessage = true; + _displaySnackBar("You have logged in successfully"); + _saveprefs( + resp.accessToken!, + resp.user?.email ?? emailTextController.text, + secretKeyTextConrtroller.text, + deviceId!, + true) + .then((value) { + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (context) => NavigationHomeScreen()), + ); + }); + } else { + provider.loading = false; + provider.showCodeField = false; + provider.showMessage = true; + } + + provider.message = resp.message; + setState(() { + emailTextController.text = provider.email!; + }); + } else { + provider.code = secretKeyTextConrtroller.text; + VerificationResponse resp = await provider.verifyCode( + emailTextController.text, + secretKeyTextConrtroller.text); + if (resp.status == 1200) { + provider.loading = false; + provider.showCodeField = false; + provider.showMessage = true; + _displaySnackBar("You have logged in successfully"); + _saveprefs( + resp.accessToken!, + emailTextController.text, + secretKeyTextConrtroller.text, + deviceId!, + 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( + + // emailTextController.text, + + // true) + // .then((value) { + // Navigator.of(context).pushReplacement( + // MaterialPageRoute( + // builder: (context) => FirebaseExample( + // title: secretKeyTextConrtroller.text, + // )), + // ); + // } + // ); + } else { + _displaySnackBar(textFieldsValidation(provider)); + } }, + // onPressed: () async { + // await ApiCall().fetchApiConstants().then( + // (value) { + // Navigator.of(context).pushReplacement( + // MaterialPageRoute( + // builder: (context) => NavigationHomeScreen()), + // ); + // }, + // ); + // }, textColor: Colors.white, fontsize: isTablet ? 22 : 18, title: provider.showCodeField ? "Verify" : "Sign In"), @@ -416,12 +457,14 @@ class _LoginScreenState extends State { } Future _saveprefs( - String token, String email, String key, bool login) async { + String token, String email, String key, String vcode, bool login) async { final SharedPreferences prefs = await _prefs; final String useremail = (prefs.getString('useremail') ?? ''); final String username = (prefs.getString('username') ?? ''); final String secretkey = (prefs.getString('secretkey') ?? ''); + final String verification_code = + (prefs.getString('verfication_code') ?? ''); final bool isloggedin = (prefs.getBool('isloggedin') ?? false); final bool isloggedout = (prefs.getBool('isloggedout') ?? false); setState(() { @@ -435,6 +478,10 @@ class _LoginScreenState extends State { _key = prefs.setString('secretkey', key).then((bool success) { return secretkey; }); + _verification_code = + prefs.setString('verfication_code', key).then((bool success) { + return verification_code; + }); _login = prefs.setBool('isloggedin', login).then((bool success) { return isloggedin; }); diff --git a/lib/view/login_components/care_view.dart b/lib/view/login_components/care_view.dart index dca50ae..321bf43 100644 --- a/lib/view/login_components/care_view.dart +++ b/lib/view/login_components/care_view.dart @@ -76,12 +76,12 @@ class CareView extends StatelessWidget { child: SlideTransition( position: _secondHalfAnimation, child: Stack(children: [ - SvgPicture.asset( - 'assets/images/sc2bg500.svg', - fit: BoxFit.fill, - // width: MediaQuery.of(context).size.width, - // height: MediaQuery.of(context).size.height, - ), + // SvgPicture.asset( + // 'assets/images/sc2bg500.svg', + // fit: BoxFit.fill, + // // width: MediaQuery.of(context).size.width, + // // height: MediaQuery.of(context).size.height, + // ), Container( padding: const EdgeInsets.only(bottom: 100), child: Column( diff --git a/lib/view/login_components/mood_diary_vew.dart b/lib/view/login_components/mood_diary_vew.dart index 688f34e..f0669d8 100644 --- a/lib/view/login_components/mood_diary_vew.dart +++ b/lib/view/login_components/mood_diary_vew.dart @@ -76,15 +76,15 @@ class MoodDiaryVew extends StatelessWidget { child: SlideTransition( position: _secondHalfAnimation, child: Stack(children: [ - Padding( - padding: const EdgeInsets.only(left: 4.0), - child: SvgPicture.asset( - 'assets/images/sc1bg1500.svg', - fit: BoxFit.cover, - // width: MediaQuery.of(context).size.width, - // height: MediaQuery.of(context).size.height, - ), - ), + // Padding( + // padding: const EdgeInsets.only(left: 4.0), + // child: SvgPicture.asset( + // 'assets/images/sc1bg1500.svg', + // fit: BoxFit.cover, + // // width: MediaQuery.of(context).size.width, + // // height: MediaQuery.of(context).size.height, + // ), + // ), Container( padding: const EdgeInsets.only(bottom: 100), child: Column( diff --git a/lib/view/login_components/relax_view.dart b/lib/view/login_components/relax_view.dart index deef445..66f73ac 100644 --- a/lib/view/login_components/relax_view.dart +++ b/lib/view/login_components/relax_view.dart @@ -71,12 +71,12 @@ class RelaxView extends StatelessWidget { child: SlideTransition( position: _secondHalfAnimation, child: Stack(children: [ - SvgPicture.asset( - 'assets/images/sc1bg1500.svg', - fit: BoxFit.cover, - // width: MediaQuery.of(context).size.width, - // height: MediaQuery.of(context).size.height, - ), + // SvgPicture.asset( + // 'assets/images/sc1bg1500.svg', + // fit: BoxFit.cover, + // // width: MediaQuery.of(context).size.width, + // // height: MediaQuery.of(context).size.height, + // ), Container( padding: const EdgeInsets.only(bottom: 100), child: Column( diff --git a/lib/view/navigation_home_screen.dart b/lib/view/navigation_home_screen.dart index 74540fc..508f475 100644 --- a/lib/view/navigation_home_screen.dart +++ b/lib/view/navigation_home_screen.dart @@ -47,7 +47,7 @@ class _NavigationHomeScreenState extends State { drawerWidth: MediaQuery.of(context).size.width * 0.75, onDrawerCall: (DrawerIndex drawerIndexdata) async { bool checkContacts = await HiveOperations.checkIfApiExists( - EventsConstants.contactsListapi); + EventsConstants.contactsListapi, EventsConstants.moduleName); if (!checkContacts && drawerIndexdata.name == "Contacts") { } else { changeIndex(drawerIndexdata); diff --git a/lib/view/profileview.dart b/lib/view/profileview.dart index ac2dccc..95706ee 100644 --- a/lib/view/profileview.dart +++ b/lib/view/profileview.dart @@ -6,6 +6,7 @@ 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'; @@ -65,6 +66,7 @@ class _HCPProfileScreenState extends State { String attachedFileName = ''; String attachedFilePath = ''; bool isLoading = false; + bool enableCancel = false; String btnText = "Add Notes"; final List _fruits = ['Events', 'Sessions']; final List topics = [ @@ -75,7 +77,8 @@ class _HCPProfileScreenState extends State { "Program Committee", "Practical Application of CDK 4/6 Inhibitor" ]; - final ValueNotifier> valueList = ValueNotifier>([]); + final ValueNotifier> valueList = + ValueNotifier>([0, 0, 0]); TextEditingController notesController = TextEditingController(text: ""); List sessionNotesList = []; Future dialogBuilder(BuildContext context, Eventsdetail eventsdetail, @@ -170,7 +173,9 @@ class _HCPProfileScreenState extends State { notesController.text = newValue.note ?? ""; if (newValue.note != "" && notesController.text.length != 0) { btnText = "Update"; + enableCancel = true; } + setState(() {}); }); }, @@ -182,7 +187,7 @@ class _HCPProfileScreenState extends State { @override void initState() { - valueList.value = [0, 0, 0]; + //valueList.value = [0, 0, 0]; WidgetsBinding.instance.addPostFrameCallback((timeStamp) { init(); }); @@ -191,10 +196,23 @@ class _HCPProfileScreenState extends State { } 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); + .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) @@ -208,12 +226,6 @@ 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(() {}); } @@ -221,8 +233,9 @@ class _HCPProfileScreenState extends State { return Consumer( builder: (BuildContext context, provider, Widget? child) { return DefaultTabController( - length: 3, + length: provider.tabs.length, child: Scaffold( + backgroundColor: EventsConstants.bgcolor, appBar: AppBar( // title: Text(""), automaticallyImplyLeading: false, @@ -279,6 +292,7 @@ class _HCPProfileScreenState extends State { expandedHeight: 280.0, // expandedHeight: MediaQuery.of(context).size.height * 0.25, backgroundColor: EventsConstants.bgcolor, + //backgroundColor: Colors.white, automaticallyImplyLeading: false, floating: false, pinned: false, @@ -305,54 +319,68 @@ class _HCPProfileScreenState extends State { pinned: true, floating: true, delegate: _SliverAppBarDelegate( - const TabBar( + TabBar( isScrollable: false, indicatorSize: TabBarIndicatorSize.tab, tabAlignment: TabAlignment.fill, - labelColor: Colors.white, - indicatorColor: Colors.white, + labelColor: Colors.black, + indicatorColor: EventsConstants.blueColor, labelStyle: TextStyle( fontWeight: FontWeight.bold, ), labelPadding: EdgeInsets.all(2), - indicatorWeight: 4.0, + indicatorWeight: 2.0, //Color.fromARGB(255, 5, 36, 62) unselectedLabelColor: Colors.grey, - tabs: _tabs, + tabs: provider.tabs, ), ), ), ]; }, - body: TabBarView(children: [ - topicsTab(widget.eventsdetail, provider), - sessionNotes(context, widget.eventsdetail, provider), - medicalInsights(), - // sessionNotes(context) - ] - // _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()), - ), + 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()), + ), ), )); }); } - buildprofile( - BuildContext context, EventSpeakersData eventsdetail, String title) { + 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}"); @@ -402,10 +430,7 @@ class _HCPProfileScreenState extends State { textAlign: TextAlign.center, text: TextSpan(children: [ TextSpan( - text: eventsdetail.orgName != null || - eventsdetail.orgName!.trim() != "" - ? '${eventsdetail.orgName}' - : "", + text: provider.getUserLoc(eventsdetail), style: TextStyle( // decoration: TextDecoration.underline, // decorationColor: Colors.blue, @@ -420,34 +445,34 @@ class _HCPProfileScreenState extends State { // softWrap: true, // overflow: TextOverflow.ellipsis, ), - TextSpan( - text: eventsdetail.country != null - ? '${eventsdetail.country},' - : "", - style: TextStyle( - // decoration: TextDecoration.underline, - // decorationColor: Colors.blue, - color: Colors.white, + // TextSpan( + // text: eventsdetail.country != null + // ? '${eventsdetail.country},' + // : "", + // style: TextStyle( + // // decoration: TextDecoration.underline, + // // decorationColor: Colors.blue, + // color: Colors.white, - fontSize: 14, + // fontSize: 14, - // fontFamily: "SourceSerif", - ), - ), - TextSpan( - text: eventsdetail.city != null - ? '${eventsdetail.city}' - : "", - style: TextStyle( - // decoration: TextDecoration.underline, - // decorationColor: Colors.blue, - color: Colors.white, + // // fontFamily: "SourceSerif", + // ), + // ), + // TextSpan( + // text: eventsdetail.city != null + // ? '${eventsdetail.city}' + // : "", + // style: TextStyle( + // // decoration: TextDecoration.underline, + // // decorationColor: Colors.blue, + // color: Colors.white, - fontSize: 14, + // fontSize: 14, - // fontFamily: "SourceSerif", - ), - ) + // // fontFamily: "SourceSerif", + // ), + // ) ])), // Text( @@ -535,7 +560,8 @@ class _HCPProfileScreenState extends State { // title: eventsdetail.kolFullName!, // eventsdetail: eventsdetail, // ), - buildprofile(context, eventsdetail, eventsdetail.kolFullName!), + buildprofile( + context, eventsdetail, eventsdetail.kolFullName!, provider), // Padding( // padding: const EdgeInsets.all(8.0), // child: Column( @@ -722,6 +748,24 @@ class _HCPProfileScreenState extends State { // 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), @@ -740,7 +784,7 @@ class _HCPProfileScreenState extends State { setState(() {}); }, width: 120, - height: 40, + height: 35, fontsize: 12, textColor: Colors.black, title: "Attach file"), @@ -758,100 +802,250 @@ class _HCPProfileScreenState extends State { ), ], )), - Align( - alignment: Alignment.center, - 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; + 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}"); + // 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 + // 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); + // 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); + // 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), + // _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, + // ), + ), ), - // 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(() {}); + // }, + // ), ), - Visibility( - visible: isLoading, - child: Center( - child: CircularProgressIndicator( - color: EventsConstants.blueColor, - )), - ), - ], - ), + ), + ], ), Divider(), Padding( @@ -918,7 +1112,7 @@ class _HCPProfileScreenState extends State { if (notesController.text.length != 0) { btnText = "Update"; } - + enableCancel = true; setState(() {}); }, width: 80, @@ -1348,21 +1542,21 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { Widget build( BuildContext context, double shrinkOffset, bool overlapsContent) { return Container( - //color: Constants.tabbgColor, - 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, + // 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), diff --git a/lib/viewmodel/eventsprovider.dart b/lib/viewmodel/eventsprovider.dart index 7604b77..4197b26 100644 --- a/lib/viewmodel/eventsprovider.dart +++ b/lib/viewmodel/eventsprovider.dart @@ -23,7 +23,9 @@ import 'package:konectar_events/model/sessionnotesmodel.dart'; import 'package:konectar_events/model/specialtymodel.dart'; import 'package:konectar_events/model/topics_cloud_model.dart'; import 'package:konectar_events/utils/apicall.dart'; +import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/utils/dateformater.dart'; +import 'package:konectar_events/viewmodel/hive_repository.dart'; import 'package:konectar_events/widgets/word_cloud.dart'; class EventsProvider extends ChangeNotifier { @@ -62,6 +64,57 @@ class EventsProvider extends ChangeNotifier { List allSessionNotes = []; late StreamSubscription> connectivitySubscription; bool isLoadingInsights = true; + + //ENABLE/DISABLE KEYS + bool enableFollow = false; + bool enableAttending = false; + bool enableDetails = false; + bool enableSpeakers = false; + bool enableInsights = false; + bool addOffline = false; + bool enableFilters = false; + var tabs = [ + Tab(text: "Details"), + Tab(text: "Speakers"), + Tab(text: "Insights"), +// Tab(text: "Medical Insights"), + ]; + initConfigModules() async { + print("CONFIG_CALLED"); + enableFollow = await HiveOperations.checkIfApiExists( + EventsConstants.followUnfollowEvent, EventsConstants.moduleName); + enableAttending = await HiveOperations.checkIfApiExists( + EventsConstants.attendNotAttendEvent, EventsConstants.moduleName); + enableDetails = await HiveOperations.checkIfApiExists( + EventsConstants.eventdetailsapi, EventsConstants.moduleName); + enableSpeakers = await HiveOperations.checkIfApiExists( + EventsConstants.speakerslistapi, EventsConstants.moduleName); + + enableInsights = await HiveOperations.checkIfApiExists( + EventsConstants.insightsTopicsCloud, EventsConstants.moduleName); + addOffline = await HiveOperations.checkIfApiExists( + EventsConstants.saveEventOffline, EventsConstants.moduleName); + enableFilters = await HiveOperations.checkIfApiExists( + EventsConstants.filtersApi, EventsConstants.moduleName); + tabs.clear(); + if (enableDetails) { + tabs.add(Tab( + text: "Details", + )); + } + if (enableSpeakers) { + tabs.add(Tab( + text: "Speakers", + )); + } + if (enableInsights) { + tabs.add(Tab( + text: "Insights", + )); + } + notifyListeners(); + } + Future onSelectAll(int page) async { isFavSeleted = false; isAllSelected = !isAllSelected; @@ -78,6 +131,27 @@ class EventsProvider extends ChangeNotifier { notifyListeners(); } + String getLocationDetails(EventsList event) { + List loc = []; + if (event.city != null && event.city != "") { + loc.add(event.city!); + } + if (event.region != null && event.region != "") { + loc.add(event.region!); + } + if (event.country != null && event.country != "") { + loc.add(event.country!); + } + return loc.join(' , '); + // return 'hdgkhjagshjdgashjdgkjhsagdkjgasljkdgsajkgdhjksaghdjkasgdkjgaskjdlsak'; + } + + String getEventDate(EventsList event) { + String date = + '${CustomDateFormatter().formatYearDate(CustomDateFormatter().convertStringToDate(event.start!))} to ${CustomDateFormatter().formatYearDate(CustomDateFormatter().convertStringToDate(event.end!))}'; + return date; + } + bool checkIfUserInterested(String eventid) { bool user = false; if (eventList.isNotEmpty) { @@ -407,7 +481,7 @@ class EventsProvider extends ChangeNotifier { FutureOr saveEventsData(EventsList eventsData) async { box = await Hive.openBox('EventsListBox'); - + //check if already exists box.add(eventsData); offlineEvents.clear(); offlineEvents = await getOfflineMyEvents(); diff --git a/lib/viewmodel/hcpprofprovider.dart b/lib/viewmodel/hcpprofprovider.dart index 630b71b..01004ce 100644 --- a/lib/viewmodel/hcpprofprovider.dart +++ b/lib/viewmodel/hcpprofprovider.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:math'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:konectar_events/model/allsessionnotesmodel.dart'; import 'package:konectar_events/model/events_speakers_k1.dart'; @@ -12,6 +13,8 @@ import 'package:konectar_events/model/sessionnotesmodel.dart'; import 'package:konectar_events/model/sessionstopics_model.dart'; import 'package:konectar_events/model/topics_cloud_model.dart'; import 'package:konectar_events/utils/apicall.dart'; +import 'package:konectar_events/utils/constants.dart'; +import 'package:konectar_events/viewmodel/hive_repository.dart'; import 'package:konectar_events/widgets/word_cloud.dart'; class HcpProfileProvider extends ChangeNotifier { @@ -23,6 +26,60 @@ class HcpProfileProvider extends ChangeNotifier { List sessionTopics = []; List allSessionNotes = []; late Box box; + bool enableSessions = false; + bool enableNotes = false; + bool enableMedInsights = false; + var tabs = [ + Tab(text: "Sessions"), + Tab(text: "Notes"), + Tab(text: "Medical Insights"), +// Tab(text: "Medical Insights"), + ]; + initConfigModules() async { + enableSessions = await HiveOperations.checkIfApiExists( + EventsConstants.showEventsTopicsAndSession, EventsConstants.moduleName); + enableNotes = await HiveOperations.checkIfApiExists( + EventsConstants.saveEventsTopicNote, EventsConstants.moduleName); + enableMedInsights = await HiveOperations.checkIfApiExists( + EventsConstants.medInsightApi, EventsConstants.moduleName); + tabs.clear(); + if (!enableSessions) { + tabs.clear(); + } else { + if (enableSessions) { + tabs.add(Tab( + text: "Sessions", + )); + } + if (enableNotes) { + tabs.add(Tab( + text: "Notes", + )); + } + if (enableMedInsights) { + tabs.add(Tab( + text: "Medical Insights", + )); + } + } + notifyListeners(); + } + + String getUserLoc(EventSpeakersData detail) { + List loc = []; + if (detail.orgName != null && detail.orgName != "") { + loc.add(detail.orgName!); + } + if (detail.city != null && detail.city != "") { + loc.add(detail.city!); + } + + if (detail.country != null && detail.country != "") { + loc.add(detail.country!); + } + return loc.join(' , '); + // return 'hdgkhjagshjdgashjdgkjhsagdkjgasljkdgsajkgdhjksaghdjkasgdkjgaskjdlsak'; + } Future getSessionTopics(EventSpeakersData detail) async { sessionTopics = await ApiCall().getSessionsTopics(detail.eid!, diff --git a/lib/viewmodel/hive_repository.dart b/lib/viewmodel/hive_repository.dart index bec0869..dc6a016 100644 --- a/lib/viewmodel/hive_repository.dart +++ b/lib/viewmodel/hive_repository.dart @@ -10,16 +10,15 @@ class HiveOperations { hiveApiConstantsBox.addAll(hiveList); } - static Future checkIfApiExists( - String api, - ) async { + static Future checkIfApiExists(String api, String moduleName) async { late Box hiveApiConstantsBox; hiveApiConstantsBox = await Hive.openBox('hiveApiConstants'); List list = hiveApiConstantsBox.values.toList(); return list.indexWhere( - (element) => element.functionName == api, + (element) => + element.functionName == api && element.module == moduleName, ) == -1 ? false diff --git a/lib/viewmodel/loginprovider.dart b/lib/viewmodel/loginprovider.dart index 480cd49..95d2295 100644 --- a/lib/viewmodel/loginprovider.dart +++ b/lib/viewmodel/loginprovider.dart @@ -6,7 +6,6 @@ import 'package:konectar_events/utils/apicall.dart'; import 'package:flutter/services.dart'; import 'package:konectar_events/utils/constants.dart'; import 'package:konectar_events/viewmodel/hive_repository.dart'; -import 'package:mobile_device_identifier/mobile_device_identifier.dart'; class LoginProvider extends ChangeNotifier { late Box box; @@ -18,7 +17,6 @@ class LoginProvider extends ChangeNotifier { String? email; String? code; String deviceId = 'Unknown'; - final _mobileDeviceIdentifierPlugin = MobileDeviceIdentifier(); init() {} Future verifyEmail(String email, String deviceid, String platform) { @@ -136,19 +134,4 @@ class LoginProvider extends ChangeNotifier { } //GET DEVICE UNIQUE ID - Future initDeviceId() async { - String deviceId; - try { - deviceId = await _mobileDeviceIdentifierPlugin.getDeviceId() ?? - 'Unknown platform version'; - } on PlatformException { - deviceId = 'Failed to get platform version.'; - } - - //if (!mounted) return; - - deviceId = deviceId; - print("DEVICE ID :$deviceId"); - notifyListeners(); - } } diff --git a/lib/widgets/home_drawer.dart b/lib/widgets/home_drawer.dart index d3a8c86..6091449 100644 --- a/lib/widgets/home_drawer.dart +++ b/lib/widgets/home_drawer.dart @@ -27,7 +27,7 @@ class _HomeDrawerState extends State { List? drawerList; final Future _prefs = SharedPreferences.getInstance(); late Future _useremail; - late Future _key; + late Future _deviceid; @override void initState() { setDrawerListArray(); @@ -35,15 +35,15 @@ class _HomeDrawerState extends State { return prefs.getString('useremail') ?? ""; }); - _key = _prefs.then((SharedPreferences prefs) { - return prefs.getString('token') ?? ""; + _deviceid = _prefs.then((SharedPreferences prefs) { + return prefs.getString('verfication_code') ?? ""; }); super.initState(); } void setDrawerListArray() async { - bool checkContacts = - await HiveOperations.checkIfApiExists(EventsConstants.contactsListapi); + bool checkContacts = await HiveOperations.checkIfApiExists( + EventsConstants.contactsListapi, EventsConstants.moduleName); if (!checkContacts) { drawerList = [ DrawerList( @@ -257,7 +257,8 @@ class _HomeDrawerState extends State { } void onTapped() async { - final resp = ApiCall().logout(await _key); + print("device id : ${await _deviceid}"); + final resp = await ApiCall().logout(await _useremail, await _deviceid); print("resp:$resp"); await SessionManager().logoutSession(false).then((value) { Navigator.of(context).popUntil((route) => route.isFirst);