Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions client/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ PODS:
- SwiftyGif (5.4.3)
- url_launcher_ios (0.0.1):
- Flutter
- webview_flutter_wkwebview (0.0.1):
- Flutter

DEPENDENCIES:
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
Expand All @@ -60,8 +62,9 @@ DEPENDENCIES:
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- sensors_plus (from `.symlinks/plugins/sensors_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)

SPEC REPOS:
trunk:
Expand All @@ -84,9 +87,11 @@ EXTERNAL SOURCES:
sensors_plus:
:path: ".symlinks/plugins/sensors_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/ios"
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"

SPEC CHECKSUMS:
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
Expand All @@ -95,12 +100,13 @@ SPEC CHECKSUMS:
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
integration_test: 13825b8a9334a850581300559b8839134b124670
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866
sensors_plus: 5717760720f7e6acd96fdbd75b7428f5ad755ec2
shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
url_launcher_ios: ae1517e5e344f5544fb090b079e11f399dfbe4d2
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3

Expand Down
2 changes: 1 addition & 1 deletion client/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
32 changes: 32 additions & 0 deletions client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.2"
webview_flutter:
dependency: transitive
description:
name: webview_flutter
sha256: "82f6787d5df55907aa01e49bd9644f4ed1cc82af7a8257dd9947815959d2e755"
url: "https://pub.dev"
source: hosted
version: "4.2.4"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: ddc167c6676f57c8b367d19fcbee267d6dc6adf81bd6c3cb87981d30746e0a6d
url: "https://pub.dev"
source: hosted
version: "3.10.1"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "6d9213c65f1060116757a7c473247c60f3f7f332cac33dc417c9e362a9a13e4f"
url: "https://pub.dev"
source: hosted
version: "2.6.0"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: "485af05f2c5f83c7f78c20e236b170ad02df7153b299ae9917345be43871d29f"
url: "https://pub.dev"
source: hosted
version: "3.8.0"
win32:
dependency: transitive
description:
Expand Down
7 changes: 7 additions & 0 deletions package/lib/src/controls/create_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import 'tooltip.dart';
import 'transparent_pointer.dart';
import 'vertical_divider.dart';
import 'window_drag_area.dart';
import 'webview.dart';

Widget createControl(Control? parent, String id, bool parentDisabled,
{Widget? nextChild}) {
Expand Down Expand Up @@ -570,6 +571,12 @@ Widget createWidget(Key? key, ControlViewModel controlView, Control? parent,
control: controlView.control,
children: controlView.children,
parentDisabled: parentDisabled);
case "webview":
return WebView(
key: key,
parent: parent,
control: controlView.control,
parentDisabled: parentDisabled);
default:
throw Exception("Unknown control type: ${controlView.control.type}");
}
Expand Down
101 changes: 101 additions & 0 deletions package/lib/src/controls/webview.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import 'dart:io' show Platform;
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';

import '../flet_app_services.dart';
import '../models/app_state.dart';
import '../models/control.dart';
import '../models/control_tree_view_model.dart';
import '../utils/colors.dart';
import 'create_control.dart';


import 'package:webview_flutter/webview_flutter.dart';

class WebView extends StatelessWidget {
final Control? parent;
final Control control;
final bool parentDisabled;

const WebView(
{Key? key,
required this.parent,
required this.control,
required this.parentDisabled})
: super(key: key);

@override
Widget build(BuildContext context) {
var result = StoreConnector<AppState, ControlTreeViewModel>(
distinct: true,
converter: (store) => ControlTreeViewModel.fromStore(store, control),
builder: (context, viewModel) {
debugPrint("MobileWebViewer build: ${control.id}");

String url = control.attrString("url") ?? "https://flet.dev/";
bool javascriptEnabled = control.attrBool("javascriptEnabled") ?? false;
var bgcolor = HexColor.fromString(Theme.of(context),
control.attrString("bgcolor") ?? "white")!;
String preventLink = control.attrString("preventLink") ?? "none";


var jsMode = JavaScriptMode.unrestricted;
if (javascriptEnabled){
jsMode = JavaScriptMode.unrestricted;
}else{
jsMode = JavaScriptMode.disabled;
}

if (Platform.isIOS || Platform.isAndroid){
var controller = WebViewController()
..setJavaScriptMode(jsMode)
..setBackgroundColor(bgcolor)
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {},
onPageStarted: (String url) {
FletAppServices.of(context).server.sendPageEvent(
eventTarget: control.id,
eventName: "page_started",
eventData: url);
},
onPageFinished: (String url) {
FletAppServices.of(context).server.sendPageEvent(
eventTarget: control.id,
eventName: "page_ended",
eventData: url);
},
onWebResourceError: (WebResourceError error) {
FletAppServices.of(context).server.sendPageEvent(
eventTarget: control.id,
eventName: "web_resource_error",
eventData: error.toString());
},
onNavigationRequest: (NavigationRequest request) {
if (request.url.startsWith(preventLink)) {
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
),
)
..loadRequest(Uri.parse(url));
return WebViewWidget(
controller: controller
);
}else if (Platform.isMacOS){
return const Text("'MobileWbBrowser' is not supported on macOS yet.");
}else if (Platform.isWindows){
return const Text("'MobileWbBrowser' is not supported on windows yey.");
}else if (Platform.isLinux){
return const Text("'MobileWbBrowser' is not supported on this platform.");
}else{
return const Text("'MobileWbBrowser' is not supported on this platform.");
}
});

return constrainedControl(context, result, parent, control);
}
}
2 changes: 2 additions & 0 deletions package/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ dependencies:
js: ^0.6.5
fl_chart: ^0.64.0

webview_flutter: ^4.2.4

dev_dependencies:
flutter_test:
sdk: flutter
Expand Down
1 change: 1 addition & 0 deletions sdk/python/packages/flet-core/src/flet_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,6 @@
from flet_core.vertical_divider import VerticalDivider
from flet_core.view import View
from flet_core.window_drag_area import WindowDragArea
from flet_core.webview import WebView
from flet_core.range_slider import RangeSlider
from flet_core.badge import Badge
Loading