Skip to content

Commit 9bf6944

Browse files
committed
Add support for custom logos and icons in Apple Wallet passes
1 parent 4756dd5 commit 9bf6944

3 files changed

Lines changed: 47 additions & 11 deletions

File tree

indico_custom_pass/plugin.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from indico_custom_pass.settings import CustomPassSettingsForm
77

8+
89
class CustomPassPlugin(IndicoPlugin):
910
"""Custom Pass
1011
@@ -16,7 +17,10 @@ class CustomPassPlugin(IndicoPlugin):
1617
'apple_pass_background_color': '#007cac',
1718
'apple_pass_foreground_color': '#ffffff',
1819
'apple_pass_label_color': '#ffffff',
19-
'apple_pass_organization_name': 'Indico',
20+
'apple_pass_logo_text': 'Indico',
21+
'apple_pass_customize_logo': False,
22+
'apple_pass_custom_icon_url': '',
23+
'apple_pass_custom_logo_url': '',
2024
'google_pass_background_color': '#007cac'
2125
}
2226

@@ -31,7 +35,21 @@ def build_pass_object(self, registration):
3135
p.backgroundColor = CustomPassPlugin.settings.get('apple_pass_background_color')
3236
p.foregroundColor = CustomPassPlugin.settings.get('apple_pass_foreground_color')
3337
p.labelColor = CustomPassPlugin.settings.get('apple_pass_label_color')
34-
p.organizationName = CustomPassPlugin.settings.get('apple_pass_organization_name')
38+
p.logoText = CustomPassPlugin.settings.get('apple_pass_logo_text')
39+
if bool(CustomPassPlugin.settings.get('apple_pass_customize_logo')):
40+
# Per apple docs:
41+
# The dimensions given above are all in points. On a non-Retina display, each point equals exactly 1 pixel.
42+
# On a Retina display, there are 2 or 3 pixels per point, depending on the device.
43+
# To support all screen sizes and resolutions, provide the original, @2x, and @3x versions of your art.
44+
# TODO
45+
# This is a easy way to fool apple to render the logo at higher resolutions, however the user shall have the
46+
# choice to provide logos for different aspect ratios, to allow for more efficient ticket sizes
47+
p.add_file_from_url('icon.png', CustomPassPlugin.settings.get('apple_pass_custom_icon_url'))
48+
p.add_file_from_url('icon@2x.png', CustomPassPlugin.settings.get('apple_pass_custom_icon_url'))
49+
p.add_file_from_url('icon@3x.png', CustomPassPlugin.settings.get('apple_pass_custom_icon_url'))
50+
p.add_file_from_url('logo.png', CustomPassPlugin.settings.get('apple_pass_custom_logo_url'))
51+
p.add_file_from_url('logo@2x.png', CustomPassPlugin.settings.get('apple_pass_custom_logo_url'))
52+
p.add_file_from_url('logo@3x.png', CustomPassPlugin.settings.get('apple_pass_custom_logo_url'))
3553
return p
3654

3755

indico_custom_pass/settings.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from indico.web.forms.base import IndicoForm
2-
from wtforms import StringField, ColorField
2+
from wtforms import StringField, ColorField, BooleanField
33
from wtforms.validators import Regexp
44

55
from indico_custom_pass import _
@@ -9,33 +9,51 @@ class CustomPassSettingsForm(IndicoForm):
99
apple_pass_background_color = ColorField(
1010
_('Apple Wallet pass background color'),
1111
description=_(
12-
'The background color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
12+
'The background color of the Apple Wallet pass.'),
1313
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
1414
default='#000000'
1515
)
1616
apple_pass_foreground_color = ColorField(
1717
_('Apple Wallet pass foreground color'),
1818
description=_(
19-
'The foreground color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
19+
'The foreground color of the Apple Wallet pass.'),
2020
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
2121
default='#ffffff'
2222
)
2323
apple_pass_label_color = ColorField(
2424
_('Apple Wallet pass label color'),
2525
description=_(
26-
'The label color of the Apple Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
26+
'The label color of the Apple Wallet pass.'),
2727
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
2828
default='#ffffff'
2929
)
30-
apple_pass_organization_name = StringField(
31-
_('Apple Wallet pass organization name'),
32-
description=_('The organization name displayed on the Apple Wallet pass.'),
30+
apple_pass_logo_text = StringField(
31+
_('Apple Wallet pass logo text'),
32+
description=_('The string displayed next to your logo on the Apple Wallet pass.'),
3333
default='Indico',
3434
)
35+
apple_pass_customize_logo = BooleanField(
36+
_('Customize Apple Wallet pass logo'),
37+
description=_(
38+
'If enabled, the logo on the Apple Wallet pass will be replaced with the image you specify below; WALLET_LOGO_URL from the official indico configuration will be ignored.'),
39+
default=False,
40+
)
41+
apple_pass_custom_logo_url = StringField(
42+
_('Apple Wallet pass custom logo URL'),
43+
description=_(
44+
'The URL of the custom logo to be used on the Apple Wallet pass. Must be a PNG image.\nPer apple docs: The logo image (logo.png) is displayed in the top left corner of the pass, next to the logo text. The allotted space is 160 x 50 points; in most cases it should be narrower.'),
45+
default='',
46+
)
47+
apple_pass_custom_icon_url = StringField(
48+
_('Apple Wallet pass custom icon URL'),
49+
description=_(
50+
'The URL of the custom icon to be used on the Apple Wallet pass. Must be a PNG image.\nPer apple docs: The icon (icon.png) is displayed when a pass is shown on the lock screen and by apps such as Mail when showing a pass attached to an email. The icon should measure 29 x 29 points.'),
51+
default='',
52+
)
3553
google_pass_background_color = ColorField(
3654
_('Google Wallet pass background color'),
3755
description=_(
38-
'The background color of the Google Wallet pass in HEX format (e.g. #000000 for black, #ffffff for white).'),
56+
'The background color of the Google Wallet pass.'),
3957
validators=[Regexp(r'^#(?:[0-9a-fA-F]{3}){1,2}$', message=_('Invalid HEX color format.'))],
4058
default='#007cac'
4159
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = 'indico-custom-pass'
33
description = 'Grants admins the ability to customize Indico Google Wallet & Apple Pay passes.'
44
readme = 'README.md'
5-
version = '1.0.3'
5+
version = '1.0.4'
66
license = {text = "MIT License"}
77
authors = [{ name = 'RobotHanzo', email = 'admin@robothanzo.dev' }]
88
classifiers = [

0 commit comments

Comments
 (0)