|
| 1 | +import 'package:collection/collection.dart'; |
| 2 | +import 'package:flutter/widgets.dart'; |
| 3 | + |
| 4 | +import '../base/TextContentBig.dart'; |
| 5 | +import '../base/TextSubtitle.dart'; |
| 6 | + |
| 7 | +class BioInfoModel { |
| 8 | + String resourcePath; |
| 9 | + String title; |
| 10 | + String description; |
| 11 | + |
| 12 | + BioInfoModel(this.resourcePath, this.title, this.description); |
| 13 | +} |
| 14 | + |
| 15 | +class BioInfoContent extends StatelessWidget { |
| 16 | + final List<BioInfoModel> data; |
| 17 | + |
| 18 | + const BioInfoContent({super.key, required this.data}); |
| 19 | + |
| 20 | + @override |
| 21 | + Widget build(BuildContext context) { |
| 22 | + return Wrap( |
| 23 | + children: data.mapIndexed((int index, BioInfoModel item) { |
| 24 | + bool isFullScreenWidth = (index + 1) % 3 == 0; |
| 25 | + return BioInfoCard(isFullWidth: isFullScreenWidth, model: item); |
| 26 | + }).toList()); |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +class BioInfoCard extends StatelessWidget { |
| 31 | + bool isFullWidth = false; |
| 32 | + BioInfoModel model; |
| 33 | + |
| 34 | + BioInfoCard({super.key, this.isFullWidth = false, required this.model}); |
| 35 | + |
| 36 | + @override |
| 37 | + Widget build(BuildContext context) { |
| 38 | + return LayoutBuilder( |
| 39 | + builder: (BuildContext context, BoxConstraints constraints) { |
| 40 | + bool enableVerticalScreenMode = constraints.maxWidth <= 600; |
| 41 | + |
| 42 | + double? containerWidth; |
| 43 | + |
| 44 | + if (enableVerticalScreenMode || isFullWidth) { |
| 45 | + containerWidth = constraints.maxWidth; |
| 46 | + } else { |
| 47 | + containerWidth = constraints.maxWidth / 2; |
| 48 | + } |
| 49 | + |
| 50 | + return Container( |
| 51 | + width: containerWidth, |
| 52 | + height: 320.0, |
| 53 | + padding: EdgeInsets.all(4.0), |
| 54 | + child: Container( |
| 55 | + decoration: BoxDecoration( |
| 56 | + image: DecorationImage( |
| 57 | + image: AssetImage(model.resourcePath), fit: BoxFit.fitWidth)), |
| 58 | + child: Column( |
| 59 | + mainAxisAlignment: MainAxisAlignment.center, |
| 60 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 61 | + children: [ |
| 62 | + TextSubtitle(text: model.title), |
| 63 | + TextContentBig(text: model.description) |
| 64 | + ], |
| 65 | + ), |
| 66 | + ) |
| 67 | + ); |
| 68 | + }); |
| 69 | + } |
| 70 | +} |
0 commit comments