my requests added.

main_design2.0
Sikander Saleem 2 years ago
parent 29d83101af
commit 6d0aa0e17c

@ -70,14 +70,13 @@ class AllRequestsProvider extends ChangeNotifier {
Map<String, dynamic> body = { Map<String, dynamic> body = {
"typeTransaction": [1, 2, 3, 4], "typeTransaction": [1, 2, 3, 4],
"statusTransaction": [1, 2, 3], "statusTransaction": [1, 2, 3],
"priority": [0], "priority": [1],
"displayData": [] "displayData": []
}; };
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]);
print("highPriorityRequests:${highPriorityRequests.total}");
notifyListeners(); notifyListeners();
} }
isHighPriorityLoading = false; isHighPriorityLoading = false;

@ -323,14 +323,14 @@
"myProfile" : "My Profile", "myProfile" : "My Profile",
"viewDetails" : "View Details", "viewDetails" : "View Details",
"requests" : "Requests", "requests" : "Requests",
"highPriorityRequests" : "High Priority\nRequests", "highPriority" : "High Priority",
"newRequests" : "New Request\nRequests", "newRequests" : "New",
"completedRequests" : "completed\nRequests", "completed" : "Completed",
"overdueRequests": "overdue\nRequests", "overdue": "Overdue",
"highPriority" : "High Priority", "highPriority" : "High Priority",
"lowPriority" : "Low Priority", "lowPriority" : "Low Priority",
"newR" : "New",
"inProgress": "In Progress", "inProgress": "In Progress",
"completed" : "completed",
"open" : "Open", "open" : "Open",
"requestType":"Request Type", "requestType":"Request Type",
"requestNo": "Request No", "requestNo": "Request No",
@ -348,8 +348,6 @@
"asset" : "Asset", "asset" : "Asset",
"addItem" : "Add Item", "addItem" : "Add Item",
"item" : "Item", "item" : "Item",
"measuredValue": "Measured Value" "measuredValue": "Measured Value",
"overdue": "Overdue"
} }

@ -13,6 +13,7 @@ import 'package:test_sa/new_views/pages/land_page/requests/asset_item_view.dart'
import 'package:test_sa/new_views/pages/land_page/requests/gas_refill_item_view.dart'; import 'package:test_sa/new_views/pages/land_page/requests/gas_refill_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/requests/ppm_item_view.dart'; import 'package:test_sa/new_views/pages/land_page/requests/ppm_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/requests/service_request_item_view.dart'; import 'package:test_sa/new_views/pages/land_page/requests/service_request_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
class ProgressFragment extends StatelessWidget { class ProgressFragment extends StatelessWidget {
@ -77,9 +78,9 @@ class ProgressFragment extends StatelessWidget {
8.height, 8.height,
TabBarView( TabBarView(
children: [ children: [
requestItemView(snapshot.openRequests?.requestsDetails ?? [], snapshot.isOpenLoading), RequestItemViewList(snapshot.openRequests?.requestsDetails ?? [], snapshot.isOpenLoading),
requestItemView(snapshot.inProgressRequests?.requestsDetails ?? [], snapshot.isInProgressLoading), RequestItemViewList(snapshot.inProgressRequests?.requestsDetails ?? [], snapshot.isInProgressLoading),
requestItemView(snapshot.closeRequests?.requestsDetails ?? [], snapshot.isCloseLoading), RequestItemViewList(snapshot.closeRequests?.requestsDetails ?? [], snapshot.isCloseLoading),
], ],
).expanded, ).expanded,
], ],
@ -89,32 +90,32 @@ class ProgressFragment extends StatelessWidget {
), ),
); );
} }
//
Widget requestItemView(List<RequestsDetails> list, bool isLoading) { // Widget requestItemView(List<RequestsDetails> list, bool isLoading) {
return ListView.separated( // return ListView.separated(
padding: const EdgeInsets.all(16), // padding: const EdgeInsets.all(16),
itemBuilder: (cxt, index) { // itemBuilder: (cxt, index) {
if (isLoading) return SizedBox().toRequestShimmer(cxt, isLoading); // if (isLoading) return SizedBox().toRequestShimmer(cxt, isLoading);
bool isServiceRequest = list[index].nameOfType == "ServiceRequest"; // bool isServiceRequest = list[index].nameOfType == "ServiceRequest";
bool isGasRefill = list[index].nameOfType == "GasRefill"; // bool isGasRefill = list[index].nameOfType == "GasRefill";
bool isAssetTransfer = list[index].nameOfType == "AssetTransfer"; // bool isAssetTransfer = list[index].nameOfType == "AssetTransfer";
bool isPPMs = list[index].nameOfType == "PPMs"; // bool isPPMs = list[index].nameOfType == "PPMs";
//
return isServiceRequest // return isServiceRequest
? ServiceRequestItemView(list[index]) // ? ServiceRequestItemView(list[index])
: isGasRefill // : isGasRefill
? GasRefillItemView(list[index]) // ? GasRefillItemView(list[index])
: isPPMs // : isPPMs
? PpmItemView(list[index]) // ? PpmItemView(list[index])
: isAssetTransfer // : isAssetTransfer
? AssetItemView(list[index]) // ? AssetItemView(list[index])
: Container( // : Container(
height: 100, // height: 100,
width: double.infinity, // width: double.infinity,
color: Colors.grey, // color: Colors.grey,
); // );
}, // },
separatorBuilder: (cxt, index) => 8.height, // separatorBuilder: (cxt, index) => 8.height,
itemCount: isLoading ? 6 : list.length); // itemCount: isLoading ? 6 : list.length);
} // }
} }

