|
|
|
@ -13,7 +13,6 @@ import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'models/swipe_transaction_history.dart';
|
|
|
|
import 'models/swipe_transaction_history.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class SwipeHistoryView extends StatefulWidget {
|
|
|
|
class SwipeHistoryView extends StatefulWidget {
|
|
|
|
@ -25,31 +24,33 @@ class SwipeHistoryView extends StatefulWidget {
|
|
|
|
State<SwipeHistoryView> createState() => _SwipeHistoryViewState();
|
|
|
|
State<SwipeHistoryView> createState() => _SwipeHistoryViewState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _SwipeHistoryViewState extends State<SwipeHistoryView> {
|
|
|
|
class _SwipeHistoryViewState extends State<SwipeHistoryView> {
|
|
|
|
DateTime dateFrom = DateTime.now();
|
|
|
|
DateTime dateFrom = DateTime.now();
|
|
|
|
DateTime dateTo = DateTime.now();
|
|
|
|
DateTime dateTo = DateTime.now();
|
|
|
|
UserProvider? _userProvider;
|
|
|
|
UserProvider? _userProvider;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
getSwipeHistory();
|
|
|
|
getSwipeHistory();
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void getSwipeHistory () {
|
|
|
|
void getSwipeHistory() {
|
|
|
|
_userProvider = Provider.of<UserProvider>(context,listen:false);
|
|
|
|
_userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
await _userProvider!.getSwipeTransactionHistory(userId: _userProvider!.user!.userID!,dateFrom: dateFrom,dateTo: dateTo);
|
|
|
|
await _userProvider!.getSwipeTransactionHistory(userId: _userProvider!.user!.userID!, dateFrom: dateFrom, dateTo: dateTo);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
appBar: const DefaultAppBar(title: 'Swipe History',),
|
|
|
|
appBar: const DefaultAppBar(
|
|
|
|
|
|
|
|
title: 'Swipe History',
|
|
|
|
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
body: Column(
|
|
|
|
crossAxisAlignment:CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -106,10 +107,8 @@ class _SwipeHistoryViewState extends State<SwipeHistoryView> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (selectedDateTime != null) {
|
|
|
|
if (selectedDateTime != null) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
dateTo = selectedDateTime;
|
|
|
|
dateTo = selectedDateTime;
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -121,48 +120,46 @@ class _SwipeHistoryViewState extends State<SwipeHistoryView> {
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory),
|
|
|
|
AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
const Divider(thickness: 2,color:AppColor.white60 ,),
|
|
|
|
const Divider(
|
|
|
|
|
|
|
|
thickness: 2,
|
|
|
|
Consumer<UserProvider>(
|
|
|
|
color: AppColor.white60,
|
|
|
|
builder: (context, snapshot,child) {
|
|
|
|
|
|
|
|
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading).expanded;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
Consumer<UserProvider>(builder: (context, snapshot, child) {
|
|
|
|
|
|
|
|
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading).expanded;
|
|
|
|
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).paddingAll(20),
|
|
|
|
).paddingAll(20),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SwipeHistoryList extends StatelessWidget {
|
|
|
|
class SwipeHistoryList extends StatelessWidget {
|
|
|
|
List<SwipeHistory> list;
|
|
|
|
List<SwipeHistory> list;
|
|
|
|
bool isLoading;
|
|
|
|
bool isLoading;
|
|
|
|
|
|
|
|
|
|
|
|
SwipeHistoryList(this.list, this.isLoading, {Key ?key}) : super(key: key);
|
|
|
|
SwipeHistoryList(this.list, this.isLoading, {Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return (list.isEmpty && !isLoading)
|
|
|
|
return (list.isEmpty && !isLoading)
|
|
|
|
? NoDataFound(message: context.translation.noDataFound).center
|
|
|
|
? NoDataFound(message: context.translation.noDataFound).center
|
|
|
|
: ListView.separated(
|
|
|
|
: ListView.separated(
|
|
|
|
padding: EdgeInsets.only(top: 12.toScreenHeight),
|
|
|
|
padding: EdgeInsets.only(top: 12.toScreenHeight),
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
if (isLoading) return const SizedBox().toRequestShimmer(cxt, isLoading);
|
|
|
|
if (isLoading) return const SizedBox().toRequestShimmer(cxt, isLoading);
|
|
|
|
return SwipeHistoryCard(list[index]);
|
|
|
|
return SwipeHistoryCard(list[index]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separatorBuilder: (cxt, index) => 12.height,
|
|
|
|
separatorBuilder: (cxt, index) => 12.height,
|
|
|
|
itemCount: isLoading ? 6 : list.length);
|
|
|
|
itemCount: isLoading ? 6 : list.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class SwipeHistoryCard extends StatelessWidget {
|
|
|
|
class SwipeHistoryCard extends StatelessWidget {
|
|
|
|
final SwipeHistory swipeHistory;
|
|
|
|
final SwipeHistory swipeHistory;
|
|
|
|
final bool showShadow;
|
|
|
|
final bool showShadow;
|
|
|
|
|
|
|
|
|
|
|
|
const SwipeHistoryCard(this.swipeHistory, {Key? key, this.showShadow = true}) : super(key: key);
|
|
|
|
const SwipeHistoryCard(this.swipeHistory, {Key? key, this.showShadow = true}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
@ -172,7 +169,8 @@ class SwipeHistoryCard extends StatelessWidget {
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Text(swipeHistory.swipeTime!.toServiceRequestDetailsFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
|
|
|
Text(swipeHistory.swipeTime!.toServiceRequestDetailsFormat,
|
|
|
|
|
|
|
|
textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
@ -185,4 +183,3 @@ class SwipeHistoryCard extends StatelessWidget {
|
|
|
|
).toShadowContainer(context, showShadow: showShadow);
|
|
|
|
).toShadowContainer(context, showShadow: showShadow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|