123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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<DashboardScreen> createState() => _DashboardScreen();
- }
-
- class _DashboardScreen extends State<DashboardScreen> {
- 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: <Widget>[
- 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;
- },
- );
- }
|