Skip to content

Commit 26f516f

Browse files
Merge pull request #302 from AndreWohnsland/dev
Make virgin and virgin only cocktails more distinguishable
2 parents 373955a + ebd7344 commit 26f516f

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

src/ui/cocktail_view.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ def generate_image_block(cocktail: Cocktail | None, mainscreen: MainScreen):
4646
header_font_size = round(square_size / 15.8)
4747
header_height = round(square_size / 6.3)
4848
single_ingredient_label = UI_LANGUAGE.get_translation("label_single_ingredient", "main_window")
49-
name_label = single_ingredient_label
50-
if cocktail is not None:
51-
prefix = "V. " if cocktail.only_virgin else ""
52-
name_label = f"{prefix}{cocktail.name}"
49+
name_label = single_ingredient_label if cocktail is None else cocktail.name
5350
button = create_button(
5451
name_label,
5552
font_size=header_font_size,
@@ -59,7 +56,8 @@ def generate_image_block(cocktail: Cocktail | None, mainscreen: MainScreen):
5956
css_class="btn-inverted btn-half-top",
6057
)
6158
if cocktail is not None and cocktail.virgin_available:
62-
icon = ICONS.generate_icon(PresetIcon.virgin, ICONS.color.background)
59+
button.setText(f" {name_label}")
60+
icon = ICONS.generate_icon(PresetIcon.virgin, ICONS.color.background, border=cocktail.only_virgin)
6361
button.setIcon(icon)
6462
button.setIconSize(QSize(20, 20))
6563
label = ClickableLabel(name_label)

src/ui/icons.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
from typing import TYPE_CHECKING, Literal
4+
from typing import TYPE_CHECKING, Any, Literal
55

66
import qtawesome as qta
77
from PyQt5.QtCore import QSize
@@ -36,6 +36,7 @@
3636
_SEARCH_ICON = "fa.search"
3737
_UPLOAD_ICON = "fa.upload"
3838
_QUESTION_ICON = "fa5.question-circle"
39+
_BORDER_ICON = "fa5.square"
3940
BUTTON_SIZE = QSize(36, 36)
4041
SMALL_BUTTON_SIZE = QSize(24, 24)
4142

@@ -61,6 +62,7 @@ class PresetIcon:
6162
huge_glass = _HUGE_GLASS
6263
skull = _SKULL
6364
easy = _EASY
65+
border = _BORDER_ICON
6466

6567

6668
@dataclass
@@ -160,19 +162,28 @@ def set_picture_window_icons(self, w: Ui_PictureWindow):
160162
fa_icon: QIcon = qta.icon(icon, color=self.color.background)
161163
self.set_icon(ui_element, fa_icon, no_text)
162164

163-
def generate_icon(self, icon_name: str, color: str, color_active: str | None = None) -> QIcon:
165+
def generate_icon(self, icon_name: str, color: str, color_active: str | None = None, border: bool = False) -> QIcon:
164166
"""Generate an icon with the given color and size.
165167
166168
Args:
167169
----
168170
icon_name (str): icon name in qta, e.g. "fa5s.cog"
169171
color (str): given color name in hex, e.g. "#007bff"
170172
color_active (str): given active color name, will use color if None, defaults to None
173+
border (bool): if True, add a border to the icon, defaults to False
171174
172175
"""
173-
if color_active is None:
174-
color_active = color
175-
return qta.icon(icon_name, color=color, color_active=color_active)
176+
icon_option: dict[str, Any] = {
177+
"color": color,
178+
"color_active": color if color_active is None else color_active,
179+
}
180+
if not border:
181+
return qta.icon(icon_name, options=[icon_option])
182+
return qta.icon(
183+
icon_name,
184+
_BORDER_ICON,
185+
options=[icon_option, {**icon_option, "scale_factor": 1.3}],
186+
)
176187

177188
def set_wait_icon(self, button: QPushButton, icon: Literal["spin", "time"] = "time", primary=False):
178189
"""Set a spinner button to the icon."""

