2020-04-25 18:59:07 +03:00
|
|
|
part of '../main.dart';
|
|
|
|
|
|
|
|
class EntityButtonCard extends StatelessWidget {
|
|
|
|
|
2020-04-27 01:46:37 +03:00
|
|
|
final ButtonCardData card;
|
2020-04-25 18:59:07 +03:00
|
|
|
|
|
|
|
EntityButtonCard({
|
|
|
|
Key key, this.card
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-04-27 01:46:37 +03:00
|
|
|
EntityWrapper entityWrapper = card.entity;
|
2020-04-25 23:53:08 +03:00
|
|
|
if (entityWrapper.entity.statelessType == StatelessEntityType.missed) {
|
2020-04-27 01:46:37 +03:00
|
|
|
return EntityModel(
|
|
|
|
entityWrapper: card.entity,
|
|
|
|
child: MissedEntityWidget(),
|
|
|
|
handleTap: false,
|
|
|
|
);
|
2020-04-25 23:53:08 +03:00
|
|
|
} else if (entityWrapper.entity.statelessType != StatelessEntityType.ghost && entityWrapper.entity.statelessType != StatelessEntityType.none) {
|
2020-04-25 18:59:07 +03:00
|
|
|
return Container(width: 0.0, height: 0.0,);
|
|
|
|
}
|
2020-04-27 23:56:33 +03:00
|
|
|
|
|
|
|
double iconSize = math.max(card.iconHeightPx, card.iconHeightRem * Theme.of(context).textTheme.body1.fontSize);
|
2020-04-25 18:59:07 +03:00
|
|
|
|
2020-04-25 23:53:08 +03:00
|
|
|
Widget buttonIcon;
|
2020-04-27 01:46:37 +03:00
|
|
|
if (!card.showIcon) {
|
2020-04-25 23:53:08 +03:00
|
|
|
buttonIcon = Container(height: Sizes.rowPadding, width: 10);
|
2020-04-27 23:56:33 +03:00
|
|
|
} else if (iconSize > 0) {
|
|
|
|
buttonIcon = SizedBox(
|
|
|
|
height: iconSize,
|
|
|
|
child: FractionallySizedBox(
|
|
|
|
widthFactor: 0.5,
|
|
|
|
child: FittedBox(
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
child: EntityIcon(
|
|
|
|
//padding: EdgeInsets.only(top: 6),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
);
|
2020-04-25 23:53:08 +03:00
|
|
|
} else {
|
2020-04-27 23:56:33 +03:00
|
|
|
buttonIcon = AspectRatio(
|
|
|
|
aspectRatio: 2,
|
|
|
|
child: FractionallySizedBox(
|
|
|
|
widthFactor: 0.5,
|
|
|
|
child: FittedBox(
|
|
|
|
fit: BoxFit.fitWidth,
|
|
|
|
child: EntityIcon(
|
|
|
|
//padding: EdgeInsets.only(top: 6),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
),
|
2020-04-25 23:53:08 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-25 18:59:07 +03:00
|
|
|
return CardWrapper(
|
2020-04-25 23:53:08 +03:00
|
|
|
child: EntityModel(
|
2020-04-27 01:46:37 +03:00
|
|
|
entityWrapper: card.entity,
|
2020-04-25 23:53:08 +03:00
|
|
|
child: InkWell(
|
|
|
|
onTap: () => entityWrapper.handleTap(),
|
|
|
|
onLongPress: () => entityWrapper.handleHold(),
|
|
|
|
onDoubleTap: () => entityWrapper.handleDoubleTap(),
|
2020-04-27 01:46:37 +03:00
|
|
|
child: Center(
|
2020-05-08 16:59:04 +03:00
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(top: 5),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: <Widget>[
|
|
|
|
buttonIcon,
|
|
|
|
_buildName(context)
|
|
|
|
],
|
|
|
|
)
|
2020-04-25 23:53:08 +03:00
|
|
|
)
|
2020-04-25 18:59:07 +03:00
|
|
|
),
|
|
|
|
),
|
2020-04-25 23:53:08 +03:00
|
|
|
handleTap: true
|
2020-04-25 18:59:07 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-27 23:56:33 +03:00
|
|
|
Widget _buildName(BuildContext context) {
|
2020-04-25 18:59:07 +03:00
|
|
|
if (card.showName) {
|
|
|
|
return EntityName(
|
|
|
|
padding: EdgeInsets.fromLTRB(Sizes.buttonPadding, 0.0, Sizes.buttonPadding, Sizes.rowPadding),
|
|
|
|
textOverflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 3,
|
2020-04-27 23:56:33 +03:00
|
|
|
textStyle: Theme.of(context).textTheme.subhead,
|
2020-04-25 18:59:07 +03:00
|
|
|
wordsWrap: true,
|
|
|
|
textAlign: TextAlign.center
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container(width: 0, height: 0);
|
|
|
|
}
|
|
|
|
}
|