From 5185b13694d87b42e55cea2051703c35853b4112 Mon Sep 17 00:00:00 2001 From: "snehalathad@aissel.com" Date: Thu, 19 Dec 2024 11:03:08 +0530 Subject: [PATCH 1/2] session expiry resolved,adding auth ,logout --- assets/api_constants.json | 22 +- lib/main.dart | 78 +++---- lib/utils/apicall.dart | 270 +++++++++++++++++------ lib/utils/constants.dart | 4 +- lib/view/home.dart | 1 + lib/view/login.dart | 141 ++---------- lib/view/login_components/care_view.dart | 14 ++ lib/widgets/home_drawer.dart | 2 +- 8 files changed, 276 insertions(+), 256 deletions(-) diff --git a/assets/api_constants.json b/assets/api_constants.json index 3fdbcb0..bd35e33 100644 --- a/assets/api_constants.json +++ b/assets/api_constants.json @@ -3,68 +3,68 @@ "api": "loadFutureEvents", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "saveUserInterestedEvent", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "saveUserAttendingEvent", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "eventOverview", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "getSpecialitiesDonutChart", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "getTopicCloudChart", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "getTopAffiliationBarChart", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "eventSpeakers", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "saveEventsTopicNote", "interval": 5, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "eventUserAnalytics", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "saveEventOffline", "interval": 0, "method": "POST", - "module": "eventapis" + "module": "apis/v1/events" }, { "api": "contactslistapi", diff --git a/lib/main.dart b/lib/main.dart index bac4c03..3801ae3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -202,19 +202,7 @@ Future main() async { print("checkhere before:$isloggedIn"); String secretkey = instance.getString('secretkey') ?? ""; - OverlaySupportEntry entry; - Connectivity().onConnectivityChanged.listen((event) { - print("CHECK INTERNET"); - print(event); - if (event.toString().contains("ConnectivityResult.none")) { - entry = showOverlayNotification((context) { - return Text("this is a message from simple notification"); - }, duration: Duration(hours: 1)); - } - }); - OverlaySupport overlaySupport = OverlaySupport.global( - child: Text("ONLINE"), - ); + runApp( MultiProvider( providers: [ @@ -260,41 +248,39 @@ Future main() async { create: (_) => HiveDataRepository( Hive.box('InteractionConfigDataBox'))), ], - child: - // SafeArea( - // top: true, - // child: - MaterialApp( - theme: ThemeData( - //fontFamily: "SourceSerif", - ), - debugShowCheckedModeBanner: false, - title: 'Dynamic Links Example', - initialRoute: '/', - routes: { - '/': (BuildContext context) => FutureBuilder( - future: SessionManager().isLoggedIn(), - builder: (context, snapshot) { - print("Data_is : $snapshot"); - if (snapshot.connectionState == ConnectionState.waiting) { - return const CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else { - final isLoggedIn = snapshot.data ?? false; - print("isLoggedIn_is : $isLoggedIn"); - print("secret : $secretkey"); - return isLoggedIn - ? NavigationHomeScreen() - : IntroductionAnimationScreen(); - } - }, - ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), - // '/details': (BuildContext context) => const HomeScreen(), - }, + child: SafeArea( + top: true, + child: MaterialApp( + theme: ThemeData( + //fontFamily: "SourceSerif", + ), + debugShowCheckedModeBanner: false, + title: 'Dynamic Links Example', + initialRoute: '/', + routes: { + '/': (BuildContext context) => FutureBuilder( + future: SessionManager().isLoggedIn(), + builder: (context, snapshot) { + print("Data_is : $snapshot"); + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else { + final isLoggedIn = snapshot.data ?? false; + print("isLoggedIn_is : $isLoggedIn"); + print("secret : $secretkey"); + return isLoggedIn + ? NavigationHomeScreen() + : IntroductionAnimationScreen(); + } + }, + ), //userInfo != null ? const Home() : OpenidScreen(credential: credential,), + // '/details': (BuildContext context) => const HomeScreen(), + }, + ), ), ), - // ), ); }); } diff --git a/lib/utils/apicall.dart b/lib/utils/apicall.dart index b8f1327..7de5740 100644 --- a/lib/utils/apicall.dart +++ b/lib/utils/apicall.dart @@ -33,9 +33,18 @@ class ApiCall { final dio = Dio(); final Future _prefs = SharedPreferences.getInstance(); - late Future _token; - String newtoken = - "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZWNyZXRlVG9rZW4iOiJiYjNmOTZmYmI5Y2U3ZjA2ZTliOTlkMzRiMGM3YjZkZTBlNjBmYWYzYmM1NDFhZjY0MGQ5ZjAzMGRlNzMxOWM4ZTAwZWNkMCIsImlhdCI6MTczNDM0OTUwNywiZXhwIjoxNzM0MzUxMzA3fQ.nN5XtgmWHVGGdyLEdICY6jTmlg1070rGFwsdyOd4CYY"; + String token = ""; + ApiCall() { + init(); + print("constructor"); + } + + init() async { + token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); + } + //K1 API CALLS Future parseInfo() async { Dio dio = Dio(); @@ -118,41 +127,42 @@ class ApiCall { Future> getEventsFromK1({int? type}) async { Dio dio = Dio(); - (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = - (HttpClient client) { - client.badCertificateCallback = - (X509Certificate cert, String host, int port) => true; - return client; - }; + // (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = + // (HttpClient client) { + // client.badCertificateCallback = + // (X509Certificate cert, String host, int port) => true; + // return client; + // }; Response response; - String date = "2024-12-17"; - var formData = - FormData.fromMap({"start": date, "order_by": 7, 'type': type ?? 1}); - // "end": DateTime(2024, 12, 14).toIso8601String(), - _token = _prefs.then((SharedPreferences prefs) { - return prefs.getString('token') ?? ""; + String date = "2024-12-12"; + var formData = FormData.fromMap({ + "start": "2024-12-16", + "order_by": 7, + 'type': type ?? 1, }); - print("SAVED TOKEN :${await _token}"); + // "end": DateTime(2024, 12, 14).toIso8601String(), + + print("SAVED TOKEN :${token}"); + + //http://192.168.2.130/konectar-staging/apiauths/logout/ try { - // dio.options.contentType = Headers.multipartFormDataContentType; - // dio.options.baseUrl = "https://cardio-staging.konectar.io/"; - - // dio.options.headers["Authorization"] = "Bearer ${newtoken}"; - response = await dio.post( - 'https://cardio-staging.konectar.io/apis/v1/events/loadFutureEvents/', + '${EventsConstants.url}${EventsConstants.eventslistapi}', options: Options( - contentType: "multipart/form-data", - followRedirects: false, - // will not throw errors + followRedirects: true, validateStatus: (status) => true, + preserveHeaderCase: true, headers: { - 'Authorization': 'Bearer ${newtoken}', + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' }), data: formData); - print("RESPONSE"); - print(response.data.toString()); + print("RESPONSE ${dio.options.headers}"); + print(response); Map jsondata = json.decode(response.data); EventsData eventresponse = EventsData.fromJson(jsondata); @@ -174,13 +184,24 @@ class ApiCall { return client; }; Response response; - var formData = FormData.fromMap( - {"user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag}); + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); + var formData = FormData.fromMap({"eid": eventid, "flag": flag}); response = await dio.post( '${EventsConstants.url}${EventsConstants.followUnfollowEvent}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), queryParameters: { - "user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag, }, @@ -199,14 +220,25 @@ class ApiCall { (X509Certificate cert, String host, int port) => true; return client; }; + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); Response response; - var formData = FormData.fromMap( - {"user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag}); + var formData = FormData.fromMap({"eid": eventid, "flag": flag}); response = await dio.post( '${EventsConstants.url}${EventsConstants.attendNotAttendEvent}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), queryParameters: { - "user_email": "vinodh@aissel.com", "eid": eventid, "flag": flag, }, @@ -223,6 +255,9 @@ class ApiCall { required String endDate, required bool client, }) async { + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); print( "FORMAT_CHECK_DATE $startDate $endDate $eventid ${DateTime(2024, 12, 03).toIso8601String()}"); Dio dio = Dio(); @@ -237,7 +272,6 @@ class ApiCall { var formData; if (client) { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -246,7 +280,6 @@ class ApiCall { }); } else { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -256,7 +289,17 @@ class ApiCall { print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( '${EventsConstants.url}${EventsConstants.specialtyOfSpeakers}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); @@ -276,6 +319,9 @@ class ApiCall { required String startDate, required String endDate, required bool client}) async { + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -287,7 +333,6 @@ class ApiCall { var formData; if (client) { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -296,7 +341,6 @@ class ApiCall { }); } else { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -306,7 +350,17 @@ class ApiCall { print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( '${EventsConstants.url}${EventsConstants.insightsTopicsCloud}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); @@ -328,6 +382,9 @@ class ApiCall { required String startDate, required String endDate, required bool client}) async { + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); Dio dio = Dio(); (dio.httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate = (HttpClient client) { @@ -339,7 +396,6 @@ class ApiCall { var formData; if (client) { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -348,7 +404,6 @@ class ApiCall { }); } else { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "eventId": eventid, "sd": startDate, "ed": endDate, @@ -358,7 +413,17 @@ class ApiCall { print("FORMDATA:${formData.toString()},$startDate,$endDate"); response = await dio.post( '${EventsConstants.url}${EventsConstants.insightsBarChart}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData); print("response SPECIALTY SPEAKERS here!!!!!!!!!!!!!!!!!!!!! "); @@ -385,14 +450,25 @@ class ApiCall { }; Response response; var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "event_id": eventid, }); + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); response = await dio.post( '${EventsConstants.url}${EventsConstants.eventdetailsapi}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), queryParameters: { - "user_email": "vinodh@aissel.com", "event_id": eventid, }, data: formData); @@ -416,17 +492,28 @@ class ApiCall { }; Response response; var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "event_id": eventid, "project_id": 1, }); // "sd": "2024-07-30", // "ed": "2024-08-03", + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); response = await dio.post( '${EventsConstants.url}${EventsConstants.speakerslistapi}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), queryParameters: { - "user_email": "vinodh@aissel.com", "event_id": eventid, }, data: formData); @@ -451,15 +538,27 @@ class ApiCall { Response response; print("formdata : eventid:$eventid kolid:$kolid kid:$kid"); var formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "event_id": eventid, "kol_id": kolid, "k_id": kid, }); // "proj_kol_id": 0, + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); response = await dio.post( '${EventsConstants.url}${EventsConstants.showEventsTopicsAndSession}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), queryParameters: { "user_email": "vinodh@aissel.com", "event_id": eventid, @@ -493,10 +592,12 @@ class ApiCall { return client; }; var formData; + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); Response response; if (filename != "") { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "kol_events_id": eventid, "kol_id": kolid, "event_attendees_id": event_attendees_id, @@ -506,7 +607,6 @@ class ApiCall { }); } else { formData = FormData.fromMap({ - "user_email": "vinodh@aissel.com", "kol_events_id": eventid, "kol_id": kolid, "event_attendees_id": event_attendees_id, @@ -518,7 +618,17 @@ class ApiCall { response = await dio.post( '${EventsConstants.url}${EventsConstants.saveEventsTopicNote}', - options: Options(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData); print("response user ADDSESSION here!!!!!!!!!!!!!!!!!!!!! "); print(response.data.toString()); @@ -540,15 +650,26 @@ class ApiCall { return client; }; Response response; - + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); 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(), + options: Options( + followRedirects: true, + validateStatus: (status) => true, + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData); print("response user ALLSESSIONNOTES here!!!!!!!!!!!!!!!!!!!!! "); List data = []; @@ -568,7 +689,9 @@ class ApiCall { dynamic jsonResult = jsonDecode(await rootBundle.loadString("assets/api_constants.json")); //dynamic jsonResult = await MockApiCall().getConfigDataMedical(); - + String token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); List responseData = apiConstantsResponseFromJson(jsonResult); print('Response_data_is: $responseData'); @@ -611,7 +734,9 @@ class ApiCall { }); try { response = await dio.post( - '${url}${EventsConstants.loginmodule}/${EventsConstants.getVerificationCode}', + 'http://192.168.2.130/konectar-staging/apiauths/getVerificationCode/', + //'https://cardio-staging.konectar.io/apiauths/getVerificationCode/', + //'${url}${EventsConstants.loginmodule}/${EventsConstants.getVerificationCode}', options: Options(), data: formData); if (response.statusCode == 200) { @@ -645,8 +770,11 @@ class ApiCall { "verification_code": code, "email_id": email, }); + print("LOGIN : API http://192.168.2.130/konectar-staging/apiauths/login"); response = await dio.post( - '${EventsConstants.loginUrl}${EventsConstants.login}', + //'http://192.168.2.130/konectar-staging/apiauths/login', + 'http://192.168.2.130/konectar-staging/apiauths/login/', + // '${EventsConstants.loginUrl}${EventsConstants.login}', options: Options(), data: formData); if (response.statusCode == 200) { @@ -671,7 +799,7 @@ class ApiCall { return client; }; print("email : $email,device : $deviceid"); - _token = _prefs.then((SharedPreferences prefs) { + String token = await _prefs.then((SharedPreferences prefs) { return prefs.getString('token') ?? ""; }); Response response; @@ -681,13 +809,19 @@ class ApiCall { "device_id": deviceid, }); response = await dio.post( - '${EventsConstants.loginUrl}${EventsConstants.logout}', + 'http://192.168.2.130/konectar-staging/apiauths/logout/', + // '${EventsConstants.loginUrl}${EventsConstants.logout}', options: Options( - contentType: "application/x-www-form-urlencoded", - followRedirects: false, - // will not throw errors + followRedirects: true, validateStatus: (status) => true, - headers: {"Authorization": "Bearer $_token"}), + preserveHeaderCase: true, + headers: { + 'Authorization': 'Bearer $token', + "Content-Type": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*', + "Accept": + 'application/json, application/x-www-form-urlencoded, multipart/form-data, */*' + }), data: formData, // queryParameters: { // "token": token, diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 602dc83..8be55c7 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -26,10 +26,10 @@ class EventsConstants { static const String stagingUrl = "https://cardio-staging.konectar.io/$moduleName/"; - static const String url = stagingUrl; + static const String url = devUrl; static const String devUrl = - "http://192.168.2.130/konectar-sandbox/$moduleName/"; + "http://192.168.2.130/konectar-staging/$moduleName/"; static const String loginUrl = "https://cardio-staging.konectar.io/$loginmodule/"; diff --git a/lib/view/home.dart b/lib/view/home.dart index 0d80ddb..d86eeaf 100644 --- a/lib/view/home.dart +++ b/lib/view/home.dart @@ -183,6 +183,7 @@ class _HomeScreenState extends State with TickerProviderStateMixin { } init() async { + await ApiCall().fetchApiConstants(); await Provider.of(context, listen: false) .initConfigModules(); // await Provider.of(context, listen: false).initFiltersData(); diff --git a/lib/view/login.dart b/lib/view/login.dart index 380bf8a..d821811 100644 --- a/lib/view/login.dart +++ b/lib/view/login.dart @@ -94,7 +94,7 @@ class _LoginScreenState extends State { if (!mounted) return; - deviceId = _deviceId; + deviceId = "device123456789hhuuww"; print("DEVICE ID########################## :$deviceId"); } @@ -140,50 +140,8 @@ class _LoginScreenState extends State { List _buildBody(Orientation orientation, LoginProvider provider) { return [ - // Expanded( - // flex: 1, - // child: Container( - // width: orientation == Orientation.portrait - // ? double.infinity - // : MediaQuery.of(context).size.height * 0.45, - // decoration: const BoxDecoration( - // gradient: LinearGradient( - // begin: Alignment.topRight, - // end: Alignment.bottomLeft, - // colors: [ - // Color.fromARGB(255, 8, 39, 92), - // Color.fromARGB(255, 11, 60, 144), - // Color.fromARGB(255, 26, 64, 129), - // ], - // )), - // child: Column( - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // // SizedBox( - // // width: isTablet ? 160 : 80, - // // height: isTablet ? 160 : 80, - // // child: CircleAvatar( - // // backgroundColor: const Color.fromARGB(255, 126, 134, 147), - // // child: Icon( - // // Icons.person, - // // size: isTablet ? 120 : 60, - // // ), - // // ), - // // ), - // // const SizedBox( - // // height: 20, - // // ), - // Text( - // 'Welcome, you are almost there!', - // style: TextStyle( - // fontSize: isTablet ? 22 : 18, color: Colors.white), - // ) - // ], - // ), - // ), - // ), SizedBox( - height: 10, + height: 40, ), SvgPicture.asset( "assets/images/konectar_logo.svg", @@ -193,29 +151,9 @@ class _LoginScreenState extends State { flex: 2, child: Center( child: Container( - // decoration: const BoxDecoration( - // gradient: LinearGradient( - // begin: Alignment.topRight, - // end: Alignment.bottomLeft, - // colors: [ - // Color.fromARGB(255, 126, 134, 147), - // Color.fromARGB(255, 193, 198, 209), - // Color.fromARGB(255, 214, 217, 223), - // ], - // )), padding: EdgeInsets.symmetric( horizontal: 30, vertical: orientation == Orientation.portrait ? 20 : 0), - // decoration: const BoxDecoration( - // gradient: LinearGradient( - // begin: Alignment.topRight, - // end: Alignment.bottomLeft, - // colors: [ - // Color.fromARGB(255, 126, 134, 147), - // Color.fromARGB(255, 193, 198, 209), - // Color.fromARGB(255, 214, 217, 223), - // ], - // )), child: _buildform(provider), ), ), @@ -287,8 +225,8 @@ class _LoginScreenState extends State { labelStyle: TextStyle(fontSize: isTablet ? 18.0 : 16), labelText: "Domain", hintStyle: TextStyle(fontSize: isTablet ? 18.0 : 16), - prefix: Text("https://"), - suffix: Text(".io/"), + prefix: Text("https:// "), + suffix: Text(" .konectar.io/"), hintText: "Enter your Domain"), ), ), @@ -331,35 +269,13 @@ class _LoginScreenState extends State { provider.loading = true; }); 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)); String domain = - "https://${domainTextConrtroller.text}.io/"; + "https://${domainTextConrtroller.text}.konectar.io/"; var resp = await provider.verifyEmail(domain, emailTextController.text, deviceId!, platform); if (resp != null) { @@ -439,50 +355,24 @@ class _LoginScreenState extends State { 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"), + title: provider.showCodeField ? "Verify Code" : "Sign In"), ), SizedBox( height: 10, ), - provider.showMessage - ? Text(provider.message!) - : provider.loading - ? Center(child: CircularProgressIndicator()) - : SizedBox.shrink(), + Center( + child: provider.showMessage + ? Text(provider.message!) + : provider.loading + ? Center(child: CircularProgressIndicator()) + : SizedBox.shrink(), + ), ]), ); } @@ -520,16 +410,11 @@ class _LoginScreenState extends State { return isloggedout; }); }); - // await SessionManager().setLoggedIn(isloggedin); - // UserData userData = - // UserData(email: email, name: token, domainUrl: domain, secretkey: key); - // await provider.saveUserData(userData); } _displaySnackBar(String msg) { final snackBar = SnackBar(content: Text(msg)); ScaffoldMessenger.of(context).showSnackBar(snackBar); - //scaffoldKeyLogin.currentState!.showSnackBar(snackBar); } String textFieldsValidation(LoginProvider provider) { diff --git a/lib/view/login_components/care_view.dart b/lib/view/login_components/care_view.dart index 321bf43..6f82d83 100644 --- a/lib/view/login_components/care_view.dart +++ b/lib/view/login_components/care_view.dart @@ -82,6 +82,20 @@ class CareView extends StatelessWidget { // // width: MediaQuery.of(context).size.width, // // height: MediaQuery.of(context).size.height, // ), + Align( + alignment: Alignment.centerRight, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(100), + topLeft: Radius.circular(100)), + color: const Color.fromARGB(255, 167, 203, 234), + shape: BoxShape.rectangle, + ), + height: MediaQuery.of(context).size.height / 2, + width: MediaQuery.of(context).size.width / 4, + ), + ), Container( padding: const EdgeInsets.only(bottom: 100), child: Column( diff --git a/lib/widgets/home_drawer.dart b/lib/widgets/home_drawer.dart index 5ec22c3..1a2f6d4 100644 --- a/lib/widgets/home_drawer.dart +++ b/lib/widgets/home_drawer.dart @@ -204,7 +204,7 @@ class _HomeDrawerState extends State { child: ListView.builder( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(0.0), - itemCount: drawerList?.length, + itemCount: drawerList?.length ?? 0, itemBuilder: (BuildContext context, int index) { return inkwell(drawerList![index]); }, -- 2.34.1 From 37c248c36fd15627e1b0d6095d797baa3d76d5f1 Mon Sep 17 00:00:00 2001 From: "snehalathad@aissel.com" Date: Thu, 19 Dec 2024 11:13:30 +0530 Subject: [PATCH 2/2] api constants updated --- lib/utils/apicall.dart | 16 +++++++++------- lib/utils/constants.dart | 2 +- lib/view/login.dart | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/utils/apicall.dart b/lib/utils/apicall.dart index 7de5740..621b878 100644 --- a/lib/utils/apicall.dart +++ b/lib/utils/apicall.dart @@ -141,7 +141,9 @@ class ApiCall { 'type': type ?? 1, }); // "end": DateTime(2024, 12, 14).toIso8601String(), - + token = await _prefs.then((SharedPreferences prefs) { + return prefs.getString('token') ?? ""; + }); print("SAVED TOKEN :${token}"); //http://192.168.2.130/konectar-staging/apiauths/logout/ @@ -734,9 +736,9 @@ class ApiCall { }); try { response = await dio.post( - 'http://192.168.2.130/konectar-staging/apiauths/getVerificationCode/', + //'http://192.168.2.130/konectar-staging/apiauths/getVerificationCode/', //'https://cardio-staging.konectar.io/apiauths/getVerificationCode/', - //'${url}${EventsConstants.loginmodule}/${EventsConstants.getVerificationCode}', + '${url}${EventsConstants.loginmodule}/${EventsConstants.getVerificationCode}', options: Options(), data: formData); if (response.statusCode == 200) { @@ -773,8 +775,8 @@ class ApiCall { print("LOGIN : API http://192.168.2.130/konectar-staging/apiauths/login"); response = await dio.post( //'http://192.168.2.130/konectar-staging/apiauths/login', - 'http://192.168.2.130/konectar-staging/apiauths/login/', - // '${EventsConstants.loginUrl}${EventsConstants.login}', + //'http://192.168.2.130/konectar-staging/apiauths/login/', + '${EventsConstants.loginUrl}${EventsConstants.login}', options: Options(), data: formData); if (response.statusCode == 200) { @@ -809,8 +811,8 @@ class ApiCall { "device_id": deviceid, }); response = await dio.post( - 'http://192.168.2.130/konectar-staging/apiauths/logout/', - // '${EventsConstants.loginUrl}${EventsConstants.logout}', + //'http://192.168.2.130/konectar-staging/apiauths/logout/', + '${EventsConstants.loginUrl}${EventsConstants.logout}', options: Options( followRedirects: true, validateStatus: (status) => true, diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 8be55c7..a2f62eb 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -26,7 +26,7 @@ class EventsConstants { static const String stagingUrl = "https://cardio-staging.konectar.io/$moduleName/"; - static const String url = devUrl; + static const String url = stagingUrl; static const String devUrl = "http://192.168.2.130/konectar-staging/$moduleName/"; diff --git a/lib/view/login.dart b/lib/view/login.dart index d821811..f79cbc4 100644 --- a/lib/view/login.dart +++ b/lib/view/login.dart @@ -94,7 +94,7 @@ class _LoginScreenState extends State { if (!mounted) return; - deviceId = "device123456789hhuuww"; + deviceId = "stagingdevice123456789hhuuww"; print("DEVICE ID########################## :$deviceId"); } -- 2.34.1