Skip to content

Commit

Permalink
[Presentation] Added a gradient param to the circle item widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Apr 16, 2022
1 parent e6c4a53 commit f202879
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/presentation/shared/images/circle_character.dart
Expand Up @@ -10,6 +10,7 @@ class CircleCharacter extends StatelessWidget {
final double radius;
final bool forDrag;
final Function(String)? onTap;
final Gradient? gradient;

const CircleCharacter({
Key? key,
Expand All @@ -18,6 +19,7 @@ class CircleCharacter extends StatelessWidget {
this.radius = 35,
this.forDrag = false,
this.onTap,
this.gradient,
}) : super(key: key);

CircleCharacter.fromItem({
Expand All @@ -26,6 +28,7 @@ class CircleCharacter extends StatelessWidget {
this.radius = 35,
this.forDrag = false,
this.onTap,
this.gradient,
}) : itemKey = item.key,
image = item.image,
super(key: key);
Expand All @@ -37,6 +40,7 @@ class CircleCharacter extends StatelessWidget {
forDrag: forDrag,
onTap: (img) => onTap != null ? onTap!(img) : _gotoCharacterPage(context),
radius: radius,
gradient: gradient,
);
}

Expand Down
15 changes: 14 additions & 1 deletion lib/presentation/shared/images/circle_item.dart
Expand Up @@ -9,6 +9,8 @@ class CircleItem extends StatelessWidget {
final Function(String)? onTap;
final BoxFit fit;
final Alignment alignment;
final Color backgroundColor;
final Gradient? gradient;

const CircleItem({
Key? key,
Expand All @@ -19,6 +21,8 @@ class CircleItem extends StatelessWidget {
this.onTap,
this.fit = BoxFit.cover,
this.alignment = Alignment.topCenter,
this.backgroundColor = Colors.transparent,
this.gradient,
}) : super(key: key);

@override
Expand All @@ -27,7 +31,7 @@ class CircleItem extends StatelessWidget {
final size = imageSizeTimesTwo ? radius * 2 : radius;
final avatar = CircleAvatar(
radius: radius,
backgroundColor: Colors.transparent,
backgroundColor: backgroundColor,
child: ClipOval(
child: FadeInImage(
placeholder: MemoryImage(kTransparentImage),
Expand All @@ -40,12 +44,21 @@ class CircleItem extends StatelessWidget {
),
);

final boxDecoration = BoxDecoration(shape: BoxShape.circle, gradient: gradient);

if (forDrag) {
if (gradient != null) {
return Container(
decoration: boxDecoration,
child: avatar,
);
}
return avatar;
}

return Container(
margin: const EdgeInsets.all(3),
decoration: boxDecoration,
child: InkWell(
radius: radius,
borderRadius: BorderRadius.circular(radius),
Expand Down
4 changes: 4 additions & 0 deletions lib/presentation/shared/images/circle_weapon.dart
Expand Up @@ -10,6 +10,7 @@ class CircleWeapon extends StatelessWidget {
final double radius;
final bool forDrag;
final Function(String)? onTap;
final Gradient? gradient;

const CircleWeapon({
Key? key,
Expand All @@ -18,6 +19,7 @@ class CircleWeapon extends StatelessWidget {
this.radius = 30,
this.forDrag = false,
this.onTap,
this.gradient,
}) : super(key: key);

CircleWeapon.fromItem({
Expand All @@ -26,6 +28,7 @@ class CircleWeapon extends StatelessWidget {
this.radius = 30,
this.forDrag = false,
this.onTap,
this.gradient,
}) : itemKey = item.key,
image = item.image,
super(key: key);
Expand All @@ -37,6 +40,7 @@ class CircleWeapon extends StatelessWidget {
radius: radius,
forDrag: forDrag,
onTap: (img) => onTap != null ? onTap!(img) : _gotoWeaponPage(context),
gradient: gradient,
);
}

Expand Down

0 comments on commit f202879

Please sign in to comment.