No Description
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 5.2KB

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