forked from pichillilorenzo/flutter_inappwebview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing a problem in safari webview and adding tabs to examples
- Loading branch information
Joao Paulo Marquesini
committed
Dec 7, 2018
1 parent
8b5a634
commit a9bcbe1
Showing
7 changed files
with
256 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.vscode/ | ||
.packages | ||
.pub/ | ||
pubspec.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; | ||
|
||
class MyChromeSafariBrowser extends ChromeSafariBrowser { | ||
MyChromeSafariBrowser(browserFallback) : super(browserFallback); | ||
@override | ||
void onOpened() { | ||
print("ChromeSafari browser opened"); | ||
} | ||
|
||
@override | ||
void onLoaded() { | ||
print("ChromeSafari browser loaded"); | ||
} | ||
|
||
@override | ||
void onClosed() { | ||
print("ChromeSafari browser closed"); | ||
} | ||
} | ||
|
||
class ChromeSafariExampleScreen extends StatefulWidget { | ||
final ChromeSafariBrowser browser = new MyChromeSafariBrowser(new InAppBrowser()); | ||
@override | ||
_ChromeSafariExampleScreenState createState() => new _ChromeSafariExampleScreenState(); | ||
} | ||
|
||
class _ChromeSafariExampleScreenState extends State<ChromeSafariExampleScreen> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return new Center( | ||
child: new RaisedButton( | ||
onPressed: () async { | ||
await widget.browser.open("https://flutter.io/"); | ||
}, | ||
child: Text("Open Chrome Safari Browser")), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; | ||
|
||
class InlineExampleScreen extends StatefulWidget { | ||
@override | ||
_InlineExampleScreenState createState() => new _InlineExampleScreenState(); | ||
} | ||
|
||
class _InlineExampleScreenState extends State<InlineExampleScreen> { | ||
InAppWebViewController webView; | ||
String url = ""; | ||
double progress = 0; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
child: Column(children: <Widget>[ | ||
Container( | ||
padding: EdgeInsets.all(20.0), | ||
child: Text( | ||
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"), | ||
), | ||
Container( | ||
padding: EdgeInsets.all(10.0), | ||
child: progress < 1.0 ? LinearProgressIndicator(value: progress) : null | ||
), | ||
Expanded( | ||
child: Container( | ||
margin: const EdgeInsets.all(10.0), | ||
decoration: | ||
BoxDecoration(border: Border.all(color: Colors.blueAccent)), | ||
child: InAppWebView( | ||
initialUrl: "https://flutter.io/", | ||
initialHeaders: {}, | ||
initialOptions: {}, | ||
onWebViewCreated: (InAppWebViewController controller) { | ||
webView = controller; | ||
}, | ||
onLoadStart: (InAppWebViewController controller, String url) { | ||
print("started $url"); | ||
setState(() { | ||
this.url = url; | ||
}); | ||
}, | ||
onProgressChanged: | ||
(InAppWebViewController controller, int progress) { | ||
setState(() { | ||
this.progress = progress / 100; | ||
}); | ||
}, | ||
), | ||
), | ||
), | ||
ButtonBar( | ||
alignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
RaisedButton( | ||
child: Icon(Icons.arrow_back), | ||
onPressed: () { | ||
if (webView != null) { | ||
webView.goBack(); | ||
} | ||
}, | ||
), | ||
RaisedButton( | ||
child: Icon(Icons.arrow_forward), | ||
onPressed: () { | ||
if (webView != null) { | ||
webView.goForward(); | ||
} | ||
}, | ||
), | ||
RaisedButton( | ||
child: Icon(Icons.refresh), | ||
onPressed: () { | ||
if (webView != null) { | ||
webView.reload(); | ||
} | ||
}, | ||
), | ||
], | ||
), | ||
])); | ||
} | ||
} |
Oops, something went wrong.