Merge branch 'master' into development_sikander

merge-requests/9/head
Sikander Saleem 2 years ago
commit ba65fbb79d

@ -296,7 +296,39 @@ class WorkListApiClient {
"RequestType": requestType, "RequestType": requestType,
"TaskID": taskId, "TaskID": taskId,
"ItemID": itemId, "ItemID": itemId,
"EmployeeNumber": "15153", "EmployeeNumber": employeeNumber,
};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
ItgFormsModel responseData = ItgFormsModel.fromJson(json);
return responseData.itgRequest;
}, url, postParams);
}
Future<ITGRequest?> rejectITGRequest(String requestType, int taskId, int itemId, String employeeNumber, String comments) async {
String url = "${ApiConsts.cocRest}ITGRejectRequest";
Map<String, dynamic> postParams = {
"RequestType": requestType,
"TaskID": taskId,
"ItemID": itemId,
"EmployeeNumber": employeeNumber,
"Comments": comments,
};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
ItgFormsModel responseData = ItgFormsModel.fromJson(json);
return responseData.itgRequest;
}, url, postParams);
}
Future<ITGRequest?> approveITGRequest(String requestType, int taskId, int itemId, String employeeNumber, String comments) async {
String url = "${ApiConsts.cocRest}ITGApproveRequest";
Map<String, dynamic> postParams = {
"RequestType": requestType,
"TaskID": taskId,
"ItemID": itemId,
"EmployeeNumber": employeeNumber,
"Comments": comments,
}; };
postParams.addAll(AppState().postParamsJson); postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) { return await ApiClient().postJsonForObject((json) {

@ -72,6 +72,33 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
return true; return true;
} }
void initProvider() {
isAttendanceTrackingLoading = true;
endTime = 0;
isTimeRemainingInSeconds = 0;
progress = 0.0;
attendanceTracking = null;
isWorkListLoading = true;
workListCounter = 0;
isMissingSwipeLoading = true;
missingSwipeCounter = 0;
isLeaveTicketBalanceLoading = true;
accrualList = null;
leaveBalanceAccrual = null;
ticketBalance = 0;
isServicesMenusLoading = true;
homeMenus = null;
getMenuEntriesList = null;
isOffersLoading = true;
getOffersList = [];
notifyListeners();
}
int calculateSeconds(String time) { int calculateSeconds(String time) {
int hour = int.parse(time.split(":")[0]); int hour = int.parse(time.split(":")[0]);
int mints = int.parse(time.split(":")[1]); int mints = int.parse(time.split(":")[1]);
@ -81,12 +108,6 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void update(context) { void update(context) {
fetchAttendanceTracking(context); fetchAttendanceTracking(context);
// isAttendanceTrackingLoading = !isAttendanceTrackingLoading;
// isWorkListLoading = !isWorkListLoading;
// attendanceTracking?.pSwipeIn = "a";
// isTimeRemainingInSeconds = calculateSeconds("00:10:30");
// endTime = DateTime.now().millisecondsSinceEpoch + Duration(seconds: isTimeRemainingInSeconds).inMilliseconds;
// notifyListeners();
} }
ItgFormsModel? itgFormsModel; ItgFormsModel? itgFormsModel;

@ -23,6 +23,7 @@ import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart';
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
import 'package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart'; import 'package:mohem_flutter_app/widgets/shimmer/offers_shimmer_widget.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class DashboardScreen extends StatefulWidget { class DashboardScreen extends StatefulWidget {
DashboardScreen({Key? key}) : super(key: key); DashboardScreen({Key? key}) : super(key: key);
@ -37,12 +38,24 @@ class _DashboardScreenState extends State<DashboardScreen> {
late DashboardProviderModel data; late DashboardProviderModel data;
final GlobalKey<ScaffoldState> _scaffoldState = GlobalKey(); final GlobalKey<ScaffoldState> _scaffoldState = GlobalKey();
final RefreshController _refreshController = RefreshController(initialRefresh: false);
int currentIndex = 0; int currentIndex = 0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
data = Provider.of<DashboardProviderModel>(context, listen: false); data = Provider.of<DashboardProviderModel>(context, listen: false);
_onRefresh();
}
@override
void dispose() {
super.dispose();
}
void _onRefresh() async {
data.initProvider();
data.fetchListMenu(); data.fetchListMenu();
data.fetchAttendanceTracking(context); data.fetchAttendanceTracking(context);
data.fetchWorkListCounter(context); data.fetchWorkListCounter(context);
@ -50,11 +63,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
data.fetchLeaveTicketBalance(context, DateTime.now()); data.fetchLeaveTicketBalance(context, DateTime.now());
data.fetchMenuEntries(); data.fetchMenuEntries();
data.getCategoryOffersListAPI(context); data.getCategoryOffersListAPI(context);
} _refreshController.refreshCompleted();
@override
void dispose() {
super.dispose();
} }
@override @override
@ -71,7 +80,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Image.memory( Image.memory(
Utils.getPostBytes(AppState().memberInformationList!.eMPLOYEEIMAGE ?? ""), Utils.getPostBytes(
AppState().memberInformationList!.eMPLOYEEIMAGE ?? "",
),
errorBuilder: (BuildContext context, error, stackTrace) { errorBuilder: (BuildContext context, error, stackTrace) {
return SvgPicture.asset( return SvgPicture.asset(
"assets/images/user.svg", "assets/images/user.svg",
@ -120,243 +131,243 @@ class _DashboardScreenState extends State<DashboardScreen> {
], ],
).paddingOnly(left: 21, right: 21, top: 48, bottom: 7), ).paddingOnly(left: 21, right: 21, top: 48, bottom: 7),
Expanded( Expanded(
child: SingleChildScrollView( child: SmartRefresher(
child: Column( enablePullDown: true,
children: [ enablePullUp: false,
Column( header: const MaterialClassicHeader(color: MyColors.gradiantEndColor,),
crossAxisAlignment: CrossAxisAlignment.start, controller: _refreshController,
children: [ onRefresh: _onRefresh,
LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color), child: SingleChildScrollView(
(AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true), child: Column(
16.height, children: [
Row( Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Expanded( children: [
child: AspectRatio( LocaleKeys.goodMorning.tr().toText14(color: MyColors.grey77Color),
aspectRatio: 159 / 159, (AppState().memberInformationList!.eMPLOYEENAME ?? "").toText24(isBold: true),
child: Consumer<DashboardProviderModel>( 16.height,
builder: (context, model, child) { Row(
return (model.isAttendanceTrackingLoading children: [
? GetAttendanceTrackingShimmer() Expanded(
: Container( child: AspectRatio(
decoration: BoxDecoration( aspectRatio: 159 / 159,
borderRadius: BorderRadius.circular(15), child: Consumer<DashboardProviderModel>(
gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ builder: (context, model, child) {
MyColors.gradiantEndColor, return (model.isAttendanceTrackingLoading
MyColors.gradiantStartColor, ? GetAttendanceTrackingShimmer()
]), : Container(
), decoration: BoxDecoration(
child: Stack( borderRadius: BorderRadius.circular(15),
alignment: Alignment.center, gradient: const LinearGradient(transform: GradientRotation(.46), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [
children: [ MyColors.gradiantEndColor,
if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"), MyColors.gradiantStartColor,
Column( ]),
crossAxisAlignment: CrossAxisAlignment.start, ),
children: [ child: Stack(
Expanded( alignment: Alignment.center,
child: Column( children: [
mainAxisSize: MainAxisSize.min, if (model.isTimeRemainingInSeconds == 0) SvgPicture.asset("assets/images/thumb.svg"),
crossAxisAlignment: CrossAxisAlignment.start, Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true), children: [
if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white), Expanded(
if (model.isTimeRemainingInSeconds != 0) child: Column(
Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ LocaleKeys.markAttendance.tr().toText14(color: Colors.white, isBold: true),
9.height, if (model.isTimeRemainingInSeconds == 0) "01-02-2022".toText12(color: Colors.white),
CountdownTimer( if (model.isTimeRemainingInSeconds != 0)
endTime: model.endTime, Column(
onEnd: null, mainAxisSize: MainAxisSize.min,
endWidget: "00:00:00".toText14(color: Colors.white, isBold: true), crossAxisAlignment: CrossAxisAlignment.start,
textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold),
),
LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white),
9.height,
ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
child: LinearProgressIndicator(
value: model.progress,
minHeight: 8,
valueColor: const AlwaysStoppedAnimation<Color>(Colors.white),
backgroundColor: const Color(0xff196D73),
),
),
],
),
],
).paddingOnly(top: 12, right: 15, left: 12),
),
Row(
children: [ children: [
Expanded( 9.height,
child: Column( CountdownTimer(
mainAxisSize: MainAxisSize.min, endTime: model.endTime,
crossAxisAlignment: CrossAxisAlignment.start, onEnd: null,
children: [ endWidget: "00:00:00".toText14(color: Colors.white, isBold: true),
LocaleKeys.checkIn.tr().toText12(color: Colors.white), textStyle: TextStyle(color: Colors.white, fontSize: 14, letterSpacing: -0.48, fontWeight: FontWeight.bold),
(model.attendanceTracking!.pSwipeIn == null ? "--:--" : model.attendanceTracking!.pSwipeIn)
.toString()
.toText14(color: Colors.white, isBold: true),
4.height,
],
).paddingOnly(right: AppState().isArabic(context) ? 12 : 0, left: AppState().isArabic(context) ? 0 : 12),
), ),
Container( LocaleKeys.timeLeftToday.tr().toText12(color: Colors.white),
width: 45, 9.height,
height: 45, ClipRRect(
padding: const EdgeInsets.only(left: 14, right: 14), borderRadius: BorderRadius.all(
decoration: BoxDecoration( Radius.circular(20),
color: const Color(0xff259EA4),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(AppState().isArabic(context) ? 0 : 15),
bottomLeft: Radius.circular(AppState().isArabic(context) ? 15 : 0),
),
), ),
child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"), child: LinearProgressIndicator(
).onPress(() { value: model.progress,
// if (AppState().isArabic(context)) { minHeight: 8,
// context.setLocale(const Locale("en", "US")); valueColor: const AlwaysStoppedAnimation<Color>(Colors.white),
// } else { backgroundColor: const Color(0xff196D73),
// context.setLocale(const Locale("ar", "SA")); ),
// } ),
showMyBottomSheet(context, child: MarkAttendanceWidget(model));
}),
], ],
), ),
], ],
).paddingOnly(top: 12, right: 15, left: 12),
),
Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.checkIn.tr().toText12(color: Colors.white),
(model.attendanceTracking!.pSwipeIn == null ? "--:--" : model.attendanceTracking!.pSwipeIn)
.toString()
.toText14(color: Colors.white, isBold: true),
4.height,
],
).paddingOnly(left: 12),
), ),
Container(
width: 45,
height: 45,
padding: const EdgeInsets.only(left: 14, right: 14),
decoration: const BoxDecoration(
color: Color(0xff259EA4),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(15),
),
),
child: SvgPicture.asset(model.isTimeRemainingInSeconds == 0 ? "assets/images/play.svg" : "assets/images/stop.svg"),
).onPress(() {
showMyBottomSheet(context, child: MarkAttendanceWidget(model));
}),
], ],
), ),
).onPress( ],
() { ),
Navigator.pushNamed(context, AppRoutes.todayAttendance); ],
}, ),
)) ).onPress(
.animatedSwither(); () {
}, Navigator.pushNamed(context, AppRoutes.todayAttendance);
},
))
.animatedSwither();
},
),
), ),
), ),
), 9.width,
9.width,
Expanded(
child: MenusWidget(),
),
],
),
],
).paddingOnly(left: 21, right: 21, top: 7),
ServicesWidget(),
// 8.height,
Container(
width: double.infinity,
padding: const EdgeInsets.only(top: 31),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)),
border: Border.all(color: MyColors.lightGreyEDColor, width: 1),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded( Expanded(
child: Column( child: MenusWidget(),
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)),
],
),
],
),
), ),
LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() {
Navigator.pushNamed(context, AppRoutes.offersAndDiscounts);
})
], ],
).paddingOnly(left: 21, right: 21), ),
Consumer<DashboardProviderModel>( ],
builder: (context, model, child) { ).paddingOnly(left: 21, right: 21, top: 7),
return SizedBox( ServicesWidget(),
height: 103 + 33, // 8.height,
child: ListView.separated( Container(
shrinkWrap: true, width: double.infinity,
physics: const BouncingScrollPhysics(), padding: const EdgeInsets.only(top: 31),
padding: const EdgeInsets.only(left: 21, right: 21, top: 13), decoration: BoxDecoration(
scrollDirection: Axis.horizontal, color: Colors.white,
itemBuilder: (cxt, index) { borderRadius: const BorderRadius.only(topRight: Radius.circular(50), topLeft: Radius.circular(50)),
return model.isOffersLoading border: Border.all(color: MyColors.lightGreyEDColor, width: 1),
? const OffersShimmerWidget() ),
: InkWell( child: Column(
onTap: () { mainAxisSize: MainAxisSize.min,
navigateToDetails(data.getOffersList[index]); children: [
}, Row(
child: SizedBox( crossAxisAlignment: CrossAxisAlignment.center,
width: 73, children: [
child: Column( Expanded(
crossAxisAlignment: CrossAxisAlignment.center, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Container( mainAxisSize: MainAxisSize.min,
width: 73, children: [
height: 73, LocaleKeys.offers.tr().toText12(),
decoration: BoxDecoration( Row(
borderRadius: const BorderRadius.all( children: [
Radius.circular(100), LocaleKeys.discounts.tr().toText24(isBold: true),
), 6.width,
border: Border.all(color: MyColors.lightGreyE3Color, width: 1), Container(
), padding: const EdgeInsets.only(left: 8, right: 8),
child: ClipRRect( decoration: BoxDecoration(
borderRadius: const BorderRadius.all( color: MyColors.yellowColor,
Radius.circular(50), borderRadius: BorderRadius.circular(10),
), ),
child: Hero( child: LocaleKeys.newString.tr().toText10(isBold: true)),
tag: "ItemImage" + data.getOffersList[index].rowID!, ],
transitionOnUserGestures: true, ),
child: Image.network( ],
data.getOffersList[index].bannerImage!, ),
fit: BoxFit.contain, ),
), LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() {
), Navigator.pushNamed(context, AppRoutes.offersAndDiscounts);
), })
],
).paddingOnly(left: 21, right: 21),
Consumer<DashboardProviderModel>(
builder: (context, model, child) {
return SizedBox(
height: 103 + 33,
child: ListView.separated(
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.only(left: 21, right: 21, top: 13),
scrollDirection: Axis.horizontal,
itemBuilder: (cxt, index) {
return model.isOffersLoading
? const OffersShimmerWidget()
: InkWell(
onTap: () {
navigateToDetails(data.getOffersList[index]);
},
child: SizedBox(
width: 73,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 73,
height: 73,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(100),
), ),
4.height, border: Border.all(color: MyColors.lightGreyE3Color, width: 1),
Expanded( ),
child: AppState().isArabic(context) child: ClipRRect(
? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) borderRadius: const BorderRadius.all(
: data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), Radius.circular(50),
), ),
], child: Hero(
tag: "ItemImage" + data.getOffersList[index].rowID!,
transitionOnUserGestures: true,
child: Image.network(
data.getOffersList[index].bannerImage!,
fit: BoxFit.contain,
),
),
),
), ),
), 4.height,
); Expanded(
}, child: AppState().isArabic(context)
separatorBuilder: (cxt, index) => 8.width, ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1)
itemCount: 6), : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1),
); ),
}, ],
), ),
], ),
), );
) },
], separatorBuilder: (cxt, index) => 8.width,
itemCount: 6),
);
},
),
],
),
)
],
),
), ),
), ),
) )

