This commit is contained in:
Alessandro Autiero
2024-05-20 17:24:00 +02:00
parent 7c2caed16c
commit 9f5590d41c
562 changed files with 3303 additions and 156787 deletions

View File

@@ -3,17 +3,38 @@ import 'package:reboot_common/common.dart';
class BuildController extends GetxController {
List<FortniteBuild>? _builds;
Rxn<FortniteBuild> selectedBuild;
Rxn<FortniteBuild> _selectedBuild;
Rx<FortniteBuildSource> _selectedBuildSource;
BuildController() : selectedBuild = Rxn();
BuildController() : _selectedBuild = Rxn(),
_selectedBuildSource = Rx(FortniteBuildSource.manifest);
List<FortniteBuild>? get builds => _builds;
FortniteBuild? get selectedBuild => _selectedBuild.value;
set selectedBuild(FortniteBuild? value) {
_selectedBuild.value = value;
if(value != null && value.source != value.source) {
_selectedBuildSource.value = value.source;
}
}
FortniteBuildSource get selectedBuildSource => _selectedBuildSource.value;
set selectedBuildSource(FortniteBuildSource value) {
_selectedBuildSource.value = value;
final selected = selectedBuild;
if(selected == null || selected.source != value) {
final selectable = builds?.firstWhereOrNull((element) => element.source == value);
_selectedBuild.value = selectable;
}
}
set builds(List<FortniteBuild>? builds) {
_builds = builds;
if(builds == null || builds.isEmpty){
return;
}
selectedBuild.value = builds[0];
final selectable = builds?.firstWhereOrNull((element) => element.source == selectedBuildSource);
_selectedBuild.value = selectable;
}
}