made a working skeleton of the overlay that comes on file selection

This commit is contained in:
ashilkn 2022-05-04 16:38:06 +05:30
parent 2209a4cb4b
commit 26a83c8bdd
9 changed files with 215 additions and 38 deletions

View file

@ -29,6 +29,13 @@ extension CustomColorScheme on ColorScheme {
Color get recoveryKeyBoxColor => brightness == Brightness.light
? Color.fromRGBO(49, 155, 86, 0.2)
: Color(0xFF1DB954);
Color get frostyBlurBackdropFilterColor =>
brightness == Brightness.light ? Colors.black : Colors.white;
Color get cancelSelectedButtonColor => brightness == Brightness.light
? Color.fromARGB(255, 225, 225, 225)
: Color.fromARGB(255, 30, 30, 30);
}
OutlinedButtonThemeData buildOutlinedButtonThemeData(

View file

@ -8,15 +8,18 @@ import 'package:photos/models/magic_metadata.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
class ArchivePage extends StatelessWidget {
final String tagPrefix;
final GalleryAppBarType appBarType;
final GalleryOverlayType overlayType;
final _selectedFiles = SelectedFiles();
ArchivePage(
{this.tagPrefix = "archived_page",
this.appBarType = GalleryAppBarType.archive,
this.overlayType = GalleryOverlayType.archive,
Key key})
: super(key: key);
@ -58,7 +61,17 @@ class ArchivePage extends StatelessWidget {
_selectedFiles,
),
),
body: gallery,
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
GalleryOverflowWidget(
overlayType,
"Hidden",
_selectedFiles,
)
],
),
);
}
}

View file

@ -1,3 +1,5 @@
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:photos/core/event_bus.dart';
@ -8,16 +10,19 @@ import 'package:photos/models/collection_items.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
class CollectionPage extends StatelessWidget {
final CollectionWithThumbnail c;
final String tagPrefix;
final GalleryAppBarType appBarType;
final GalleryOverlayType overlayType;
final _selectedFiles = SelectedFiles();
CollectionPage(this.c,
{this.tagPrefix = "collection",
this.appBarType = GalleryAppBarType.owned_collection,
this.overlayType = GalleryOverlayType.owned_collection,
Key key})
: super(key: key);
@ -48,12 +53,23 @@ class CollectionPage extends StatelessWidget {
preferredSize: Size.fromHeight(50.0),
child: GalleryAppBarWidget(
appBarType,
c.collection.name, //title
c.collection.name,
_selectedFiles,
collection: c.collection,
),
),
body: gallery,
// body: gallery,
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
GalleryOverflowWidget(
overlayType,
c.collection.name,
_selectedFiles,
)
],
),
);
}
}

View file

@ -9,6 +9,7 @@ import 'package:photos/models/device_folder.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
class DeviceFolderPage extends StatelessWidget {
final DeviceFolder folder;
@ -46,7 +47,17 @@ class DeviceFolderPage extends StatelessWidget {
path: folder.thumbnail.deviceFolder,
),
),
body: gallery,
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
GalleryOverflowWidget(
GalleryOverlayType.local_folder,
folder.name,
_selectedFiles,
)
],
),
);
}

View file

