-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
element_reaction_card.dart
79 lines (75 loc) · 2.36 KB
/
element_reaction_card.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import 'package:flutter/material.dart';
import 'package:genshindb/presentation/shared/images/element_image.dart';
import 'package:genshindb/presentation/shared/styles.dart';
class ElementReactionCard extends StatelessWidget {
final String name;
final String effect;
final List<String> principal;
final List<String> secondary;
final bool showPlusIcon;
final bool showImages;
final String? description;
const ElementReactionCard.withImages({
Key? key,
required this.name,
required this.effect,
required this.principal,
required this.secondary,
this.showPlusIcon = true,
}) : showImages = true,
description = null,
super(key: key);
const ElementReactionCard.withoutImage({
Key? key,
required this.name,
required this.effect,
required this.description,
this.showPlusIcon = true,
}) : principal = const [],
secondary = const [],
showImages = false,
super(key: key);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final principalImgs = principal.map((e) => ElementImage.fromPath(path: e)).toList();
final secondaryImgs = secondary.map((e) => ElementImage.fromPath(path: e)).toList();
return Card(
shape: Styles.cardShape,
margin: Styles.edgeInsetAll5,
child: Padding(
padding: Styles.edgeInsetAll5,
child: Column(
children: [
if (showImages)
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
alignment: WrapAlignment.center,
children: [
...principalImgs,
if (showPlusIcon) const Icon(Icons.add),
...secondaryImgs,
],
),
if (!showImages)
Text(
description!,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold),
),
Text(
name,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold),
),
Text(
effect,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle2!.copyWith(fontSize: 12),
)
],
),
),
);
}
}