-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1733 from ardriveapp/dev
PE-6085: Release ArDrive App v2.43.0
- Loading branch information
Showing
18 changed files
with
714 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- New Feature: Search (for quickly locating files and navigating through folders and drives) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:ardrive/search/domain/repository/search_repository.dart'; | ||
import 'package:ardrive/search/search_result.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
part 'search_event.dart'; | ||
part 'search_state.dart'; | ||
|
||
class SearchBloc extends Bloc<SearchEvent, SearchState> { | ||
final SearchRepository _searchRepository; | ||
|
||
SearchBloc( | ||
this._searchRepository, | ||
) : super(SearchInitial()) { | ||
on<SearchEvent>((event, emit) async { | ||
if (event is SearchQueryChanged) { | ||
if (event.query.isEmpty) { | ||
emit(SearchQueryEmpty()); | ||
} else { | ||
final results = await _searchRepository.search(event.query); | ||
|
||
if (results.isEmpty) { | ||
emit(SearchEmpty()); | ||
} else { | ||
emit(SearchSuccess(results)); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
part of 'search_bloc.dart'; | ||
|
||
sealed class SearchEvent extends Equatable { | ||
const SearchEvent(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class SearchQueryChanged extends SearchEvent { | ||
final String query; | ||
|
||
const SearchQueryChanged(this.query); | ||
|
||
@override | ||
List<Object> get props => [query]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
part of 'search_bloc.dart'; | ||
|
||
sealed class SearchState extends Equatable { | ||
const SearchState(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
final class SearchInitial extends SearchState {} | ||
|
||
final class SearchEmpty extends SearchState {} | ||
|
||
final class SearchQueryEmpty extends SearchState {} | ||
|
||
final class SearchSuccess extends SearchState { | ||
final List<SearchResult> results; | ||
|
||
const SearchSuccess(this.results); | ||
|
||
@override | ||
List<Object> get props => [results]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:ardrive/models/daos/drive_dao/drive_dao.dart'; | ||
import 'package:ardrive/search/search_result.dart'; | ||
|
||
abstract class SearchRepository { | ||
Future<List<SearchResult>> search(String query); | ||
} | ||
|
||
class ArDriveSearchRepository implements SearchRepository { | ||
final DriveDao _driveDao; | ||
|
||
ArDriveSearchRepository(this._driveDao); | ||
|
||
@override | ||
Future<List<SearchResult>> search(String query) async { | ||
if (query.isEmpty) return Future.value([]); | ||
|
||
String sanitizedQuery = query.toLowerCase(); | ||
|
||
return _driveDao.search(query: sanitizedQuery, type: SearchQueryType.name); | ||
} | ||
} |
Oops, something went wrong.