Commit ab9c5258 authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

stop user filter being case sensitive and dumb

parent 6807fa46
......@@ -99,6 +99,4 @@ tags
# End of https://www.gitignore.io/api/vim,dart,linux,macos,visualstudiocode
lib/main.dart
test/common_data.dart
\ No newline at end of file
lib/main.dart
\ No newline at end of file
......@@ -113,14 +113,24 @@ class UsersBloc extends Bloc<UsersEvent, UsersState> {
yield UsersState.exception(e);
}
} else if (event is FilterUsers) {
_filteredList = _users.where((User user) => user.name.contains(event.username)).toList();
final f = event.username.toLowerCase();
_filteredList = _users.where((User user) => user.name.contains(f)).toList();
yield UsersState.result(_filteredList);
} else if (event is FilterAll) {
final f = event.filter.toLowerCase();
_filteredList = _users
.where((User user) =>
user.name.toLowerCase().contains(f) ||
(user.card?.toString() ?? '').toLowerCase().contains(f))
.toList();
}
}
void onCreateUser(String name, String password, {int card, int pin}) =>
add(CreateUser(name, password, card: card, pin: pin));
void onFilter(String filter) => add(FilterAll(filter));
void onFilterByUser(String username) => add(FilterUsers(username));
void onGetCredit(int userId) => add(GetCredit(userId));
......
......@@ -19,6 +19,17 @@ class CreateUser extends UsersEvent {
String toString() => toMap().toString();
}
class FilterAll extends UsersEvent {
final String filter;
FilterAll(this.filter);
Map<String, dynamic> toMap() => <String, dynamic>{'filter': filter};
@override
String toString() => toMap().toString();
}
class FilterUsers extends UsersEvent {
final String username;
......
name: blocs_astaprint
version: 1.0.0
version: 1.0.1
description: >-
Business Logic for the AStAPrint admin interface
author: Leon Tappe <ltappe@asta.upb.de>
......
const String user = 'ltappe';
const String pw = 'Johnnycash_1';
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment