Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dashboard_screen.dart 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import 'dart:convert';
  2. import 'dart:ffi';
  3. import 'package:employee_selfservice_mobile/Screens/Menu/Canvasing/canvasingDetail_screen.dart';
  4. import 'package:employee_selfservice_mobile/Screens/Menu/Canvasing/getAll_post.dart';
  5. import 'package:employee_selfservice_mobile/Screens/Menu/History/getHistory_post.dart';
  6. import 'package:employee_selfservice_mobile/constants.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:fluttertoast/fluttertoast.dart';
  9. import 'package:google_fonts/google_fonts.dart';
  10. import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
  11. import 'package:shared_preferences/shared_preferences.dart';
  12. import 'package:webview_flutter/webview_flutter.dart';
  13. import 'dart:developer' as logDev;
  14. import '../../background.dart';
  15. class DashboardScreen extends StatefulWidget {
  16. const DashboardScreen({Key? key}) : super(key: key);
  17. @override
  18. State<DashboardScreen> createState() => _DashboardScreen();
  19. }
  20. class _DashboardScreen extends State<DashboardScreen> {
  21. WebViewController controller = WebViewController();
  22. int user_id = 0;
  23. @override
  24. initState() {
  25. super.initState();
  26. getUserID();
  27. //logDev.log(user_id.toString(), name: "user id setelah balikan??");
  28. controller = WebViewController()
  29. ..setJavaScriptMode(JavaScriptMode.unrestricted)
  30. ..setBackgroundColor(const Color(0x00000000))
  31. ..setNavigationDelegate(
  32. NavigationDelegate(
  33. onProgress: (int progress) {
  34. // Update loading bar.
  35. },
  36. onPageStarted: (String url) {},
  37. onPageFinished: (String url) {},
  38. onWebResourceError: (WebResourceError error) {},
  39. onNavigationRequest: (NavigationRequest request) {
  40. if (request.url.startsWith('https://www.youtube.com/')) {
  41. return NavigationDecision.prevent;
  42. }
  43. return NavigationDecision.navigate;
  44. },
  45. ),
  46. )
  47. ..loadRequest(Uri.parse(baseURL + "/dashboard/"));
  48. /* WidgetsBinding.instance.addPostFrameCallback((_) async {
  49. });*/
  50. }
  51. getUserID() async {
  52. final SharedPreferences prefs = await SharedPreferences.getInstance();
  53. user_id = prefs.getInt('user_id')!;
  54. logDev.log(user_id.toString(), name: "user id??");
  55. return user_id;
  56. }
  57. @override
  58. Widget build(BuildContext context) {
  59. var size = MediaQuery.of(context).size;
  60. return Scaffold(
  61. body: Stack(
  62. children: [
  63. Column(
  64. children: <Widget>[
  65. Stack(
  66. children: [
  67. WavyHeader(),
  68. Container(
  69. margin: EdgeInsets.only(
  70. top: (size.height / 6) - 20),
  71. padding: EdgeInsets.fromLTRB(0, 5, 25, 5),
  72. child: Row(
  73. mainAxisAlignment: MainAxisAlignment.end,
  74. crossAxisAlignment: CrossAxisAlignment.end,
  75. children: [
  76. Text(
  77. 'DASHBOARD CANVASING\t\t',
  78. maxLines: 1,
  79. style: GoogleFonts.luckiestGuy(
  80. fontSize: 28,
  81. color: Color(0xFF4858A7),
  82. fontStyle: FontStyle.italic,
  83. ),
  84. ),
  85. Image.asset(
  86. 'assets/icons/menu/ic_history.png',
  87. width: 40,
  88. height: 40,
  89. ),
  90. ],
  91. )
  92. ),
  93. ],
  94. ),
  95. ],
  96. ),
  97. Container(
  98. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height / 6) + 40,
  99. left: 5, right: 5, bottom: 10),
  100. child: WebViewWidget(controller: controller),
  101. )
  102. ]),
  103. );
  104. }
  105. }
  106. alertDialogFailedRetrievedData(BuildContext context) {
  107. Widget okButton = TextButton(
  108. child: Text("Refresh"),
  109. onPressed: () {
  110. Navigator.of(context, rootNavigator: true).pop();
  111. Navigator.pushReplacement(
  112. context, MaterialPageRoute(builder: (context) => DashboardScreen()));
  113. },
  114. );
  115. Widget noButton = TextButton(
  116. child: Text("Back"),
  117. onPressed: () {
  118. Navigator.of(context, rootNavigator: true).pop();
  119. Navigator.pop(context);
  120. },
  121. );
  122. // set up the AlertDialog
  123. AlertDialog alert = AlertDialog(
  124. title: Text("Canvasing"),
  125. content: Text("Failed to Retrieve Data"),
  126. actions: [
  127. noButton,
  128. okButton,
  129. ],
  130. );
  131. // show the dialog
  132. showDialog(
  133. context: context,
  134. barrierDismissible: false,
  135. builder: (BuildContext context) {
  136. return alert;
  137. },
  138. );
  139. }