Reduce size of card badges, and change trade offers to show all cards by default, but in minimized mode. expand button now toggles between minimized mode and expanded mode for all cards on the trade offer
This commit is contained in:
parent
01becbee48
commit
fa4f38301b
16 changed files with 117 additions and 236 deletions
|
|
@ -97,19 +97,12 @@ def render_trade_offer_png(context, offer, show_friend_code=False):
|
|||
]
|
||||
|
||||
num_cards = max(len(have_cards_available), len(want_cards_available))
|
||||
aspect_ratio = 1.91
|
||||
base_height = (round(num_cards / 2) * 56) + 138
|
||||
image_height = (num_cards * 52) + ((num_cards - 1) * 8) + 106
|
||||
# cards | padding between cards | header/footer
|
||||
if (len(have_cards_available) + len(want_cards_available)) >= 4:
|
||||
base_width = (4 * 144) + 96
|
||||
image_width = (4 * 160) + 160
|
||||
else:
|
||||
base_width = (2 * 144) + 128
|
||||
|
||||
if base_height > base_width:
|
||||
image_height = base_height
|
||||
image_width = int(round(image_height * aspect_ratio)) + 1
|
||||
else:
|
||||
image_width = base_width
|
||||
image_height = int(round(image_width / aspect_ratio))
|
||||
image_width = (2 * 160) + 92
|
||||
|
||||
request = context.get("request")
|
||||
if request.get_host().startswith("localhost"):
|
||||
|
|
@ -129,6 +122,7 @@ def render_trade_offer_png(context, offer, show_friend_code=False):
|
|||
'friend_code': offer.initiated_by.friend_code,
|
||||
'show_friend_code': show_friend_code,
|
||||
'num_cards_available': len(have_cards_available) + len(want_cards_available),
|
||||
'expanded': (len(have_cards_available) + len(want_cards_available)) >= 4,
|
||||
'image_width': image_width,
|
||||
'image_height': image_height,
|
||||
'base_url': base_url,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from meta.views import Meta
|
|||
from .models import TradeOffer, TradeAcceptance
|
||||
from .forms import (TradeAcceptanceCreateForm, TradeOfferCreateForm, TradeAcceptanceTransitionForm)
|
||||
from django.template.loader import render_to_string
|
||||
from trades.templatetags.trade_offer_tags import render_trade_offer
|
||||
from trades.templatetags.trade_offer_tags import render_trade_offer_png
|
||||
from playwright.sync_api import sync_playwright
|
||||
from django.conf import settings
|
||||
from .mixins import FriendCodeRequiredMixin
|
||||
|
|
@ -514,7 +514,7 @@ class TradeOfferPNGView(View):
|
|||
trade_offer.image.open()
|
||||
return HttpResponse(trade_offer.image.read(), content_type="image/png")
|
||||
|
||||
tag_context = trade_offer_tags.render_trade_offer_png(
|
||||
tag_context = render_trade_offer_png(
|
||||
{'request': request}, trade_offer, show_friend_code=True
|
||||
)
|
||||
image_width = tag_context.get('image_width')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue