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 = {
"typeTransaction": [1, 2, 3, 4],
"statusTransaction": [1, 2, 3],
"priority": [0],
"priority": [1],
"displayData": []
};
response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]);
print("highPriorityRequests:${highPriorityRequests.total}");
notifyListeners();
}
isHighPriorityLoading = false;

@ -323,14 +323,14 @@
"myProfile" : "My Profile",
"viewDetails" : "View Details",
"requests" : "Requests",
"highPriorityRequests" : "High Priority\nRequests",
"newRequests" : "New Request\nRequests",
"completedRequests" : "completed\nRequests",
"overdueRequests": "overdue\nRequests",
"highPriority" : "High Priority",
"newRequests" : "New",
"completed" : "Completed",
"overdue": "Overdue",
"highPriority" : "High Priority",
"lowPriority" : "Low Priority",
"newR" : "New",
"inProgress": "In Progress",
"completed" : "completed",
"open" : "Open",
"requestType":"Request Type",
"requestNo": "Request No",
@ -348,8 +348,6 @@
"asset" : "Asset",
"addItem" : "Add 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/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/widgets/request_item_view_list.dart';
import 'package:test_sa/views/app_style/colors.dart';
class ProgressFragment extends StatelessWidget {
@ -77,9 +78,9 @@ class ProgressFragment extends StatelessWidget {
8.height,
TabBarView(
children: [
requestItemView(snapshot.openRequests?.requestsDetails ?? [], snapshot.isOpenLoading),
requestItemView(snapshot.inProgressRequests?.requestsDetails ?? [], snapshot.isInProgressLoading),
requestItemView(snapshot.closeRequests?.requestsDetails ?? [], snapshot.isCloseLoading),
RequestItemViewList(snapshot.openRequests?.requestsDetails ?? [], snapshot.isOpenLoading),
RequestItemViewList(snapshot.inProgressRequests?.requestsDetails ?? [], snapshot.isInProgressLoading),
RequestItemViewList(snapshot.closeRequests?.requestsDetails ?? [], snapshot.isCloseLoading),
],
).expanded,
],
@ -89,32 +90,32 @@ class ProgressFragment extends StatelessWidget {
),
);
}
Widget requestItemView(List<RequestsDetails> list, bool isLoading) {
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);
}
//
// Widget requestItemView(List<RequestsDetails> list, bool isLoading) {
// 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);
// }
}

@ -8,6 +8,7 @@ import 'package:test_sa/extensions/text_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/common_widgets/app_floating_action_button.dart';
import 'package:test_sa/new_views/pages/land_page/requests_list_page.dart';
class RequestsFragment extends StatelessWidget {
RequestsFragment({Key key}) : super(key: key);
@ -22,17 +23,17 @@ class RequestsFragment extends StatelessWidget {
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 191 / 237, crossAxisSpacing: 16, mainAxisSpacing: 16),
children: [
gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriorityRequests, context, snapshot.isHighPriorityLoading),
gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdueRequests, context, snapshot.isOverdueLoading),
gridItem(snapshot.openRequests?.total?.count?.toString() ?? "-", "new_request", context.translation.newRequests, context, snapshot.isOpenLoading),
gridItem(snapshot.closeRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completedRequests, context, snapshot.isCloseLoading),
gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriority, context, snapshot.isHighPriorityLoading, 0),
gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdue, context, snapshot.isOverdueLoading, 1),
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.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(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -48,7 +49,7 @@ class RequestsFragment extends StatelessWidget {
],
).expanded,
Text(
title,
"$title\n${context.translation.requests}",
style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50),
).toShimmer(isShow: isLoading),
8.height,
@ -68,6 +69,10 @@ class RequestsFragment extends StatelessWidget {
],
).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: (() {
_scaffoldKey.currentState.isDrawerOpen ? _scaffoldKey.currentState.closeDrawer() : _scaffoldKey.currentState.openDrawer();
})),
old_page.LandPage(),
// old_page.LandPage(),
MyRequestsPage(),
SingleDevicePicker(),
if (_userProvider.user.type == UsersTypes.engineer) CalendarPage(),
MyRequestsPage(),

@ -1,47 +1,78 @@
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 '../../../app_style/app_color.dart';
import '../../../common_widgets/app_search_field.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.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 {
const MyRequestsPage({Key key}) : super(key: key);
MyRequestsPage({Key key}) : super(key: key);
AllRequestsProvider _provider;
@override
Widget build(BuildContext context) {
if (_provider == null) {
_provider = Provider.of<AllRequestsProvider>(context, listen: false);
_provider.getAllRequests();
}
return Scaffold(
appBar: AppBar(
leadingWidth: 0,
title: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
appBar: AppBar(
automaticallyImplyLeading: false,
titleSpacing: 0,
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Expanded(child: SizedBox(height: 50, child: AppSearchField())),
const SizedBox(
width: 20,
),
Container(
height: 40,
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(
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: const TabBarView(
children: <Widget>[
Center(
child: Text(""),
),
Center(
child: Text(""),
),
Center(
child: Text(""),
),
],
),
);
body: Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
return RequestItemViewList(snapshot.allRequestsAndCount?.requestsDetails ?? [], snapshot.isAllLoading);
}));
}
}

@ -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