@ -8,6 +8,7 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_floating_action_button.dart'; import 'package:test_sa/new_views/common_widgets/app_floating_action_button.dart';
import 'package:test_sa/new_views/pages/land_page/requests_list_page.dart';
class RequestsFragment extends StatelessWidget { class RequestsFragment extends StatelessWidget {
RequestsFragment({Key key}) : super(key: key); RequestsFragment({Key key}) : super(key: key);
@ -22,17 +23,17 @@ class RequestsFragment extends StatelessWidget {
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 191 / 237, crossAxisSpacing: 16, mainAxisSpacing: 16), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 191 / 237, crossAxisSpacing: 16, mainAxisSpacing: 16),
children: [ children: [
gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriorityRequests, context, snapshot.isHighPriorityLoading), gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriority, context, snapshot.isHighPriorityLoading, 0),
gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdueRequests, context, snapshot.isOverdueLoading), gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdue, context, snapshot.isOverdueLoading, 1),
gridItem(snapshot.openRequests?.total?.count?.toString() ?? "-", "new_request", context.translation.newRequests, context, snapshot.isOpenLoading), gridItem(snapshot.openRequests?.total?.count?.toString() ?? "-", "new_request", context.translation.newR, context, snapshot.isOpenLoading, 2),
gridItem(snapshot.closeRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completedRequests, context, snapshot.isCloseLoading), gridItem(snapshot.closeRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completed, context, snapshot.isCloseLoading, 3),
], ],
), ),
), ),
); );
} }
Widget gridItem(String value, String icon, String title, BuildContext context, bool isLoading) { Widget gridItem(String value, String icon, String title, BuildContext context, bool isLoading, int index) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -48,7 +49,7 @@ class RequestsFragment extends StatelessWidget {
], ],
).expanded, ).expanded,
Text( Text(
title, "$title\n${context.translation.requests}",
style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50), style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50),
).toShimmer(isShow: isLoading), ).toShimmer(isShow: isLoading),
8.height, 8.height,
@ -68,6 +69,10 @@ class RequestsFragment extends StatelessWidget {
], ],
).toShimmer(isShow: isLoading), ).toShimmer(isShow: isLoading),
], ],
).toShadowContainer(context); ).toShadowContainer(context).onPress(isLoading
? null
: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => RequestsListPage(index)));
});
} }
} }

