feat: basic trainer support
This commit is contained in:
94
lib/model/trainer_model.dart
Normal file
94
lib/model/trainer_model.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class TrainerModel {
|
||||
const TrainerModel(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.family,
|
||||
required this.bundles,
|
||||
required this.manual});
|
||||
final String id;
|
||||
final String name;
|
||||
final String family;
|
||||
final List<String> bundles;
|
||||
final bool manual;
|
||||
|
||||
static Future<List<TrainerModel>> load() async {
|
||||
final data =
|
||||
jsonDecode(await rootBundle.loadString('assets/trainer_models.json'))
|
||||
as List;
|
||||
return data
|
||||
.map((entry) => TrainerModel(
|
||||
id: entry['id'] as String,
|
||||
name: entry['name'] as String,
|
||||
family: entry['family'] as String,
|
||||
bundles: List<String>.from(entry['bundles'] as List),
|
||||
manual: entry['manual'] as bool))
|
||||
.toList();
|
||||
}
|
||||
|
||||
bool matches(String query) {
|
||||
final text =
|
||||
'$name $family $id ${family == 'ifit' ? 'ProForm NordicTrack' : ''}'
|
||||
.toLowerCase();
|
||||
return query
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.split(RegExp(r'\s+'))
|
||||
.every(text.contains);
|
||||
}
|
||||
|
||||
String get limitations {
|
||||
if ([
|
||||
'schwinn-ic4',
|
||||
'yesoul',
|
||||
'cycling-sensors',
|
||||
'elite-misuro',
|
||||
'keiser-m3i',
|
||||
'ifit-freestride',
|
||||
'flywheel',
|
||||
'lifefit-ic5',
|
||||
'sole-bike',
|
||||
'sole-r92',
|
||||
'kettler-c12',
|
||||
'inspire',
|
||||
'keep-bike',
|
||||
'mcf-bike',
|
||||
'volava',
|
||||
'ultrasport',
|
||||
'apex-bike',
|
||||
'npe-cable',
|
||||
'csc-bike',
|
||||
'lifespan-bike',
|
||||
'xcx-bike',
|
||||
'chrono-bike',
|
||||
'mepanel',
|
||||
'octane-q37',
|
||||
'fitplus-bike',
|
||||
'snode-bike'
|
||||
].contains(id) ||
|
||||
family == 'nautilus') {
|
||||
return 'Data only';
|
||||
}
|
||||
if (family == 'ftms' || id == 'renpho' || id == 'horizon-gr7') {
|
||||
return 'Controls depend on trainer features';
|
||||
}
|
||||
if (['tacx', 'elite', 'wahoo'].contains(family)) {
|
||||
return 'Power control. Simulation support varies';
|
||||
}
|
||||
if (id == 'cycleops') return 'Power control';
|
||||
if (id == 'technogym') return 'Power and resistance control';
|
||||
return 'Resistance control. Features vary by model';
|
||||
}
|
||||
|
||||
String get bundleLabel => bundles
|
||||
.map((b) => switch (b) {
|
||||
'standard' => 'Standard',
|
||||
'legacy' => 'Legacy fitness equipment',
|
||||
'ifit' => 'iFit / ProForm / NordicTrack',
|
||||
'vendor' => 'Vendor bikes / ellipticals',
|
||||
_ => b,
|
||||
})
|
||||
.join(', ');
|
||||
}
|
||||
Reference in New Issue
Block a user