Resolves #539 Fix button card without entity

This commit is contained in:
Yegor Vialov
2020-04-25 20:53:08 +00:00
parent 05c1427aa8
commit 2c3335ebf3
11 changed files with 115 additions and 104 deletions

View File

@ -10,39 +10,45 @@ class EntityButtonCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
card.linkedEntityWrapper.overrideName = card.name?.toUpperCase() ??
card.linkedEntityWrapper.displayName.toUpperCase();
//card.linkedEntityWrapper.overrideName = card.name?.toUpperCase() ??
// card.linkedEntityWrapper.displayName.toUpperCase();
EntityWrapper entityWrapper = card.linkedEntityWrapper;
if (entityWrapper.entity.statelessType == StatelessEntityType.MISSED) {
if (entityWrapper.entity.statelessType == StatelessEntityType.missed) {
return MissedEntityWidget();
}
if (entityWrapper.entity.statelessType > StatelessEntityType.MISSED) {
} else if (entityWrapper.entity.statelessType != StatelessEntityType.ghost && entityWrapper.entity.statelessType != StatelessEntityType.none) {
return Container(width: 0.0, height: 0.0,);
}
double widthBase = math.min(MediaQuery.of(context).size.width, MediaQuery.of(context).size.height) / 6;
Widget buttonIcon;
if (entityWrapper.icon == null || entityWrapper.icon.isEmpty) {
buttonIcon = Container(height: Sizes.rowPadding, width: 10);
} else {
buttonIcon = EntityIcon(
padding: EdgeInsets.fromLTRB(2.0, 6.0, 2.0, 2.0),
size: widthBase / (card.depth * 0.5),
);
}
return CardWrapper(
child: Center(
child: EntityModel(
entityWrapper: card.linkedEntityWrapper,
child: InkWell(
onTap: () => entityWrapper.handleTap(),
onLongPress: () => entityWrapper.handleHold(),
onDoubleTap: () => entityWrapper.handleDoubleTap(),
child: EntityModel(
entityWrapper: card.linkedEntityWrapper,
child: InkWell(
onTap: () => entityWrapper.handleTap(),
onLongPress: () => entityWrapper.handleHold(),
onDoubleTap: () => entityWrapper.handleDoubleTap(),
child: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
EntityIcon(
padding: EdgeInsets.fromLTRB(2.0, 6.0, 2.0, 2.0),
size: widthBase / (card.depth * 0.5),
),
buttonIcon,
_buildName()
],
),
)
),
handleTap: true
),
handleTap: true
)
);
}