lab3
This commit is contained in:
parent
d912a9656b
commit
20046f13f6
109
lib/main.dart
109
lib/main.dart
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'CourseStatus.dart';
|
||||
import 'University.dart';
|
||||
import 'student.dart';
|
||||
|
||||
@ -52,8 +53,7 @@ class _UniversityScreenState extends State<UniversityScreen> {
|
||||
appBar: AppBar(
|
||||
title: Text('Строев Владимир, ПИбд-32'),
|
||||
),
|
||||
body: const MyWidget()
|
||||
/*Column(
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -108,92 +108,74 @@ class _UniversityScreenState extends State<UniversityScreen> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: university.students.length,
|
||||
itemBuilder: (context, index) {
|
||||
Student student = university.students[index];
|
||||
return ListTile(
|
||||
title: Text(student.name),
|
||||
subtitle: Text('Age: ${student.age}, Courses: ${student.courses.join(", ")}'),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: MyWidget(students: university.students),
|
||||
),
|
||||
],
|
||||
)*/,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyWidget extends StatelessWidget {
|
||||
const MyWidget ({super.key});
|
||||
final List<Student> students;
|
||||
|
||||
const MyWidget({super.key, required this.students});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final data = [
|
||||
_CardData(
|
||||
text: "Hello",
|
||||
icon: Icons.warning_amber,
|
||||
descriptionText: "mumumu"),
|
||||
_CardData(
|
||||
text: 'H',
|
||||
descriptionText: "pupupu",),
|
||||
_CardData(
|
||||
text: "LLo",
|
||||
icon: Icons.dangerous,
|
||||
descriptionText: "kukuku"),
|
||||
];
|
||||
return Center(
|
||||
child:SingleChildScrollView(
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: data.map((e) => _Card.fromData(e)).toList(),
|
||||
children: students.map((e) => _Card.fromData(e)).toList(),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CardData{
|
||||
final String text;
|
||||
final IconData icon;
|
||||
final String descriptionText;
|
||||
final String? imageUrl;
|
||||
|
||||
_CardData({required this.text,
|
||||
this.icon = Icons.ac_unit_outlined,
|
||||
required this.descriptionText,
|
||||
this.imageUrl,});
|
||||
}
|
||||
|
||||
class _Card extends StatelessWidget {
|
||||
final String text;
|
||||
final IconData icon;
|
||||
final String descriptionText;
|
||||
final String name;
|
||||
final int age;
|
||||
final List<String> courses;
|
||||
final String? imageUrl;
|
||||
|
||||
const _Card(this.text, {
|
||||
this.icon = Icons.ac_unit_outlined,
|
||||
required this.descriptionText,
|
||||
this.imageUrl = 'https://distribution.faceit-cdn.net/images/679409f5-2896-4942-b976-62f5d31bd9eb.jpeg',
|
||||
const _Card(this.name, {
|
||||
required this.age,
|
||||
required this.courses,
|
||||
this.imageUrl = 'https://gryazoveckij-r19.gosweb.gosuslugi.ru/netcat_files/460/2008/net_foto_muzh.jpg',
|
||||
});
|
||||
|
||||
factory _Card.fromData(_CardData data) => _Card(data.text,
|
||||
icon: data.icon,
|
||||
descriptionText: data.descriptionText);
|
||||
String getYearWord(int age) {
|
||||
if (age % 10 == 1) {
|
||||
return " год";
|
||||
} else if (age % 10 < 5 && age % 10 != 0) {
|
||||
return " года";
|
||||
} else {
|
||||
return " лет";
|
||||
}
|
||||
}
|
||||
|
||||
factory _Card.fromData(Student data) => _Card(data.name,
|
||||
age: data.age, courses: data.courses);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 16),
|
||||
margin: const EdgeInsets.only(top: 16, left: 16, right: 16, bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.orangeAccent,
|
||||
color: Colors.blueAccent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@ -205,20 +187,19 @@ class _Card extends StatelessWidget {
|
||||
errorBuilder: (_, __, ___) => const Placeholder(),),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(text, style: Theme.of(context).textTheme.headlineLarge
|
||||
),
|
||||
Text(descriptionText, style: Theme.of(context).textTheme.bodyLarge)
|
||||
Text(name, style: Theme.of(context).textTheme.headlineLarge),
|
||||
SizedBox(height: 8),
|
||||
Text(age.toString() + getYearWord(age), style: Theme.of(context).textTheme.bodyLarge),
|
||||
SizedBox(height: 8),
|
||||
Text('Courses: ${courses.join(", ")}', style: Theme.of(context).textTheme.bodyMedium),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Icon(icon),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user