-
-
Notifications
You must be signed in to change notification settings - Fork 63
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 #9 from Frezyx/dev
Implement filter and FlutterTalkerData models
- Loading branch information
Showing
33 changed files
with
556 additions
and
133 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
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## 0.6.0 | ||
- Implement filter for logs | ||
|
||
## 0.5.2 | ||
- Add title for default models | ||
|
||
## 0.5.1 | ||
- Fix README images urls | ||
|
||
|
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 @@ | ||
export 'talker_filter.dart'; |
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,67 @@ | ||
import 'package:talker/src/src.dart'; | ||
|
||
abstract class Filter<T> { | ||
bool filter(T item); | ||
} | ||
|
||
class TalkerFilter implements Filter<TalkerDataInterface> { | ||
TalkerFilter({ | ||
required this.titles, | ||
required this.types, | ||
this.searchQuery, | ||
}); | ||
|
||
final List<String> titles; | ||
final List<Type> types; | ||
final String? searchQuery; | ||
|
||
@override | ||
bool filter(TalkerDataInterface item) { | ||
var match = false; | ||
|
||
if (titles.isNotEmpty) { | ||
match = match || titles.contains(item.displayTitle); | ||
} | ||
|
||
if (types.isNotEmpty) { | ||
match = match || _checkTypeMatch(item); | ||
} | ||
|
||
if (searchQuery?.isNotEmpty ?? false) { | ||
final fullMsg = item.generateTextMessage(); | ||
final fullUpperMsg = fullMsg.toUpperCase(); | ||
final fullLowerMsg = fullMsg.toLowerCase(); | ||
final textContain = fullUpperMsg.contains(searchQuery!) || | ||
fullLowerMsg.contains(searchQuery!); | ||
match = match || textContain; | ||
} | ||
|
||
if (titles.isEmpty && types.isEmpty && (searchQuery?.isEmpty ?? true)) { | ||
match = true; | ||
} | ||
return match; | ||
} | ||
|
||
bool _checkTypeMatch(TalkerDataInterface item) { | ||
var match = false; | ||
for (final type in types) { | ||
if (item.runtimeType == type) { | ||
match = true; | ||
break; | ||
} | ||
} | ||
return match; | ||
} | ||
|
||
TalkerFilter copyWith({ | ||
List<String>? titles, | ||
List<Type>? types, | ||
String? searchQuery, | ||
}) { | ||
return TalkerFilter( | ||
titles: titles ?? this.titles, | ||
types: types ?? this.types, | ||
searchQuery: searchQuery ?? this.searchQuery, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'filter/filter.dart'; | ||
export 'talker_data/talker_data.dart'; |
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
Oops, something went wrong.