my requests added.
parent
29d83101af
commit
6d0aa0e17c
@ -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…
Reference in New Issue