@ -80,41 +80,40 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
@override
Widget build(BuildContext context) {
if (widget.selectedFiles.files.isEmpty) {
return AppBar(
backgroundColor: widget.type == GalleryAppBarType.homepage
? Color(0x00000000)
: null,
elevation: 0,
title: widget.type == GalleryAppBarType.homepage
? Container()
: TextButton(
child: Text(
_appBarTitle,
style: Theme.of(context)
.textTheme
.headline5
.copyWith(fontSize: 16),
),
onPressed: () => _renameAlbum(context),
),
actions: _getDefaultActions(context),
);
}
// if (widget.selectedFiles.files.isEmpty) {
return AppBar(
leading: Tooltip(
message: "clear selection",
child: IconButton(
icon: Icon(Platform.isAndroid ? Icons.clear : CupertinoIcons.clear),
onPressed: () {
_clearSelectedFiles();
},
),
),
title: Text(widget.selectedFiles.files.length.toString()),
actions: _getActions(context),
backgroundColor:
widget.type == GalleryAppBarType.homepage ? Color(0x00000000) : null,
elevation: 0,
title: widget.type == GalleryAppBarType.homepage
? const SizedBox.shrink()
: TextButton(
child: Text(
_appBarTitle,
style: Theme.of(context)
.textTheme
.headline5
.copyWith(fontSize: 16),
),
onPressed: () => _renameAlbum(context),
),
actions: _getDefaultActions(context),
);
// }
// return AppBar(
// leading: Tooltip(
// message: "clear selection",
// child: IconButton(
// icon: Icon(Platform.isAndroid ? Icons.clear : CupertinoIcons.clear),
// onPressed: () {
// _clearSelectedFiles();
// },
// ),
// ),
// title: Text(widget.selectedFiles.files.length.toString()),
// actions: _getActions(context),
// );
}
Future<dynamic> _renameAlbum(BuildContext context) async {

View file

@ -0,0 +1,111 @@
import 'dart:async';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/events/subscription_purchased_event.dart';
import 'package:photos/models/collection.dart';
import 'package:photos/models/selected_files.dart';
enum GalleryOverlayType {
homepage,
archive,
trash,
local_folder,
// indicator for gallery view of collections shared with the user
shared_collection,
owned_collection,
search_results
}
class GalleryOverflowWidget extends StatefulWidget {
final GalleryOverlayType type;
final String title;
final SelectedFiles selectedFiles;
final String path;
final Collection collection;
GalleryOverflowWidget(
this.type,
this.title,
this.selectedFiles, {
this.path,
this.collection,
});
@override
_GalleryOverflowWidgetState createState() => _GalleryOverflowWidgetState();
}
class _GalleryOverflowWidgetState extends State<GalleryOverflowWidget> {
final _logger = Logger("GalleryOverlay");
StreamSubscription _userAuthEventSubscription;
Function() _selectedFilesListener;
String _appBarTitle;
final GlobalKey shareButtonKey = GlobalKey();
@override
void initState() {
_selectedFilesListener = () {
setState(() {});
};
widget.selectedFiles.addListener(_selectedFilesListener);
_userAuthEventSubscription =
Bus.instance.on<SubscriptionPurchasedEvent>().listen((event) {
setState(() {});
});
_appBarTitle = widget.title;
super.initState();
}
@override
void dispose() {
_userAuthEventSubscription.cancel();
widget.selectedFiles.removeListener(_selectedFilesListener);
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.selectedFiles.files.isNotEmpty) {
return Container(
height: 108,
color: Colors.transparent,
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 50, sigmaY: 50),
child: Container(
color: Theme.of(context)
.colorScheme
.frostyBlurBackdropFilterColor
.withOpacity(0.6),
height: 46,
width: double.infinity,
),
),
),
),
const SizedBox(height: 16),
Container(
height: 32,
width: 86,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
color:
Theme.of(context).colorScheme.cancelSelectedButtonColor),
),
],
),
);
} else {
return const SizedBox.shrink();
}
}
}

View file

@ -40,6 +40,7 @@ import 'package:photos/ui/extents_page_view.dart';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_footer_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
import 'package:photos/ui/grant_permissions_widget.dart';
import 'package:photos/ui/landing_page_widget.dart';
import 'package:photos/ui/loading_photos_widget.dart';
@ -311,6 +312,11 @@ class _HomeWidgetState extends State<HomeWidget> {
_selectedFiles,
selectedTabIndex: _selectedTabIndex,
)),
Align(
alignment: Alignment.bottomCenter,
child: GalleryOverflowWidget(
GalleryOverlayType.homepage, null, _selectedFiles),
)
],
);
}

View file

@ -327,6 +327,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
child: Icon(
Icons.check_circle_rounded,
size: 20,
color: Colors.white, //same for both themes
),
),
)

View file

@ -8,15 +8,18 @@ import 'package:photos/models/selected_files.dart';
import 'package:photos/models/trash_file.dart';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/gallery_app_bar_widget.dart';
import 'package:photos/ui/gallery_overlay_widget.dart';
class TrashPage extends StatelessWidget {
final String tagPrefix;
final GalleryAppBarType appBarType;
final GalleryOverlayType overlayType;
final _selectedFiles = SelectedFiles();
TrashPage({
this.tagPrefix = "trash_page",
this.appBarType = GalleryAppBarType.trash,
this.overlayType = GalleryOverlayType.trash,
Key key,
}) : super(key: key);
@ -53,7 +56,17 @@ class TrashPage extends StatelessWidget {
_selectedFiles,
),
),
body: gallery,
body: Stack(
alignment: Alignment.bottomCenter,
children: [
gallery,
GalleryOverflowWidget(
overlayType,
"Trash",
_selectedFiles,
)
],
),
);
}