-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reporting environment issues #213
Changes from 2 commits
6110b71
2f2ef42
41256c5
3648b34
a5cf24a
3946c07
77786ae
dbaf6a2
a123a51
90bcf0e
2b44add
e7e97d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
|
||
import '../../providers/test_events.dart'; | ||
import '../expandable.dart'; | ||
import '../blocking_provider_preloader.dart'; | ||
|
||
class TestEventLogExpandable extends ConsumerWidget { | ||
class TestEventLogExpandable extends StatelessWidget { | ||
const TestEventLogExpandable({ | ||
super.key, | ||
required this.testExecutionId, | ||
|
@@ -16,66 +14,57 @@ class TestEventLogExpandable extends ConsumerWidget { | |
final bool initiallyExpanded; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final testEvents = ref.watch(testEventsProvider(testExecutionId)); | ||
|
||
return Expandable( | ||
title: const Text('Event Log'), | ||
initiallyExpanded: initiallyExpanded, | ||
children: <Widget>[ | ||
testEvents.when( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we deleting the Expandable here, I don't see it anywhere in the new code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried manually testing everything now, so hopefully I didn't miss anything else |
||
loading: () => const Center(child: YaruCircularProgressIndicator()), | ||
error: (error, stackTrace) => Center(child: Text('Error: $error')), | ||
data: (testEvents) => DataTable( | ||
columns: const <DataColumn>[ | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Event Name', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
), | ||
Widget build(BuildContext context) { | ||
return BlockingProviderPreloader( | ||
provider: testEventsProvider(testExecutionId), | ||
builder: (_, testEvents) => DataTable( | ||
columns: const <DataColumn>[ | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Event Name', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Timestamp', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
), | ||
), | ||
), | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Timestamp', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Detail', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
), | ||
), | ||
), | ||
DataColumn( | ||
label: Expanded( | ||
child: Text( | ||
'Detail', | ||
style: TextStyle(fontStyle: FontStyle.italic), | ||
), | ||
], | ||
rows: testEvents | ||
.map( | ||
(testEvent) => DataRow( | ||
cells: <DataCell>[ | ||
DataCell(Text(testEvent.eventName)), | ||
DataCell(Text(testEvent.timestamp)), | ||
DataCell( | ||
Tooltip( | ||
message: testEvent.detail, | ||
child: Text( | ||
testEvent.detail, | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 1, | ||
), | ||
), | ||
), | ||
), | ||
], | ||
rows: testEvents | ||
.map( | ||
(testEvent) => DataRow( | ||
cells: <DataCell>[ | ||
DataCell(Text(testEvent.eventName)), | ||
DataCell(Text(testEvent.timestamp)), | ||
DataCell( | ||
Tooltip( | ||
message: testEvent.detail, | ||
child: Text( | ||
testEvent.detail, | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 1, | ||
), | ||
], | ||
), | ||
), | ||
) | ||
.toList(), | ||
), | ||
), | ||
], | ||
], | ||
), | ||
) | ||
.toList(), | ||
), | ||
); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:yaru/yaru.dart'; | ||
|
||
class BlockingProviderPreloader<T> extends ConsumerWidget { | ||
const BlockingProviderPreloader({ | ||
super.key, | ||
required this.provider, | ||
required this.builder, | ||
}); | ||
|
||
final ProviderListenable<AsyncValue<T>> provider; | ||
final Widget Function(BuildContext context, T value) builder; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final value = ref.watch(provider); | ||
|
||
return value.when( | ||
data: (value) => builder(context, value), | ||
error: (e, stack) => | ||
Center(child: Text('Error:\n$e\nStackTrace:\n$stack')), | ||
loading: () => const Center(child: YaruCircularProgressIndicator()), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe make the TestCaseIsueePreloader a generic
ReportedIssuesPreloader
that will watch for both providers, it seems like we are repeating most of the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired by this comment, I refactored most loading of providers into two widgets:
NonBlockingProviderPreloader
andBlockingProviderRreloader
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can you not love a code clean-up 😄