mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	* Add i18n framework to mobile app and write simple translation generator * Replace all texts in login_form with i18n keys * Localization of sharing section * Localization of asset viewer section * Use JSON as base translation format * Add check for missing/unused translation keys * Add localizely * Remove i18n directory in favour of localizely * Backup Translation * More translations * Translate home page * Translation of search page * Translate new server version announcement * Reformat code * Fix typo in german translation * Update englisch translations * Change translation keys to match dart filenames * Add /api to translated endpoint_urls * Update localizely.yml * Add languages to ios plist * Remove unused keys * Added script to check outdated key in other translations * Add download key to localizely.yml Co-authored-by: Alex <alex.tran1502@gmail.com>
		
			
				
	
	
		
			100 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
import 'package:auto_route/auto_route.dart';
 | 
						|
import 'package:easy_localization/easy_localization.dart';
 | 
						|
import 'package:flutter/material.dart';
 | 
						|
import 'package:flutter_hooks/flutter_hooks.dart';
 | 
						|
import 'package:hooks_riverpod/hooks_riverpod.dart';
 | 
						|
import 'package:immich_mobile/modules/sharing/models/asset_selection_page_result.model.dart';
 | 
						|
import 'package:immich_mobile/modules/sharing/providers/asset_selection.provider.dart';
 | 
						|
import 'package:immich_mobile/modules/sharing/ui/asset_grid_by_month.dart';
 | 
						|
import 'package:immich_mobile/modules/sharing/ui/month_group_title.dart';
 | 
						|
import 'package:immich_mobile/shared/providers/asset.provider.dart';
 | 
						|
import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart';
 | 
						|
 | 
						|
class AssetSelectionPage extends HookConsumerWidget {
 | 
						|
  const AssetSelectionPage({Key? key}) : super(key: key);
 | 
						|
  @override
 | 
						|
  Widget build(BuildContext context, WidgetRef ref) {
 | 
						|
    ScrollController scrollController = useScrollController();
 | 
						|
    var assetGroupMonthYear = ref.watch(assetGroupByMonthYearProvider);
 | 
						|
    final selectedAssets =
 | 
						|
        ref.watch(assetSelectionProvider).selectedNewAssetsForAlbum;
 | 
						|
    final newAssetsForAlbum =
 | 
						|
        ref.watch(assetSelectionProvider).selectedAdditionalAssetsForAlbum;
 | 
						|
    final isAlbumExist = ref.watch(assetSelectionProvider).isAlbumExist;
 | 
						|
 | 
						|
    List<Widget> imageGridGroup = [];
 | 
						|
 | 
						|
    String _buildAssetCountText() {
 | 
						|
      if (isAlbumExist) {
 | 
						|
        return (selectedAssets.length + newAssetsForAlbum.length).toString();
 | 
						|
      } else {
 | 
						|
        return selectedAssets.length.toString();
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
    Widget _buildBody() {
 | 
						|
      assetGroupMonthYear.forEach((monthYear, assetGroup) {
 | 
						|
        imageGridGroup
 | 
						|
            .add(MonthGroupTitle(month: monthYear, assetGroup: assetGroup));
 | 
						|
        imageGridGroup.add(AssetGridByMonth(assetGroup: assetGroup));
 | 
						|
      });
 | 
						|
 | 
						|
      return Stack(
 | 
						|
        children: [
 | 
						|
          DraggableScrollbar.semicircle(
 | 
						|
            backgroundColor: Theme.of(context).primaryColor,
 | 
						|
            controller: scrollController,
 | 
						|
            heightScrollThumb: 48.0,
 | 
						|
            child: CustomScrollView(
 | 
						|
              controller: scrollController,
 | 
						|
              slivers: [...imageGridGroup],
 | 
						|
            ),
 | 
						|
          ),
 | 
						|
        ],
 | 
						|
      );
 | 
						|
    }
 | 
						|
 | 
						|
    return Scaffold(
 | 
						|
      appBar: AppBar(
 | 
						|
        elevation: 0,
 | 
						|
        leading: IconButton(
 | 
						|
          icon: const Icon(Icons.close_rounded),
 | 
						|
          onPressed: () {
 | 
						|
            ref.watch(assetSelectionProvider.notifier).removeAll();
 | 
						|
            AutoRouter.of(context).pop(null);
 | 
						|
          },
 | 
						|
        ),
 | 
						|
        title: selectedAssets.isEmpty
 | 
						|
            ? const Text(
 | 
						|
                'share_add_photos',
 | 
						|
                style: TextStyle(fontSize: 18),
 | 
						|
              ).tr()
 | 
						|
            : Text(
 | 
						|
                _buildAssetCountText(),
 | 
						|
                style: const TextStyle(fontSize: 18),
 | 
						|
              ),
 | 
						|
        centerTitle: false,
 | 
						|
        actions: [
 | 
						|
          if ((!isAlbumExist && selectedAssets.isNotEmpty) ||
 | 
						|
              (isAlbumExist && newAssetsForAlbum.isNotEmpty))
 | 
						|
            TextButton(
 | 
						|
              onPressed: () {
 | 
						|
                var payload = AssetSelectionPageResult(
 | 
						|
                  isAlbumExist: isAlbumExist,
 | 
						|
                  selectedAdditionalAsset: newAssetsForAlbum,
 | 
						|
                  selectedNewAsset: selectedAssets,
 | 
						|
                );
 | 
						|
                AutoRouter.of(context).pop(payload);
 | 
						|
              },
 | 
						|
              child: const Text(
 | 
						|
                "share_add",
 | 
						|
                style: TextStyle(fontWeight: FontWeight.bold),
 | 
						|
              ).tr(),
 | 
						|
            ),
 | 
						|
        ],
 | 
						|
      ),
 | 
						|
      body: _buildBody(),
 | 
						|
    );
 | 
						|
  }
 | 
						|
}
 |