-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathtest_suite_card.dart
More file actions
150 lines (141 loc) · 4.36 KB
/
test_suite_card.dart
File metadata and controls
150 lines (141 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2025 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2025-08-14
*
*/
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../services/testing/testing_models.dart';
import '../../../services/testing/testing_service.dart';
import '../../../themes/stack_colors.dart';
import '../../../utilities/text_styles.dart';
import '../../../widgets/loading_indicator.dart';
import '../../../widgets/rounded_white_container.dart';
class TestSuiteCard extends ConsumerWidget {
const TestSuiteCard({
super.key,
required this.testType,
required this.status,
this.onTap,
});
final TestType testType;
final TestSuiteStatus status;
final VoidCallback? onTap;
@override
Widget build(BuildContext context, WidgetRef ref) {
final testingService = ref.read(testingServiceProvider.notifier);
final colors = Theme.of(context).extension<StackColors>()!;
return GestureDetector(
onTap: onTap,
child: RoundedWhiteContainer(
padding: const EdgeInsets.all(2),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
testingService.getDisplayNameForTest(testType),
style: STextStyles.titleBold12(context),
),
const SizedBox(height: 2),
Text(
_getSubtitleForStatus(status),
style: STextStyles.label(context).copyWith(
color: _getColorForStatus(status, colors),
),
),
],
),
),
const SizedBox(width: 12),
const SizedBox(
width: 20,
height: 20,
),
],
),
),
Positioned.fill(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(right: 12),
child: _buildStatusIndicator(status, colors),
),
],
),
),
],
),
),
);
}
Widget _buildStatusIndicator(TestSuiteStatus status, StackColors colors) {
switch (status) {
case TestSuiteStatus.waiting:
return Icon(
Icons.schedule,
size: 20,
color: colors.textSubtitle1,
);
case TestSuiteStatus.running:
return const SizedBox(
width: 20,
height: 20,
child: LoadingIndicator(
width: 20,
height: 20,
),
);
case TestSuiteStatus.passed:
return Icon(
Icons.check_circle,
size: 20,
color: colors.accentColorGreen,
);
case TestSuiteStatus.failed:
return Icon(
Icons.error,
size: 20,
color: colors.accentColorRed,
);
}
}
String _getSubtitleForStatus(TestSuiteStatus status) {
switch (status) {
case TestSuiteStatus.waiting:
return "Ready to test";
case TestSuiteStatus.running:
return "Running tests...";
case TestSuiteStatus.passed:
return "All tests passed";
case TestSuiteStatus.failed:
return "Tests failed";
}
}
Color _getColorForStatus(TestSuiteStatus status, StackColors colors) {
switch (status) {
case TestSuiteStatus.waiting:
return colors.textSubtitle1;
case TestSuiteStatus.running:
return colors.accentColorGreen;
case TestSuiteStatus.passed:
return colors.accentColorGreen;
case TestSuiteStatus.failed:
return colors.accentColorRed;
}
}
}