Survey title key fix

flutter_upgrade_with_timesheet_changes
aamir-csol 5 months ago
parent c191d4c0c0
commit 676e662967

@ -2,10 +2,13 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:http/io_client.dart'; import 'package:http/io_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/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/exceptions/api_exception.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart';
import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/main.dart';
// ignore_for_file: avoid_annotating_with_dynamic // ignore_for_file: avoid_annotating_with_dynamic
@ -13,18 +16,14 @@ import 'package:mohem_flutter_app/main.dart';
typedef FactoryConstructor<U> = U Function(dynamic); typedef FactoryConstructor<U> = U Function(dynamic);
class APIError { class APIError {
int? errorCode; dynamic errorCode;
int? errorType; int? errorType;
String? errorMessage; String? errorMessage;
int? errorStatusCode; int? errorStatusCode;
APIError(this.errorCode, this.errorMessage, this.errorType, this.errorStatusCode); APIError(this.errorCode, this.errorMessage, this.errorType, this.errorStatusCode);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage, 'errorType': errorType, 'ErrorStatusCode': errorStatusCode};
'errorCode': errorCode,
'errorMessage': errorMessage,
'errorType': errorType,
'ErrorStatusCode': errorStatusCode
};
@override @override
String toString() { String toString() {
@ -46,22 +45,22 @@ APIException _throwAPIException(Response response) {
APIError? apiError; APIError? apiError;
if (response.body != null && response.body.isNotEmpty) { if (response.body != null && response.body.isNotEmpty) {
var jsonError = jsonDecode(response.body); var jsonError = jsonDecode(response.body);
apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'],jsonError['ErrorStatusCode']); apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'], jsonError['ErrorStatusCode']);
} }
return APIException(APIException.BAD_REQUEST, error: apiError); return APIException(APIException.BAD_REQUEST, error: apiError);
case 401: case 401:
return APIException(APIException.UNAUTHORIZED); return const APIException(APIException.UNAUTHORIZED);
case 403: case 403:
return APIException(APIException.FORBIDDEN); return const APIException(APIException.FORBIDDEN);
case 404: case 404:
return APIException(APIException.NOT_FOUND); return const APIException(APIException.NOT_FOUND);
case 500: case 500:
return APIException(APIException.INTERNAL_SERVER_ERROR); return const APIException(APIException.INTERNAL_SERVER_ERROR);
case 444: case 444:
var downloadUrl = response.headers["location"]; var downloadUrl = response.headers["location"];
return APIException(APIException.UPGRADE_REQUIRED, arguments: downloadUrl); return APIException(APIException.UPGRADE_REQUIRED, arguments: downloadUrl);
default: default:
return APIException(APIException.OTHER); return const APIException(APIException.OTHER);
} }
} }
@ -72,8 +71,16 @@ class ApiClient {
factory ApiClient() => _instance; factory ApiClient() => _instance;
Future<U> postJsonForObject<T, U>(FactoryConstructor<U> factoryConstructor, String url, T jsonObject, Future<U> postJsonForObject<T, U>(
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0, bool isFormData = false}) async { FactoryConstructor<U> factoryConstructor,
String url,
T jsonObject, {
String? token,
Map<String, dynamic>? queryParameters,
Map<String, String>? headers,
int retryTimes = 0,
bool isFormData = false,
}) async {
var _headers = {'Accept': 'application/json'}; var _headers = {'Accept': 'application/json'};
if (headers != null && headers.isNotEmpty) { if (headers != null && headers.isNotEmpty) {
_headers.addAll(headers); _headers.addAll(headers);
@ -102,6 +109,9 @@ class ApiClient {
if (jsonData["ErrorMessage"] == null) { if (jsonData["ErrorMessage"] == null) {
return factoryConstructor(jsonData); return factoryConstructor(jsonData);
} else if (jsonData["MessageStatus"] == 2 && jsonData["IsOTPMaxLimitExceed"] == true) {
await Utils.performLogout(AppRoutes.navigatorKey.currentContext, null);
throw const APIException(APIException.UNAUTHORIZED, error: null);
} else { } else {
APIError? apiError; APIError? apiError;
apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0, jsonData['ErrorStatusCode']); apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0, jsonData['ErrorStatusCode']);
@ -116,8 +126,15 @@ class ApiClient {
} }
} }
Future<Response> postJsonForResponse<T>(String url, T jsonObject, Future<Response> postJsonForResponse<T>(
{String? token, Map<String, dynamic>? queryParameters, Map<String, String>? headers, int retryTimes = 0, bool isFormData = false}) async { String url,
T jsonObject, {
String? token,
Map<String, dynamic>? queryParameters,
Map<String, String>? headers,
int retryTimes = 0,
bool isFormData = false,
}) async {
String? requestBody; String? requestBody;
late Map<String, String> stringObj; late Map<String, String> stringObj;
if (jsonObject != null) { if (jsonObject != null) {
@ -152,9 +169,9 @@ class ApiClient {
var queryString = new Uri(queryParameters: queryParameters).query; var queryString = new Uri(queryParameters: queryParameters).query;
url = url + '?' + queryString; url = url + '?' + queryString;
} }
var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 120)); var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(const Duration(seconds: 120));
if (response. statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
return response; return response;
} else { } else {
throw _throwAPIException(response); throw _throwAPIException(response);
@ -162,7 +179,7 @@ class ApiClient {
} on SocketException catch (e) { } on SocketException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);
@ -170,7 +187,7 @@ class ApiClient {
} on HttpException catch (e) { } on HttpException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);
@ -180,7 +197,7 @@ class ApiClient {
} on ClientException catch (e) { } on ClientException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);
@ -219,7 +236,7 @@ class ApiClient {
var queryString = new Uri(queryParameters: queryParameters).query; var queryString = new Uri(queryParameters: queryParameters).query;
url = url + '?' + queryString; url = url + '?' + queryString;
} }
var response = await _get(Uri.parse(url), headers: _headers).timeout(Duration(seconds: 60)); var response = await _get(Uri.parse(url), headers: _headers).timeout(const Duration(seconds: 60));
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
return response; return response;
@ -229,7 +246,7 @@ class ApiClient {
} on SocketException catch (e) { } on SocketException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);
@ -237,7 +254,7 @@ class ApiClient {
} on HttpException catch (e) { } on HttpException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);
@ -247,7 +264,7 @@ class ApiClient {
} on ClientException catch (e) { } on ClientException catch (e) {
if (retryTimes > 0) { if (retryTimes > 0) {
print('will retry after 3 seconds...'); print('will retry after 3 seconds...');
await Future.delayed(Duration(seconds: 3)); await Future.delayed(const Duration(seconds: 3));
return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1);
} else { } else {
throw APIException(APIException.OTHER, arguments: e); throw APIException(APIException.OTHER, arguments: e);

@ -5,17 +5,17 @@ class ApiConsts {
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver
// static String baseUrl = "http://10.201.204.101:2024"; // static String baseUrl = "http://10.201.204.101:2024";
// static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://webservices.hmg.com"; // PreProd
// static String baseUrl = "https://hmgwebservices.com"; // Live server // static String baseUrl = "https://hmgwebservices.com"; // Live server
// static String baseUrl = "https://mohemm.hmg.com"; // New Live server // static String baseUrl = "https://mohemm.hmg.com"; // New Live server
// //
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver
// static String baseUrl = "http://10.20.200.111:1010/"; // static String baseUrl = "http://10.20.200.111:1010/";
// static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://webservices.hmg.com"; // PreProd
static String baseUrl = "https://mohemm.hmg.com"; // static String baseUrl = "https://mohemm.hmg.com";
// static String baseUrl = "https://hmgwebservices.com"; // Live server // static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server static String baseUrlServices = baseUrl + "/Services/"; // server
@ -55,6 +55,7 @@ class ApiConsts {
static String marathonBaseUrlUAT = "https://marathoon.com/uatservice/api/"; static String marathonBaseUrlUAT = "https://marathoon.com/uatservice/api/";
static String marathonBaseUrl = marathonBaseUrlLive; static String marathonBaseUrl = marathonBaseUrlLive;
// static String marathonBaseUrl = marathonBaseUrlUAT; // static String marathonBaseUrl = marathonBaseUrlUAT;
static String marathonBaseUrlServices = "https://marathoon.com/service/"; static String marathonBaseUrlServices = "https://marathoon.com/service/";
static String marathonParticipantLoginUrl = marathonBaseUrl + "auth/participantlogin"; static String marathonParticipantLoginUrl = marathonBaseUrl + "auth/participantlogin";
@ -86,5 +87,3 @@ class SharedPrefsConsts {
static String mohemmWifiPassword = "mohemmWifiPassword"; static String mohemmWifiPassword = "mohemmWifiPassword";
static String editItemForSale = "editItemForSale"; static String editItemForSale = "editItemForSale";
} }

@ -16,6 +16,7 @@ import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_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/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
import 'package:mohem_flutter_app/widgets/loading_dialog.dart'; import 'package:mohem_flutter_app/widgets/loading_dialog.dart';
import 'package:nfc_manager/nfc_manager.dart'; import 'package:nfc_manager/nfc_manager.dart';
@ -386,4 +387,16 @@ class Utils {
return false; return false;
} }
} }
static Future<void> performLogout(BuildContext? context, ChatProviderModel? chatData) async {
AppState().isAuthenticated = false;
AppState().isLogged = false;
AppState().setPostParamsInitConfig();
if (chatData != null) {
chatData.disposeData();
}
// SharedPreferences prefs = await SharedPreferences.getInstance();
// await prefs.clear();
Navigator.pushNamedAndRemoveUntil(context!, AppRoutes.login, (Route<dynamic> route) => false, arguments: null);
}
} }

