Merge pull request 'api constants stored in hive' (#5) from snehalatha_dev into dev
Reviewed-on: #5
This commit is contained in:
commit
22ca98508f
|
@ -0,0 +1,80 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"api": "loadFutureEvents",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveUserInterestedEvent",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveUserAttendingEvent",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "getSpecialitiesDonutChart",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "getTopicCloudChart",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "getTopAffiliationBarChart",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "eventSpeakers",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveEventsTopicNote",
|
||||||
|
"interval": 5,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "eventUserAnalytics",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveEventOffline",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "eventapis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "contactslistapi",
|
||||||
|
"interval": 5,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "contactsapi"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveContactsOffline",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "contactsapi"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api": "saveInteraction",
|
||||||
|
"interval": 0,
|
||||||
|
"method": "POST",
|
||||||
|
"module": "contactsapi"
|
||||||
|
}
|
||||||
|
]
|
|
@ -64,6 +64,7 @@ import 'package:konectar_events/contacts_module/ui_screen/interactionform/model/
|
||||||
import 'package:konectar_events/contacts_module/ui_screen/interactionform/repository/hive_repository.dart';
|
import 'package:konectar_events/contacts_module/ui_screen/interactionform/repository/hive_repository.dart';
|
||||||
import 'package:konectar_events/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart';
|
import 'package:konectar_events/contacts_module/ui_screen/interactionform/viewinteractionprovider.dart';
|
||||||
import 'package:konectar_events/firebaseexample.dart';
|
import 'package:konectar_events/firebaseexample.dart';
|
||||||
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
||||||
import 'package:konectar_events/model/myeventsmodel.dart';
|
import 'package:konectar_events/model/myeventsmodel.dart';
|
||||||
import 'package:konectar_events/model/neweventsmodel.dart';
|
import 'package:konectar_events/model/neweventsmodel.dart';
|
||||||
import 'package:konectar_events/model/sessionnotesmodel.dart';
|
import 'package:konectar_events/model/sessionnotesmodel.dart';
|
||||||
|
@ -175,11 +176,13 @@ Future main() async {
|
||||||
Hive.registerAdapter(ProAdapter());
|
Hive.registerAdapter(ProAdapter());
|
||||||
Hive.registerAdapter(Training1Adapter());
|
Hive.registerAdapter(Training1Adapter());
|
||||||
Hive.registerAdapter(SpeAdapter());
|
Hive.registerAdapter(SpeAdapter());
|
||||||
|
Hive.registerAdapter(HiveApiConstantsAdapter());
|
||||||
|
|
||||||
await Hive.openBox<UserData>("UserDataBox");
|
await Hive.openBox<UserData>("UserDataBox");
|
||||||
await Hive.openBox<EventsList>("EventsListBox");
|
await Hive.openBox<EventsList>("EventsListBox");
|
||||||
await Hive.openBox<SessionNotesModel>("SessionNotesModelBox");
|
await Hive.openBox<SessionNotesModel>("SessionNotesModelBox");
|
||||||
await Hive.openBox<MyEventsModel>("MyEventsBox");
|
await Hive.openBox<MyEventsModel>("MyEventsBox");
|
||||||
|
await Hive.openBox<HiveApiConstants>("hiveApiConstants");
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
// FirebaseMessaging.instance.getToken().then((value) {
|
// FirebaseMessaging.instance.getToken().then((value) {
|
||||||
|
@ -259,38 +262,34 @@ Future main() async {
|
||||||
],
|
],
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
top: true,
|
top: true,
|
||||||
child: new OverlaySupport.global(
|
child: MaterialApp(
|
||||||
toastTheme: ToastThemeData(background: Colors.green),
|
theme: ThemeData(
|
||||||
child: MaterialApp(
|
//fontFamily: "SourceSerif",
|
||||||
theme: ThemeData(
|
),
|
||||||
//fontFamily: "SourceSerif",
|
debugShowCheckedModeBanner: false,
|
||||||
),
|
title: 'Dynamic Links Example',
|
||||||
debugShowCheckedModeBanner: false,
|
initialRoute: '/',
|
||||||
title: 'Dynamic Links Example',
|
routes: <String, WidgetBuilder>{
|
||||||
initialRoute: '/',
|
'/': (BuildContext context) => FutureBuilder<bool>(
|
||||||
routes: <String, WidgetBuilder>{
|
future: SessionManager().isLoggedIn(),
|
||||||
'/': (BuildContext context) => FutureBuilder<bool>(
|
builder: (context, snapshot) {
|
||||||
future: SessionManager().isLoggedIn(),
|
print("Data_is : $snapshot");
|
||||||
builder: (context, snapshot) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
print("Data_is : $snapshot");
|
return const CircularProgressIndicator();
|
||||||
if (snapshot.connectionState ==
|
} else if (snapshot.hasError) {
|
||||||
ConnectionState.waiting) {
|
return Text('Error: ${snapshot.error}');
|
||||||
return const CircularProgressIndicator();
|
} else {
|
||||||
} else if (snapshot.hasError) {
|
final isLoggedIn = snapshot.data ?? false;
|
||||||
return Text('Error: ${snapshot.error}');
|
print("isLoggedIn_is : $isLoggedIn");
|
||||||
} else {
|
print("secret : $secretkey");
|
||||||
final isLoggedIn = snapshot.data ?? false;
|
return isLoggedIn
|
||||||
print("isLoggedIn_is : $isLoggedIn");
|
? IntroductionAnimationScreen()
|
||||||
print("secret : $secretkey");
|
: IntroductionAnimationScreen();
|
||||||
return isLoggedIn
|
}
|
||||||
? IntroductionAnimationScreen()
|
},
|
||||||
: IntroductionAnimationScreen();
|
), //userInfo != null ? const Home() : OpenidScreen(credential: credential,),
|
||||||
}
|
// '/details': (BuildContext context) => const HomeScreen(),
|
||||||
},
|
},
|
||||||
), //userInfo != null ? const Home() : OpenidScreen(credential: credential,),
|
|
||||||
// '/details': (BuildContext context) => const HomeScreen(),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final apiConstantsResponse = apiConstantsResponseFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
List<ApiConstantsResponse> apiConstantsResponseFromJson(List<dynamic> json) =>
|
||||||
|
List<ApiConstantsResponse>.from(
|
||||||
|
json.map((x) => ApiConstantsResponse.fromJson(x)));
|
||||||
|
|
||||||
|
String apiConstantsResponseToJson(List<ApiConstantsResponse> data) =>
|
||||||
|
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
|
||||||
|
|
||||||
|
class ApiConstantsResponse {
|
||||||
|
String? api;
|
||||||
|
int? interval;
|
||||||
|
String? method;
|
||||||
|
String? module;
|
||||||
|
|
||||||
|
ApiConstantsResponse({
|
||||||
|
this.api,
|
||||||
|
this.interval,
|
||||||
|
this.method,
|
||||||
|
this.module,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory ApiConstantsResponse.fromJson(Map<String, dynamic> json) =>
|
||||||
|
ApiConstantsResponse(
|
||||||
|
api: json["api"],
|
||||||
|
interval: json["interval"],
|
||||||
|
method: json["method"],
|
||||||
|
module: json["module"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"api": api,
|
||||||
|
"interval": interval,
|
||||||
|
"method": method,
|
||||||
|
"module": module,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Method { POST }
|
||||||
|
|
||||||
|
final methodValues = EnumValues({"POST": Method.POST});
|
||||||
|
|
||||||
|
enum Module { CONTACTSAPI, EVENTAPIS }
|
||||||
|
|
||||||
|
final moduleValues = EnumValues(
|
||||||
|
{"contactsapi": Module.CONTACTSAPI, "eventapis": Module.EVENTAPIS});
|
||||||
|
|
||||||
|
class EnumValues<T> {
|
||||||
|
Map<String, T> map;
|
||||||
|
late Map<T, String> reverseMap;
|
||||||
|
|
||||||
|
EnumValues(this.map);
|
||||||
|
|
||||||
|
Map<T, String> get reverse {
|
||||||
|
reverseMap = map.map((k, v) => MapEntry(v, k));
|
||||||
|
return reverseMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:konectar_events/utils/hivetypeids.dart';
|
import 'package:konectar_events/utils/hivetypeids.dart';
|
||||||
|
part 'hive_api_constants.g.dart';
|
||||||
|
|
||||||
@HiveType(typeId: HiveTypeIdConstants.hiveApiConstantsId)
|
@HiveType(typeId: HiveTypeIdConstants.hiveApiConstantsId)
|
||||||
class HiveApiConstants {
|
class HiveApiConstants {
|
||||||
|
@ -7,6 +8,11 @@ class HiveApiConstants {
|
||||||
String? functionName;
|
String? functionName;
|
||||||
@HiveField(1)
|
@HiveField(1)
|
||||||
int? interval;
|
int? interval;
|
||||||
|
@HiveField(2)
|
||||||
|
String? method;
|
||||||
|
@HiveField(3)
|
||||||
|
String? module;
|
||||||
|
|
||||||
HiveApiConstants({this.functionName, this.interval});
|
HiveApiConstants(
|
||||||
|
{this.functionName, this.interval, this.method, this.module});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'hive_api_constants.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// TypeAdapterGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
class HiveApiConstantsAdapter extends TypeAdapter<HiveApiConstants> {
|
||||||
|
@override
|
||||||
|
final int typeId = 106;
|
||||||
|
|
||||||
|
@override
|
||||||
|
HiveApiConstants read(BinaryReader reader) {
|
||||||
|
final numOfFields = reader.readByte();
|
||||||
|
final fields = <int, dynamic>{
|
||||||
|
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||||
|
};
|
||||||
|
return HiveApiConstants(
|
||||||
|
functionName: fields[0] as String?,
|
||||||
|
interval: fields[1] as int?,
|
||||||
|
)
|
||||||
|
..method = fields[2] as String?
|
||||||
|
..module = fields[3] as String?;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void write(BinaryWriter writer, HiveApiConstants obj) {
|
||||||
|
writer
|
||||||
|
..writeByte(4)
|
||||||
|
..writeByte(0)
|
||||||
|
..write(obj.functionName)
|
||||||
|
..writeByte(1)
|
||||||
|
..write(obj.interval)
|
||||||
|
..writeByte(2)
|
||||||
|
..write(obj.method)
|
||||||
|
..writeByte(3)
|
||||||
|
..write(obj.module);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => typeId.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
identical(this, other) ||
|
||||||
|
other is HiveApiConstantsAdapter &&
|
||||||
|
runtimeType == other.runtimeType &&
|
||||||
|
typeId == other.typeId;
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import 'package:dio/io.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:konectar_events/model/affiliationsmodel.dart';
|
import 'package:konectar_events/model/affiliationsmodel.dart';
|
||||||
import 'package:konectar_events/model/allsessionnotesmodel.dart';
|
import 'package:konectar_events/model/allsessionnotesmodel.dart';
|
||||||
|
import 'package:konectar_events/model/api_constants_model.dart';
|
||||||
import 'package:konectar_events/model/events_details.dart';
|
import 'package:konectar_events/model/events_details.dart';
|
||||||
import 'package:konectar_events/model/events_list_resp_2.dart';
|
import 'package:konectar_events/model/events_list_resp_2.dart';
|
||||||
import 'package:konectar_events/model/events_speakers_k1.dart';
|
import 'package:konectar_events/model/events_speakers_k1.dart';
|
||||||
|
@ -14,6 +15,7 @@ import 'package:konectar_events/model/eventsdetailmodel.dart';
|
||||||
import 'package:konectar_events/model/eventsmodel.dart';
|
import 'package:konectar_events/model/eventsmodel.dart';
|
||||||
import 'package:konectar_events/model/eventsoverview.dart';
|
import 'package:konectar_events/model/eventsoverview.dart';
|
||||||
import 'package:konectar_events/model/eventspeakers.dart';
|
import 'package:konectar_events/model/eventspeakers.dart';
|
||||||
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
||||||
import 'package:konectar_events/model/keywords_model.dart';
|
import 'package:konectar_events/model/keywords_model.dart';
|
||||||
import 'package:konectar_events/model/neweventsmodel.dart';
|
import 'package:konectar_events/model/neweventsmodel.dart';
|
||||||
import 'package:konectar_events/model/scope_model.dart';
|
import 'package:konectar_events/model/scope_model.dart';
|
||||||
|
@ -22,6 +24,7 @@ import 'package:konectar_events/model/sessionstopics_model.dart';
|
||||||
import 'package:konectar_events/model/specialtymodel.dart';
|
import 'package:konectar_events/model/specialtymodel.dart';
|
||||||
import 'package:konectar_events/model/topics_cloud_model.dart';
|
import 'package:konectar_events/model/topics_cloud_model.dart';
|
||||||
import 'package:konectar_events/utils/constants.dart';
|
import 'package:konectar_events/utils/constants.dart';
|
||||||
|
import 'package:konectar_events/viewmodel/hive_repository.dart';
|
||||||
|
|
||||||
class ApiCall {
|
class ApiCall {
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
|
@ -540,6 +543,39 @@ class ApiCall {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LOCAL API CONSTANTS
|
||||||
|
|
||||||
|
Future<dynamic> fetchApiConstants() async {
|
||||||
|
dynamic jsonResult =
|
||||||
|
jsonDecode(await rootBundle.loadString("assets/api_constants.json"));
|
||||||
|
//dynamic jsonResult = await MockApiCall().getConfigDataMedical();
|
||||||
|
|
||||||
|
List<ApiConstantsResponse> responseData =
|
||||||
|
apiConstantsResponseFromJson(jsonResult);
|
||||||
|
print('Response_data_is: $responseData');
|
||||||
|
List<ApiConstantsResponse> eventslist = responseData
|
||||||
|
.where(
|
||||||
|
(element) => element.module == EventsConstants.moduleName,
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
List<HiveApiConstants> hiveApiConstantsList = [];
|
||||||
|
if (eventslist.isNotEmpty) {
|
||||||
|
for (ApiConstantsResponse obj in eventslist) {
|
||||||
|
HiveApiConstants hiveApiConstants = HiveApiConstants(
|
||||||
|
functionName: obj.api,
|
||||||
|
interval: obj.interval,
|
||||||
|
method: obj.method,
|
||||||
|
module: obj.module);
|
||||||
|
hiveApiConstantsList.add(hiveApiConstants);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print("APICONST LIST LENGTH:${hiveApiConstantsList.length}");
|
||||||
|
if (hiveApiConstantsList.isNotEmpty) {
|
||||||
|
HiveOperations.saveApiConstants(hiveApiConstantsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//************ K2 API CALLS ***********************************************************************************************************************************
|
//************ K2 API CALLS ***********************************************************************************************************************************
|
||||||
|
|
||||||
Future<List<EventsList>> getEventsFromK2(int page, String search,
|
Future<List<EventsList>> getEventsFromK2(int page, String search,
|
||||||
|
|
|
@ -19,31 +19,37 @@ class EventsConstants {
|
||||||
static const String domainUrl = "http://192.168.2.109:8007/api/method/";
|
static const String domainUrl = "http://192.168.2.109:8007/api/method/";
|
||||||
|
|
||||||
//192.0.0.2:8007 - iphone
|
//192.0.0.2:8007 - iphone
|
||||||
// 192.168.2.109:8007 - office
|
// 192.168.2.109:8007 - office jkqehjkq
|
||||||
//K1 API~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//K1 API~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
static const String moduleName = "eventapis";
|
||||||
|
|
||||||
static const String stagingUrl =
|
static const String stagingUrl =
|
||||||
"https://cardio-staging.konectar.io/eventapis/";
|
"https://cardio-staging.konectar.io/$moduleName/";
|
||||||
static const String url = stagingUrl;
|
static const String url = stagingUrl;
|
||||||
|
|
||||||
static const String devUrl =
|
static const String devUrl =
|
||||||
"http://192.168.2.130/konectar-sandbox/eventapis/";
|
"http://192.168.2.130/konectar-sandbox/$moduleName/";
|
||||||
static const String eventslistapi = "loadFutureEvents/";
|
|
||||||
static const String followUnfollowEvent = "saveUserInterestedEvent/";
|
static const String eventslistapi = "loadFutureEvents";
|
||||||
static const String attendNotAttendEvent = "saveUserAttendingEvent/";
|
static const String followUnfollowEvent = "saveUserInterestedEvent";
|
||||||
|
static const String attendNotAttendEvent = "saveUserAttendingEvent";
|
||||||
static const String specialtyOfSpeakers = "getSpecialitiesDonutChart";
|
static const String specialtyOfSpeakers = "getSpecialitiesDonutChart";
|
||||||
static const String insightsTopicsCloud = "getTopicCloudChart/";
|
static const String insightsTopicsCloud = "getTopicCloudChart";
|
||||||
static const String insightsBarChart = "getTopAffiliationBarChart/";
|
static const String insightsBarChart = "getTopAffiliationBarChart";
|
||||||
static const String speakerslistapi = "eventSpeakers";
|
static const String speakerslistapi = "eventSpeakers";
|
||||||
static const String eventdetailsapi = "eventOverview";
|
static const String eventdetailsapi = "eventOverview";
|
||||||
static const String showEventsTopicsAndSession = "showEventsTopicsAndSession";
|
static const String showEventsTopicsAndSession = "showEventsTopicsAndSession";
|
||||||
static const String getTopicNotes = "getTopicNotes";
|
static const String getTopicNotes = "getTopicNotes";
|
||||||
static const String saveEventsTopicNote = "saveEventsTopicNote";
|
static const String saveEventsTopicNote = "saveEventsTopicNote";
|
||||||
static const String eventUserAnalytics = "eventUserAnalytics";
|
static const String eventUserAnalytics = "eventUserAnalytics";
|
||||||
|
//MY CONSTANTS
|
||||||
|
static const String saveEventOffline = "saveEventOffline";
|
||||||
|
static const String contactsListapi = "contactslistapi";
|
||||||
|
|
||||||
//Hive
|
//Hive
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
{
|
"contacts":{
|
||||||
name:"loadFutureEvents",
|
name:"loadFutureEvents",
|
||||||
interval:5,
|
interval:5,
|
||||||
method:POST,
|
method:POST,
|
||||||
|
|
|
@ -389,10 +389,14 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
// _displaySnackBar(textFieldsValidation(provider));
|
// _displaySnackBar(textFieldsValidation(provider));
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
Navigator.of(context).pushReplacement(
|
await ApiCall().fetchApiConstants().then(
|
||||||
MaterialPageRoute(
|
(value) {
|
||||||
builder: (context) => NavigationHomeScreen()),
|
Navigator.of(context).pushReplacement(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => NavigationHomeScreen()),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import 'package:konectar_events/utils/constants.dart';
|
||||||
import 'package:konectar_events/utils/dateformater.dart';
|
import 'package:konectar_events/utils/dateformater.dart';
|
||||||
import 'package:konectar_events/view/helpdesk.dart';
|
import 'package:konectar_events/view/helpdesk.dart';
|
||||||
import 'package:konectar_events/view/home.dart';
|
import 'package:konectar_events/view/home.dart';
|
||||||
|
import 'package:konectar_events/viewmodel/hive_repository.dart';
|
||||||
import 'package:konectar_events/widgets/drawerusercontroller.dart';
|
import 'package:konectar_events/widgets/drawerusercontroller.dart';
|
||||||
import 'package:konectar_events/widgets/home_drawer.dart';
|
import 'package:konectar_events/widgets/home_drawer.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
@ -44,8 +45,13 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
body: DrawerUserController(
|
body: DrawerUserController(
|
||||||
screenIndex: drawerIndex,
|
screenIndex: drawerIndex,
|
||||||
drawerWidth: MediaQuery.of(context).size.width * 0.75,
|
drawerWidth: MediaQuery.of(context).size.width * 0.75,
|
||||||
onDrawerCall: (DrawerIndex drawerIndexdata) {
|
onDrawerCall: (DrawerIndex drawerIndexdata) async {
|
||||||
changeIndex(drawerIndexdata);
|
bool checkContacts = await HiveOperations.checkIfApiExists(
|
||||||
|
EventsConstants.contactsListapi);
|
||||||
|
if (!checkContacts && drawerIndexdata.name == "Contacts") {
|
||||||
|
} else {
|
||||||
|
changeIndex(drawerIndexdata);
|
||||||
|
}
|
||||||
//callback from drawer for replace screen as user need with passing DrawerIndex(Enum index)
|
//callback from drawer for replace screen as user need with passing DrawerIndex(Enum index)
|
||||||
},
|
},
|
||||||
screenView: screenView,
|
screenView: screenView,
|
||||||
|
@ -218,7 +224,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
||||||
screenView = const HomeScreen();
|
screenView = const HomeScreen();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case DrawerIndex.Help:
|
case DrawerIndex.Contacts:
|
||||||
setState(() {
|
setState(() {
|
||||||
screenView = Contacts1();
|
screenView = Contacts1();
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
||||||
|
|
||||||
|
class HiveOperations {
|
||||||
|
static Future<void> saveApiConstants(List<HiveApiConstants> hiveList) async {
|
||||||
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
||||||
|
hiveApiConstantsBox =
|
||||||
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
||||||
|
|
||||||
|
hiveApiConstantsBox.addAll(hiveList);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<bool> checkIfApiExists(
|
||||||
|
String api,
|
||||||
|
) async {
|
||||||
|
late Box<HiveApiConstants> hiveApiConstantsBox;
|
||||||
|
hiveApiConstantsBox =
|
||||||
|
await Hive.openBox<HiveApiConstants>('hiveApiConstants');
|
||||||
|
|
||||||
|
List<HiveApiConstants> list = hiveApiConstantsBox.values.toList();
|
||||||
|
return list.indexWhere(
|
||||||
|
(element) => element.functionName == api,
|
||||||
|
) ==
|
||||||
|
-1
|
||||||
|
? false
|
||||||
|
: true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,16 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
|
import 'package:konectar_events/model/hive_api_constants.dart';
|
||||||
import 'package:konectar_events/model/userdata_model.dart';
|
import 'package:konectar_events/model/userdata_model.dart';
|
||||||
import 'package:konectar_events/utils/apicall.dart';
|
import 'package:konectar_events/utils/apicall.dart';
|
||||||
import 'package:flutter/services.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';
|
import 'package:mobile_device_identifier/mobile_device_identifier.dart';
|
||||||
|
|
||||||
class LoginProvider extends ChangeNotifier {
|
class LoginProvider extends ChangeNotifier {
|
||||||
late Box<UserData> box;
|
late Box<UserData> box;
|
||||||
|
|
||||||
bool showCodeField = false;
|
bool showCodeField = false;
|
||||||
bool showMessage = false;
|
bool showMessage = false;
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
@ -37,6 +41,79 @@ class LoginProvider extends ChangeNotifier {
|
||||||
print(userData2.imageBytes);
|
print(userData2.imageBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> saveApiData() async {
|
||||||
|
List<HiveApiConstants> hiveList = [
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "loadFutureEvents",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "saveUserInterestedEvent",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "saveUserAttendingEvent",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "getSpecialitiesDonutChart",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "getTopicCloudChart",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "getTopAffiliationBarChart",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "eventSpeakers",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "eventOverview",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "showEventsTopicsAndSession",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "getTopicNotes",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "saveEventsTopicNote",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "eventUserAnalytics",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
HiveApiConstants(
|
||||||
|
functionName: "saveEventOffline",
|
||||||
|
interval: 0,
|
||||||
|
method: "POST",
|
||||||
|
module: "eventapis"),
|
||||||
|
// HiveApiConstants(functionName: "contactslistapi", interval: 0),
|
||||||
|
];
|
||||||
|
|
||||||
|
HiveOperations.saveApiConstants(hiveList);
|
||||||
|
}
|
||||||
|
|
||||||
Future<UserData> getUserData() async {
|
Future<UserData> getUserData() async {
|
||||||
box = await Hive.openBox<UserData>('UserDataBox');
|
box = await Hive.openBox<UserData>('UserDataBox');
|
||||||
Iterable<UserData> data = box.values;
|
Iterable<UserData> data = box.values;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:konectar_events/utils/app_theme.dart';
|
||||||
import 'package:konectar_events/utils/constants.dart';
|
import 'package:konectar_events/utils/constants.dart';
|
||||||
import 'package:konectar_events/utils/sessionmanager.dart';
|
import 'package:konectar_events/utils/sessionmanager.dart';
|
||||||
import 'package:konectar_events/view/login.dart';
|
import 'package:konectar_events/view/login.dart';
|
||||||
|
import 'package:konectar_events/viewmodel/hive_repository.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class HomeDrawer extends StatefulWidget {
|
class HomeDrawer extends StatefulWidget {
|
||||||
|
@ -40,42 +41,75 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDrawerListArray() {
|
void setDrawerListArray() async {
|
||||||
drawerList = <DrawerList>[
|
bool checkContacts =
|
||||||
DrawerList(
|
await HiveOperations.checkIfApiExists(EventsConstants.contactsListapi);
|
||||||
index: DrawerIndex.Help,
|
if (!checkContacts) {
|
||||||
labelName: 'Contacts',
|
drawerList = <DrawerList>[
|
||||||
icon: Icon(Icons.account_circle),
|
DrawerList(
|
||||||
// isAssetsImage: true,
|
index: DrawerIndex.HOME,
|
||||||
// imageName: 'assets/images/supportIcon.png',
|
labelName: 'Events',
|
||||||
),
|
icon: Icon(Icons.event),
|
||||||
DrawerList(
|
),
|
||||||
index: DrawerIndex.HOME,
|
|
||||||
labelName: 'Events',
|
|
||||||
icon: Icon(Icons.event),
|
|
||||||
),
|
|
||||||
|
|
||||||
DrawerList(
|
DrawerList(
|
||||||
index: DrawerIndex.FeedBack,
|
index: DrawerIndex.FeedBack,
|
||||||
labelName: 'HelpDesk',
|
labelName: 'HelpDesk',
|
||||||
icon: Icon(Icons.help),
|
icon: Icon(Icons.help),
|
||||||
),
|
),
|
||||||
DrawerList(
|
DrawerList(
|
||||||
index: DrawerIndex.Invite,
|
index: DrawerIndex.Invite,
|
||||||
labelName: 'Medical Insight',
|
labelName: 'Medical Insight',
|
||||||
icon: Icon(Icons.group),
|
icon: Icon(Icons.group),
|
||||||
),
|
),
|
||||||
// DrawerList(
|
// DrawerList(
|
||||||
// index: DrawerIndex.Share,
|
// index: DrawerIndex.Share,
|
||||||
// labelName: 'Rate the app',
|
// labelName: 'Rate the app',
|
||||||
// icon: Icon(Icons.share),
|
// icon: Icon(Icons.share),
|
||||||
// ),
|
// ),
|
||||||
// DrawerList(
|
// DrawerList(
|
||||||
// index: DrawerIndex.About,
|
// index: DrawerIndex.About,
|
||||||
// labelName: 'About Us',
|
// labelName: 'About Us',
|
||||||
// icon: Icon(Icons.info),
|
// icon: Icon(Icons.info),
|
||||||
// ),
|
// ),
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
drawerList = <DrawerList>[
|
||||||
|
DrawerList(
|
||||||
|
index: DrawerIndex.Contacts,
|
||||||
|
labelName: 'Contacts',
|
||||||
|
icon: Icon(Icons.account_circle),
|
||||||
|
// isAssetsImage: true,
|
||||||
|
// imageName: 'assets/images/supportIcon.png',
|
||||||
|
),
|
||||||
|
DrawerList(
|
||||||
|
index: DrawerIndex.HOME,
|
||||||
|
labelName: 'Events',
|
||||||
|
icon: Icon(Icons.event),
|
||||||
|
),
|
||||||
|
|
||||||
|
DrawerList(
|
||||||
|
index: DrawerIndex.FeedBack,
|
||||||
|
labelName: 'HelpDesk',
|
||||||
|
icon: Icon(Icons.help),
|
||||||
|
),
|
||||||
|
DrawerList(
|
||||||
|
index: DrawerIndex.Invite,
|
||||||
|
labelName: 'Medical Insight',
|
||||||
|
icon: Icon(Icons.group),
|
||||||
|
),
|
||||||
|
// DrawerList(
|
||||||
|
// index: DrawerIndex.Share,
|
||||||
|
// labelName: 'Rate the app',
|
||||||
|
// icon: Icon(Icons.share),
|
||||||
|
// ),
|
||||||
|
// DrawerList(
|
||||||
|
// index: DrawerIndex.About,
|
||||||
|
// labelName: 'About Us',
|
||||||
|
// icon: Icon(Icons.info),
|
||||||
|
// ),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -345,7 +379,7 @@ class _HomeDrawerState extends State<HomeDrawer> {
|
||||||
enum DrawerIndex {
|
enum DrawerIndex {
|
||||||
HOME,
|
HOME,
|
||||||
FeedBack,
|
FeedBack,
|
||||||
Help,
|
Contacts,
|
||||||
Share,
|
Share,
|
||||||
About,
|
About,
|
||||||
Invite,
|
Invite,
|
||||||
|
|
Loading…
Reference in New Issue