|
|
|
@ -4,6 +4,7 @@ import 'dart:convert';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/api/login_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/offers_and_discounts_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/offers_and_discounts_api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
@ -48,7 +49,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
|
|
|
|
|
|
|
bool _isLoadingCategories = true;
|
|
|
|
bool _isLoadingCategories = true;
|
|
|
|
List<WalaPlusCategoryModel> _categories = <WalaPlusCategoryModel>[];
|
|
|
|
List<WalaPlusCategoryModel> _categories = <WalaPlusCategoryModel>[];
|
|
|
|
|
|
|
|
bool _hasRegisteredMobileLoginInfo = false;
|
|
|
|
bool _isLoadingExclusiveOffers = true;
|
|
|
|
bool _isLoadingExclusiveOffers = true;
|
|
|
|
List<WalaPlusRetailerModel> _exclusiveOffers = <WalaPlusRetailerModel>[];
|
|
|
|
List<WalaPlusRetailerModel> _exclusiveOffers = <WalaPlusRetailerModel>[];
|
|
|
|
|
|
|
|
|
|
|
|
@ -70,6 +71,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
_fetchCategories();
|
|
|
|
_fetchCategories();
|
|
|
|
_fetchExclusiveOffers();
|
|
|
|
_fetchExclusiveOffers();
|
|
|
|
_initCityAndFetchSections();
|
|
|
|
_initCityAndFetchSections();
|
|
|
|
|
|
|
|
_registerMobileLoginInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _initCityAndFetchSections() async {
|
|
|
|
Future<void> _initCityAndFetchSections() async {
|
|
|
|
@ -101,10 +103,63 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Only drives the benefits strip now - Travel Essentials/Home & Kitchen/Latest on Mazaya each
|
|
|
|
Future<void> _registerMobileLoginInfo() async {
|
|
|
|
// fetch independently (see _fetchCategorySection/_fetchLatestOnMazaya). Still fetched in
|
|
|
|
if (_hasRegisteredMobileLoginInfo) return;
|
|
|
|
// parallel with those though, since it also feeds each fixed-category section's title (the
|
|
|
|
if (!ApiConsts.isDependetLogin) return;
|
|
|
|
// top-level categories list is the primary source there - see _sectionTitle).
|
|
|
|
_hasRegisteredMobileLoginInfo = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
int loginType = AppState().dependentLoginType ?? 1;
|
|
|
|
|
|
|
|
String nationalId = AppState().getUserName ?? "";
|
|
|
|
|
|
|
|
String dob = AppState().dependentDob ?? "";
|
|
|
|
|
|
|
|
String name = AppState().dependentName ?? "";
|
|
|
|
|
|
|
|
String mobile = AppState().postParamsObject?.mobileNumber ?? "";
|
|
|
|
|
|
|
|
String tokenID =
|
|
|
|
|
|
|
|
(AppState().postParamsObject?.tokenID != null &&
|
|
|
|
|
|
|
|
AppState().postParamsObject!.tokenID!.isNotEmpty)
|
|
|
|
|
|
|
|
? AppState().postParamsObject!.tokenID!
|
|
|
|
|
|
|
|
: (AppState().authenticationTokenID ?? "");
|
|
|
|
|
|
|
|
if (tokenID.isEmpty) {
|
|
|
|
|
|
|
|
tokenID = await Utils.getStringFromPrefs("P_DEP_TOKEN_ID");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int sessionId = AppState().postParamsObject?.pSessionId ?? 0;
|
|
|
|
|
|
|
|
String email = AppState().postParamsObject?.pEmailAddress ?? "";
|
|
|
|
|
|
|
|
String deviceToken =
|
|
|
|
|
|
|
|
AppState().getIsHuawei
|
|
|
|
|
|
|
|
? AppState().getHuaweiPushToken
|
|
|
|
|
|
|
|
: ((AppState().getDeviceToken != null &&
|
|
|
|
|
|
|
|
AppState().getDeviceToken!.isNotEmpty &&
|
|
|
|
|
|
|
|
AppState().getDeviceToken != "null")
|
|
|
|
|
|
|
|
? AppState().getDeviceToken!
|
|
|
|
|
|
|
|
: "");
|
|
|
|
|
|
|
|
if (deviceToken.isEmpty || deviceToken == "null") {
|
|
|
|
|
|
|
|
String savedToken = await Utils.getStringFromPrefs(
|
|
|
|
|
|
|
|
"P_DEP_DEVICE_TOKEN",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (savedToken.isNotEmpty && savedToken != "null") {
|
|
|
|
|
|
|
|
deviceToken = savedToken;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await LoginApiClient().insertMobileLoginInfoDependent(
|
|
|
|
|
|
|
|
loginType: loginType,
|
|
|
|
|
|
|
|
nationalId: nationalId,
|
|
|
|
|
|
|
|
dob: dob,
|
|
|
|
|
|
|
|
dependentName: name,
|
|
|
|
|
|
|
|
mobileNumber: mobile,
|
|
|
|
|
|
|
|
tokenID: tokenID,
|
|
|
|
|
|
|
|
sessionId: sessionId,
|
|
|
|
|
|
|
|
email: email,
|
|
|
|
|
|
|
|
deviceToken: deviceToken,
|
|
|
|
|
|
|
|
channel: AppState().postParamsObject?.channel,
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// if (kDebugMode) {
|
|
|
|
|
|
|
|
print("Error calling insertMobileLoginInfoDependent: $e");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Future<void> _fetchCategories() async {
|
|
|
|
Future<void> _fetchCategories() async {
|
|
|
|
setState(() => _isLoadingCategories = true);
|
|
|
|
setState(() => _isLoadingCategories = true);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|