[mob][photos] Used better names

This commit is contained in:
Aman Raj Singh Mourya
2024-08-21 13:36:54 +05:30
parent 5792c2bae6
commit 70cc6a35d7
5 changed files with 48 additions and 39 deletions

View File

@@ -17,11 +17,11 @@ import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/divider_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/settings/new_album_card_widget.dart";
import 'package:photos/ui/tabs/section_title.dart';
import "package:photos/ui/tabs/shared/all_quick_links_page.dart";
import "package:photos/ui/tabs/shared/empty_state.dart";
import "package:photos/ui/tabs/shared/quick_link_album_item.dart";
import "package:photos/ui/viewer/gallery/collect_photos_card_widget.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
import "package:photos/utils/debouncer.dart";
import "package:photos/utils/navigation_util.dart";
@@ -319,7 +319,7 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>
],
)
: const SizedBox.shrink(),
const NewAlbumCardWidget(),
const CollectPhotosCardWidget(),
const SizedBox(height: 32),
],
),

View File

@@ -12,21 +12,22 @@ import "package:photos/ui/viewer/gallery/hooks/add_photos_sheet.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/share_util.dart";
class EmptyAlbumStateNew extends StatefulWidget {
final Collection c;
class CollectPhotosBottomButtons extends StatefulWidget {
final Collection? c;
final SelectedFiles? selectedFiles;
const EmptyAlbumStateNew(
const CollectPhotosBottomButtons(
this.c, {
super.key,
this.selectedFiles,
});
@override
State<EmptyAlbumStateNew> createState() => _EmptyAlbumStateNewState();
State<CollectPhotosBottomButtons> createState() => _EmptyAlbumStateNewState();
}
class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {
class _EmptyAlbumStateNewState extends State<CollectPhotosBottomButtons> {
final ValueNotifier<bool> _hasSelectedFilesNotifier = ValueNotifier(false);
final GlobalKey shareLinkAlbumButtonKey = GlobalKey();
@override
void initState() {
@@ -41,18 +42,27 @@ class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {
super.dispose();
}
// Future<String> _getAlbumShareUrl() async {
// try {
// final String collectionKey = Base58Encode(
// CollectionsService.instance.getCollectionKey(widget.c.id),
// );
// } catch (e) {
// await showGenericErrorDialog(
// context: context,
// error: e,
// );
// }
// return "";
// }
@override
Widget build(BuildContext context) {
final GlobalKey shareLinkAlbumButtonKey = GlobalKey();
Future<String> getAlbumShareUrl() async {
final PublicURL url = widget.c.publicURLs!.firstOrNull!;
final String collectionKey = Base58Encode(
CollectionsService.instance.getCollectionKey(widget.c.id),
);
return "${url.url}#$collectionKey";
}
final PublicURL url = widget.c!.publicURLs!.firstOrNull!;
final String collectionKey = Base58Encode(
CollectionsService.instance.getCollectionKey(widget.c!.id),
);
final String urlValue = "${url.url}#$collectionKey";
return ValueListenableBuilder(
valueListenable: _hasSelectedFilesNotifier,
builder: (context, value, child) {
@@ -71,8 +81,6 @@ class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 0, 24, 12),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Container(
@@ -89,7 +97,7 @@ class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {
shouldSurfaceExecutionStates: false,
onTap: () async {
try {
await showAddPhotosSheet(context, widget.c);
await showAddPhotosSheet(context, widget.c!);
} catch (e) {
await showGenericErrorDialog(
context: context,
@@ -107,11 +115,10 @@ class _EmptyAlbumStateNewState extends State<EmptyAlbumStateNew> {
icon: Icons.adaptive.share,
shouldSurfaceExecutionStates: false,
onTap: () async {
final String shareUrl = await getAlbumShareUrl();
await shareAlbumLinkWithPlaceholder(
context,
widget.c,
shareUrl,
widget.c!,
urlValue,
shareLinkAlbumButtonKey,
);
},

View File

@@ -13,14 +13,15 @@ import "package:photos/ui/viewer/gallery/collection_page.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/navigation_util.dart";
class NewAlbumCardWidget extends StatefulWidget {
const NewAlbumCardWidget({super.key});
class CollectPhotosCardWidget extends StatefulWidget {
const CollectPhotosCardWidget({super.key});
@override
State<NewAlbumCardWidget> createState() => _NewAlbumCardWidgetState();
State<CollectPhotosCardWidget> createState() =>
_CollectPhotosCardWidgetState();
}
class _NewAlbumCardWidgetState extends State<NewAlbumCardWidget> {
class _CollectPhotosCardWidgetState extends State<CollectPhotosCardWidget> {
Future<void> _onTapCreateAlbum() async {
final String currentDate =
DateFormat('MMMM d, yyyy').format(DateTime.now());
@@ -45,12 +46,13 @@ class _NewAlbumCardWidgetState extends State<NewAlbumCardWidget> {
routeToPage(
context,
CollectionPage(
isNewCollection: true,
isFromCollectPhotos: true,
CollectionWithThumbnail(c, null),
),
);
} catch (e, s) {
Logger("CreateNewAlbumIcon").severe("Failed to rename album", e, s);
Logger("CollectPhotosCardWidget")
.severe("Failed to rename album", e, s);
rethrow;
}
},

View File

@@ -12,8 +12,8 @@ import 'package:photos/models/gallery_type.dart';
import 'package:photos/models/selected_files.dart';
import 'package:photos/services/ignored_files_service.dart';
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
import "package:photos/ui/viewer/gallery/collect_photos_bottom_buttons.dart";
import "package:photos/ui/viewer/gallery/empty_album_state.dart";
import "package:photos/ui/viewer/gallery/empty_album_state_new.dart";
import 'package:photos/ui/viewer/gallery/empty_state.dart';
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart';
@@ -23,13 +23,13 @@ class CollectionPage extends StatelessWidget {
final CollectionWithThumbnail c;
final String tagPrefix;
final bool? hasVerifiedLock;
final bool isNewCollection;
final bool isFromCollectPhotos;
CollectionPage(
this.c, {
this.tagPrefix = "collection",
this.hasVerifiedLock = false,
this.isNewCollection = false,
this.isFromCollectPhotos = false,
Key? key,
}) : super(key: key);
@@ -91,10 +91,10 @@ class CollectionPage extends StatelessWidget {
emptyState: galleryType == GalleryType.ownedCollection
? EmptyAlbumState(
c.collection,
isNewCollection: isNewCollection,
isFromCollectPhotos: isFromCollectPhotos,
)
: const EmptyState(),
footer: isNewCollection
footer: isFromCollectPhotos
? const SizedBox(height: 20)
: const SizedBox(height: 212),
);
@@ -108,8 +108,8 @@ class CollectionPage extends StatelessWidget {
collection: c.collection,
),
),
floatingActionButton: isNewCollection
? EmptyAlbumStateNew(
floatingActionButton: isFromCollectPhotos
? CollectPhotosBottomButtons(
c.collection,
selectedFiles: _selectedFiles,
)

View File

@@ -8,16 +8,16 @@ import "package:photos/utils/dialog_util.dart";
class EmptyAlbumState extends StatelessWidget {
final Collection c;
final bool isNewCollection;
final bool isFromCollectPhotos;
const EmptyAlbumState(
this.c, {
super.key,
this.isNewCollection = false,
this.isFromCollectPhotos = false,
});
@override
Widget build(BuildContext context) {
return isNewCollection
return isFromCollectPhotos
? Stack(
children: [
Center(