-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IB: Bringup Simulator embeds extension using webview.
* flutter_markdown has some issues because of which we are using our own fork of the same. (manjotsidhu/packages@29bb87f) * We have updated flutter_markdown from 0.5.2 -> 0.6.2. * flutter_html needed update because of Sub6Resources/flutter_html#500. * flutter_html updated from 1.0.2 -> 1.3.0, which depends on flutter_svg, flutter_svg updated from 0.19.3 -> 0.20.0-nullsafety.3 Signed-off-by: Manjot Sidhu <[email protected]>
- Loading branch information
1 parent
2fa8ec7
commit 7e76b63
Showing
4 changed files
with
65 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_html/flutter_html.dart'; | ||
import 'package:flutter_html/html_parser.dart'; | ||
import 'package:flutter_markdown/flutter_markdown.dart'; | ||
import 'package:webview_flutter/webview_flutter.dart'; | ||
import 'package:markdown/markdown.dart' as md; | ||
|
||
class IbWebViewBuilder extends MarkdownElementBuilder { | ||
final BuildContext context; | ||
|
||
IbWebViewBuilder({this.context}); | ||
|
||
@override | ||
Widget visitElementAfter(md.Element element, TextStyle preferredStyle) { | ||
var textContent = element.textContent; | ||
|
||
return Html( | ||
data: textContent, | ||
customRender: { | ||
'iframe': (RenderContext context, Widget child, attributes, _) { | ||
final width = MediaQuery.of(context.buildContext).size.width; | ||
final height = (width * 9) / 16; | ||
|
||
return SizedBox( | ||
width: width, | ||
height: height, | ||
child: WebView( | ||
initialUrl: attributes['src'], | ||
javascriptMode: JavascriptMode.unrestricted, | ||
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow, | ||
), | ||
); | ||
}, | ||
}, | ||
); | ||
} | ||
} |
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
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,16 @@ | ||
import 'package:markdown/markdown.dart' as md; | ||
|
||
class IbEmbedSyntax extends md.BlockSyntax { | ||
IbEmbedSyntax() : super(); | ||
|
||
@override | ||
md.Node parse(md.BlockParser parser) { | ||
var text = parser.current; | ||
parser.advance(); | ||
|
||
return md.Element.text('iframe', text); | ||
} | ||
|
||
@override | ||
RegExp get pattern => RegExp(r'^<iframe.+>.+<\/iframe>'); | ||
} |
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