PIbd-32_Stroev_V_M_PMD/lib/main.dart

68 lines
1.8 KiB
Dart
Raw Permalink Normal View History

2024-10-01 20:53:17 +04:00
import 'package:flutter/material.dart';
2024-10-22 08:55:54 +04:00
import 'package:labs/presentation/home_page/home_page.dart';
2024-10-02 23:27:54 +04:00
import 'CourseStatus.dart';
2024-10-01 20:53:17 +04:00
import 'University.dart';
2024-10-22 08:55:54 +04:00
import 'domain/models/Student.dart';
2024-10-01 20:53:17 +04:00
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'University App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: UniversityScreen(),
);
}
}
class UniversityScreen extends StatefulWidget {
@override
_UniversityScreenState createState() => _UniversityScreenState();
}
class _UniversityScreenState extends State<UniversityScreen> {
final University university = University();
final TextEditingController nameController = TextEditingController();
final TextEditingController ageController = TextEditingController();
List<String> selectedCourses = [];
2024-10-03 15:39:20 +04:00
void _addStudent() async {
await Future.delayed(Duration(seconds: 1));
2024-10-01 20:53:17 +04:00
String name = nameController.text;
int age = int.tryParse(ageController.text) ?? 0;
if (name.isNotEmpty && age > 0 && selectedCourses.isNotEmpty) {
setState(() {
// Создаем новый список курсов для каждого студента
List<String> studentCourses = List.from(selectedCourses);
university.addStudent(Student(name, age, studentCourses));
nameController.clear();
ageController.clear();
selectedCourses.clear();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Строев Владимир, ПИбд-32'),
),
2024-10-02 23:27:54 +04:00
body: Column(
2024-10-01 20:53:17 +04:00
children: [
Expanded(
2024-10-22 08:55:54 +04:00
child: MyHomePage(),
2024-10-01 20:53:17 +04:00
),
],
2024-10-02 23:27:54 +04:00
),
2024-10-02 22:51:30 +04:00
);
}
}