123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986 |
- import 'dart:async';
- import 'dart:convert';
-
- import 'package:app_settings/app_settings.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_map/plugin_api.dart';
- import 'package:geolocator/geolocator.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'package:employee_selfservice_mobile/Screens/Menu/Absensi/RequestHttp/checkIn_post.dart';
- import 'package:employee_selfservice_mobile/Screens/Menu/Absensi/RequestHttp/checkStatus_post.dart';
- import 'package:employee_selfservice_mobile/Screens/Menu/Absensi/absensi_history_screen.dart';
- import 'package:intl/intl.dart';
- import 'package:latlong2/latlong.dart' as latlong;
- import 'package:location/location.dart' as loc;
- import 'dart:developer' as logDev;
-
- import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
- import 'package:sliding_up_panel/sliding_up_panel.dart';
-
- import 'RequestHttp/checkOut_post.dart';
- import 'RequestHttp/historyAbsensi_post.dart';
-
- class AbsensiScreen extends StatefulWidget {
- const AbsensiScreen({Key? key}) : super(key: key);
-
- @override
- State<AbsensiScreen> createState() => _AbsensiScreenState();
- }
-
- class _AbsensiScreenState extends State<AbsensiScreen> {
- //Visibility Button Check In & Check Out
- bool visibleCheckIn = false;
- bool visibleCheckOut = false;
-
- latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664);
- late Position position;
-
- late String showCheckIn_List;
- late String showCheckOut_List;
-
- MapController _mapController = MapController();
-
- @override
- void initState() {
- showCheckIn_List = "";
- showCheckOut_List = "";
-
- WidgetsBinding.instance.addPostFrameCallback((_) {
- determinePosition();
- });
- super.initState();
- }
-
- determinePosition() async {
- StreamSubscription<ServiceStatus> serviceStatusStream = Geolocator.getServiceStatusStream().listen(
- (ServiceStatus status) {
- print(status);
- });
-
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 3,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
-
- await loading.show();
-
- bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
- logDev.log(serviceEnabled.toString(), name: "ON/OFF LOCATION SERVICE");
- if (!serviceEnabled) {
- //return Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- //await loading.hide();
- //alertDialogEnableLocaionServices(context);
- return Future.error('Location services are disabled.');
- }
-
- LocationPermission permission = await Geolocator.checkPermission();
-
- if (permission == LocationPermission.deniedForever) {
- await loading.hide();
- //return Future.error('Location permissions are permanently denied, we cannot request permissions.');
- return alertDialogPermissionDeniedForever(context);
- } else if (permission == LocationPermission.denied) {
- permission = await Geolocator.requestPermission();
- if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
- await loading.hide();
- //return Future.error('Location permissions are denied (actual value: $permission).');
- return alertDialogPermissionDenied(context);
- }
- }
-
- position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
- logDev.log(position.toString(), name: "Position GEOLOCATOR");
- if (position.isMocked) {
- await loading.hide();
- setState(() {
- alertDialogFakeGPSDetected(context);
- });
- } else {
- point = latlong.LatLng(position.latitude, position.longitude);
- logDev.log(point.toString(), name: "POINT GEOLOCATOR");
- _mapController.move(point, 18);
-
- //Check Status
- CheckStatus_Post.connectToAPI().then((valueResult) async {
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String result = object['result'].toString();
- logDev.log(result, name: "Status Absensi Result");
- if (result.contains("not_checked_in")) {
- setState(() {
- visibleCheckIn = !visibleCheckIn;
- visibleCheckOut = visibleCheckOut;
- });
- await loading.hide();
- } else if (result.contains("checked_in")) {
- setState(() {
- visibleCheckIn = visibleCheckIn;
- visibleCheckOut = !visibleCheckOut;
- });
- await loading.hide();
- } else {
- setState(() {
- alertDialogFailedResponse(context);
- });
- await loading.hide();
- }
- } else {
- setState(() {
- alertDialogFailedResponse(context);
- });
- await loading.hide();
- }
- await loading.hide();
- });
-
- //History
- HistoryAbsensi_Post.connectToAPI().then((valueResult) async {
- Map<String, dynamic> object = jsonDecode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String result = object['result'].toString();
- if (result.contains("failed")) {
- await loading.hide();
- alertDialogFailedRetrievedData(context);
- } else {
- List <dynamic> historyAbsensi = object['result'];
- await loading.hide();
- setState(() {
- String check_in = historyAbsensi[0]['check_in'].toString();
- String check_out = historyAbsensi[0]['check_out'].toString();
- logDev.log(historyAbsensi[0]['check_in'].toString(), name: "CHECK IN TIME");
-
- if (check_in != "false") {
- //Convert UTC to Local Time - Check In Time
- DateTime checkInTime = DateFormat("yyyy-MM-dd HH:mm:ss").parse(
- check_in, true);
- String checkInTimeLocal = checkInTime.toLocal().toString();
- String showCheckInTime = checkInTimeLocal.substring(11, 19);
- //logDev.log(showCheckInTime.substring(0,5), name: "SHOW CHECK IN TIME");
- showCheckIn_List = showCheckInTime.substring(0, 5);
- } else if (check_in == "false") {
- String show_check_in = "-";
- showCheckIn_List = show_check_in;
- }
-
- if (check_out != "false") {
- //Convert UTC to Local Time - Check Out Time
- DateTime checkOutTime = DateFormat("yyyy-MM-dd HH:mm:ss").parse(
- check_out, true);
- String checkOutTimeLocal = checkOutTime.toLocal().toString();
- String showCheckOutTime = checkOutTimeLocal.substring(11, 19);
- //logDev.log(showCheckOutTime, name: "SHOW CHECK OUT TIME");
- showCheckOut_List = showCheckOutTime.substring(0, 5);
- } else if (check_out == "false") {
- String show_check_out = "-";
- showCheckOut_List = show_check_out;
- }
- });
- }
- } else {
- alertDialogFailedRetrievedData(context);
- }
- });
-
- }
- }
-
- updatePosition() async {
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 3,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
-
- bool serviceEnabled;
- LocationPermission permission;
-
- serviceEnabled = await Geolocator.isLocationServiceEnabled();
- if (!serviceEnabled) {
- await loading.hide();
- return Future.error('Location services are disabled.');
- }
-
- permission = await Geolocator.checkPermission();
-
- if (permission == LocationPermission.deniedForever) {
- await loading.hide();
- return alertDialogPermissionDeniedForever(context);
- } else if (permission == LocationPermission.denied) {
- permission = await Geolocator.requestPermission();
- if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
- await loading.hide();
- return alertDialogPermissionDenied(context);
- }
- }
-
- position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
- if (position.isMocked) {
- await loading.hide();
- setState(() {
- alertDialogFakeGPSDetected(context);
- });
- } else {
- await loading.hide();
- setState((){
- point = latlong.LatLng(position.latitude, position.longitude);
- logDev.log(point.toString(), name: "UPDATE POINT GEOLOCATOR");
- _mapController.move(point, 18);
- });
- }
- }
-
- goCheckIn() async {
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 3,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
-
- await loading.show();
- position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
- if (position.isMocked) {
- await loading.hide();
- setState(() {
- alertDialogFakeGPSDetected(context);
- });
- } else {
- await loading.hide();
- setState((){
- point = latlong.LatLng(position.latitude, position.longitude);
- _mapController.move(point, 18);
- });
- }
- String coordinate = point.latitude.toString()+", "+ point.longitude.toString();
-
- CheckIn_Post.connectToAPI(coordinate).then((valueResult) async {
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String result = object['result'].toString();
- logDev.log(result, name: "Check In Result");
- if (result.contains("failed")) {
- await loading.hide();
- setState(() {
- alertDialogFailedRetrievedData(context);
- });
- } else if (result.contains("Anda sudah check in")) {
- await loading.hide();
- setState(() {
- alertDialogFailedCheckIn(context);
- });
- } else {
- await loading.hide();
- setState(() {
- alertDialogSuccessCheckIn(context);
- });
- }
- } else {
- setState(() {
- alertDialogFailedResponse(context);
- });
- await loading.hide();
- }
- });
- }
-
- goCheckOut() async {
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 3,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
-
- await loading.show();
-
- position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
- if (position.isMocked) {
- await loading.hide();
- setState(() {
- alertDialogFakeGPSDetected(context);
- });
- } else {
- await loading.hide();
- setState((){
- point = latlong.LatLng(position.latitude, position.longitude);
- _mapController.move(point, 18);
- });
- }
- String coordinate = point.latitude.toString()+", "+ point.longitude.toString();
-
- CheckOut_Post.connectToAPI(coordinate).then((valueResult) async {
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String result = object['result'].toString();
- logDev.log(result, name: "Check Out Result");
- if (result.contains("failed")) {
- await loading.hide();
- setState(() {
- alertDialogFailedRetrievedData(context);
- });
- } else if (result.contains("Anda belum check in")) {
- await loading.hide();
- setState(() {
- alertDialogFailedCheckOut(context);
- });
- } else {
- await loading.hide();
- setState(() {
- alertDialogSuccessCheckOut(context);
- });
- }
- } else {
- setState(() {
- alertDialogFailedResponse(context);
- });
- await loading.hide();
- }
- });
- }
-
- PanelController _panelController = PanelController();
-
- void togglePanel() => _panelController.isPanelOpen
- ? _panelController.close()
- : _panelController.open();
-
- @override
- Widget build(BuildContext context) {
- var size = MediaQuery.of(context).size;
- return Scaffold(
- body: SlidingUpPanel(
- controller: _panelController,
- parallaxEnabled: true,
- maxHeight: size.height * 0.5,
- minHeight: size.height * 0.3,
- body: Container (
- child: Stack(
- children: [
- FlutterMap(
- mapController: _mapController,
- options: new MapOptions(
- onTap: (p, point) async {}, center: point, zoom: 15),
- children: [
- TileLayer(
- minZoom: 1,
- maxZoom: 22,
- maxNativeZoom: 18,
- minNativeZoom: 1,
- backgroundColor: Colors.black54,
- urlTemplate:
- 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
- subdomains: ['a', 'b', 'c'],
- ),
- MarkerLayer(markers: [
- Marker(
- width: 135,
- height: 135,
- point: point,
- builder: (ctx) => Container(
- child: Icon(
- Icons.location_on,
- color: Colors.red,
- ),
- ))
- ])
- ],
- ),
- Container(
- alignment: AlignmentDirectional.bottomEnd,
- child: Container(
- margin: EdgeInsets.fromLTRB(10, 15, 0, (size.height*0.3) + 15),
- child: RawMaterialButton(
- onPressed: () {
- setState(() {
- updatePosition();
- });
- },
- elevation: 5.0,
- fillColor: Colors.white,
- child: Image.asset('assets/images/location1.png',
- height: 40, width: 40),
- padding: EdgeInsets.all(5.0),
- shape: CircleBorder(),
- ),
- ),
- ),
- ],
- ),
- ),
- panel: Center(
- child: Column(
- children: [
- GestureDetector(
- onTap: togglePanel,
- child: Center(
- child: Container(
- margin: EdgeInsets.only(top: 15),
- height: 5,
- width: size.width * 0.1,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10),
- color: Colors.grey
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 15),
- child: Center(
- child: Text(
- 'ATTENDANCE',
- maxLines: 1,
- style: GoogleFonts.luckiestGuy(
- fontSize: 28,
- color: Color(0xFF4858A7),
- fontStyle: FontStyle.italic,
- ),
- ),
- ),
- ),
- Container(
- width: double.infinity,
- margin: EdgeInsets.fromLTRB(10, 15, 10, 10),
- decoration:
- BoxDecoration(border: Border.all(color: Colors.black), borderRadius: BorderRadius.all(Radius.circular(15))),
- child: Column(
- children: <Widget>[
- Container(
- child: Text(
- "Last Attendance",
- style: GoogleFonts.patrickHand(
- fontSize: 21, color: Colors.white),
- ),
- width: double.infinity,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topRight,
- end: Alignment.bottomRight,
- colors: [
- /*Color(0xFFD21404),
- Color(0xFFFD7267),*/
- Color(0xFF4858A7),
- Color(0xFF6474C6),
- ]),
- border: Border.all(color: Colors.black), borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
- ),
- Container(
- width: double.infinity,
- padding: EdgeInsets.all(15),
- decoration:
- BoxDecoration(border: Border.all(color: Colors.black), borderRadius: BorderRadius.only(bottomLeft: Radius.circular(15), bottomRight: Radius.circular(15))),
- child: Column(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- Expanded(
- flex: 5,
- child: Column(
- children: [
- Text('Check In',
- style: GoogleFonts.fredoka(
- fontSize: 19)),
- Text(showCheckIn_List,
- style: GoogleFonts.barlowSemiCondensed(
- fontSize: 19)),
- ],
- )),
- Expanded(
- flex: 5,
- child: Column(
- children: [
- Text('Check Out',
- style: GoogleFonts.fredoka(
- fontSize: 19)),
- Text(showCheckOut_List,
- style: GoogleFonts.barlowSemiCondensed(
- fontSize: 19)),
- ],
- )),
- ],
- ),
- Row(
- children: [
- Visibility(
- visible: visibleCheckIn,
- child: Container(
- margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
- width: size.width - 54,
- child: ElevatedButton(
- onPressed: () {
- goCheckIn();
- },
- child: Text('Check In'),
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.all(
- Color(0xFF6474C6))),
- ),
- ),
- ),
- Visibility(
- visible: visibleCheckOut,
- child: Container(
- margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
- width: size.width - 54,
- child: ElevatedButton(
- onPressed: () {
- goCheckOut();
- },
- child: Text('Check Out'),
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.all(
- Color(0xFF6474C6))),
- ),
- ),
- ),
- ],
- )
- ],
- ),
- )
- ],
- ),
- ),
- Container(
- margin: EdgeInsets.fromLTRB(10, 15, 10, 15),
- child: InkWell(
- child: Container(
- padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
- width: double.infinity,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(5),
- gradient: LinearGradient(colors: [
- Color(0xFF2D4059),
- Color(0xFF2D4059),
- /*Color(0xFFEAFFD0),
- Color(0xFF95E1D3),*/
- ])),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(' See Attendance History \t\t',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: Colors.white,
- fontSize: 17,
- fontWeight: FontWeight.w500)),
- Image.asset(
- 'assets/images/ic_arrow_white.png',
- width: 30,
- height: 30,
- )
- ],
- )),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => HistoryAbsensi()));
- },
- ),
- )
- ],
- ),
- ),
-
- borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
- ),
- );
- }
- }
-
- alertDialogFailedRetrievedData(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Refresh"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- Widget noButton = TextButton(
- child: Text("Back"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pop(context);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Failed to Retrieve Data"),
- actions: [
- noButton,
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogFailedResponse(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Refresh"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- Widget noButton = TextButton(
- child: Text("Back"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pop(context);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Server Response Error"),
- actions: [
- noButton,
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogSuccessCheckIn(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Ok"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Successfully Checked In"),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogSuccessCheckOut(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Ok"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Successfully Checked Out"),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogFailedCheckIn(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Ok"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("You've already checked in"),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogFailedCheckOut(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Ok"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("You haven't checked in"),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogFakeGPSDetected(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Refresh"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Fake GPS Detected, Please Use Default GPS!"),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogPermissionDenied(BuildContext context) {
- Widget okButton = TextButton(
- child: Text("Refresh"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
- },
- );
-
- Widget noButton = TextButton(
- child: Text("Back"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pop(context);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content:
- Text("Location permissions are denied, we cannot request permissions"),
- actions: [
- noButton,
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogPermissionDeniedForever(BuildContext context) {
- Widget noButton = TextButton(
- child: Text("Back"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pop(context);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text(
- "Location permissions are permanently denied, we cannot request permissions. Please configure it in your device settings."),
- actions: [noButton],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- alertDialogEnableLocaionServices(BuildContext context) {
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 3,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
-
- Widget okButton = TextButton(
- child: Text("Open Settings"),
- onPressed: () {
- //AppSettings.openLocationSettings();
- Navigator.of(context, rootNavigator: true).pop();
- loading.hide();
- /* Navigator.pushReplacement(
- context, MaterialPageRoute(builder: (context) => AbsensiScreen()));*/
- },
- );
-
- Widget noButton = TextButton(
- child: Text("No, thanks"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pop(context);
- loading.hide();
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content:
- Text("For a better experience, please turn on your device location"),
- actions: [
- noButton,
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
|