Skip to content

Commit

Permalink
Merge branch 'main' of github.com:immich-app/immich
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 committed Mar 28, 2023
2 parents 6f3f8b0 + b49f66b commit 10ccbea
Show file tree
Hide file tree
Showing 49 changed files with 307 additions and 86 deletions.
6 changes: 5 additions & 1 deletion mobile/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,9 @@
"motion_photos_page_title": "Motion Photos",
"search_page_motion_photos": "Motion Photos",
"search_page_recently_added": "Recently added",
"search_page_categories": "Categories"
"search_page_categories": "Categories",
"search_page_screenshots": "Screenshots",
"search_page_selfies": "Selfies",
"search_suggestion_list_smart_search_hint_1": "Smart search is enabled by default, to search for metadata use the syntax ",
"search_suggestion_list_smart_search_hint_2": "m:your-search-term"
}
Binary file removed mobile/flutter_01.png
Binary file not shown.
1 change: 1 addition & 0 deletions mobile/lib/modules/backup/services/backup.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class BackupService {
);
req.headers["Authorization"] =
"Bearer ${Store.get(StoreKey.accessToken)}";
req.headers["Transfer-Encoding"] = "chunked";

req.fields['deviceAssetId'] = entity.id;
req.fields['deviceId'] = deviceId;
Expand Down
8 changes: 8 additions & 0 deletions mobile/lib/modules/login/ui/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ class EmailInput extends StatelessWidget {
labelText: 'login_form_label_email'.tr(),
border: const OutlineInputBorder(),
hintText: 'login_form_email_hint'.tr(),
hintStyle: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14,
),
),
validator: _validateInput,
autovalidateMode: AutovalidateMode.always,
Expand Down Expand Up @@ -487,6 +491,10 @@ class PasswordInput extends StatelessWidget {
labelText: 'login_form_label_password'.tr(),
border: const OutlineInputBorder(),
hintText: 'login_form_password_hint'.tr(),
hintStyle: const TextStyle(
fontWeight: FontWeight.normal,
fontSize: 14,
),
),
autofillHints: const [AutofillHints.password],
keyboardType: TextInputType.text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ class SearchResultPageNotifier extends StateNotifier<SearchResultPageState> {

final SearchService _searchService;

void search(String searchTerm) async {
void search(String searchTerm, {bool clipEnable = true}) async {
state = state.copyWith(
searchResult: [],
isError: false,
isLoading: true,
isSuccess: false,
);

List<Asset>? assets = await _searchService.searchAsset(searchTerm);
List<Asset>? assets = await _searchService.searchAsset(
searchTerm,
clipEnable: clipEnable,
);

if (assets != null) {
state = state.copyWith(
Expand Down
11 changes: 8 additions & 3 deletions mobile/lib/modules/search/services/search.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ class SearchService {
}
}

Future<List<Asset>?> searchAsset(String searchTerm) async {
Future<List<Asset>?> searchAsset(
String searchTerm, {
bool clipEnable = true,
}) async {
// TODO search in local DB: 1. when offline, 2. to find local assets
try {
final SearchResponseDto? results = await _apiService.searchApi
.search(query: searchTerm, clip: true);
final SearchResponseDto? results = await _apiService.searchApi.search(
query: searchTerm,
clip: clipEnable,
);
if (results == null) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions mobile/lib/modules/search/ui/curated_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:immich_mobile/shared/models/store.dart';
class CuratedRow extends StatelessWidget {
final List<CuratedContent> content;
final double imageSize;

/// Callback with the content and the index when tapped
final Function(CuratedContent, int)? onTap;

Expand All @@ -19,7 +19,6 @@ class CuratedRow extends StatelessWidget {

@override
Widget build(BuildContext context) {

// Guard empty [content]
if (content.isEmpty) {
// Return empty thumbnail
Expand Down
7 changes: 3 additions & 4 deletions mobile/lib/modules/search/ui/explore_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ExploreGrid extends StatelessWidget {
width: 100,
child: ThumbnailWithInfo(
textInfo: '',
onTap: () {
},
onTap: () {},
),
),
);
Expand All @@ -42,15 +41,15 @@ class ExploreGrid extends StatelessWidget {
return ThumbnailWithInfo(
imageUrl: thumbnailRequestUrl,
textInfo: content.label,
borderRadius: 0,
onTap: () {
AutoRouter.of(context).push(
SearchResultRoute(searchTerm: content.label),
SearchResultRoute(searchTerm: 'm:${content.label}'),
);
},
);
},
itemCount: curatedContent.length,
);
}

}
7 changes: 6 additions & 1 deletion mobile/lib/modules/search/ui/search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
},
icon: const Icon(Icons.arrow_back_ios_rounded),
)
: const Icon(Icons.search_rounded),
: const Icon(
Icons.search_rounded,
size: 20,
),
title: TextField(
controller: searchTermController,
focusNode: searchFocusNode,
Expand All @@ -55,6 +58,8 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
hintText: 'search_bar_hint'.tr(),
hintStyle: Theme.of(context).textTheme.titleSmall?.copyWith(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.5),
fontWeight: FontWeight.w500,
fontSize: 14,
),
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
Expand Down
31 changes: 31 additions & 0 deletions mobile/lib/modules/search/ui/search_result_grid.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/home/ui/asset_grid/thumbnail_image.dart';
import 'package:immich_mobile/shared/models/asset.dart';

class SearchResultGrid extends HookConsumerWidget {
const SearchResultGrid({super.key, required this.assets});

final List<Asset> assets;

@override
Widget build(BuildContext context, WidgetRef ref) {
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
childAspectRatio: 1,
crossAxisSpacing: 4,
mainAxisSpacing: 4,
),
itemCount: assets.length,
itemBuilder: (context, index) {
final asset = assets[index];
return ThumbnailImage(
asset: asset,
assetList: assets,
useGrayBoxPlaceholder: true,
);
},
);
}
}
29 changes: 28 additions & 1 deletion mobile/lib/modules/search/ui/search_suggestion_list.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart';
Expand All @@ -12,20 +13,46 @@ class SearchSuggestionList extends ConsumerWidget {
final searchTerm = ref.watch(searchPageStateProvider).searchTerm;
final searchSuggestion =
ref.watch(searchPageStateProvider).searchSuggestion;
var isDarkTheme = Theme.of(context).brightness == Brightness.dark;

return Container(
color: searchTerm.isEmpty
? Colors.black.withOpacity(0.5)
: Theme.of(context).scaffoldBackgroundColor,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
color: isDarkTheme ? Colors.grey[800] : Colors.grey[100],
child: Padding(
padding: const EdgeInsets.all(16.0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: 'search_suggestion_list_smart_search_hint_1'.tr(),
style: Theme.of(context).textTheme.bodyMedium,
),
TextSpan(
text: 'search_suggestion_list_smart_search_hint_2'.tr(),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
)
],
),
),
),
),
),
SliverFillRemaining(
hasScrollBody: true,
child: ListView.builder(
itemBuilder: ((context, index) {
return ListTile(
onTap: () {
onSubmitted(searchSuggestion[index]);
onSubmitted("m:${searchSuggestion[index]}");
},
title: Text(searchSuggestion[index]),
);
Expand Down
31 changes: 26 additions & 5 deletions mobile/lib/modules/search/ui/thumbnail_with_info.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:immich_mobile/shared/models/store.dart';
import 'package:immich_mobile/utils/capitalize_first_letter.dart';

// ignore: must_be_immutable
class ThumbnailWithInfo extends StatelessWidget {
const ThumbnailWithInfo({
ThumbnailWithInfo({
Key? key,
required this.textInfo,
this.imageUrl,
this.noImageIcon,
this.borderRadius = 10,
required this.onTap,
}) : super(key: key);

final String textInfo;
final String? imageUrl;
final Function onTap;
final IconData? noImageIcon;
double borderRadius;

@override
Widget build(BuildContext context) {
Expand All @@ -29,12 +33,12 @@ class ThumbnailWithInfo extends StatelessWidget {
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
borderRadius: BorderRadius.circular(borderRadius),
color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
),
child: imageUrl != null
? ClipRRect(
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(borderRadius),
child: CachedNetworkImage(
width: double.infinity,
height: double.infinity,
Expand All @@ -55,15 +59,32 @@ class ThumbnailWithInfo extends StatelessWidget {
),
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(borderRadius),
color: Colors.white,
gradient: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
Colors.grey.withOpacity(0.0),
textInfo == ''
? Colors.black.withOpacity(0.1)
: Colors.black.withOpacity(0.5),
],
stops: const [0.0, 1.0],
),
),
),
Positioned(
bottom: 12,
left: 14,
child: Text(
textInfo,
textInfo == '' ? textInfo : textInfo.capitalizeFirstLetter(),
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 12,
fontSize: 14,
),
),
),
Expand Down
Loading

0 comments on commit 10ccbea

Please sign in to comment.