swipe module for normal users

main_design2.1
WaseemAbbasi22 11 months ago
parent 5036873d6a
commit d9ddd04c25

@ -190,6 +190,9 @@ class UserProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
isUserConfirmSwipe = true;
await getSwipeLastTransaction(userId: user.userID);
if(showSwipeOnly){
await getSwipeTransactionHistory(userId: user.userID,dateFrom: DateTime.now(),dateTo: DateTime.now());
}
notifyListeners();
}

@ -261,12 +261,13 @@ class MyApp extends StatelessWidget {
LoginPage.routeName: (_) => const LoginPage(),
UnsafeDeviceScreen.routeName: (_) => const UnsafeDeviceScreen(),
SwipeSuccessView.routeName: (_) => const SwipeSuccessView(),
SwipeHistoryView.routeName: (_) => const SwipeHistoryView(),
SwipeHistoryView.routeName: (_) => const SwipeHistoryView(),
SwipeHistoryView.routeName: (_) => SwipeHistoryView(),
SwipeView.routeName: (_) => const SwipeView(),
///todo deleted
//old.LandPage.id: (_) => const old.LandPage(),
LandPage.routeName: (_) => const LandPage(),
SwipeView.routeName: (_) => const SwipeView(),
NewGasRefillRequestPage.routeName: (_) => const NewGasRefillRequestPage(),
ServiceRequestsPage.id: (_) => ServiceRequestsPage(),
ReportIssuesPage.id: (_) => const ReportIssuesPage(),

@ -66,7 +66,7 @@ class AppDrawer extends StatelessWidget {
if ((userProvider.user?.email ?? "").isNotEmpty) (userProvider.user?.email)?.heading6(context)?.custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
18.height,
const Divider().defaultStyle(context),
userProvider.showSwipeOnly?SizedBox().expanded:
ListView(
padding: const EdgeInsets.only(top: 24),
children: [
@ -78,7 +78,7 @@ class AppDrawer extends StatelessWidget {
// 18.height,
drawerItem("setting", context.translation.settings, context).onPress(() => Navigator.of(context).pushNamed(SettingsPage.id)),
18.height,
if(userProvider.user!=null&&!userProvider.user.employeeIsHMG)
if(userProvider.user!=null&&!userProvider.user.employeeIsHMG&& !userProvider.showSwipeOnly)
drawerItem("swipe", "Swipe History", context) .onPress(() => Navigator.of(context).pushNamed(SwipeHistoryView.routeName)),
// 18.height,
// drawerItem("whats_new", context.translation.whatsNew, context),

@ -10,136 +10,139 @@ import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
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/no_item_found.dart';
import 'models/swipe_transaction_history.dart';
class SwipeHistoryView extends StatefulWidget {
static const routeName = '/swipe_list_view';
bool showAppBar = true;
const SwipeHistoryView({Key key}) : super(key: key);
SwipeHistoryView({Key key, this.showAppBar = true}) : super(key: key);
@override
State<SwipeHistoryView> createState() => _SwipeHistoryViewState();
}
class _SwipeHistoryViewState extends State<SwipeHistoryView> {
DateTime dateFrom = DateTime.now();
DateTime dateTo = DateTime.now();
UserProvider _userProvider;
@override
void initState() {
getSwipeHistory();
super.initState();
}
void getSwipeHistory () {
_userProvider = Provider.of<UserProvider>(context,listen:false);
void getSwipeHistory() {
_userProvider = Provider.of<UserProvider>(context, listen: false);
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
Widget build(BuildContext context) {
return Scaffold(
appBar: const DefaultAppBar(title: 'Swipe History',),
body: Column(
crossAxisAlignment:CrossAxisAlignment.start,
children: [
8.height,
Row(
children: [
ADatePicker(
label: context.translation.from,
date: dateFrom,
from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
formatDateWithTime: true,
onDatePicker: (selectedDate) {
if (selectedDate != null) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
if (selectedDateTime != null) {
setState(() {
dateFrom = selectedDateTime;
});
}
}
});
}
},
).expanded,
8.width,
ADatePicker(
label: context.translation.to,
date: dateTo,
from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
formatDateWithTime: true,
onDatePicker: (selectedDate) {
if (selectedDate != null) {
showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
).then((selectedTime) {
// Handle the selected date and time here.
if (selectedTime != null) {
DateTime selectedDateTime = DateTime(
selectedDate.year,
selectedDate.month,
selectedDate.day,
selectedTime.hour,
selectedTime.minute,
);
if (selectedDateTime != null) {
setState(() {
dateTo = selectedDateTime;
});
}
}
});
}
},
).expanded,
],
),
12.height,
AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory),
8.height,
Divider(thickness: 2,),
Consumer<UserProvider>(
builder: (context, snapshot,child) {
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading).expanded;
}
),
],
).paddingAll(20),
return Scaffold(
appBar: widget.showAppBar ? const DefaultAppBar(title: 'Swipe History') : null,
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
8.height,
Row(
children: [
ADatePicker(
label: context.translation.from,
showDateOnly: true,
date: dateFrom,
from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
formatDateWithTime: false,
onDatePicker: (selectedDate) {
if (selectedDate != null) {
setState(() {
dateFrom = selectedDate;
});
}
// if (selectedDate != null) {
// showTimePicker(
// context: context,
// initialTime: TimeOfDay.now(),
// ).then((selectedTime) {
// // Handle the selected date and time here.
// if (selectedTime != null) {
// DateTime selectedDateTime = DateTime(
// selectedDate.year,
// selectedDate.month,
// selectedDate.day,
// selectedTime.hour,
// selectedTime.minute,
// );
// if (selectedDateTime != null) {
//
// }
// }
// });
// }
},
).expanded,
8.width,
ADatePicker(
label: context.translation.to,
date: dateTo,
from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
formatDateWithTime: false,
onDatePicker: (selectedDate) {
if (selectedDate != null) {
setState(() {
dateTo = selectedDate;
});
}
// if (selectedDate != null) {
// showTimePicker(
// context: context,
// initialTime: TimeOfDay.now(),
// ).then((selectedTime) {
// // Handle the selected date and time here.
// if (selectedTime != null) {
// DateTime selectedDateTime = DateTime(
// selectedDate.year,
// selectedDate.month,
// selectedDate.day,
// selectedTime.hour,
// selectedTime.minute,
// );
// if (selectedDateTime != null) {
// setState(() {
// dateTo = selectedDateTime;
// });
// }
// }
// });
// }
},
).expanded,
],
),
12.height,
AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory),
8.height,
const Divider(
thickness: 2,
),
Consumer<UserProvider>(builder: (context, snapshot, child) {
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading);
}),
],
).paddingOnly(start: 20, end: 20, bottom: 20),
),
);
}
}
class SwipeHistoryList extends StatelessWidget {
List<SwipeHistory> list;
bool isLoading;
@ -149,21 +152,29 @@ class SwipeHistoryList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return (list.isEmpty && !isLoading)
? NoItemFound(message: context.translation.noDataFound)
? context.translation.noDataFound.heading5(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50).center
: ListView.separated(
padding: EdgeInsets.only(top: 12.toScreenHeight),
itemBuilder: (cxt, index) {
if (isLoading) return const SizedBox().toRequestShimmer(cxt, isLoading);
return SwipeHistoryCard(list[index]);
},
separatorBuilder: (cxt, index) => 12.height,
itemCount: isLoading ? 6 : list.length);
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.only(top: 12.toScreenHeight),
itemBuilder: (cxt, index) {
if (isLoading)
return const SizedBox(
height: 20,
).toRequestShimmer(cxt, isLoading);
return SwipeHistoryCard(list[index]);
},
separatorBuilder: (cxt, index) => 12.height,
itemCount: isLoading ? 6 : list.length);
}
}
class SwipeHistoryCard extends StatelessWidget {
final SwipeHistory swipeHistory;
final bool showShadow;
const SwipeHistoryCard(this.swipeHistory, {Key key, this.showShadow = true}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
@ -173,7 +184,8 @@ class SwipeHistoryCard extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
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,
@ -186,4 +198,3 @@ class SwipeHistoryCard extends StatelessWidget {
).toShadowContainer(context, showShadow: showShadow);
}
}

