From ab2b348e3b6641c0844d757be46e2744a0075e35 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta Date: Tue, 10 Aug 2021 12:51:13 +0530 Subject: [PATCH] Show toast for live photo --- lib/core/constants.dart | 3 +++ lib/ui/zoomable_live_image.dart | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/core/constants.dart b/lib/core/constants.dart index a000c1540..452119c39 100644 --- a/lib/core/constants.dart +++ b/lib/core/constants.dart @@ -14,3 +14,6 @@ const int kGalleryLoadStartTime = -8000000000000000; // Wednesday, March 6, 1748 // used to identify which ente file are available in app cache const String kSharedMediaIdentifier = 'ente-shared://'; + +const int kMaxLivePhotoToastCount = 2; +const String kLivePhotoToastCounterKey = "show_live_photo_toast"; \ No newline at end of file diff --git a/lib/ui/zoomable_live_image.dart b/lib/ui/zoomable_live_image.dart index 30656caba..1a2c9f6a4 100644 --- a/lib/ui/zoomable_live_image.dart +++ b/lib/ui/zoomable_live_image.dart @@ -4,18 +4,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:logging/logging.dart'; -import 'package:photo_view/photo_view.dart'; -import 'package:photos/core/cache/thumbnail_cache.dart'; import 'package:photos/core/constants.dart'; -import 'package:photos/core/event_bus.dart'; -import 'package:photos/db/files_db.dart'; -import 'package:photos/events/local_photos_updated_event.dart'; import 'package:photos/models/file.dart'; -import 'package:photos/ui/loading_widget.dart'; import 'package:photos/ui/zoomable_image.dart'; import 'package:photos/utils/file_util.dart'; -import 'package:photos/utils/thumbnail_util.dart'; import 'package:photos/utils/toast_util.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:video_player/video_player.dart'; class ZoomableLiveImage extends StatefulWidget { @@ -42,6 +36,7 @@ class _ZoomableLiveImageState extends State File _livePhoto; bool _loadLivePhotoVideo = false; + VideoPlayerController _videoPlayerController; ChewieController _chewieController; @@ -49,6 +44,7 @@ class _ZoomableLiveImageState extends State void initState() { _livePhoto = widget.photo; _loadLiveVideo(); + _showLivePhotoToast(); super.initState(); } @@ -134,4 +130,13 @@ class _ZoomableLiveImageState extends State } }); } + + void _showLivePhotoToast() async { + var _preferences = await SharedPreferences.getInstance(); + int promptTillNow = _preferences.getInt(kLivePhotoToastCounterKey) ?? 0; + if (promptTillNow < kMaxLivePhotoToastCount) { + showToast("press and hold to play video"); + } + _preferences.setInt(kLivePhotoToastCounterKey, promptTillNow + 1); + } }