@ -50,7 +50,8 @@ class _LandPageState extends State<LandPage> {
DashboardPage(onDrawerPress: (() { DashboardPage(onDrawerPress: (() {
_scaffoldKey.currentState.isDrawerOpen ? _scaffoldKey.currentState.closeDrawer() : _scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState.isDrawerOpen ? _scaffoldKey.currentState.closeDrawer() : _scaffoldKey.currentState.openDrawer();
})), })),
old_page.LandPage(), // old_page.LandPage(),
MyRequestsPage(),
SingleDevicePicker(), SingleDevicePicker(),
if (_userProvider.user.type == UsersTypes.engineer) CalendarPage(), if (_userProvider.user.type == UsersTypes.engineer) CalendarPage(),
MyRequestsPage(), MyRequestsPage(),

@ -1,47 +1,78 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import '../../../app_style/app_color.dart'; import 'package:test_sa/extensions/text_extensions.dart';
import '../../../common_widgets/app_search_field.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list.dart';
class MyRequestsPage extends StatelessWidget { class MyRequestsPage extends StatelessWidget {
const MyRequestsPage({Key key}) : super(key: key); MyRequestsPage({Key key}) : super(key: key);
AllRequestsProvider _provider;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_provider == null) {
_provider = Provider.of<AllRequestsProvider>(context, listen: false);
_provider.getAllRequests();
}
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leadingWidth: 0, automaticallyImplyLeading: false,
title: Padding( titleSpacing: 0,
padding: const EdgeInsets.only(bottom: 10), title: Row(
child: Row( mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
const Expanded(child: SizedBox(height: 50, child: AppSearchField())), Container(
const SizedBox( height: 40,
width: 20, padding: const EdgeInsets.only(left: 16, right: 8),
), alignment: Alignment.center,
decoration: ShapeDecoration(
color: Color(0xFFEAF1F4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
child: Row(
children: [
const Icon(Icons.search, color: Color(0xFF757575), size: 16),
8.width,
Text(
context.translation.search,
style: AppTextStyles.bodyText.copyWith(
color: const Color(0xFF757575),
),
).expanded,
],
),
).onPress(() async {
// final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => AssetSearchScreen(data: _searchAsset)));
// if (result != null) {
// _searchAsset = result;
// }
// _searchableList.clear();
// _searchableList.addAll(_devicesProvider.devices);
}).expanded,
16.width,
Text( Text(
context.translation.filter, context.translation.filter,
style: TextStyle(color: AppColor.primary50, fontSize: Theme.of(context).textTheme.bodySmall.fontSize, fontWeight: FontWeight.w500), style: AppTextStyles.bodyText2.copyWith(color: const Color(0xFF4A8DB7)),
) ).onPress(() async {
// final result = await Navigator.push(context, MaterialPageRoute(builder: (context) => AssetFilterScreen(data: _searchAsset)));
// if (result != null) {
// _searchAsset = result;
// }
// _searchableList.clear();
// _searchableList.addAll(_devicesProvider.devices);
}),
], ],
), ).paddingOnly(start: 16, end: 16),
), ),
), body: Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
body: const TabBarView( return RequestItemViewList(snapshot.allRequestsAndCount?.requestsDetails ?? [], snapshot.isAllLoading);
children: <Widget>[ }));
Center(
child: Text(""),
),
Center(
child: Text(""),
),
Center(
child: Text(""),
),
],
),
);
} }
} }

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/all_requests_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list.dart';
class RequestsListPage extends StatelessWidget {
static const String routeName = "/requests-list-page";
final int index;
RequestsListPage(this.index, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
String title = index == 0
? context.translation.highPriority
: index == 1
? context.translation.overdue
: index == 2
? context.translation.newR
: index == 3
? context.translation.completed
: "";
return Scaffold(
appBar: DefaultAppBar(title: "$title ${context.translation.requests}"),
body: Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
bool isLoading = index == 0
? snapshot.isHighPriorityLoading
: index == 1
? snapshot.isOverdueLoading
: index == 2
? snapshot.isOpenLoading
: index == 3
? snapshot.isCloseLoading
: false;
List<RequestsDetails> list = index == 0
? snapshot.highPriorityRequests.requestsDetails
: index == 1
? snapshot.overdueRequests.requestsDetails
: index == 2
? snapshot.openRequests.requestsDetails
: index == 3
? snapshot.closeRequests.requestsDetails
: [];
return RequestItemViewList(list, isLoading);
}));
}
}

@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/new_views/pages/land_page/requests/asset_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/requests/gas_refill_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/requests/ppm_item_view.dart';
import 'package:test_sa/new_views/pages/land_page/requests/service_request_item_view.dart';
class RequestItemViewList extends StatelessWidget {
List<RequestsDetails> list;
bool isLoading;
RequestItemViewList(this.list, this.isLoading, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.separated(
padding: const EdgeInsets.all(16),
itemBuilder: (cxt, index) {
if (isLoading) return SizedBox().toRequestShimmer(cxt, isLoading);
bool isServiceRequest = list[index].nameOfType == "ServiceRequest";
bool isGasRefill = list[index].nameOfType == "GasRefill";
bool isAssetTransfer = list[index].nameOfType == "AssetTransfer";
bool isPPMs = list[index].nameOfType == "PPMs";
return isServiceRequest
? ServiceRequestItemView(list[index])
: isGasRefill
? GasRefillItemView(list[index])
: isPPMs
? PpmItemView(list[index])
: isAssetTransfer
? AssetItemView(list[index])
: Container(
height: 100,
width: double.infinity,
color: Colors.grey,
);
},
separatorBuilder: (cxt, index) => 8.height,
itemCount: isLoading ? 6 : list.length);
}
}
Loading…
Cancel
Save