@ -56,6 +56,8 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
int currentIndex = 0; int currentIndex = 0;
bool isDisplayMazaya = false;
@override @override
void initState() { void initState() {
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
@ -153,7 +155,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
data.fetchLeaveTicketBalance(context, DateTime.now()); data.fetchLeaveTicketBalance(context, DateTime.now());
data.fetchMenuEntries(); data.fetchMenuEntries();
data.fetchEventActivity(); data.fetchEventActivity();
// data.getCategoryOffersListAPI(context); data.getCategoryOffersListAPI(context);
marathonProvider.getMarathonDetailsFromApi(); marathonProvider.getMarathonDetailsFromApi();
marathonProvider.getMarathonTutorial(); marathonProvider.getMarathonTutorial();
if (isFromInit) { if (isFromInit) {
@ -421,116 +423,231 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
], ],
).paddingOnly(left: 21, right: 21, top: 7, bottom: 21), ).paddingOnly(left: 21, right: 21, top: 7, bottom: 21),
eventActivityWidget(context), eventActivityWidget(context),
if (isDisplayMazaya) ...[
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Directionality(
textDirection: AppState().isArabic(context) ? ui.TextDirection.rtl : ui.TextDirection.ltr,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: const LinearGradient(colors: [Color(0xFF91C481), Color(0xFF7CCED7)], begin: Alignment.centerLeft, end: Alignment.centerRight),
),
child: Padding(
padding: const EdgeInsets.all(3.0), // This creates the border width
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(17), // Slightly less than outer radius
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 4,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Expanded(
flex: 2,
child: RichText(
text:
AppState().isArabic(context)
? TextSpan(
children: [
TextSpan(
text: 'اطلع على مميزات',
style: TextStyle(
fontSize: 16,
letterSpacing: -0.2,
fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins',
fontWeight: FontWeight.w700,
height: 24 / 16,
color: Color(0xFF5D5E5E),
),
),
TextSpan(
text: ' مزايا',
style: TextStyle(
fontSize: 16,
fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins',
fontWeight: FontWeight.w700,
letterSpacing: -0.2,
height: 24 / 16,
color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed
),
),
],
)
: TextSpan(
children: [
TextSpan(
text: LocaleKeys.explore.tr() + ' ',
style: const TextStyle(
fontSize: 16,
letterSpacing: -0.2,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 24 / 16,
color: Color(0xFF5D5E5E),
),
),
TextSpan(
text: LocaleKeys.mazaya.tr(),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
fontFamily: 'Poppins',
letterSpacing: -0.2,
height: 24 / 16,
color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed
),
),
TextSpan(
text: ' ' + LocaleKeys.benefits.tr(),
style: const TextStyle(
fontSize: 16,
letterSpacing: -0.2,
fontFamily: 'Poppins',
fontWeight: FontWeight.w700,
height: 24 / 16,
color: Color(0xFF5D5E5E),
),
),
],
),
),
),
const Expanded(flex: 1, child: SizedBox()),
],
),
const SizedBox(height: 8),
LocaleKeys.mazayaDesc.tr().toText11(color: const Color(0xFF5D5E5E)),
],
),
),
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
SvgPicture.asset("assets/icons/mazaya_brand.svg", width: 90, height: 47),
const SizedBox(height: 28),
LocaleKeys.viewallofferMazaya.tr().toText12(isUnderLine: true, color: const Color(0xFF3B3D4A)).onPress(() {
Navigator.pushNamed(context, AppRoutes.offersAndDiscounts);
}),
],
),
),
],
).paddingOnly(left: 21, right: 21, top: 14, bottom: 14),
),
),
).paddingOnly(left: 21, right: 21, top: 0, bottom: 21),
),
],
),
],
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Directionality( Row(
textDirection: AppState().isArabic(context) ? ui.TextDirection.rtl : ui.TextDirection.ltr, crossAxisAlignment: CrossAxisAlignment.center,
child: Container( children: [
decoration: BoxDecoration( Expanded(
borderRadius: BorderRadius.circular(20), child: Column(
gradient: const LinearGradient(colors: [Color(0xFF91C481), Color(0xFF7CCED7)], begin: Alignment.centerLeft, end: Alignment.centerRight), crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
LocaleKeys.offers.tr().toText12(),
Row(
children: [
LocaleKeys.discounts.tr().toText24(isBold: true),
6.width,
Container(
padding: const EdgeInsets.only(left: 8, right: 8),
decoration: BoxDecoration(color: MyColors.yellowColor, borderRadius: BorderRadius.circular(10)),
child: LocaleKeys.newString.tr().toText10(isBold: true),
),
],
),
],
),
), ),
child: Padding( LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() {
padding: const EdgeInsets.all(3.0), // This creates the border width Navigator.pushNamed(context, AppRoutes.offersAndDiscounts);
child: Container( }),
decoration: BoxDecoration( ],
color: Colors.white, ).paddingOnly(left: 21, right: 21),
borderRadius: BorderRadius.circular(17), // Slightly less than outer radius Consumer<DashboardProviderModel>(
), builder: (BuildContext context, DashboardProviderModel model, Widget? child) {
child: Row( return SizedBox(
mainAxisAlignment: MainAxisAlignment.spaceBetween, height: 103 + 33,
crossAxisAlignment: CrossAxisAlignment.start, child: ListView.separated(
children: [ shrinkWrap: true,
Expanded( physics: const BouncingScrollPhysics(),
flex: 4, padding: const EdgeInsets.only(left: 21, right: 21, top: 13),
child: Column( scrollDirection: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.start, itemBuilder: (BuildContext cxt, int index) {
mainAxisAlignment: MainAxisAlignment.start, return model.isOffersLoading
children: [ ? const OffersShimmerWidget()
Row( : InkWell(
onTap: () {
navigateToDetails(data.getOffersList[index]);
},
child: SizedBox(
width: 73,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Expanded( Container(
flex: 2, width: 73,
child: RichText( height: 73,
text: decoration: BoxDecoration(
AppState().isArabic(context) color: Colors.white,
? TextSpan( borderRadius: const BorderRadius.all(Radius.circular(100)),
children: [ border: Border.all(color: MyColors.lightGreyE3Color, width: 1),
TextSpan(
text: 'اطلع على مميزات',
style: TextStyle(fontSize: 16, letterSpacing: -0.2, fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins', fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)),
),
TextSpan(
text: ' مزايا',
style: TextStyle(
fontSize: 16,
fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins',
fontWeight: FontWeight.w700,
letterSpacing: -0.2,
height: 24 / 16,
color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed
),
),
],
)
: TextSpan(
children: [
TextSpan(
text: LocaleKeys.explore.tr() + ' ',
style: const TextStyle(fontSize: 16, letterSpacing: -0.2, fontFamily: 'Poppins', fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)),
),
TextSpan(
text: LocaleKeys.mazaya.tr(),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
fontFamily: 'Poppins',
letterSpacing: -0.2,
height: 24 / 16,
color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed
),
),
TextSpan(
text: ' ' + LocaleKeys.benefits.tr(),
style: const TextStyle(fontSize: 16, letterSpacing: -0.2,
fontFamily: 'Poppins',fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)),
),
],
),
), ),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(50)),
child: Hero(
tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!,
transitionOnUserGestures: true,
child: Image.network(data.getOffersList[index].logo ?? "", fit: BoxFit.contain),
),
),
),
4.height,
Expanded(
child:
AppState().isArabic(context)
? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1)
: data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1),
), ),
const Expanded(flex: 1, child: SizedBox()),
], ],
), ),
const SizedBox(height: 8), ),
LocaleKeys.mazayaDesc.tr().toText11(color: const Color(0xFF5D5E5E)), );
], },
), separatorBuilder: (BuildContext cxt, int index) => 8.width,
), itemCount: 9,
Expanded(
flex: 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
SvgPicture.asset("assets/icons/mazaya_brand.svg", width: 90, height: 47),
const SizedBox(height: 28),
LocaleKeys.viewallofferMazaya.tr().toText12(isUnderLine: true, color: const Color(0xFF3B3D4A)).onPress(() {
Navigator.pushNamed(context, AppRoutes.offersAndDiscounts);
}),
],
),
),
],
).paddingOnly(left: 21, right: 21, top: 14, bottom: 14),
), ),
), );
).paddingOnly(left: 21, right: 21, top: 0, bottom: 21), },
), ),
], ],
), ),
Container( Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.only(top: 31), padding: const EdgeInsets.only(top: 31),
@ -602,7 +719,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
height: Platform.isAndroid ? 70 : 100, height: Platform.isAndroid ? 70 : 100,
child: BottomNavigationBar( child: BottomNavigationBar(
items: <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: SvgPicture.asset("assets/icons/home.svg", color: currentIndex == 0 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4), label: LocaleKeys.home.tr()), BottomNavigationBarItem(
icon: SvgPicture.asset("assets/icons/home.svg", color: currentIndex == 0 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4),
label: LocaleKeys.home.tr(),
),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: SvgPicture.asset("assets/icons/create_req.svg", color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4), icon: SvgPicture.asset("assets/icons/create_req.svg", color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4),
label: LocaleKeys.mowadhafhiRequest.tr(), label: LocaleKeys.mowadhafhiRequest.tr(),

@ -49,32 +49,18 @@ class _AppDrawerState extends State<AppDrawer> {
children: <Widget>[ children: <Widget>[
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [Image.asset("assets/images/logos/main_mohemm_logo.png", width: 134, height: 24), const Icon(Icons.clear).onPress(() => Navigator.pop(context))],
Image.asset("assets/images/logos/main_mohemm_logo.png", width: 134, height: 24),
const Icon(Icons.clear).onPress(() => Navigator.pop(context)),
],
).paddingOnly(left: 4, right: 14), ).paddingOnly(left: 4, right: 14),
Row( Row(
children: [ children: [
AppState().memberInformationList!.eMPLOYEEIMAGE == null AppState().memberInformationList!.eMPLOYEEIMAGE == null
? SvgPicture.asset( ? SvgPicture.asset("assets/images/user.svg", height: 52, width: 52)
"assets/images/user.svg", : CircleAvatar(radius: 52 / 2, backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), backgroundColor: Colors.black),
height: 52,
width: 52,
)
: CircleAvatar(
radius: 52 / 2,
backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)),
backgroundColor: Colors.black,
),
12.width, 12.width,
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), AppState().memberInformationList!.getPositionName().toText14(weight: FontWeight.w500)],
AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), ).expanded,
AppState().memberInformationList!.getPositionName().toText14(weight: FontWeight.w500),
],
).expanded
], ],
).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21),
// Row( // Row(
@ -99,67 +85,77 @@ class _AppDrawerState extends State<AppDrawer> {
// ), // ),
// ], // ],
// ).paddingOnly(left: 14, right: 14, bottom: 14), // ).paddingOnly(left: 14, right: 14, bottom: 14),
const Divider( const Divider(height: 1, thickness: 1, color: MyColors.lightGreyEFColor),
height: 1,
thickness: 1,
color: MyColors.lightGreyEFColor,
),
ListView( ListView(
padding: const EdgeInsets.only(top: 21, bottom: 21), padding: const EdgeInsets.only(top: 21, bottom: 21),
children: [ children: [
ListView.builder( ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemCount: drawerMenuItemList.length, itemCount: drawerMenuItemList.length,
itemBuilder: (cxt, index) { itemBuilder: (cxt, index) {
return menuItem(drawerMenuItemList[index].icon, drawerMenuItemList[index].title, drawerMenuItemList[index].routeName, onPress: () { return menuItem(
drawerMenuItemList[index].icon,
drawerMenuItemList[index].title,
drawerMenuItemList[index].routeName,
onPress: () {
Navigator.pushNamed(context, drawerMenuItemList[index].routeName); Navigator.pushNamed(context, drawerMenuItemList[index].routeName);
}); },
}), );
},
),
menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())), menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())),
if (AppState().businessCardPrivilege) if (AppState().businessCardPrivilege)
menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: BusinessCardDialog(), isBusniessCard: true)), menuItem(
menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: performLogout), "assets/images/drawer/view_business_card.svg",
LocaleKeys.viewBusinessCard.tr(),
"",
closeDrawer: false,
onPress: () => showMDialog(context, child: BusinessCardDialog(), isBusniessCard: true),
),
menuItem(
"assets/images/drawer/logout.svg",
LocaleKeys.logout.tr(),
"",
color: MyColors.redA3Color,
closeDrawer: false,
onPress: () async {
await Utils.performLogout(context, chatData);
},
),
// menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {Navigator.pushNamed(context, AppRoutes.survey,); // menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {Navigator.pushNamed(context, AppRoutes.survey,);
], ],
).expanded, ).expanded,
const Divider( const Divider(height: 1, thickness: 1, color: MyColors.lightGreyEFColor),
height: 1,
thickness: 1,
color: MyColors.lightGreyEFColor,
),
Row( Row(
children: [ children: [
RichText( RichText(
text: TextSpan(text: LocaleKeys.poweredBy.tr() + " ", style: const TextStyle(color: MyColors.grey98Color, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), children: [ text: TextSpan(
TextSpan( text: LocaleKeys.poweredBy.tr() + " ",
text: LocaleKeys.cloudSolutions.tr(), style: const TextStyle(color: MyColors.grey98Color, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600),
style: const TextStyle(color: MyColors.grey3AColor, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), children: [TextSpan(text: LocaleKeys.cloudSolutions.tr(), style: const TextStyle(color: MyColors.grey3AColor, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600))],
), ),
]),
).expanded, ).expanded,
Image.asset("assets/images/logos/bn_cloud_soloution.jpg", width: 40, height: 40) Image.asset("assets/images/logos/bn_cloud_soloution.jpg", width: 40, height: 40),
], ],
).paddingOnly(left: 21, right: 21, top: 21) ).paddingOnly(left: 21, right: 21, top: 21),
], ],
).paddingOnly(top: 21, bottom: 21), ).paddingOnly(top: 21, bottom: 21),
); );
} }
Widget menuItem(String icon, String title, String routeName, {Color? color, bool closeDrawer = true, VoidCallback? onPress}) { Widget menuItem(String icon, String title, String routeName, {Color? color, bool closeDrawer = true, VoidCallback? onPress}) {
return Row( return Row(children: [SvgPicture.asset(icon, height: 20, width: 20), 9.width, title.toText14(color: color, textAlign: AppState().isArabic(context) ? TextAlign.right : null).expanded])
children: [ .paddingOnly(left: 21, top: 10, bottom: 10, right: 21)
SvgPicture.asset(icon, height: 20, width: 20), .onPress(
9.width, closeDrawer
title.toText14(color: color, textAlign: AppState().isArabic(context) ? TextAlign.right : null).expanded, ? () async {
], Navigator.pop(context);
).paddingOnly(left: 21, top: 10, bottom: 10, right: 21).onPress(closeDrawer Future.delayed(const Duration(microseconds: 200), onPress);
? () async { }
Navigator.pop(context); : onPress!,
Future.delayed(const Duration(microseconds: 200), onPress); );
}
: onPress!);
} }
void postLanguageChange(BuildContext context) { void postLanguageChange(BuildContext context) {
@ -170,14 +166,4 @@ class _AppDrawerState extends State<AppDrawer> {
widget.onLanguageChange(); widget.onLanguageChange();
setState(() {}); setState(() {});
} }
void performLogout() async {
AppState().isAuthenticated = false;
AppState().isLogged = false;
AppState().setPostParamsInitConfig();
chatData.disposeData();
// SharedPreferences prefs = await SharedPreferences.getInstance();
// await prefs.clear();
Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route<dynamic> route) => false, arguments: null);
}
} }

@ -39,7 +39,7 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true, showLogo: true, logoPath: "assets/icons/mazaya_brand.svg"), appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true, showLogo: false, logoPath: "assets/icons/mazaya_brand.svg"),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

Loading…
Cancel
Save