-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
artifact_card.dart
92 lines (86 loc) · 2.83 KB
/
artifact_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
80
81
82
83
84
85
86
87
88
89
90
91
92
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:genshindb/application/bloc.dart';
import 'package:genshindb/domain/models/models.dart';
import 'package:genshindb/presentation/artifact/artifact_page.dart';
import 'package:genshindb/presentation/shared/extensions/rarity_extensions.dart';
import 'package:genshindb/presentation/shared/gradient_card.dart';
import 'package:genshindb/presentation/shared/rarity.dart';
import 'package:genshindb/presentation/shared/styles.dart';
import 'package:transparent_image/transparent_image.dart';
import 'artifact_stats.dart';
class ArtifactCard extends StatelessWidget {
final String keyName;
final String name;
final String image;
final int rarity;
final List<ArtifactCardBonusModel> bonus;
final double imgWidth;
final double imgHeight;
final bool withoutDetails;
const ArtifactCard({
Key key,
@required this.keyName,
@required this.name,
@required this.image,
@required this.rarity,
@required this.bonus,
this.imgWidth = 140,
this.imgHeight = 120,
}) : withoutDetails = false,
super(key: key);
const ArtifactCard.withoutDetails({
Key key,
@required this.keyName,
@required this.name,
@required this.image,
@required this.rarity,
}) : imgWidth = 70,
imgHeight = 60,
bonus = const [],
withoutDetails = true,
super(key: key);
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return InkWell(
onTap: () => _gotoDetailPage(context),
child: GradientCard(
shape: Styles.mainCardShape,
elevation: Styles.cardTenElevation,
gradient: rarity.getRarityGradient(),
child: Padding(
padding: Styles.edgeInsetAll5,
child: Column(
children: [
FadeInImage(
width: imgWidth,
height: imgHeight,
placeholder: MemoryImage(kTransparentImage),
image: AssetImage(image),
),
if (!withoutDetails)
Center(
child: Tooltip(
message: name,
child: Text(
name,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold),
),
),
),
Rarity(stars: rarity),
if (bonus.isNotEmpty) ArtifactStats(bonus: bonus),
],
),
),
),
);
}
Future<void> _gotoDetailPage(BuildContext context) async {
context.read<ArtifactBloc>().add(ArtifactEvent.loadArtifact(key: keyName));
final route = MaterialPageRoute(builder: (ctx) => ArtifactPage());
await Navigator.of(context).push(route);
}
}