ente/lib/ui/common/web_page.dart

46 lines
1.3 KiB
Dart
Raw Normal View History

// @dart=2.9
2021-01-08 09:24:15 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:photos/ui/common/loading_widget.dart';
2021-01-08 09:24:15 +00:00
class WebPage extends StatefulWidget {
final String title;
final String url;
const WebPage(this.title, this.url, {Key key}) : super(key: key);
@override
2022-07-03 09:45:00 +00:00
State<WebPage> createState() => _WebPageState();
2021-01-08 09:24:15 +00:00
}
class _WebPageState extends State<WebPage> {
bool _hasLoadedPage = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2022-07-04 06:02:17 +00:00
// force dark theme for appBar till website/family plans add supports for light theme
backgroundColor: const Color.fromRGBO(10, 20, 20, 1.0),
2022-05-16 20:03:47 +00:00
foregroundColor: Colors.white,
2022-07-04 06:02:17 +00:00
iconTheme: const IconThemeData(color: Colors.white),
2021-01-08 09:24:15 +00:00
title: Text(widget.title),
actions: [_hasLoadedPage ? Container() : const EnteLoadingWidget()],
2021-01-08 09:24:15 +00:00
),
backgroundColor: Colors.black,
body: InAppWebView(
initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
2022-05-09 14:51:15 +00:00
initialOptions: InAppWebViewGroupOptions(
2022-06-11 08:23:52 +00:00
crossPlatform: InAppWebViewOptions(transparentBackground: true),
),
onLoadStop: (c, url) {
2021-01-08 09:24:15 +00:00
setState(() {
_hasLoadedPage = true;
});
},
),
);
}
}