@ -23,10 +23,10 @@ class ServicesWidget extends StatelessWidget {
"assets/images/monthly_attendance.svg", "assets/images/monthly_attendance.svg",
"assets/images/ticket_request.svg", "assets/images/ticket_request.svg",
"assets/images/ticket_request.svg", "assets/images/ticket_request.svg",
"assets/images/dynamic_screens.svg", "assets/images/ticket_request.svg",
"assets/images/dynamic_screens.svg", "assets/images/ticket_request.svg",
"assets/images/dynamic_screens.svg", "assets/images/ticket_request.svg",
"assets/images/dynamic_screens.svg" "assets/images/ticket_request.svg"
]; ];
return Consumer<DashboardProviderModel>( return Consumer<DashboardProviderModel>(

@ -25,6 +25,7 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> {
List<GetSaleCategoriesList> getSaleCategoriesList = []; List<GetSaleCategoriesList> getSaleCategoriesList = [];
List<GetItemsForSaleList> getItemsForSaleList = []; List<GetItemsForSaleList> getItemsForSaleList = [];
List<GetItemsForSaleList> _foundItemsForSaleList = [];
ScrollController gridScrollController = ScrollController(); ScrollController gridScrollController = ScrollController();
int currentPageNo = 1; int currentPageNo = 1;
@ -61,20 +62,10 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> {
isInputTypeNum: false, isInputTypeNum: false,
isReadOnly: false, isReadOnly: false,
onChange: (String value) { onChange: (String value) {
// _runFilter(value); _runFilter(value);
}, },
).paddingOnly(left: 21, right: 21, top: 21), ).paddingOnly(left: 21, right: 21, top: 21),
Row( LocaleKeys.browseCategories.tr().toText17().paddingOnly(left: 21, right: 21, top: 21),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
LocaleKeys.browseCategories.tr().toText17(),
// todo @haroon define the purpose of this icon button
IconButton(
icon: const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0),
onPressed: () => Navigator.pop(context),
),
],
).paddingOnly(left: 21, right: 21),
SizedBox( SizedBox(
height: 105.0, height: 105.0,
child: getSaleCategoriesList.isNotEmpty child: getSaleCategoriesList.isNotEmpty
@ -132,10 +123,22 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> {
); );
} }
void _runFilter(String enteredKeyword) {
List<GetItemsForSaleList> results = [];
if (enteredKeyword.isEmpty) {
results = getItemsForSaleList;
} else {
results = getItemsForSaleList.where((offer) => offer.title!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList();
}
setState(() {
_foundItemsForSaleList = results;
});
}
List<Widget> getItemsForSaleWidgets() { List<Widget> getItemsForSaleWidgets() {
List<Widget> itemsList = []; List<Widget> itemsList = [];
getItemsForSaleList.forEach((element) { _foundItemsForSaleList.forEach((element) {
itemsList.add(getItemCard(element)); itemsList.add(getItemCard(element));
}); });
@ -200,6 +203,7 @@ class _ItemsForSaleFragmentState extends State<ItemsForSaleFragment> {
getItemsForSaleListLocal.clear(); getItemsForSaleListLocal.clear();
getItemsForSaleListLocal = await ItemsForSaleApiClient().getItemsForSale(itgPageNo, itgCategoryID); getItemsForSaleListLocal = await ItemsForSaleApiClient().getItemsForSale(itgPageNo, itgCategoryID);
getItemsForSaleList.addAll(getItemsForSaleListLocal); getItemsForSaleList.addAll(getItemsForSaleListLocal);
_foundItemsForSaleList = getItemsForSaleList;
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (ex) { } catch (ex) {

@ -25,6 +25,7 @@ class OffersAndDiscountsHome extends StatefulWidget {
class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> { class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
List<GetCategoriesList> getCategoriesList = []; List<GetCategoriesList> getCategoriesList = [];
List<OffersListModel> getOffersList = []; List<OffersListModel> getOffersList = [];
List<OffersListModel> _foundOffersList = [];
int currentCategoryID = 0; int currentCategoryID = 0;
@ -54,18 +55,10 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
isInputTypeNum: false, isInputTypeNum: false,
isReadOnly: false, isReadOnly: false,
onChange: (String value) { onChange: (String value) {
// _runFilter(value); _runFilter(value);
}, },
).paddingOnly(left: 21, right: 21, top: 21), ).paddingOnly(left: 21, right: 21, top: 21),
Row( LocaleKeys.browseCategories.tr().toText17().paddingOnly(left: 21, right: 21, top: 21),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
LocaleKeys.browseCategories.tr().toText17(),
const Icon(Icons.filter_alt_sharp, color: MyColors.darkIconColor, size: 28.0).onPress(() {
Navigator.pop(context);
}),
],
).paddingOnly(left: 21, right: 21, top: 21),
SizedBox( SizedBox(
height: 110.0, height: 110.0,
child: getCategoriesList.isNotEmpty child: getCategoriesList.isNotEmpty
@ -81,6 +74,7 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
onTap: () { onTap: () {
setState(() { setState(() {
currentCategoryID = getCategoriesList[index].id!; currentCategoryID = getCategoriesList[index].id!;
getCategoryOffersListAPI();
// getItemsForSaleList.clear(); // getItemsForSaleList.clear();
// currentPageNo = 1; // currentPageNo = 1;
// getItemsForSale(currentPageNo, currentCategoryID); // getItemsForSale(currentPageNo, currentCategoryID);
@ -146,7 +140,7 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
List<Widget> getItemsForSaleWidgets() { List<Widget> getItemsForSaleWidgets() {
List<Widget> itemsList = []; List<Widget> itemsList = [];
for (var element in getOffersList) { for (var element in _foundOffersList) {
itemsList.add(getItemCard(element)); itemsList.add(getItemCard(element));
} }
@ -213,6 +207,18 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
); );
} }
void _runFilter(String enteredKeyword) {
List<OffersListModel> results = [];
if (enteredKeyword.isEmpty) {
results = getOffersList;
} else {
results = getOffersList.where((offer) => offer.title!.toLowerCase().contains(enteredKeyword.toLowerCase())).toList();
}
setState(() {
_foundOffersList = results;
});
}
void navigateToDetails(OffersListModel offersListModelObj) { void navigateToDetails(OffersListModel offersListModelObj) {
List<OffersListModel> getOffersDetailList = []; List<OffersListModel> getOffersDetailList = [];
getOffersDetailList.clear(); getOffersDetailList.clear();
@ -258,6 +264,7 @@ class _OffersAndDiscountsHomeState extends State<OffersAndDiscountsHome> {
try { try {
Utils.showLoading(context); Utils.showLoading(context);
getOffersList = await OffersAndDiscountsApiClient().getOffersList(currentCategoryID, 100); getOffersList = await OffersAndDiscountsApiClient().getOffersList(currentCategoryID, 100);
_foundOffersList = getOffersList;
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (ex) { } catch (ex) {

@ -11,8 +11,6 @@ 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/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart';
import 'package:mohem_flutter_app/models/itg_forms_models/allowed_actions_model.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/allowed_actions_model.dart';
import 'package:mohem_flutter_app/models/itg_forms_models/itg_request_model.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/itg_request_model.dart';
import 'package:mohem_flutter_app/models/itg_forms_models/request_detail_model.dart'; import 'package:mohem_flutter_app/models/itg_forms_models/request_detail_model.dart';
@ -20,7 +18,7 @@ import 'package:mohem_flutter_app/ui/work_list/itg_fragments/approval_level_frag
import 'package:mohem_flutter_app/ui/work_list/itg_fragments/request_detail_fragment.dart'; import 'package:mohem_flutter_app/ui/work_list/itg_fragments/request_detail_fragment.dart';
import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/dialogs/accept_reject_input_dialog.dart'; import 'package:mohem_flutter_app/widgets/dialogs/itg_comments_dialog.dart';
class ItgDetailScreen extends StatefulWidget { class ItgDetailScreen extends StatefulWidget {
ItgDetailScreen({Key? key}) : super(key: key); ItgDetailScreen({Key? key}) : super(key: key);
@ -56,22 +54,21 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
ITGRequest? itgRequest; ITGRequest? itgRequest;
void getItgData() async { void getItgData() async {
// try { try {
Utils.showLoading(context); Utils.showLoading(context);
itgRequest = await WorkListApiClient().getITGFormDetails(requestDetails!.requestType!, requestDetails!.iD!, requestDetails!.itemID!, ""); itgRequest = await WorkListApiClient().getITGFormDetails(requestDetails!.requestType!, requestDetails!.iD!, requestDetails!.itemID!, AppState().memberInformationList?.eMPLOYEENUMBER ?? "");
allowedActionList = itgRequest?.allowedActions ?? []; allowedActionList = itgRequest?.allowedActions ?? [];
if (allowedActionList.isNotEmpty) { if (allowedActionList.isNotEmpty) {
isCloseAvailable = allowedActionList.any((element) => element.action == "CLOSE"); isCloseAvailable = allowedActionList.any((element) => element.action == "CLOSE");
isApproveAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Approve"); isApproveAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Approve");
// isAnswerAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Answer");
isRejectAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Reject"); isRejectAvailable = itgRequest!.allowedActions!.any((element) => element.action == "Reject");
} }
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
// } catch (ex) { } catch (ex) {
// Utils.hideLoading(context); Utils.hideLoading(context);
// Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
// } }
} }
void getDataFromState() { void getDataFromState() {
@ -341,34 +338,39 @@ class _ItgDetailScreenState extends State<ItgDetailScreen> {
void performAction(String actionMode) { void performAction(String actionMode) {
showDialog( showDialog(
context: context, context: context,
builder: (cxt) => AcceptRejectInputDialog( builder: (cxt) => ITGCommentsDialog(
message: LocaleKeys.requestedItems.tr(), message: LocaleKeys.writeComment.tr(),
// notificationGetRespond: notificationNoteInput,
onTap: (note) { onTap: (note) {
Map<String, dynamic> payload = { if (actionMode == "APPROVED") {
"P_ACTION_MODE": actionMode, performApproveAction(requestDetails!.requestType!, requestDetails!.iD!, requestDetails!.itemID!, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note);
"P_APPROVER_INDEX": null, } else {
"P_COMMENTS": "", performRejectAction(requestDetails!.requestType!, requestDetails!.iD!, requestDetails!.itemID!, AppState().memberInformationList?.eMPLOYEENUMBER ?? "", note);
"P_FORWARD_TO_USER_NAME": "", }
// "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID!,
"RespondAttributeList": [
// if (notificationNoteInput != null) {notificationNoteInput!.attributeName: note}
],
};
performNotificationAction(payload);
}, },
), ),
); );
} }
void performNotificationAction(Map<String, dynamic> payload) async { void performRejectAction(String requestType, int taskId, int itemId, String employeeNumber, String comments) async {
try {
Utils.showLoading(context);
ITGRequest? itgRequest = await WorkListApiClient().rejectITGRequest(requestType, taskId, itemId, employeeNumber, comments);
Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Navigator.pop(context, "delegate_reload");
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void performApproveAction(String requestType, int taskId, int itemId, String employeeNumber, String comments) async {
try { try {
Utils.showLoading(context); Utils.showLoading(context);
GenericResponseModel model = await WorkListApiClient().postNotificationActions(payload); ITGRequest? itgRequest = await WorkListApiClient().approveITGRequest(requestType, taskId, itemId, employeeNumber, comments);
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr());
Navigator.pop(context, true); Navigator.pop(context, "delegate_reload");
} catch (ex) { } catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);

@ -32,17 +32,45 @@ class WorkListScreen extends StatefulWidget {
class _WorkListScreenState extends State<WorkListScreen> { class _WorkListScreenState extends State<WorkListScreen> {
List<WorkListItemTypeModelData> workListItemTypes = [ List<WorkListItemTypeModelData> workListItemTypes = [
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'HR', fullName: LocaleKeys.humanResource.tr(), active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'HRSSA', disable: false), value: 0,
name: 'HR',
fullName: LocaleKeys.humanResource.tr(),
active: false,
color: [Color(0xff32D892), Color(0xff1AB170)],
icon: "assets/images/miss_swipe.svg",
key: 'HRSSA',
disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'MR', fullName: LocaleKeys.moveOrder.tr(), active: false, color: [Color(0xff58DCFA), Color(0xff3CB9D5)], icon: "assets/images/miss_swipe.svg", key: 'INVMOA', disable: false), value: 0, name: 'MR', fullName: LocaleKeys.moveOrder.tr(), active: false, color: [Color(0xff58DCFA), Color(0xff3CB9D5)], icon: "assets/images/miss_swipe.svg", key: 'INVMOA', disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'PR', fullName: LocaleKeys.purchaseRequisition.tr(), active: false, color: [Color(0xff48EACF), Color(0xff3DCAB3)], icon: "assets/images/miss_swipe.svg", key: 'REQAPPRV', disable: false), value: 0,
name: 'PR',
fullName: LocaleKeys.purchaseRequisition.tr(),
active: false,
color: [Color(0xff48EACF), Color(0xff3DCAB3)],
icon: "assets/images/miss_swipe.svg",
key: 'REQAPPRV',
disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'PO', fullName: LocaleKeys.purchaseOrder.tr(), active: false, color: [Color(0xff5099E3), Color(0xff3670AA)], icon: "assets/images/miss_swipe.svg", key: 'POAPPRV', disable: false), value: 0,
name: 'PO',
fullName: LocaleKeys.purchaseOrder.tr(),
active: false,
color: [Color(0xff5099E3), Color(0xff3670AA)],
icon: "assets/images/miss_swipe.svg",
key: 'POAPPRV',
disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'ITG', fullName: LocaleKeys.ITGForms.tr(), active: false, color: [Color(0xffEB8C90), Color(0xffDE6C70)], icon: "assets/images/miss_swipe.svg", key: 'ITG', disable: false), value: 0, name: 'ITG', fullName: LocaleKeys.ITGForms.tr(), active: false, color: [Color(0xffEB8C90), Color(0xffDE6C70)], icon: "assets/images/miss_swipe.svg", key: 'ITG', disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'IC', fullName: LocaleKeys.itemCreation.tr(), active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'INVITEM', disable: false), value: 0,
name: 'IC',
fullName: LocaleKeys.itemCreation.tr(),
active: false,
color: [Color(0xff32D892), Color(0xff1AB170)],
icon: "assets/images/miss_swipe.svg",
key: 'INVITEM',
disable: false),
WorkListItemTypeModelData( WorkListItemTypeModelData(
value: 0, name: 'STAMP', fullName: LocaleKeys.stamp.tr(), active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'STAMP', disable: false), value: 0, name: 'STAMP', fullName: LocaleKeys.stamp.tr(), active: false, color: [Color(0xff32D892), Color(0xff1AB170)], icon: "assets/images/miss_swipe.svg", key: 'STAMP', disable: false),
]; ];
@ -232,6 +260,7 @@ class _WorkListScreenState extends State<WorkListScreen> {
var shouldReloadData = await Navigator.pushNamed(context, AppRoutes.itgDetail); var shouldReloadData = await Navigator.pushNamed(context, AppRoutes.itgDetail);
if (shouldReloadData != null) { if (shouldReloadData != null) {
if (shouldReloadData.toString() == "delegate_reload") { if (shouldReloadData.toString() == "delegate_reload") {
providerData.itgFormsModel!.totalCount = providerData.itgFormsModel!.totalCount! - 1;
calculateCounter(); calculateCounter();
getWorkList(); getWorkList();
} }

@ -0,0 +1,102 @@
import 'package:easy_localization/src/public_ext.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/int_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/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart';
class ITGCommentsDialog extends StatelessWidget {
final String? title;
final String? message;
final String? okTitle;
final Function(String) onTap;
ITGCommentsDialog({Key? key, this.title, @required this.message, this.okTitle, required this.onTap}) : super(key: key);
String note = "";
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(),
insetPadding: const EdgeInsets.only(left: 21, right: 21),
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 18, bottom: 28),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Text(
title ?? LocaleKeys.confirm.tr(),
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xff2B353E), height: 35 / 24, letterSpacing: -0.96),
),
),
),
IconButton(
padding: EdgeInsets.zero,
icon: const Icon(Icons.close),
color: const Color(0xff2B353E),
constraints: const BoxConstraints(),
onPressed: () {
Navigator.pop(context);
},
)
],
),
Text(
message ?? "",
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff808080), letterSpacing: -0.48),
),
// if (notificationGetRespond != null) ...[
14.height,
InputWidget(
"Enter a Note",
LocaleKeys.comments.tr(),
TextEditingController(),
isBackgroundEnable: true,
isInputTypeNum: false,
lines: 3,
onChange: (String note) {
this.note = note;
},
),
// ],
28.height,
Row(
children: [
DefaultButton(
LocaleKeys.cancel.tr(),
() => Navigator.pop(context),
colors: const [MyColors.lightGreyEAColor, MyColors.lightGreyEAColor],
textColor: MyColors.darkTextColor,
).expanded,
10.width,
DefaultButton(
LocaleKeys.ok.tr(),
() {
Navigator.pop(context);
onTap(note);
},
colors: const [
Color(0xff28C884),
Color(0xff1BB271),
],
).expanded,
],
),
],
),
),
);
}
}

@ -75,6 +75,7 @@ dependencies:
url_launcher: ^6.0.15 url_launcher: ^6.0.15
share: 2.0.4 share: 2.0.4
flutter_rating_bar: ^4.0.1 flutter_rating_bar: ^4.0.1
pull_to_refresh: ^2.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save