68 lines
1.8 KiB
Dart
68 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:labs/presentation/home_page/home_page.dart';
|
|
import 'CourseStatus.dart';
|
|
import 'University.dart';
|
|
import 'domain/models/Student.dart';
|
|
|
|
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 = [];
|
|
|
|
void _addStudent() async {
|
|
await Future.delayed(Duration(seconds: 1));
|
|
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'),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
child: MyHomePage(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|