import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:plugin_basic/utils/ext_get_nav.dart';
import 'package:router/path/router_path.dart';
import 'package:shared/utils/log_utils.dart';

import '../base/base_stateless_page.dart';
import '../widget/webview_page.dart';

/*
 * 全局的公共Web页面
 */
class GlobalWebPage extends BaseStatelessPage {
  GlobalWebPage({super.key});

  //启动当前页面
  static void startInstance(
    String title,
    String url, {
    bool isShowAppBar = true,
  }) {
    return Get.start(RouterPath.GLOBAL_WEB, arguments: {'title': title, 'initialUrl': Uri.encodeFull(url), 'isShowAppBar': isShowAppBar});
  }

  @override
  GetxController createRawController() {
    throw UnimplementedError();
  }

  @override
  void initState() {}

  @override
  Widget buildWidget(BuildContext context) {
    bool isShowAppBar = Get.arguments['isShowAppBar'];
    String initialUrl = Get.arguments['initialUrl'];
    String title = Get.arguments['title'];
    Log.d("GlobalWebPage 的参数 isShowAppBar：$isShowAppBar title:$title initialUrl:$initialUrl ");
    return WebViewPage(
      showAppbar: isShowAppBar,
      initialUrl: initialUrl,
      arguments: {'title': title},
    );
  }
}
