dAppPage.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:polkawallet_sdk/polkawallet_sdk.dart';
  4. import 'package:polkawallet_sdk/storage/keyring.dart';
  5. import 'package:polkawallet_sdk/webviewWithExtension/webviewWithExtension.dart';
  6. class DAppPage extends StatefulWidget {
  7. DAppPage(this.sdk, this.keyring);
  8. static const String route = '/extension/app';
  9. final WalletSDK sdk;
  10. final Keyring keyring;
  11. @override
  12. _DAppPageState createState() => _DAppPageState();
  13. }
  14. class _DAppPageState extends State<DAppPage> {
  15. bool _loading = true;
  16. @override
  17. Widget build(BuildContext context) {
  18. final url = ModalRoute.of(context)?.settings.arguments as String;
  19. return Scaffold(
  20. appBar: AppBar(
  21. title: Text(
  22. url,
  23. style: TextStyle(fontSize: 16),
  24. ),
  25. centerTitle: true),
  26. body: SafeArea(
  27. child: Stack(
  28. children: [
  29. WebViewWithExtension(
  30. widget.sdk.api,
  31. url,
  32. widget.keyring,
  33. onPageFinished: (url) {
  34. setState(() {
  35. _loading = false;
  36. });
  37. },
  38. onSignBytesRequest: (req) async {
  39. print(req);
  40. return null;
  41. },
  42. onSignExtrinsicRequest: (req) async {
  43. print(req);
  44. return null;
  45. },
  46. onConnectRequest: (req) async {
  47. print(req);
  48. return true;
  49. },
  50. ),
  51. _loading ? Center(child: CupertinoActivityIndicator()) : Container()
  52. ],
  53. ),
  54. ),
  55. );
  56. }
  57. }