import 'dart:convert'; import 'dart:ffi'; import 'package:employee_selfservice_mobile/Screens/Menu/Canvasing/canvasingDetail_screen.dart'; import 'package:employee_selfservice_mobile/Screens/Menu/Canvasing/getAll_post.dart'; import 'package:employee_selfservice_mobile/Screens/Menu/History/getHistory_post.dart'; import 'package:employee_selfservice_mobile/constants.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'dart:developer' as logDev; import '../../background.dart'; class DashboardScreen extends StatefulWidget { const DashboardScreen({Key? key}) : super(key: key); @override State createState() => _DashboardScreen(); } class _DashboardScreen extends State { WebViewController controller = WebViewController(); int user_id = 0; @override initState() { super.initState(); getUserID(); //logDev.log(user_id.toString(), name: "user id setelah balikan??"); controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setBackgroundColor(const Color(0x00000000)) ..setNavigationDelegate( NavigationDelegate( onProgress: (int progress) { // Update loading bar. }, onPageStarted: (String url) {}, onPageFinished: (String url) {}, onWebResourceError: (WebResourceError error) {}, onNavigationRequest: (NavigationRequest request) { if (request.url.startsWith('https://www.youtube.com/')) { return NavigationDecision.prevent; } return NavigationDecision.navigate; }, ), ) ..loadRequest(Uri.parse(baseURL + "/dashboard/")); /* WidgetsBinding.instance.addPostFrameCallback((_) async { });*/ } getUserID() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); user_id = prefs.getInt('user_id')!; logDev.log(user_id.toString(), name: "user id??"); return user_id; } @override Widget build(BuildContext context) { var size = MediaQuery.of(context).size; return Scaffold( body: Stack( children: [ Column( children: [ Stack( children: [ WavyHeader(), Container( margin: EdgeInsets.only( top: (size.height / 6) - 20), padding: EdgeInsets.fromLTRB(0, 5, 25, 5), child: Row( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( 'DASHBOARD CANVASING\t\t', maxLines: 1, style: GoogleFonts.luckiestGuy( fontSize: 28, color: Color(0xFF4858A7), fontStyle: FontStyle.italic, ), ), Image.asset( 'assets/icons/menu/ic_history.png', width: 40, height: 40, ), ], ) ), ], ), ], ), Container( margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height / 6) + 40, left: 5, right: 5, bottom: 10), child: WebViewWidget(controller: controller), ) ]), ); } } alertDialogFailedRetrievedData(BuildContext context) { Widget okButton = TextButton( child: Text("Refresh"), onPressed: () { Navigator.of(context, rootNavigator: true).pop(); Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => DashboardScreen())); }, ); 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("Canvasing"), content: Text("Failed to Retrieve Data"), actions: [ noButton, okButton, ], ); // show the dialog showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return alert; }, ); }