swipe module for normal users

main_design2.1
WaseemAbbasi22 1 year ago
parent 5036873d6a
commit d9ddd04c25

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

@ -261,12 +261,13 @@ class MyApp extends StatelessWidget {
LoginPage.routeName: (_) => const LoginPage(), LoginPage.routeName: (_) => const LoginPage(),
UnsafeDeviceScreen.routeName: (_) => const UnsafeDeviceScreen(), UnsafeDeviceScreen.routeName: (_) => const UnsafeDeviceScreen(),
SwipeSuccessView.routeName: (_) => const SwipeSuccessView(), SwipeSuccessView.routeName: (_) => const SwipeSuccessView(),
SwipeHistoryView.routeName: (_) => const SwipeHistoryView(), SwipeHistoryView.routeName: (_) => SwipeHistoryView(),
SwipeHistoryView.routeName: (_) => const SwipeHistoryView(), SwipeView.routeName: (_) => const SwipeView(),
///todo deleted ///todo deleted
//old.LandPage.id: (_) => const old.LandPage(), //old.LandPage.id: (_) => const old.LandPage(),
LandPage.routeName: (_) => const LandPage(), LandPage.routeName: (_) => const LandPage(),
SwipeView.routeName: (_) => const SwipeView(),
NewGasRefillRequestPage.routeName: (_) => const NewGasRefillRequestPage(), NewGasRefillRequestPage.routeName: (_) => const NewGasRefillRequestPage(),
ServiceRequestsPage.id: (_) => ServiceRequestsPage(), ServiceRequestsPage.id: (_) => ServiceRequestsPage(),
ReportIssuesPage.id: (_) => const ReportIssuesPage(), 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), if ((userProvider.user?.email ?? "").isNotEmpty) (userProvider.user?.email)?.heading6(context)?.custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
18.height, 18.height,
const Divider().defaultStyle(context), const Divider().defaultStyle(context),
userProvider.showSwipeOnly?SizedBox().expanded:
ListView( ListView(
padding: const EdgeInsets.only(top: 24), padding: const EdgeInsets.only(top: 24),
children: [ children: [
@ -78,7 +78,7 @@ class AppDrawer extends StatelessWidget {
// 18.height, // 18.height,
drawerItem("setting", context.translation.settings, context).onPress(() => Navigator.of(context).pushNamed(SettingsPage.id)), drawerItem("setting", context.translation.settings, context).onPress(() => Navigator.of(context).pushNamed(SettingsPage.id)),
18.height, 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)), drawerItem("swipe", "Swipe History", context) .onPress(() => Navigator.of(context).pushNamed(SwipeHistoryView.routeName)),
// 18.height, // 18.height,
// drawerItem("whats_new", context.translation.whatsNew, context), // 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/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.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/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 'package:test_sa/views/widgets/loaders/no_item_found.dart';
import 'models/swipe_transaction_history.dart'; import 'models/swipe_transaction_history.dart';
class SwipeHistoryView extends StatefulWidget { class SwipeHistoryView extends StatefulWidget {
static const routeName = '/swipe_list_view'; 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 @override
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: widget.showAppBar ? const DefaultAppBar(title: 'Swipe History') : null,
body: Column( body: SingleChildScrollView(
crossAxisAlignment:CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
8.height, children: [
Row( 8.height,
children: [ Row(
ADatePicker( children: [
label: context.translation.from, ADatePicker(
date: dateFrom, label: context.translation.from,
from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day), showDateOnly: true,
formatDateWithTime: true, date: dateFrom,
onDatePicker: (selectedDate) { from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
if (selectedDate != null) { formatDateWithTime: false,
showTimePicker( onDatePicker: (selectedDate) {
context: context, if (selectedDate != null) {
initialTime: TimeOfDay.now(), setState(() {
).then((selectedTime) { dateFrom = selectedDate;
// Handle the selected date and time here. });
if (selectedTime != null) { }
DateTime selectedDateTime = DateTime(
selectedDate.year, // if (selectedDate != null) {
selectedDate.month, // showTimePicker(
selectedDate.day, // context: context,
selectedTime.hour, // initialTime: TimeOfDay.now(),
selectedTime.minute, // ).then((selectedTime) {
); // // Handle the selected date and time here.
if (selectedDateTime != null) { // if (selectedTime != null) {
setState(() { // DateTime selectedDateTime = DateTime(
dateFrom = selectedDateTime; // 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: true, ).expanded,
onDatePicker: (selectedDate) { 8.width,
if (selectedDate != null) { ADatePicker(
showTimePicker( label: context.translation.to,
context: context, date: dateTo,
initialTime: TimeOfDay.now(), from: DateTime(DateTime.now().year - 5, DateTime.now().month, DateTime.now().day),
).then((selectedTime) { formatDateWithTime: false,
// Handle the selected date and time here. onDatePicker: (selectedDate) {
if (selectedTime != null) { if (selectedDate != null) {
DateTime selectedDateTime = DateTime( setState(() {
selectedDate.year, dateTo = selectedDate;
selectedDate.month, });
selectedDate.day, }
selectedTime.hour, // if (selectedDate != null) {
selectedTime.minute, // showTimePicker(
); // context: context,
if (selectedDateTime != null) { // initialTime: TimeOfDay.now(),
setState(() { // ).then((selectedTime) {
dateTo = selectedDateTime; // // Handle the selected date and time here.
// if (selectedTime != null) {
}); // DateTime selectedDateTime = DateTime(
// selectedDate.year,
} // selectedDate.month,
} // selectedDate.day,
}); // selectedTime.hour,
} // selectedTime.minute,
}, // );
).expanded, // if (selectedDateTime != null) {
], // setState(() {
), // dateTo = selectedDateTime;
12.height, // });
// }
AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory), // }
8.height, // });
Divider(thickness: 2,), // }
},
Consumer<UserProvider>( ).expanded,
builder: (context, snapshot,child) { ],
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading).expanded; ),
} 12.height,
), AppFilledButton(label: context.translation.search, maxWidth: false, onPressed: getSwipeHistory),
8.height,
const Divider(
], thickness: 2,
).paddingAll(20), ),
Consumer<UserProvider>(builder: (context, snapshot, child) {
return SwipeHistoryList(snapshot.swipeHistory ?? [], snapshot.isLoading);
}),
],
).paddingOnly(start: 20, end: 20, bottom: 20),
),
); );
} }
} }
class SwipeHistoryList extends StatelessWidget { class SwipeHistoryList extends StatelessWidget {
List<SwipeHistory> list; List<SwipeHistory> list;
bool isLoading; bool isLoading;
@ -149,21 +152,29 @@ class SwipeHistoryList extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return (list.isEmpty && !isLoading) 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( : ListView.separated(
padding: EdgeInsets.only(top: 12.toScreenHeight), physics: const NeverScrollableScrollPhysics(),
itemBuilder: (cxt, index) { shrinkWrap: true,
if (isLoading) return const SizedBox().toRequestShimmer(cxt, isLoading); padding: EdgeInsets.only(top: 12.toScreenHeight),
return SwipeHistoryCard(list[index]); itemBuilder: (cxt, index) {
}, if (isLoading)
separatorBuilder: (cxt, index) => 12.height, return const SizedBox(
itemCount: isLoading ? 6 : list.length); height: 20,
).toRequestShimmer(cxt, isLoading);
return SwipeHistoryCard(list[index]);
},
separatorBuilder: (cxt, index) => 12.height,
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(
@ -173,7 +184,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,
@ -186,4 +198,3 @@ class SwipeHistoryCard extends StatelessWidget {
).toShadowContainer(context, showShadow: showShadow); ).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/dashboard_fragments/requests_fragment.dart';
import 'package:test_sa/new_views/pages/land_page/widgets/dialogs/dialog.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/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/new_views/swipe_module/utils/swipe_general_utils.dart';
import 'package:test_sa/views/pages/user/notifications/notifications_page.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), ).paddingOnly(start: 16, end: 16),
), ),
body: Column( body: Stack(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Column(
context.translation.welcome, children: [
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), Text(
), context.translation.welcome,
Text( style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
_userProvider.user?.username ?? "", ),
style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600), 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( Positioned(
onTap: () async { right: 20.toScreenWidth,
bool isNfcSupported = await NfcManager.instance.isAvailable(); bottom: 60.toScreenHeight,
SwipeGeneralUtils.instance.showSwipeTypeBottomSheetSheet(isNfcSupported: isNfcSupported); child: GestureDetector(
}, onTap: () async {
child: CircularAnimatedContainer( bool isNfcSupported = await NfcManager.instance.isAvailable();
child: Container( SwipeGeneralUtils.instance.showSwipeTypeBottomSheetSheet(isNfcSupported: isNfcSupported);
},
child: CircularAnimatedContainer(child: Container(
width: 100.toScreenWidth, width: 100.toScreenWidth,
height: 100.toScreenHeight, height: 100.toScreenHeight,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: AppColor.white, color: AppColor.white,
border: Border.all(color: AppColor.primary80.withOpacity(0.5), width: 2), border: Border.all(color: AppColor.primary80.withOpacity(0.5), width: 2),
), ),
child: Consumer<UserProvider>(builder: (context, userProvider, child) { child: Consumer<UserProvider>(
return Column( builder: (context, userProvider,child) {
mainAxisAlignment: MainAxisAlignment.center, return Column(
crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ crossAxisAlignment: CrossAxisAlignment.center,
'swipe'.toSvgAsset(width: 32, height: 32), children: [
8.height, 'swipe'.toSvgAsset(width: 32, height: 32),
Text( 8.height,
("${context.translation.checkIn}\n${userProvider.swipeTransactionModel != null && userProvider.swipeTransactionModel.swipeTime != null ? SwipeGeneralUtils.instance.formatTimeOnly(userProvider.swipeTransactionModel.swipeTime) : ' --:--'}"), Text(
style: AppTextStyles.bodyText2.copyWith(color: AppColor.neutral80, fontWeight: FontWeight.w500, fontFamily: "Poppins"), ("${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, ),
),),
),
),
], ],
), ),
), ),

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

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

Loading…
Cancel
Save