mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
Video & Web view
This commit is contained in:
parent
00e281f865
commit
63d435ea0e
1
android/settings_aar.gradle
Normal file
1
android/settings_aar.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||
@ -6,9 +6,10 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:tablet_app/Components/loading.dart';
|
import 'package:tablet_app/Components/loading.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_context.dart';
|
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||||
import 'package:tablet_app/Screens/Map/map_view.dart';
|
import 'package:tablet_app/Screens/Map/map_view.dart';
|
||||||
import 'file:///C:/Users/Thomas%20Fransolet/Documents/Documents/Perso/MuseeDeLaFraise/tablet-app/lib/Screens/webView.dart';
|
|
||||||
import 'package:tablet_app/Models/map-marker.dart';
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
import 'package:tablet_app/Models/tabletContext.dart';
|
import 'package:tablet_app/Models/tabletContext.dart';
|
||||||
|
import 'package:tablet_app/Screens/Video/video_view.dart';
|
||||||
|
import 'package:tablet_app/Screens/Web/web_view.dart';
|
||||||
import 'package:tablet_app/app_context.dart';
|
import 'package:tablet_app/app_context.dart';
|
||||||
import 'package:tablet_app/constants.dart';
|
import 'package:tablet_app/constants.dart';
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
@ -52,7 +53,10 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case SectionType.web : // WEB
|
case SectionType.web : // WEB
|
||||||
elementToShow = WebViewWidget(url: 'Test');
|
elementToShow = WebViewWidget(section: sectionSelected);
|
||||||
|
break;
|
||||||
|
case SectionType.video : // Video
|
||||||
|
elementToShow = VideoViewWidget(section: sectionSelected);
|
||||||
break;
|
break;
|
||||||
case SectionType.slider :
|
case SectionType.slider :
|
||||||
elementToShow = Padding(
|
elementToShow = Padding(
|
||||||
@ -123,7 +127,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height * 0.85,
|
height: size.height * 0.85,
|
||||||
decoration: BoxDecoration(
|
decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web ? BoxDecoration(
|
||||||
color: kBackgroundLight,
|
color: kBackgroundLight,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.circular(30.0),
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
@ -135,7 +139,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
offset: Offset(0, 1.5), // changes position of shadow
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
) : null,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(0.0),
|
padding: const EdgeInsets.all(0.0),
|
||||||
child: elementToShow),
|
child: elementToShow),
|
||||||
@ -262,13 +266,13 @@ boxDecoration(SectionDTO section) {
|
|||||||
color: kBackgroundLight,
|
color: kBackgroundLight,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.circular(30.0),
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
image: new DecorationImage(
|
image: section.imageSource != null ? new DecorationImage(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.dstATop),
|
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.dstATop),
|
||||||
image: new NetworkImage(
|
image: new NetworkImage(
|
||||||
section.imageSource,
|
section.imageSource,
|
||||||
),
|
),
|
||||||
),
|
): null,
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: kBackgroundSecondGrey,
|
color: kBackgroundSecondGrey,
|
||||||
|
|||||||
61
lib/Screens/Video/video_view.dart
Normal file
61
lib/Screens/Video/video_view.dart
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
|
||||||
|
|
||||||
|
class VideoViewWidget extends StatefulWidget {
|
||||||
|
final SectionDTO section;
|
||||||
|
VideoViewWidget({this.section});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_VideoViewWidget createState() => _VideoViewWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VideoViewWidget extends State<VideoViewWidget> {
|
||||||
|
YoutubePlayer _videoView;
|
||||||
|
VideoDTO videoDTO;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
print(widget.section.data);
|
||||||
|
videoDTO = VideoDTO.fromJson(jsonDecode(widget.section.data));
|
||||||
|
print(videoDTO);
|
||||||
|
|
||||||
|
String videoId;
|
||||||
|
videoId = YoutubePlayer.convertUrlToId(videoDTO.source_);
|
||||||
|
print(videoId);
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
YoutubePlayerController _controller = YoutubePlayerController(
|
||||||
|
initialVideoId: videoId,
|
||||||
|
flags: YoutubePlayerFlags(
|
||||||
|
autoPlay: true,
|
||||||
|
controlsVisibleAtStart: false,
|
||||||
|
loop: true,
|
||||||
|
hideControls: false,
|
||||||
|
hideThumbnail: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
_videoView = YoutubePlayer(
|
||||||
|
controller: _controller,
|
||||||
|
showVideoProgressIndicator: false,
|
||||||
|
/*progressIndicatorColor: Colors.amber,
|
||||||
|
progressColors: ProgressBarColors(
|
||||||
|
playedColor: Colors.amber,
|
||||||
|
handleColor: Colors.amberAccent,
|
||||||
|
),*/
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_videoView = null;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => _videoView;
|
||||||
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
class WebViewWidget extends StatefulWidget {
|
class WebViewWidget extends StatefulWidget {
|
||||||
final String url;
|
final SectionDTO section;
|
||||||
WebViewWidget({this.url});
|
WebViewWidget({this.section});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_WebViewWidget createState() => _WebViewWidget();
|
_WebViewWidget createState() => _WebViewWidget();
|
||||||
@ -11,27 +14,34 @@ class WebViewWidget extends StatefulWidget {
|
|||||||
|
|
||||||
class _WebViewWidget extends State<WebViewWidget> {
|
class _WebViewWidget extends State<WebViewWidget> {
|
||||||
WebView _webView;
|
WebView _webView;
|
||||||
|
WebDTO webDTO;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
print(widget.section.data);
|
||||||
|
webDTO = WebDTO.fromJson(jsonDecode(widget.section.data));
|
||||||
|
print(webDTO);
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
_webView = WebView(
|
_webView = WebView(
|
||||||
initialUrl: "https://my.matterport.com/show/?m=k8bvdezfHbT",
|
initialUrl: webDTO.source_, //"https://my.matterport.com/show/?m=k8bvdezfHbT"
|
||||||
javascriptMode: JavascriptMode.unrestricted,
|
javascriptMode: JavascriptMode.unrestricted,
|
||||||
navigationDelegate: (NavigationRequest request) {
|
navigationDelegate: (NavigationRequest request) {
|
||||||
if (request.url != "https://my.matterport.com/show/?m=k8bvdezfHbT") {
|
print(request.url);
|
||||||
|
print(webDTO.source_);
|
||||||
|
if (request.url != webDTO.source_) {
|
||||||
print('blocking navigation to $request}');
|
print('blocking navigation to $request}');
|
||||||
return NavigationDecision.prevent;
|
return NavigationDecision.prevent;
|
||||||
}
|
}
|
||||||
print('allowing navigation to $request');
|
print('allowing navigation to $request');
|
||||||
return NavigationDecision.navigate;
|
return NavigationDecision.navigate;
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
|
||||||
_webView = null;
|
_webView = null;
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
42
pubspec.lock
42
pubspec.lock
@ -57,6 +57,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.15.0"
|
||||||
|
convert:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: convert
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
|
crypto:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: crypto
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.5"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -90,6 +104,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_inappwebview:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.0+4"
|
||||||
flutter_plugin_android_lifecycle:
|
flutter_plugin_android_lifecycle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -177,6 +198,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.3.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.9.7"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -301,6 +329,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.3"
|
version: "0.0.3"
|
||||||
|
uuid:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: uuid
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.2"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -315,6 +350,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.10"
|
version: "2.0.10"
|
||||||
|
youtube_player_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: youtube_player_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.0+7"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0 <3.0.0"
|
dart: ">=2.12.0 <3.0.0"
|
||||||
flutter: ">=2.0.0"
|
flutter: ">=2.0.0"
|
||||||
|
|||||||
@ -34,6 +34,7 @@ dependencies:
|
|||||||
unique_identifier: ^0.0.3
|
unique_identifier: ^0.0.3
|
||||||
enum_to_string: ^2.0.1
|
enum_to_string: ^2.0.1
|
||||||
carousel_slider: ^4.0.0
|
carousel_slider: ^4.0.0
|
||||||
|
youtube_player_flutter: ^7.0.0+7
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user