mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 00:21: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/Screens/Map/map_context.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/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/constants.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
@ -52,7 +53,10 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
);
|
||||
break;
|
||||
case SectionType.web : // WEB
|
||||
elementToShow = WebViewWidget(url: 'Test');
|
||||
elementToShow = WebViewWidget(section: sectionSelected);
|
||||
break;
|
||||
case SectionType.video : // Video
|
||||
elementToShow = VideoViewWidget(section: sectionSelected);
|
||||
break;
|
||||
case SectionType.slider :
|
||||
elementToShow = Padding(
|
||||
@ -123,7 +127,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
child: Container(
|
||||
width: size.width,
|
||||
height: size.height * 0.85,
|
||||
decoration: BoxDecoration(
|
||||
decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web ? BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
@ -135,7 +139,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
) : null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(0.0),
|
||||
child: elementToShow),
|
||||
@ -262,13 +266,13 @@ boxDecoration(SectionDTO section) {
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
image: new DecorationImage(
|
||||
image: section.imageSource != null ? new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.dstATop),
|
||||
image: new NetworkImage(
|
||||
section.imageSource,
|
||||
),
|
||||
),
|
||||
): null,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
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:managerapi/api.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class WebViewWidget extends StatefulWidget {
|
||||
final String url;
|
||||
WebViewWidget({this.url});
|
||||
final SectionDTO section;
|
||||
WebViewWidget({this.section});
|
||||
|
||||
@override
|
||||
_WebViewWidget createState() => _WebViewWidget();
|
||||
@ -11,27 +14,34 @@ class WebViewWidget extends StatefulWidget {
|
||||
|
||||
class _WebViewWidget extends State<WebViewWidget> {
|
||||
WebView _webView;
|
||||
WebDTO webDTO;
|
||||
@override
|
||||
void initState() {
|
||||
print(widget.section.data);
|
||||
webDTO = WebDTO.fromJson(jsonDecode(widget.section.data));
|
||||
print(webDTO);
|
||||
|
||||
super.initState();
|
||||
_webView = WebView(
|
||||
initialUrl: "https://my.matterport.com/show/?m=k8bvdezfHbT",
|
||||
initialUrl: webDTO.source_, //"https://my.matterport.com/show/?m=k8bvdezfHbT"
|
||||
javascriptMode: JavascriptMode.unrestricted,
|
||||
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}');
|
||||
return NavigationDecision.prevent;
|
||||
}
|
||||
print('allowing navigation to $request');
|
||||
return NavigationDecision.navigate;
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_webView = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
42
pubspec.lock
42
pubspec.lock
@ -57,6 +57,20 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -90,6 +104,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -177,6 +198,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.7"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -301,6 +329,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.3"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -315,6 +350,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
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:
|
||||
dart: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=2.0.0"
|
||||
|
||||
@ -34,6 +34,7 @@ dependencies:
|
||||
unique_identifier: ^0.0.3
|
||||
enum_to_string: ^2.0.1
|
||||
carousel_slider: ^4.0.0
|
||||
youtube_player_flutter: ^7.0.0+7
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user