fix: move panorama icon to middle

This commit is contained in:
Prateek Sunal
2024-08-09 20:18:28 +05:30
parent 8db29a25a4
commit 38c3e73638
3 changed files with 121 additions and 106 deletions

View File

@@ -12,6 +12,7 @@ import 'package:photos/core/errors.dart';
import "package:photos/core/event_bus.dart";
import "package:photos/events/file_swipe_lock_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/file/extensions/file_props.dart";
import 'package:photos/models/file/file.dart';
import "package:photos/models/file/file_type.dart";
import "package:photos/services/local_authentication_service.dart";
@@ -21,10 +22,12 @@ import "package:photos/ui/tools/editor/video_editor_page.dart";
import "package:photos/ui/viewer/file/file_app_bar.dart";
import "package:photos/ui/viewer/file/file_bottom_bar.dart";
import 'package:photos/ui/viewer/file/file_widget.dart';
import "package:photos/ui/viewer/file/panorama_viewer_screen.dart";
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/file_util.dart';
import 'package:photos/utils/navigation_util.dart';
import "package:photos/utils/thumbnail_util.dart";
import 'package:photos/utils/toast_util.dart';
enum DetailPageMode {
@@ -184,6 +187,48 @@ class _DetailPageState extends State<DetailPage> {
},
valueListenable: _selectedIndexNotifier,
),
ValueListenableBuilder(
valueListenable: _selectedIndexNotifier,
builder: (BuildContext context, int selectedIndex, _) {
if (_files![selectedIndex].isPanorama() == true) {
return ValueListenableBuilder(
valueListenable: _enableFullScreenNotifier,
builder: (context, value, child) {
return IgnorePointer(
ignoring: value,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 200),
opacity: !value ? 1.0 : 0.0,
child: Align(
alignment: Alignment.center,
child: Tooltip(
message: S.of(context).panorama,
child: IconButton(
style: IconButton.styleFrom(
backgroundColor: const Color(0xAA252525),
fixedSize: const Size(44, 44),
),
icon: const Icon(
Icons.threesixty,
color: Colors.white,
size: 26,
),
onPressed: () async {
await openPanoramaViewerPage(
_files![selectedIndex],
);
},
),
),
),
),
);
},
);
}
return const SizedBox();
},
),
],
),
),
@@ -191,6 +236,24 @@ class _DetailPageState extends State<DetailPage> {
);
}
Future<void> openPanoramaViewerPage(EnteFile file) async {
final fetchedFile = await getFile(file);
if (fetchedFile == null) {
return;
}
final fetchedThumbnail = await getThumbnail(file);
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) {
return PanoramaViewerScreen(
file: fetchedFile,
thumbnail: fetchedThumbnail,
);
},
),
).ignore();
}
Widget _buildPageView(BuildContext context) {
return PageView.builder(
clipBehavior: Clip.none,

View File

@@ -17,12 +17,9 @@ import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/actions/file/file_actions.dart";
import 'package:photos/ui/collections/collection_action_sheet.dart';
import "package:photos/ui/viewer/file/panorama_viewer_screen.dart";
import 'package:photos/utils/delete_file_util.dart';
import "package:photos/utils/file_util.dart";
import "package:photos/utils/panorama_util.dart";
import 'package:photos/utils/share_util.dart';
import "package:photos/utils/thumbnail_util.dart";
class FileBottomBar extends StatefulWidget {
final EnteFile file;
@@ -198,92 +195,59 @@ class FileBottomBarState extends State<FileBottomBar> {
curve: Curves.easeInOut,
child: Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (widget.file.isPanorama() == true)
Align(
alignment: Alignment.centerRight,
child: Tooltip(
message: S.of(context).panorama,
child: Padding(
padding: const EdgeInsets.only(
top: 12,
bottom: 12,
right: 20,
),
child: IconButton(
style: IconButton.styleFrom(
backgroundColor: const Color(0xFF252525),
fixedSize: const Size(44, 44),
),
icon: const Icon(
Icons.vrpano_outlined,
color: Colors.white,
size: 26,
),
onPressed: () async {
await openPanoramaViewerPage(widget.file);
},
),
),
),
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.black.withOpacity(0.6),
Colors.black.withOpacity(0.72),
],
stops: const [0, 0.8, 1],
),
),
child: Padding(
padding: EdgeInsets.only(bottom: safeAreaBottomPadding),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
widget.file.caption?.isNotEmpty ?? false
? Padding(
padding: const EdgeInsets.fromLTRB(
16,
12,
16,
0,
),
child: GestureDetector(
onTap: () async {
await _displayDetails(widget.file);
await Future.delayed(
const Duration(milliseconds: 500),
); //Waiting for some time till the caption gets updated in db if the user closes the bottom sheet without pressing 'done'
safeRefresh();
},
child: Text(
widget.file.caption!,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: getEnteTextTheme(context)
.mini
.copyWith(color: textBaseDark),
textAlign: TextAlign.center,
),
),
)
: const SizedBox.shrink(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: children,
),
],
),
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.black.withOpacity(0.6),
Colors.black.withOpacity(0.72),
],
stops: const [0, 0.8, 1],
),
],
),
child: Padding(
padding: EdgeInsets.only(bottom: safeAreaBottomPadding),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
widget.file.caption?.isNotEmpty ?? false
? Padding(
padding: const EdgeInsets.fromLTRB(
16,
12,
16,
0,
),
child: GestureDetector(
onTap: () async {
await _displayDetails(widget.file);
await Future.delayed(
const Duration(milliseconds: 500),
); //Waiting for some time till the caption gets updated in db if the user closes the bottom sheet without pressing 'done'
safeRefresh();
},
child: Text(
widget.file.caption!,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: getEnteTextTheme(context)
.mini
.copyWith(color: textBaseDark),
textAlign: TextAlign.center,
),
),
)
: const SizedBox.shrink(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: children,
),
],
),
),
),
),
),
@@ -292,24 +256,6 @@ class FileBottomBarState extends State<FileBottomBar> {
);
}
Future<void> openPanoramaViewerPage(EnteFile file) async {
final fetchedFile = await getFile(file);
if (fetchedFile == null) {
return;
}
final fetchedThumbnail = await getThumbnail(file);
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) {
return PanoramaViewerScreen(
file: fetchedFile,
thumbnail: fetchedThumbnail,
);
},
),
).ignore();
}
Future<void> _showSingleFileDeleteSheet(EnteFile file) async {
await showSingleFileDeleteSheet(
context,

View File

@@ -36,6 +36,12 @@ class _PanoramaViewerScreenState extends State<PanoramaViewerScreen> {
super.initState();
}
@override
void dispose() {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
super.dispose();
}
void initTimer() {
timer = Timer(const Duration(seconds: 5), () {
setState(() {