diff --git a/lib/main.dart b/lib/main.dart index aa8d62e..4251456 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,15 +7,15 @@ void main() { class MyApp extends StatelessWidget { const MyApp({super.key}); - @override + @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), - home: const MyHomePage(title: 'Yacobchuk S.V.'), + home: const MyHomePage(title: 'Yackobchuk S.V.'), ); } } @@ -23,8 +23,6 @@ class MyApp extends StatelessWidget { class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); - - final String title; @override @@ -32,39 +30,145 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - _counter++; - }); - } + final Color _color = Colors.orangeAccent; @override Widget build(BuildContext context) { - return Scaffold( + return Scaffold( appBar: AppBar( - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - title: Text(widget.title), + backgroundColor: _color, + title: Text(widget.title), ), - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), ); + body: const MyWidget(), + ); } } + +class _CardData{ + final String text; + final String descriptionText; + final IconData icon; + final String? imageUrl; + + _CardData( + this.text, { + required this.descriptionText, + this.icon= Icons.ac_unit_outlined, + this.imageUrl, + }); +} + +class MyWidget extends StatelessWidget { + const MyWidget({super.key}); // ключи + + @override + Widget build(BuildContext context) { + final data = [ + _CardData( + 'mouse', + descriptionText: 'hahaha', + icon: Icons.abc, + imageUrl: + 'https://sun34-1.userapi.com/impg/_DLT-op0LbBdgh5h-ILvC7IMDY5kbLR349v7vA/tX7vtk6mNlA.jpg?size=736x736&quality=96&sign=47f2b0f63bf249c62f4498fb637695d5&type=album' + ), + _CardData( + 'mouse2', + descriptionText: 'ahahaha', + icon: Icons.access_alarm_outlined, + imageUrl: + 'https://sun165-1.userapi.com/impg/EVLbaLilqr8xw5tsqZLQQb6DSYrdKo7Q9sYSsw/H4FRwyMR6Ec.jpg?size=1280x960&quality=96&sign=f606e4ae3d1ccd27917cd1ffa6d91e58&type=album' + ), + _CardData( + 'mouse3', + descriptionText: 'eeee', + icon: Icons.access_alarm_rounded, + imageUrl: + 'https://sun165-1.userapi.com/impg/Jxmp-zwq--f7KagZ6HuImLY7HrgQo-kyP1xhmw/JejdXP88_VE.jpg?size=736x981&quality=96&sign=5597f4d123422be17118ff4b1f570a9d&type=album' + ), + ]; + + return Center( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: data.map((e) => _Card.fromData(e)).toList(), + ) + ), + ); + } +} + +class _Card extends StatelessWidget { + final String text; + final String descriptionText; + final IconData icon; + final String? imageUrl; + + const _Card( + this.text, { + this.icon = Icons.ac_unit_outlined, + required this.descriptionText, + this.imageUrl, + }); + + factory _Card.fromData(_CardData data) => _Card( + data.text, + descriptionText: data.descriptionText, + icon: data.icon, + imageUrl: data.imageUrl, + ); + + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(top: 16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.orangeAccent, + borderRadius: BorderRadius.circular(20), + border: Border.all( + color: Colors.black12, + width: 2 + ) + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + SizedBox( + height: 140, + width: 100, + child: Image.network( + imageUrl ?? '', + errorBuilder: (_, __, ___) => const Placeholder(), + ) + ), + Expanded ( + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + text, + style: Theme.of(context).textTheme.headlineLarge, + ), + Text( + descriptionText, + style: Theme.of(context).textTheme.bodyLarge, + ) + ], + ), + ), + ), + const Spacer(), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Icon(icon), + ), + ], + ), + ); + } +} \ No newline at end of file