ecosystem_simulation/lib/main_screen.dart

107 lines
3.6 KiB
Dart
Raw Normal View History

2024-08-31 13:32:04 +02:00
import 'package:ecosim/src/benchmark/benchmark_screen.dart';
import 'package:ecosim/src/ecosim/params_screen.dart';
import 'package:ecosim/src/seeking/seeking_screen.dart';
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
// Start screen of the application
// Here the user can select which simulation
// they want to run
class MainScreen extends StatelessWidget {
const MainScreen({super.key});
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
return Scaffold(
appBar: AppBar(
title: Text(
'Ecosystem Simulation',
style: theme.textTheme.h3,
),
),
body: SingleChildScrollView(
child: Center(
child: Column(
children: [
const SizedBox(height: 32),
ShadButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ParameterScreen(),
),
);
},
text: const Text("Start Ecosystem Simulation"),
),
const SizedBox(height: 32),
const Divider(),
const SizedBox(height: 16),
Text(
'Other Simulation Demos',
style: theme.textTheme.lead,
),
const SizedBox(height: 16),
ShadButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SeekingScreen(),
),
);
},
text: const Text("Seeking a Target"),
),
const SizedBox(height: 16),
ShadButton(
onPressed: () {
showShadDialog(
2024-10-06 21:27:39 +02:00
context: context,
builder: (context) {
final formKey = GlobalKey<ShadFormState>();
return ShadDialog(
title: const Text('Set Benchmark Boid Count'),
content: Column(
children: [
ShadForm(
key: formKey,
child: ShadInputFormField(
label: const Text('Boid Count'),
id: 'benchmark_boid_count',
initialValue: '500',
2024-08-31 13:32:04 +02:00
),
2024-10-06 21:27:39 +02:00
),
ShadButton(
text: const Text('Start Benchmark'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
BenchmarkSimulationScreen(
boids: int.parse(formKey.currentState!
.value['benchmark_boid_count']),
2024-08-31 13:32:04 +02:00
),
2024-10-06 21:27:39 +02:00
),
);
},
)
],
),
);
},
);
2024-08-31 13:32:04 +02:00
},
text: const Text("Benchmark"),
),
],
),
),
),
);
}
}