Skip to content

Commit

Permalink
Resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 committed Feb 27, 2022
2 parents d2edc0b + bfde308 commit e608c61
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 39 deletions.
4 changes: 1 addition & 3 deletions mobile/lib/modules/home/ui/immich_sliver_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import 'package:immich_mobile/shared/providers/backup.provider.dart';
class ImmichSliverAppBar extends ConsumerWidget {
const ImmichSliverAppBar({
Key? key,
required this.imageGridGroup,
this.onPopBack,
}) : super(key: key);

final List<Widget> imageGridGroup;
final Function? onPopBack;

@override
Expand Down Expand Up @@ -46,7 +44,7 @@ class ImmichSliverAppBar extends ConsumerWidget {
style: GoogleFonts.snowburstOne(
textStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
fontSize: 22,
color: Theme.of(context).primaryColor,
),
),
Expand Down
9 changes: 1 addition & 8 deletions mobile/lib/modules/home/views/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class HomePage extends HookConsumerWidget {
return null;
}, []);

onPopBackFromBackupPage() {
// ref.read(assetProvider.notifier).getAllAsset();
}

Widget _buildBody() {
if (assetGroupByDateTime.isNotEmpty) {
int? lastMonth;
Expand Down Expand Up @@ -88,10 +84,7 @@ class HomePage extends HookConsumerWidget {
child: null,
),
)
: ImmichSliverAppBar(
imageGridGroup: _imageGridGroup,
onPopBack: onPopBackFromBackupPage,
),
: const ImmichSliverAppBar(),
duration: const Duration(milliseconds: 350),
),
..._imageGridGroup
Expand Down
5 changes: 3 additions & 2 deletions mobile/lib/modules/login/ui/login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LoginForm extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final usernameController = useTextEditingController(text: '[email protected]');
final passwordController = useTextEditingController(text: 'password');
final serverEndpointController = useTextEditingController(text: 'http://192.168.1.103:2283');
final serverEndpointController = useTextEditingController(text: 'http://192.168.1.216:2283');

return Center(
child: ConstrainedBox(
Expand Down Expand Up @@ -124,7 +124,8 @@ class LoginButton extends ConsumerWidget {
if (isAuthenicated) {
// Resume backup (if enable) then navigate
ref.watch(backupProvider.notifier).resumeBackup();
AutoRouter.of(context).pushNamed("/home-page");
// AutoRouter.of(context).pushNamed("/home-page");
AutoRouter.of(context).pushNamed("/tab-controller-page");
} else {
ImmichToast.show(
context: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,47 @@ import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

<<<<<<< HEAD
=======
import 'package:immich_mobile/modules/search/services/search.service.dart';

>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
class SearchPageState {
final String searchTerm;
final bool isSearchEnabled;
final List<String> searchSuggestion;
<<<<<<< HEAD
=======
final List<String> userSuggestedSearchTerms;
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

SearchPageState({
required this.searchTerm,
required this.isSearchEnabled,
required this.searchSuggestion,
<<<<<<< HEAD
=======
required this.userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
});

SearchPageState copyWith({
String? searchTerm,
bool? isSearchEnabled,
List<String>? searchSuggestion,
<<<<<<< HEAD
=======
List<String>? userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}) {
return SearchPageState(
searchTerm: searchTerm ?? this.searchTerm,
isSearchEnabled: isSearchEnabled ?? this.isSearchEnabled,
searchSuggestion: searchSuggestion ?? this.searchSuggestion,
<<<<<<< HEAD
=======
userSuggestedSearchTerms: userSuggestedSearchTerms ?? this.userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
);
}

Expand All @@ -31,6 +52,10 @@ class SearchPageState {
'searchTerm': searchTerm,
'isSearchEnabled': isSearchEnabled,
'searchSuggestion': searchSuggestion,
<<<<<<< HEAD
=======
'userSuggestedSearchTerms': userSuggestedSearchTerms,
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
};
}

Expand All @@ -39,6 +64,10 @@ class SearchPageState {
searchTerm: map['searchTerm'] ?? '',
isSearchEnabled: map['isSearchEnabled'] ?? false,
searchSuggestion: List<String>.from(map['searchSuggestion']),
<<<<<<< HEAD
=======
userSuggestedSearchTerms: List<String>.from(map['userSuggestedSearchTerms']),
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
);
}

Expand All @@ -47,8 +76,14 @@ class SearchPageState {
factory SearchPageState.fromJson(String source) => SearchPageState.fromMap(json.decode(source));

@override
<<<<<<< HEAD
String toString() =>
'SearchPageState(searchTerm: $searchTerm, isSearchEnabled: $isSearchEnabled, searchSuggestion: $searchSuggestion)';
=======
String toString() {
return 'SearchPageState(searchTerm: $searchTerm, isSearchEnabled: $isSearchEnabled, searchSuggestion: $searchSuggestion, userSuggestedSearchTerms: $userSuggestedSearchTerms)';
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

@override
bool operator ==(Object other) {
Expand All @@ -58,11 +93,25 @@ class SearchPageState {
return other is SearchPageState &&
other.searchTerm == searchTerm &&
other.isSearchEnabled == isSearchEnabled &&
<<<<<<< HEAD
listEquals(other.searchSuggestion, searchSuggestion);
}

@override
int get hashCode => searchTerm.hashCode ^ isSearchEnabled.hashCode ^ searchSuggestion.hashCode;
=======
listEquals(other.searchSuggestion, searchSuggestion) &&
listEquals(other.userSuggestedSearchTerms, userSuggestedSearchTerms);
}

@override
int get hashCode {
return searchTerm.hashCode ^
isSearchEnabled.hashCode ^
searchSuggestion.hashCode ^
userSuggestedSearchTerms.hashCode;
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}

class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
Expand All @@ -72,9 +121,18 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
searchTerm: "",
isSearchEnabled: false,
searchSuggestion: [],
<<<<<<< HEAD
),
);

=======
userSuggestedSearchTerms: [],
),
);

final SearchService _searchService = SearchService();

>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
void enableSearch() {
state = state.copyWith(isSearchEnabled: true);
}
Expand All @@ -90,7 +148,11 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
}

void _getSearchSuggestion(String searchTerm) {
<<<<<<< HEAD
var searchList = ['January', '01 2022', 'feburary', "February", 'home', '3413'];
=======
var searchList = state.userSuggestedSearchTerms;
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18

var newList = searchList.where((e) => e.toLowerCase().contains(searchTerm));

Expand All @@ -100,6 +162,15 @@ class SearchPageStateNotifier extends StateNotifier<SearchPageState> {
state = state.copyWith(searchSuggestion: []);
}
}
<<<<<<< HEAD
=======

void getSuggestedSearchTerms() async {
var userSuggestedSearchTerms = await _searchService.getUserSuggestedSearchTerms();

state = state.copyWith(userSuggestedSearchTerms: userSuggestedSearchTerms);
}
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}

