|
|
|
|
@ -4,6 +4,7 @@ import 'dart:convert';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.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/app_state/app_state.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
@ -11,6 +12,7 @@ import 'package:mohem_flutter_app/classes/consts.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart';
|
|
|
|
|
@ -48,7 +50,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
|
|
|
|
|
bool _isLoadingCategories = true;
|
|
|
|
|
List<WalaPlusCategoryModel> _categories = <WalaPlusCategoryModel>[];
|
|
|
|
|
|
|
|
|
|
bool _hasRegisteredMobileLoginInfo = false;
|
|
|
|
|
bool _isLoadingExclusiveOffers = true;
|
|
|
|
|
List<WalaPlusRetailerModel> _exclusiveOffers = <WalaPlusRetailerModel>[];
|
|
|
|
|
|
|
|
|
|
@ -70,6 +72,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
_fetchCategories();
|
|
|
|
|
_fetchExclusiveOffers();
|
|
|
|
|
_initCityAndFetchSections();
|
|
|
|
|
_registerMobileLoginInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _initCityAndFetchSections() async {
|
|
|
|
|
@ -101,10 +104,63 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only drives the benefits strip now - Travel Essentials/Home & Kitchen/Latest on Mazaya each
|
|
|
|
|
// fetch independently (see _fetchCategorySection/_fetchLatestOnMazaya). Still fetched in
|
|
|
|
|
// parallel with those though, since it also feeds each fixed-category section's title (the
|
|
|
|
|
// top-level categories list is the primary source there - see _sectionTitle).
|
|
|
|
|
Future<void> _registerMobileLoginInfo() async {
|
|
|
|
|
if (_hasRegisteredMobileLoginInfo) return;
|
|
|
|
|
if (!ApiConsts.isDependetLogin) return;
|
|
|
|
|
_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 {
|
|
|
|
|
setState(() => _isLoadingCategories = true);
|
|
|
|
|
try {
|
|
|
|
|
@ -458,7 +514,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
appBar: AppBarWidget(
|
|
|
|
|
context,
|
|
|
|
|
title: LocaleKeys.mazayaDeals.tr(),
|
|
|
|
|
showHomeButton: true,
|
|
|
|
|
showHomeButton: ApiConsts.isDependetLogin ? false : true,
|
|
|
|
|
// Discover is the dependent-login landing page - no back button there (logout is still
|
|
|
|
|
// reachable via the explicit logout action below). Employees reaching Discover from the
|
|
|
|
|
// regular dashboard can still pop back normally.
|
|
|
|
|
@ -1023,7 +1079,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
title.toText20(
|
|
|
|
|
color: const Color(0xFF202F32),
|
|
|
|
|
weight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
).toShimmer(isShow: isLoading),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: onSeeAll,
|
|
|
|
|
child: Row(
|
|
|
|
|
@ -1055,7 +1111,7 @@ class _MazayaDiscoverScreenState extends State<MazayaDiscoverScreen> {
|
|
|
|
|
subtitle.toText11(
|
|
|
|
|
color: const Color(0xFF78817F),
|
|
|
|
|
weight: FontWeight.w400,
|
|
|
|
|
),
|
|
|
|
|
).toShimmer(isShow: isLoading),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|