flutter fixes and pipeline speedup
This commit is contained in:
@@ -68,17 +68,20 @@ class _TractionPageState extends State<TractionPage> {
|
||||
}
|
||||
|
||||
bool get _hasFilters {
|
||||
final dynamicFieldsUsed = _dynamicControllers.values
|
||||
.any((controller) => controller.text.trim().isNotEmpty) ||
|
||||
_enumSelections.values
|
||||
.any((value) => (value ?? '').toString().trim().isNotEmpty);
|
||||
final dynamicFieldsUsed =
|
||||
_dynamicControllers.values.any(
|
||||
(controller) => controller.text.trim().isNotEmpty,
|
||||
) ||
|
||||
_enumSelections.values.any(
|
||||
(value) => (value ?? '').toString().trim().isNotEmpty,
|
||||
);
|
||||
|
||||
return [
|
||||
_selectedClass,
|
||||
_classController.text,
|
||||
_numberController.text,
|
||||
_nameController.text,
|
||||
].any((value) => (value ?? '').toString().trim().isNotEmpty) ||
|
||||
_selectedClass,
|
||||
_classController.text,
|
||||
_numberController.text,
|
||||
_nameController.text,
|
||||
].any((value) => (value ?? '').toString().trim().isNotEmpty) ||
|
||||
dynamicFieldsUsed;
|
||||
}
|
||||
|
||||
@@ -109,7 +112,11 @@ class _TractionPageState extends State<TractionPage> {
|
||||
}
|
||||
|
||||
void _clearFilters() {
|
||||
for (final controller in [_classController, _numberController, _nameController]) {
|
||||
for (final controller in [
|
||||
_classController,
|
||||
_numberController,
|
||||
_nameController,
|
||||
]) {
|
||||
controller.clear();
|
||||
}
|
||||
for (final controller in _dynamicControllers.values) {
|
||||
@@ -135,9 +142,13 @@ class _TractionPageState extends State<TractionPage> {
|
||||
List<EventField> _activeEventFields(List<EventField> fields) {
|
||||
return fields
|
||||
.where(
|
||||
(field) =>
|
||||
!['class', 'number', 'name', 'build date', 'build_date']
|
||||
.contains(field.name.toLowerCase()),
|
||||
(field) => ![
|
||||
'class',
|
||||
'number',
|
||||
'name',
|
||||
'build date',
|
||||
'build_date',
|
||||
].contains(field.name.toLowerCase()),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
@@ -147,7 +158,10 @@ class _TractionPageState extends State<TractionPage> {
|
||||
if (field.enumValues != null) {
|
||||
_enumSelections.putIfAbsent(field.name, () => null);
|
||||
} else {
|
||||
_dynamicControllers.putIfAbsent(field.name, () => TextEditingController());
|
||||
_dynamicControllers.putIfAbsent(
|
||||
field.name,
|
||||
() => TextEditingController(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,17 +242,22 @@ class _TractionPageState extends State<TractionPage> {
|
||||
);
|
||||
},
|
||||
fieldViewBuilder:
|
||||
(context, controller, focusNode, onFieldSubmitted) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Class',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onSubmitted: (_) => _refreshTraction(),
|
||||
);
|
||||
},
|
||||
(
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Class',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onSubmitted: (_) => _refreshTraction(),
|
||||
);
|
||||
},
|
||||
optionsViewBuilder: (context, onSelected, options) {
|
||||
final optionList = options.toList();
|
||||
if (optionList.isEmpty) {
|
||||
@@ -323,7 +342,9 @@ class _TractionPageState extends State<TractionPage> {
|
||||
: Icons.expand_more,
|
||||
),
|
||||
label: Text(
|
||||
_showAdvancedFilters ? 'Hide filters' : 'More filters',
|
||||
_showAdvancedFilters
|
||||
? 'Hide filters'
|
||||
: 'More filters',
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
@@ -344,24 +365,26 @@ class _TractionPageState extends State<TractionPage> {
|
||||
? const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
)
|
||||
: extraFields.isEmpty
|
||||
? const Text('No extra filters available right now.')
|
||||
: Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: extraFields
|
||||
.map(
|
||||
(field) => _buildFilterInput(
|
||||
context,
|
||||
field,
|
||||
isMobile,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
? const Text('No extra filters available right now.')
|
||||
: Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: extraFields
|
||||
.map(
|
||||
(field) => _buildFilterInput(
|
||||
context,
|
||||
field,
|
||||
isMobile,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
secondChild: const SizedBox.shrink(),
|
||||
),
|
||||
@@ -404,8 +427,9 @@ class _TractionPageState extends State<TractionPage> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: OutlinedButton.icon(
|
||||
onPressed:
|
||||
data.isTractionLoading ? null : () => _refreshTraction(append: true),
|
||||
onPressed: data.isTractionLoading
|
||||
? null
|
||||
: () => _refreshTraction(append: true),
|
||||
icon: data.isTractionLoading
|
||||
? const SizedBox(
|
||||
height: 14,
|
||||
@@ -580,7 +604,11 @@ class _TractionPageState extends State<TractionPage> {
|
||||
(Color, Color) _statusChipColors(BuildContext context, String status) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final isDark = scheme.brightness == Brightness.dark;
|
||||
Color blend(Color base, {double bgOpacity = 0.18, double fgOpacity = 0.82}) {
|
||||
Color blend(
|
||||
Color base, {
|
||||
double bgOpacity = 0.18,
|
||||
double fgOpacity = 0.82,
|
||||
}) {
|
||||
final bg = Color.alphaBlend(
|
||||
base.withOpacity(isDark ? bgOpacity + 0.07 : bgOpacity),
|
||||
scheme.surface,
|
||||
@@ -719,7 +747,10 @@ class _TractionPageState extends State<TractionPage> {
|
||||
) {
|
||||
final width = isMobile ? double.infinity : 220.0;
|
||||
if (field.enumValues != null && field.enumValues!.isNotEmpty) {
|
||||
final options = field.enumValues!.map((e) => e.toString()).toSet().toList();
|
||||
final options = field.enumValues!
|
||||
.map((e) => e.toString())
|
||||
.toSet()
|
||||
.toList();
|
||||
final currentValue = _enumSelections[field.name];
|
||||
final safeValue = options.contains(currentValue) ? currentValue : null;
|
||||
return SizedBox(
|
||||
@@ -732,14 +763,9 @@ class _TractionPageState extends State<TractionPage> {
|
||||
),
|
||||
items: [
|
||||
const DropdownMenuItem(value: null, child: Text('Any')),
|
||||
...options
|
||||
.map(
|
||||
(value) => DropdownMenuItem(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
...options.map(
|
||||
(value) => DropdownMenuItem(value: value, child: Text(value)),
|
||||
),
|
||||
],
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
@@ -757,7 +783,9 @@ class _TractionPageState extends State<TractionPage> {
|
||||
TextInputType? inputType;
|
||||
if (field.type != null) {
|
||||
final type = field.type!.toLowerCase();
|
||||
if (type.contains('int') || type.contains('num') || type.contains('double')) {
|
||||
if (type.contains('int') ||
|
||||
type.contains('num') ||
|
||||
type.contains('double')) {
|
||||
inputType = const TextInputType.numberWithOptions(decimal: true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user