Created
May 25, 2022 07:04
-
-
Save bullheadandplato/51e0d50ccd1fd868a01971ddd500e0f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:collection/collection.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:ticaret_yeri/domain/ad/ad_info.dart'; | |
class HighlightView extends StatelessWidget { | |
final List<AdInfo> highlights; | |
const HighlightView({Key? key, required this.highlights}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return highlights.isEmpty | |
? const SizedBox.shrink() | |
: GridView.count( | |
crossAxisCount: 2, | |
shrinkWrap: true, | |
childAspectRatio: 1 / 0.4, | |
physics: const NeverScrollableScrollPhysics(), | |
children: highlights | |
.mapIndexed((index, e) => _HighlightItemView( | |
info: e, | |
index: index, | |
)) | |
.toList()); | |
} | |
} | |
class _HighlightItemView extends StatelessWidget { | |
final AdInfo info; | |
final int index; | |
const _HighlightItemView({Key? key, required this.info, required this.index}) | |
: super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final theme = Theme.of(context); | |
return Container( | |
decoration: BoxDecoration( | |
border: Border( | |
bottom: BorderSide(color: Colors.black.withAlpha(20)), | |
left: index % 2 == 0 | |
? BorderSide.none | |
: BorderSide(color: Colors.black.withAlpha(20))), | |
color: const Color(0xfffff9f5)), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text( | |
info.name, | |
style: theme.textTheme.bodySmall | |
?.copyWith(color: theme.primaryColor), | |
textAlign: TextAlign.center, | |
), | |
const SizedBox( | |
height: 2, | |
), | |
Text( | |
info.value, | |
maxLines: 2, | |
overflow: TextOverflow.ellipsis, | |
style: theme.textTheme.bodySmall?.copyWith(color: Colors.black), | |
textAlign: TextAlign.center, | |
), | |
]), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment