cellular-automata/lib/components/configuration_component.dart

50 lines
1.6 KiB
Dart

import 'package:angular/angular.dart';
import 'package:angular_components/material_button/material_button.dart';
import 'package:angular_components/material_icon/material_icon.dart';
import 'package:angular_components/material_input/material_input.dart';
import 'package:angular_components/material_input/material_number_accessor.dart';
import 'package:angular_components/material_slider/material_slider.dart';
import 'package:angular_components/material_tooltip/material_tooltip.dart';
import 'package:rules_of_living/service/configuration_service.dart';
@Component(
selector: "configuration",
templateUrl: "configuration_component.html",
styleUrls: [
"configuration_component.css"
],
directives: [
MaterialButtonComponent,
MaterialIconComponent,
MaterialSliderComponent,
MaterialTooltipDirective,
materialInputDirectives,
materialNumberInputDirectives,
NgModel
])
class ConfigurationComponent {
final ConfigurationService config;
int get width => config.gridSize.x;
void set width(num value) {
if (value == null || value <= 0) return;
config.setGridSize(x: value.toInt());
}
int get height => config.gridSize.y;
void set height(num value) {
if (value == null || value <= 0) return;
config.setGridSize(y: value.toInt());
}
int get simSpeed => config.simSpeed;
void set simSpeed(int value) => config.simSpeed = value;
String get speedSliderTooltip => "Simulation Speed: $simSpeed";
ConfigurationComponent(this.config);
void onEdgesClicked() {
config.toggleGrid();
}
}