From e4737f403ecd03e93bd3d4ae0f183057af1866ad Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 1 Nov 2022 09:36:08 +0300 Subject: [PATCH] attendance file fixed --- lib/ui/landing/today_attendance_screen2.dart | 214 +++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 lib/ui/landing/today_attendance_screen2.dart diff --git a/lib/ui/landing/today_attendance_screen2.dart b/lib/ui/landing/today_attendance_screen2.dart new file mode 100644 index 0000000..17bb03a --- /dev/null +++ b/lib/ui/landing/today_attendance_screen2.dart @@ -0,0 +1,214 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:easy_localization/src/public_ext.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; +import 'package:mohem_flutter_app/classes/date_uitl.dart'; +import 'package:mohem_flutter_app/extensions/int_extensions.dart'; +import 'package:mohem_flutter_app/extensions/string_extensions.dart'; +import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; +import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; +import 'package:mohem_flutter_app/widgets/circular_step_progress_bar.dart'; +import 'package:mohem_flutter_app/widgets/mark_attendance_widget.dart'; +import 'package:nfc_manager/nfc_manager.dart'; +import 'package:provider/provider.dart'; +import 'package:wifi_iot/wifi_iot.dart'; + +class TodayAttendanceScreen2 extends StatefulWidget { + TodayAttendanceScreen2({Key? key}) : super(key: key); + + @override + _TodayAttendanceScreenState createState() { + return _TodayAttendanceScreenState(); + } +} + +class _TodayAttendanceScreenState extends State { + ValueNotifier result = ValueNotifier(null); + late DashboardProviderModel data; + + @override + void initState() { + super.initState(); + data = Provider.of(context, listen: false); + } + + @override + void dispose() { + super.dispose(); + // Stop Session + NfcManager.instance.stopSession(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: MyColors.backgroundBlackColor, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios, color: Colors.white), + onPressed: () => Navigator.pop(context), + ), + actions: [ + IconButton( + onPressed: () { + data.fetchAttendanceTracking(context); + }, + icon: const Icon( + Icons.ac_unit, + color: Colors.white, + ), + ) + ], + ), + backgroundColor: MyColors.backgroundBlackColor, + body: Consumer( + builder: (context, model, child) { + return (model.isAttendanceTrackingLoading + ? Center(child: CircularProgressIndicator()) + : Column( + children: [ + Container( + width: double.infinity, + color: MyColors.backgroundBlackColor, + padding: EdgeInsets.only(top: 1, left: 21, right: 21, bottom: 21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DateUtil.getWeekDayMonthDayYearDateFormatted(DateTime.now(), "en").toText24(isBold: true, color: Colors.white), + LocaleKeys.timeLeftToday.tr().toText16(color: Color(0xffACACAC)), + Center( + child: Container( + margin: EdgeInsets.only(left: 21, right: 21, top: 18), + child: AspectRatio( + aspectRatio: 1, + child: CircularStepProgressBar( + totalSteps: 16 * 4, + currentStep: (model.progress * 100).toInt(), + selectedColor: MyColors.gradiantEndColor, + unselectedColor: MyColors.grey70Color, + child: Center( + child: Padding( + padding: const EdgeInsets.all(21.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + flex: 1, + child: CountdownTimer( + endTime: model.endTime, + widgetBuilder: (context, v) { + return AutoSizeText( + getValue(v?.hours) + " : " + getValue(v?.min) + " : " + getValue(v?.sec), + maxLines: 1, + style: const TextStyle(color: Colors.white, fontSize: 42, letterSpacing: -1.92, fontWeight: FontWeight.bold, height: 1), + ); + }, + onEnd: null, + endWidget: "00:00:00".toTextAuto(color: Colors.white, isBold: true, fontSize: 30, letterSpacing: -1.92), + textStyle: const TextStyle(color: Colors.white, fontSize: 30, letterSpacing: -1.92, fontWeight: FontWeight.bold, height: 1), + ).center, + ), + Expanded( + flex: 1, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + LocaleKeys.shiftTime.tr().tr().toTextAuto(color: MyColors.greyACColor, fontSize: 18, maxLine: 1).paddingOnly(left: 21,right: 21), + (model.attendanceTracking!.pShtName ?? "00:00:00").toString().toTextAuto(color: Colors.white, isBold: true, fontSize: 26, maxLine: 1), + ], + ), + ) + ], + ), + ), + ), + ), + ), + ), + ).expanded, + ], + ), + ).toExpanded(flex: 2), + Center( + child: Container( + decoration: const BoxDecoration( + borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), + gradient: LinearGradient( + transform: GradientRotation(.64), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.only(left: 21, right: 21, top: 21, bottom: 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)), + gradient: LinearGradient(transform: GradientRotation(.64), begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ]), + ), + child: Column( + children: [ + Row( + children: [ + commonStatusView(LocaleKeys.checkIn.tr(), (model.attendanceTracking!.pSwipeIn) ?? "- - : - -"), + commonStatusView(LocaleKeys.checkOut.tr(), (model.attendanceTracking!.pSwipeOut) ?? "- - : - -") + ], + ), + 21.height, + Row( + children: [ + commonStatusView(LocaleKeys.lateIn.tr(), (model.attendanceTracking!.pLateInHours) ?? "- - : - -"), + commonStatusView(LocaleKeys.regular.tr(), (model.attendanceTracking!.pScheduledHours) ?? "- - : - -") + ], + ), + ], + ), + ), //.expanded, + + MarkAttendanceWidget(model, topPadding: 21), + ], + ), + ), + ) + ], + )) + .animatedSwither(); + }, + ), + ); + } + + String getValue(int? v) { + if (v == null) { + return "00"; + } else if (v.toString().length == 1) { + return "0" + v.toString(); + } else { + return v.toString(); + } + } + + Future closeWifiRequest() async { + await WiFiForIoTPlugin.forceWifiUsage(false); + bool v = await WiFiForIoTPlugin.disconnect(); + return v; + } + + Widget commonStatusView(String title, String time) => Expanded( + child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ + title.toText12(color: Colors.white.withOpacity(.69)), + time.toText22(color: Colors.white, isBold: true), + ]), + ); +}