@ -22,6 +22,7 @@ import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/recent_act
import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart';
import 'package:test_sa/new_views/pages/land_page/widgets/dialogs/dialog.dart';
import 'package:test_sa/new_views/swipe_module/circular_animated_widget.dart';
import 'package:test_sa/new_views/swipe_module/swipe_history_view.dart';
import 'package:test_sa/new_views/swipe_module/utils/swipe_general_utils.dart';
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
@ -102,55 +103,64 @@ class _SwipeViewState extends State<SwipeView> {
],
).paddingOnly(start: 16, end: 16),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.center,
body: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
context.translation.welcome,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
),
Text(
_userProvider.user?.username ?? "",
style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600),
),
Column(
children: [
Text(
context.translation.welcome,
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
),
Text(
_userProvider.user?.username ?? "",
style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600),
),
],
).paddingOnly(start: 16, end: 16, top: 8, bottom: 8),
SwipeHistoryView(showAppBar: false).expanded,
],
).paddingOnly(start: 16, end: 16, top: 8, bottom: 8),
GestureDetector(
onTap: () async {
bool isNfcSupported = await NfcManager.instance.isAvailable();
SwipeGeneralUtils.instance.showSwipeTypeBottomSheetSheet(isNfcSupported: isNfcSupported);
},
child: CircularAnimatedContainer(
child: Container(
),
Positioned(
right: 20.toScreenWidth,
bottom: 60.toScreenHeight,
child: GestureDetector(
onTap: () async {
bool isNfcSupported = await NfcManager.instance.isAvailable();
SwipeGeneralUtils.instance.showSwipeTypeBottomSheetSheet(isNfcSupported: isNfcSupported);
},
child: CircularAnimatedContainer(child: Container(
width: 100.toScreenWidth,
height: 100.toScreenHeight,
decoration: BoxDecoration(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.white,
border: Border.all(color: AppColor.primary80.withOpacity(0.5), width: 2),
),
child: Consumer<UserProvider>(builder: (context, userProvider, child) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
'swipe'.toSvgAsset(width: 32, height: 32),
8.height,
Text(
("${context.translation.checkIn}\n${userProvider.swipeTransactionModel != null && userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime) : ' --:--'}"),
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral80, fontWeight: FontWeight.w500, fontFamily: "Poppins"),
),
],
);
}),
),
).center,
).expanded,
child: Consumer<UserProvider>(
builder: (context, userProvider,child) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
'swipe'.toSvgAsset(width: 32, height: 32),
8.height,
Text(
("${context.translation.checkIn}\n${userProvider.swipeTransactionModel != null && userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime) : '--:--'}"),
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral80, fontWeight: FontWeight.w500, fontFamily: "Poppins"),
),
],
);
}
),
),),
),
),
],
),
),

@ -12,7 +12,7 @@ class ADatePicker extends StatelessWidget {
final DateTime to;
final String label;
final Function(DateTime) onDatePicker;
final bool enable, withBorder;
final bool enable, withBorder,showDateOnly;
final Color backgroundColor;
final bool formatDateWithTime;
@ -23,6 +23,7 @@ class ADatePicker extends StatelessWidget {
this.backgroundColor,
this.date,
this.formatDateWithTime = false,
this.showDateOnly = false,
this.onDatePicker,
this.from,
this.to,

@ -18,7 +18,8 @@ class NoItemFound extends StatelessWidget {
Center(
child: Text(message ?? "no item found", style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)),
),
ListView(),
ListView(
),
],
);
}

Loading…
Cancel
Save