final searchPageStateProvider = StateNotifierProvider<SearchPageStateNotifier, SearchPageState>((ref) {
Expand Down
20 changes: 20 additions & 0 deletions mobile/lib/modules/search/services/search.service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:immich_mobile/shared/services/network.service.dart';

class SearchService {
final NetworkService _networkService = NetworkService();

Future<List<String>?> getUserSuggestedSearchTerms() async {
try {
var res = await _networkService.getRequest(url: "asset/searchTerm");
List<dynamic> decodedData = jsonDecode(res.toString());

return List.from(decodedData);
} catch (e) {
debugPrint("[ERROR] [getUserSuggestedSearchTerms] ${e.toString()}");
return [];
}
}
}
4 changes: 4 additions & 0 deletions mobile/lib/modules/search/ui/search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class SearchBar extends HookConsumerWidget with PreferredSizeWidget {
focusNode: searchFocusNode,
autofocus: false,
onTap: () {
<<<<<<< HEAD
=======
ref.watch(searchPageStateProvider.notifier).getSuggestedSearchTerms();
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
ref.watch(searchPageStateProvider.notifier).enableSearch();
searchFocusNode.requestFocus();
},
Expand Down
6 changes: 6 additions & 0 deletions mobile/lib/modules/search/views/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ class SearchPage extends HookConsumerWidget {
final isSearchEnabled = ref.watch(searchPageStateProvider).isSearchEnabled;

useEffect(() {
<<<<<<< HEAD
searchFocusNode = FocusNode();
return () {
searchFocusNode.dispose();
};
=======
print("search");
searchFocusNode = FocusNode();
return () => searchFocusNode.dispose();
>>>>>>> bfde3084924e247bc8f7004babf38605fe341a18
}, []);

return Scaffold(
Expand Down
13 changes: 11 additions & 2 deletions mobile/lib/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import 'package:auto_route/auto_route.dart';
import 'package:flutter/widgets.dart';
import 'package:immich_mobile/modules/login/views/login_page.dart';
import 'package:immich_mobile/modules/home/views/home_page.dart';
import 'package:immich_mobile/modules/search/views/search_page.dart';
import 'package:immich_mobile/routing/auth_guard.dart';
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
import 'package:immich_mobile/shared/views/backup_controller_page.dart';
import 'package:immich_mobile/modules/asset_viewer/views/image_viewer_page.dart';
import 'package:immich_mobile/shared/views/tab_controller_page.dart';
import 'package:immich_mobile/shared/views/video_viewer_page.dart';

part 'router.gr.dart';
Expand All @@ -14,10 +16,17 @@ part 'router.gr.dart';
replaceInRouteName: 'Page,Route',
routes: <AutoRoute>[
AutoRoute(page: LoginPage, initial: true),
AutoRoute(page: HomePage, guards: [AuthGuard]),
AutoRoute(page: BackupControllerPage, guards: [AuthGuard]),
AutoRoute(
page: TabControllerPage,
guards: [AuthGuard],
children: [
AutoRoute(page: HomePage, guards: [AuthGuard]),
AutoRoute(page: SearchPage, guards: [AuthGuard])
],
),
AutoRoute(page: ImageViewerPage, guards: [AuthGuard]),
AutoRoute(page: VideoViewerPage, guards: [AuthGuard]),
AutoRoute(page: BackupControllerPage, guards: [AuthGuard]),
],
)
class AppRouter extends _$AppRouter {
Expand Down
Loading

0 comments on commit e608c61

Please sign in to comment.