src/ui/setup_cocktail_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def update_cocktail_data(self):
110110
self.prepare_button.setText(
111111
UI_LANGUAGE.get_translation("prepare_button", "cocktail_selection", amount=amount, unit=cfg.EXP_MAKER_UNIT)
112112
)
113-
virgin_prefix = "V. " if self.cocktail.is_virgin else ""
113+
virgin_prefix = "Virgin " if self.cocktail.is_virgin else ""
114114
self.LAlkoholname.setText(f"{virgin_prefix}{self.cocktail.name}")
115115
display_volume = self._decide_rounding(amount * cfg.EXP_MAKER_FACTOR, 20)
116116
self.LMenge.setText(f"{display_volume} {cfg.EXP_MAKER_UNIT}")

web_client/src/components/cocktail/CocktailList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ const CocktailList: React.FC = () => {
5454
role='button'
5555
>
5656
<h2 className='text-center py-1 flex items-center justify-center'>
57-
{cocktail.virgin_available && <MdNoDrinks className='mr-2' />}
58-
{cocktail.only_virgin && 'V. '}
57+
{cocktail.virgin_available && (
58+
<MdNoDrinks className={`mr-2 ${cocktail.only_virgin && 'border-2 border-background rounded-full'}`} />
59+
)}
5960
{cocktail.name}
6061
</h2>
6162
<div className='relative w-full' style={{ paddingTop: '100%' }}>

web_client/src/components/cocktail/CocktailSelection.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const alcoholFactor = {
3434
const CocktailSelection: React.FC<CocktailModalProps> = ({ selectedCocktail, handleCloseModal }) => {
3535
const originalCocktail = JSON.parse(JSON.stringify(selectedCocktail));
3636
const [alcohol, setAlcohol] = useState<alcoholState>(selectedCocktail.only_virgin ? 'virgin' : 'normal');
37-
const [displayCocktail, setDisplayCocktail] = useState<Cocktail>(selectedCocktail);
37+
const [displayCocktail, setDisplayCocktail] = useState<Cocktail>(
38+
selectedCocktail.only_virgin ? scaleCocktail(originalCocktail, alcoholFactor['virgin']) : selectedCocktail,
39+
);
3840
const [isProgressModalOpen, setIsProgressModalOpen] = useState(false);
3941
// Refill state
4042
const [isRefillOpen, setIsRefillOpen] = useState(false);
@@ -52,8 +54,7 @@ const CocktailSelection: React.FC<CocktailModalProps> = ({ selectedCocktail, han
5254
setDisplayCocktail(originalCocktail);
5355
} else {
5456
setAlcohol(state);
55-
const factor = alcoholFactor[state];
56-
setDisplayCocktail(scaleCocktail(originalCocktail, factor));
57+
setDisplayCocktail(scaleCocktail(originalCocktail, alcoholFactor[state]));
5758
}
5859
};
5960

@@ -142,13 +143,13 @@ const CocktailSelection: React.FC<CocktailModalProps> = ({ selectedCocktail, han
142143
<AiOutlineCloseCircle className='text-danger' size={34} />
143144
</button>
144145
</div>
145-
<div>
146-
<h2 className='text-2xl font-bold text-center text-neutral underline'>
147-
{alcohol === 'virgin' && 'V. '}
146+
<div className='flex-grow flex flex-col justify-center w-full'>
147+
<h2 className='text-2xl md:text-3xl lg:text-4xl font-bold text-center text-neutral underline mb-2'>
148+
{alcohol === 'virgin' && 'Virgin '}
148149
{selectedCocktail.name}
149150
</h2>
150-
<div className='mt-2'>
151-
<ul className='text-center'>
151+
<div className='my-2'>
152+
<ul className='text-center text-base md:text-lg lg:text-xl space-y-1'>
152153
{machineIngredients.map((ingredient) => (
153154
<li key={ingredient.id} className='text-text'>
154155
{ingredient.name}:

web_client/src/components/ingredient/IngredientList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const IngredientList: React.FC = () => {
136136
overlayClassName='overlay z-20'
137137
>
138138
{selectedIngredient && (
139-
<div className='px-4 rounded w-full h-full flex flex-col'>
139+
<div className='px-1 rounded w-full h-full flex flex-col'>
140140
<div className='flex justify-between items-center mb-2'>
141141
<h2 className='text-xl font-bold text-secondary'>
142142
{selectedIngredient.name || t('ingredients.newIngredient')}

0 commit comments

Comments
 (0)