Skip to content

Commit

Permalink
fix(client): Exception widget for organization drop down
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Aug 3, 2024
1 parent 05a8a5d commit 580d5df
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
74 changes: 41 additions & 33 deletions wrestling_scoreboard_client/lib/view/screens/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,45 +177,53 @@ class HomeState extends ConsumerState<Home> {
},
),
),
Row(children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: SimpleDropdown<Type?>(
options: [null, ...dataTypes..remove(ParticipantState)].map((type) => MapEntry(
type,
Text(type != null ? localizeType(context, type) : '${localizations.optionSelect} Type'),
)),
selected: searchType,
onChange: (value) {
setState(() {
searchType = value;
});
},
isExpanded: false,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child:
ManyConsumer<Organization, Null>(builder: (BuildContext context, List<Organization> organizations) {
return SimpleDropdown<Organization?>(
options: [null, ...organizations].map((organization) => MapEntry(
organization,
Text(organization != null
? organization.name
: '${localizations.optionSelect} ${localizations.organization}'),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: SimpleDropdown<Type?>(
options: [null, ...dataTypes..remove(ParticipantState)].map((type) => MapEntry(
type,
Text(type != null ? localizeType(context, type) : '${localizations.optionSelect} Type'),
)),
selected: searchOrganization,
selected: searchType,
onChange: (value) {
setState(() {
searchOrganization = value;
searchType = value;
});
},
isExpanded: false,
);
}),
),
]),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: ManyConsumer<Organization, Null>(
builder: (BuildContext context, List<Organization> organizations) {
return SimpleDropdown<Organization?>(
options: [null, ...organizations].map((organization) => MapEntry(
organization,
Text(organization != null
? organization.name
: '${localizations.optionSelect} ${localizations.organization}'),
)),
selected: searchOrganization,
onChange: (value) {
setState(() {
searchOrganization = value;
});
},
isExpanded: false,
);
},
onException: (context, exception, {stackTrace}) => SizedBox(
width: 250,
child: ExceptionInfo(AppLocalizations.of(context)!.notFoundException, stackTrace: stackTrace),
),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(
Expand Down
4 changes: 3 additions & 1 deletion wrestling_scoreboard_client/lib/view/widgets/consumer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ class ManyConsumer<T extends DataObject, S extends DataObject?> extends Consumer
final List<T>? initialData;
final S? filterObject;
final Widget Function(BuildContext context, List<T> data) builder;
final Widget Function(BuildContext context, Object? exception, {StackTrace? stackTrace})? onException;

const ManyConsumer({required this.builder, this.initialData, this.filterObject, super.key});
const ManyConsumer({required this.builder, this.onException, this.initialData, this.filterObject, super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -98,6 +99,7 @@ class ManyConsumer<T extends DataObject, S extends DataObject?> extends Consumer
.onWebSocketConnection
.sink
.add(WebSocketConnectionState.connecting),
onException: onException,
);
}
}
Expand Down

0 comments on commit 580d5df

Please sign in to comment.