From 27b47afa09132947caf916d106dc35fd1d4710a3 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:01:11 +0400 Subject: [PATCH] lab2-lection --- lib/ExtensionStudent.dart | 1 - lib/main.dart | 106 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/lib/ExtensionStudent.dart b/lib/ExtensionStudent.dart index 1a0a349..12206d5 100644 --- a/lib/ExtensionStudent.dart +++ b/lib/ExtensionStudent.dart @@ -1,4 +1,3 @@ -import 'CourseStatus.dart'; import 'Student.dart'; extension StudentCourseStatus on Student { diff --git a/lib/main.dart b/lib/main.dart index a1a5431..b1db378 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'CourseStatus.dart'; import 'University.dart'; import 'student.dart'; @@ -53,7 +52,8 @@ class _UniversityScreenState extends State { appBar: AppBar( title: Text('Строев Владимир, ПИбд-32'), ), - body: Column( + body: const MyWidget() + /*Column( children: [ Padding( padding: const EdgeInsets.all(8.0), @@ -120,7 +120,107 @@ class _UniversityScreenState extends State { ), ), ], + )*/, + ); + } +} + +class MyWidget extends StatelessWidget { + const MyWidget ({super.key}); + + @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( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: data.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? 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', + }); + + factory _Card.fromData(_CardData data) => _Card(data.text, + icon: data.icon, + descriptionText: data.descriptionText); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(top: 16), + decoration: BoxDecoration( + color: Colors.orangeAccent, + borderRadius: BorderRadius.circular(20), + ), + padding: const EdgeInsets.all(16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(20), + child: SizedBox( + height: 140, + width: 100, + child: Image.network(imageUrl ?? '', + fit: BoxFit.cover, + errorBuilder: (_, __, ___) => const Placeholder(),), + ), + ), + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(text, style: Theme.of(context).textTheme.headlineLarge + ), + Text(descriptionText, style: Theme.of(context).textTheme.bodyLarge) + ], + ), + ), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Icon(icon), + ), + ], ), ); } -} \ No newline at end of file +}