diff --git a/README.md b/README.md index 4bed65f181..b3921a2cdb 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Loading ~4000 images/videos # Note -This project is under heavy development, there will be continous functions, features and api changes. - **!! NOT READY FOR PRODUCTION! DO NOT USE TO STORE YOUR ASSETS !!** +This project is under heavy development, there will be continous functions, features and api changes. + # Features [x] Upload assets(videos/images) diff --git a/mobile/lib/modules/home/providers/asset.provider.dart b/mobile/lib/modules/home/providers/asset.provider.dart index 92ec188a25..e4f72188f7 100644 --- a/mobile/lib/modules/home/providers/asset.provider.dart +++ b/mobile/lib/modules/home/providers/asset.provider.dart @@ -14,7 +14,7 @@ class AssetNotifier extends StateNotifier> { bool isFetching = false; // Get All assets - getImmichAssets() async { + getAllAssets() async { GetAllAssetResponse? res = await _assetService.getAllAsset(); nextPageKey = res?.nextPageKey; diff --git a/mobile/lib/modules/home/ui/control_bottom_app_bar.dart b/mobile/lib/modules/home/ui/control_bottom_app_bar.dart new file mode 100644 index 0000000000..7ad8f4119a --- /dev/null +++ b/mobile/lib/modules/home/ui/control_bottom_app_bar.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; +import 'package:immich_mobile/modules/home/ui/delete_diaglog.dart'; + +class ControlBottomAppBar extends StatelessWidget { + const ControlBottomAppBar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Positioned( + bottom: 0, + left: 0, + child: Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height * 0.15, + decoration: BoxDecoration( + borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)), + color: Colors.grey[300]?.withOpacity(0.98), + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ControlBoxButton( + iconData: Icons.delete_forever_rounded, + label: "Delete", + onPressed: () { + showDialog( + context: context, + builder: (BuildContext context) { + return const DeleteDialog(); + }, + ); + }, + ), + ], + ), + ) + ], + ), + ), + ); + } +} + +class ControlBoxButton extends StatelessWidget { + const ControlBoxButton({Key? key, required this.label, required this.iconData, required this.onPressed}) + : super(key: key); + + final String label; + final IconData iconData; + final Function onPressed; + + @override + Widget build(BuildContext context) { + return SizedBox( + width: 60, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + IconButton( + onPressed: () { + onPressed(); + }, + icon: Icon(iconData, size: 30), + ), + Text(label) + ], + ), + ); + } +} diff --git a/mobile/lib/modules/home/ui/delete_diaglog.dart b/mobile/lib/modules/home/ui/delete_diaglog.dart new file mode 100644 index 0000000000..8613760a22 --- /dev/null +++ b/mobile/lib/modules/home/ui/delete_diaglog.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; + +class DeleteDialog extends StatelessWidget { + const DeleteDialog({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return AlertDialog( + backgroundColor: Colors.grey[200], + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + title: const Text("Delete Permanently"), + content: const Text("These items will be permanently deleted from Immich and from your device"), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text( + "Cancel", + style: TextStyle(color: Colors.blueGrey), + ), + ), + TextButton( + onPressed: () {}, + child: Text( + "Delete", + style: TextStyle(color: Colors.red[400]), + ), + ), + ], + ); + } +} diff --git a/mobile/lib/modules/home/ui/disable_multi_select_button.dart b/mobile/lib/modules/home/ui/disable_multi_select_button.dart new file mode 100644 index 0000000000..bb1094a594 --- /dev/null +++ b/mobile/lib/modules/home/ui/disable_multi_select_button.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/modules/home/providers/home_page_state.provider.dart'; + +class DisableMultiSelectButton extends ConsumerWidget { + const DisableMultiSelectButton({ + Key? key, + required this.onPressed, + required this.selectedItemCount, + }) : super(key: key); + + final Function onPressed; + final int selectedItemCount; + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Positioned( + top: 0, + left: 0, + child: Padding( + padding: const EdgeInsets.only(left: 16.0, top: 46), + child: Material( + elevation: 20, + borderRadius: BorderRadius.circular(35), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(35), + color: Colors.grey[100], + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4.0), + child: TextButton.icon( + onPressed: () { + onPressed(); + }, + icon: const Icon(Icons.close_rounded), + label: Text( + selectedItemCount.toString(), + style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 18), + )), + ), + ), + ), + ), + ); + } +} diff --git a/mobile/lib/modules/home/ui/edit_bottom_app_bar.dart b/mobile/lib/modules/home/ui/edit_bottom_app_bar.dart deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mobile/lib/modules/home/views/home_page.dart b/mobile/lib/modules/home/views/home_page.dart index 82ffe1cddf..e5ea1ebe27 100644 --- a/mobile/lib/modules/home/views/home_page.dart +++ b/mobile/lib/modules/home/views/home_page.dart @@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/modules/home/providers/home_page_state.provider.dart'; +import 'package:immich_mobile/modules/home/ui/control_bottom_app_bar.dart'; import 'package:immich_mobile/modules/home/ui/daily_title_text.dart'; +import 'package:immich_mobile/modules/home/ui/disable_multi_select_button.dart'; import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart'; import 'package:immich_mobile/modules/home/ui/image_grid.dart'; import 'package:immich_mobile/modules/home/ui/immich_sliver_appbar.dart'; @@ -32,7 +34,7 @@ class HomePage extends HookConsumerWidget { } useEffect(() { - ref.read(assetProvider.notifier).getImmichAssets(); + ref.read(assetProvider.notifier).getAllAssets(); _scrollController.addListener(_scrollControllerCallback); return () { @@ -48,7 +50,7 @@ class HomePage extends HookConsumerWidget { if (_imageGridGroup.isNotEmpty && _imageGridGroup.length < 20) { ref.read(assetProvider.notifier).getOlderAsset(); } else if (_imageGridGroup.isEmpty) { - ref.read(assetProvider.notifier).getImmichAssets(); + ref.read(assetProvider.notifier).getAllAssets(); } } @@ -90,116 +92,6 @@ class HomePage extends HookConsumerWidget { } } - _buildDisableMultiSelectButton() { - return Positioned( - top: 0, - left: 0, - child: Padding( - padding: const EdgeInsets.only(left: 16.0, top: 46), - child: Material( - elevation: 20, - borderRadius: BorderRadius.circular(35), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(35), - color: Colors.grey[100], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4.0), - child: TextButton.icon( - onPressed: () { - ref.watch(homePageStateProvider.notifier).disableMultiSelect(); - }, - icon: const Icon(Icons.close_rounded), - label: Text( - homePageState.selectedItems.length.toString(), - style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 18), - )), - ), - ), - ), - ), - ); - } - - _buildControlBottomBar() { - return Positioned( - bottom: 0, - left: 0, - child: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height * 0.15, - decoration: BoxDecoration( - borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)), - color: Colors.grey[300]?.withOpacity(0.98), - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: 60, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - IconButton( - onPressed: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - backgroundColor: Colors.grey[200], - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), - title: const Text("Delete Permanently"), - content: const Text( - "These items will be permanently deleted from Immich and from your device"), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: const Text( - "Cancel", - style: TextStyle(color: Colors.blueGrey), - ), - ), - TextButton( - onPressed: () {}, - child: Text( - "Delete", - style: TextStyle(color: Colors.red[400]), - ), - ), - ], - ); - }, - ); - }, - icon: const Icon( - Icons.delete_forever_rounded, - size: 30, - ), - ), - const Text( - "Delete", - softWrap: true, - ) - ], - ), - ), - ], - ), - ) - ], - ), - ), - ); - } - return SafeArea( bottom: !isMultiSelectEnable, top: !isMultiSelectEnable, @@ -230,8 +122,13 @@ class HomePage extends HookConsumerWidget { ], ), ), - isMultiSelectEnable ? _buildDisableMultiSelectButton() : Container(), - isMultiSelectEnable ? _buildControlBottomBar() : Container(), + isMultiSelectEnable + ? DisableMultiSelectButton( + onPressed: ref.watch(homePageStateProvider.notifier).disableMultiSelect, + selectedItemCount: homePageState.selectedItems.length, + ) + : Container(), + isMultiSelectEnable ? const ControlBottomAppBar() : Container(), ], ), ); diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock index b566ebb8e1..9df915f441 100644 --- a/mobile/pubspec.lock +++ b/mobile/pubspec.lock @@ -513,13 +513,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.3" meta: dependency: transitive description: @@ -825,7 +818,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.3" timing: dependency: transitive description: