web_page.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_inappwebview/flutter_inappwebview.dart';
  3. import 'package:photos/ui/common/loading_widget.dart';
  4. class WebPage extends StatefulWidget {
  5. final String title;
  6. final String url;
  7. const WebPage(this.title, this.url, {Key? key}) : super(key: key);
  8. @override
  9. State<WebPage> createState() => _WebPageState();
  10. }
  11. class _WebPageState extends State<WebPage> {
  12. bool _hasLoadedPage = false;
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. appBar: AppBar(
  17. // force dark theme for appBar till website/family plans add supports for light theme
  18. backgroundColor: const Color.fromRGBO(10, 20, 20, 1.0),
  19. foregroundColor: Colors.white,
  20. iconTheme: const IconThemeData(color: Colors.white),
  21. title: Text(widget.title),
  22. actions: [_hasLoadedPage ? Container() : const EnteLoadingWidget()],
  23. ),
  24. backgroundColor: Colors.black,
  25. body: InAppWebView(
  26. initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
  27. initialOptions: InAppWebViewGroupOptions(
  28. crossPlatform: InAppWebViewOptions(transparentBackground: true),
  29. ),
  30. onLoadStop: (c, url) {
  31. setState(() {
  32. _hasLoadedPage = true;
  33. });
  34. },
  35. ),
  36. );
  37. }
  38. }