Skip to content

Commit

Permalink
Add more explicit deactivate button to camera to make it easier for t…
Browse files Browse the repository at this point in the history
…he user
  • Loading branch information
Odrec committed Jun 24, 2024
1 parent 50aea5b commit 5cfdca1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Binary file modified locale/de/LC_MESSAGES/base.mo
Binary file not shown.
4 changes: 4 additions & 0 deletions locale/de/LC_MESSAGES/base.po
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ msgstr "Kamera aktivieren"
msgid "Deactivate camera"
msgstr "Kamera deaktivieren"

#: src/chatbot_manager.py:417
msgid "Use photo"
msgstr "Foto verwenden"

#: src/chatbot_utils.py:312
msgid "Take a photo"
msgstr "Ein Foto machen"
Expand Down
12 changes: 9 additions & 3 deletions src/chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _clear_photo_callback():
session_state['photo_to_use'] = []

@staticmethod
def _activate_camera_callback():
def _toggle_camera_callback():
"""
Toggle the camera activation within the session state.
Expand Down Expand Up @@ -405,18 +405,24 @@ def _display_camera(self):
existing photos if the 'Use photo' button is pressed.
"""
col3, col4, col5 = st.columns([1, 1, 1])

with col4:
float_parent(f"bottom: 20rem; background-color: var(--default-backgroundColor); padding-top: 1rem;")
st.camera_input(
session_state['_']("Take a photo"),
key='your_photo',
label_visibility="hidden")
if session_state['your_photo']:
st.button("Use photo",
st.button(session_state['_']("Use photo"),
key='use_photo_button',
type='primary',
use_container_width=True,
on_click=self._upload_images_callback)

st.button(session_state['_']("Deactivate camera"),
use_container_width=True,
on_click=self._toggle_camera_callback)

if session_state['your_photo']:
if session_state['use_photo_button']:
session_state['photo_to_use'] = session_state['your_photo']
Expand Down Expand Up @@ -456,7 +462,7 @@ def _display_chat_buttons(self):

st.button("📷",
key='activate_camera_key',
on_click=self._activate_camera_callback,
on_click=self._toggle_camera_callback,
help=session_state['_'](session_state['toggle_camera_label'])
)

Expand Down

0 comments on commit 5cfdca1

Please sign in to comment.