import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:vitalapp/store/store.dart';

// ignore: must_be_immutable
class DashboardPage extends StatefulWidget {
  const DashboardPage({super.key});

  @override
  State<DashboardPage> createState() => _DashboardPageState();
}

class _DashboardPageState extends State<DashboardPage> {
  late InAppWebViewController inAppWebViewController;

  InAppWebView webView = InAppWebView(
    initialUrlRequest: URLRequest(
      url: Uri.parse(
        "${Store.app.homePageUrl}&token=${Store.user.token}",
      ),
    ),
    initialOptions: InAppWebViewGroupOptions(
      crossPlatform: InAppWebViewOptions(
        javaScriptEnabled: true,
        useShouldOverrideUrlLoading: true,
        mediaPlaybackRequiresUserGesture: true,
        applicationNameForUserAgent: "dface-yjxdh-webview",
      ),
      android: AndroidInAppWebViewOptions(
        mixedContentMode: AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
      ),
      ios: IOSInAppWebViewOptions(
        allowsInlineMediaPlayback: true,
      ),
    ),
  );

  @override
  Widget build(BuildContext context) {
    return webView;

    // return const DashboardDemoView();
  }
}
