Skip to content

Commit

Permalink
Merge pull request #3 from rahilmansuri1/bug-fixes-ui
Browse files Browse the repository at this point in the history
Update content on the Terms and Conditions page and fix UI bugs.
  • Loading branch information
pv-gaurangpatel authored Feb 6, 2025
2 parents cfa3a8d + 27efea2 commit f18f91b
Show file tree
Hide file tree
Showing 20 changed files with 527 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.0
current_version = 0.1.1
commit = False
tag = False
allow_dirty = True
Expand Down
3 changes: 3 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[codespell]
# Ignore specific words that are intentional and should not be corrected
ignore-words-list = arbitral
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iris-wallet-desktop"
version = "0.1.0"
version = "0.1.1"
description = ""
readme = "README.md"
license = ""
Expand Down
3 changes: 3 additions & 0 deletions src/model/selection_page_model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-few-public-methods
"""
Module containing models related to the wallet method and transfer type widget.
"""
Expand Down Expand Up @@ -29,3 +30,5 @@ class AssetDataModel(BaseModel):
asset_type: str
asset_id: str | None = None
close_page_navigation: str | None = None
expiry_time: int | None = None
expiry_unit: str | None = None
Binary file modified src/translations/en_IN.qm
Binary file not shown.
148 changes: 141 additions & 7 deletions src/translations/en_IN.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"""
from __future__ import annotations

__version__ = '0.1.0'
__version__ = '0.1.1'
8 changes: 8 additions & 0 deletions src/views/components/receive_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ def retranslate_ui(self):
),
)

self.copy_button.clicked.connect(
lambda: self.copy_button.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'copied', None,
),
),
)

def update_qr_and_address(self, address: str):
"""This method used to set qr and address"""
qr_image = set_qr_code(str(address))
Expand Down
13 changes: 9 additions & 4 deletions src/views/ui_bitcoin_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from PySide6.QtWidgets import QWidget

import src.resources_rc
from src.data.repository.setting_repository import SettingRepository
from src.model.enums.enums_model import NetworkEnumModel
from src.model.enums.enums_model import TransferStatusEnumModel
from src.model.transaction_detail_page_model import TransactionDetailPageModel
from src.utils.common_utils import get_bitcoin_explorer_url
Expand Down Expand Up @@ -238,10 +240,13 @@ def retranslate_ui(self):
'iris_wallet_desktop', 'transaction_id', None,
),
)
self.bitcoin_tx_id_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{self.tx_id}</a>",
)
if SettingRepository.get_wallet_network() != NetworkEnumModel.REGTEST:
self.bitcoin_tx_id_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{self.tx_id}</a>",
)
else:
self.bitcoin_tx_id_value.setText(self.tx_id)
self.btc_amount_label.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'amount', None,
Expand Down
2 changes: 2 additions & 0 deletions src/views/ui_create_ln_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ def get_ln_invoice(self):
params=AssetDataModel(
asset_type='create_invoice',
close_page_navigation=self.asset_type,
expiry_time=int(self.expiry_input.text()),
expiry_unit=self.time_unit_combobox.currentText(),
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/views/ui_ln_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def setup_ui_connection(self):
"""Set up connections for UI elements."""
self.close_button.clicked.connect(
lambda: close_button_navigation(
self, self._view_model.page_navigation.term_and_condition_page,
self, self.view_model.page_navigation.term_and_condition_page,
),
)
self.proceed_button.clicked.connect(self.set_ln_url)
Expand Down
33 changes: 31 additions & 2 deletions src/views/ui_receive_rgb_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
from __future__ import annotations

from PySide6.QtCore import QCoreApplication
from PySide6.QtWidgets import QVBoxLayout
from PySide6.QtWidgets import QWidget

Expand Down Expand Up @@ -31,6 +32,8 @@ def __init__(self, view_model, params: AssetDataModel):
self.originating_page = params.asset_type
self.asset_id = params.asset_id
self.close_page_navigation = params.close_page_navigation
self.expiry_time = params.expiry_time
self.expiry_unit = params.expiry_unit
self.default_min_confirmation = SettingCardRepository.get_default_min_confirmation()
self.receive_rgb_asset_page = ReceiveAssetWidget(
self._view_model,
Expand Down Expand Up @@ -69,6 +72,16 @@ def generate_invoice(self):
def setup_ui_connection(self):
"""Set up connections for UI elements."""
self.show_receive_rgb_loading()
self.receive_rgb_asset_page.copy_button.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'copy_rgb_invoice', None,
),
)
self.receive_rgb_asset_page.address_label.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'rgb_invoice_label', None,
),
)
self.receive_rgb_asset_page.copy_button.clicked.connect(
lambda: copy_text(self.receive_rgb_asset_page.receiver_address),
)
Expand All @@ -82,7 +95,7 @@ def setup_ui_connection(self):
self.update_address,
)
self._view_model.ln_offchain_view_model.invoice_get_event.connect(
self.update_address,
lambda address: self.update_address(address, ln_invoice=True),
)
self._view_model.receive_rgb25_view_model.message.connect(
self.handle_message,
Expand Down Expand Up @@ -130,9 +143,25 @@ def close_button_navigation(self):
}',
)

def update_address(self, address: str):
def update_address(self, address: str, ln_invoice: bool = False):
"""This method used to update new address"""
self.receive_rgb_asset_page.update_qr_and_address(address)
if ln_invoice:
self.receive_rgb_asset_page.copy_button.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'copy_ln_invoice', None,
),
)
self.receive_rgb_asset_page.address_label.setText(
QCoreApplication.translate(
'iris_wallet_desktop', 'ln_invoice_label', None,
),
)
self.receive_rgb_asset_page.wallet_address_description_text.setText(
QCoreApplication.translate('iris_wallet_desktop', 'ln_invoice_info', None).format(
self.expiry_time, self.expiry_unit,
),
)

def handle_message(self, msg_type: int, message: str):
"""This method handled to show message."""
Expand Down
24 changes: 16 additions & 8 deletions src/views/ui_rgb_asset_transaction_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from PySide6.QtWidgets import QWidget

import src.resources_rc
from src.data.repository.setting_repository import SettingRepository
from src.model.enums.enums_model import NetworkEnumModel
from src.model.enums.enums_model import PaymentStatus
from src.model.enums.enums_model import TransferStatusEnumModel
from src.model.rgb_model import RgbAssetPageLoadModel
Expand Down Expand Up @@ -377,10 +379,6 @@ def set_rgb_asset_value(self):
else:
unblinded_and_change_utxo_value = None
self.url = get_bitcoin_explorer_url(self.params.tx_id)
self.tx_id_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{self.tx_id}</a>",
)
if self.params.receive_utxo is not None:
self.url = get_bitcoin_explorer_url(self.params.receive_utxo)
unblinded_and_change_utxo_value = insert_zero_width_spaces(
Expand All @@ -391,10 +389,20 @@ def set_rgb_asset_value(self):
unblinded_and_change_utxo_value = insert_zero_width_spaces(
self.params.change_utxo,
)
self.unblinded_and_change_utxo_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{unblinded_and_change_utxo_value}</a>",
)
if SettingRepository.get_wallet_network() != NetworkEnumModel.REGTEST:
self.unblinded_and_change_utxo_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{unblinded_and_change_utxo_value}</a>",
)
self.tx_id_value.setText(
f"<a style='color: #03CA9B;' href='{self.url}'>"
f"{self.tx_id}</a>",
)
else:
self.unblinded_and_change_utxo_value.setText(
unblinded_and_change_utxo_value,
)
self.tx_id_value.setText(self.tx_id)
self.blinded_utxo_value.setText(self.params.recipient_id)
if self.params.consignment_endpoints:
consignment_endpoint = self.params.consignment_endpoints[0].endpoint or 'N/A'
Expand Down
14 changes: 9 additions & 5 deletions src/views/ui_send_ln_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,15 @@ def _display_invoice_detail(self, detail):

def _update_max_asset_local_balance(self, detail):
"""Updates the maximum asset local balance for the given asset_id."""
max_balance = None
for channel in self._view_model.channel_view_model.channels:
if channel.asset_id == detail.asset_id and channel.is_usable and channel.ready:
max_balance = max(max_balance or 0, channel.asset_local_amount)
self.max_asset_local_balance = max_balance
if detail.asset_id:
max_balance = None
for channel in self._view_model.channel_view_model.channels:
if channel.asset_id == detail.asset_id and channel.is_usable and channel.ready:
max_balance = max(
max_balance or 0,
channel.asset_local_amount,
)
self.max_asset_local_balance = max_balance

def _validate_asset_amount(self, detail):
"""Validates the asset amount and updates the UI accordingly."""
Expand Down
82 changes: 72 additions & 10 deletions src/views/ui_term_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
from PySide6.QtCore import QCoreApplication
from PySide6.QtCore import QSize
from PySide6.QtCore import Qt
from PySide6.QtGui import QTextOption
from PySide6.QtWidgets import QFrame
from PySide6.QtWidgets import QGridLayout
from PySide6.QtWidgets import QHBoxLayout
from PySide6.QtWidgets import QLabel
from PySide6.QtWidgets import QPlainTextEdit
from PySide6.QtWidgets import QSizePolicy
from PySide6.QtWidgets import QSpacerItem
from PySide6.QtWidgets import QTextBrowser
from PySide6.QtWidgets import QWidget

import src.resources_rc
from src.utils.constant import PRIVACY_POLICY_URL
from src.utils.helpers import load_stylesheet
from src.viewmodels.main_view_model import MainViewModel
from src.views.components.buttons import PrimaryButton
Expand Down Expand Up @@ -85,14 +87,28 @@ def __init__(self, view_model):

self.grid_layout_10_tnc.addWidget(self.tnc_line_tnc, 1, 0, 1, 1)

self.tnc_text_desc = QPlainTextEdit(self.tnc_widget)
self.tnc_text_desc = QTextBrowser(self.tnc_widget)
self.tnc_text_desc.setObjectName('TnC_Text_Desc')
self.tnc_text_desc.setMinimumSize(QSize(644, 348))
self.tnc_text_desc.setMaximumSize(QSize(644, 348))
self.tnc_text_desc.setStyleSheet(
load_stylesheet('views/qss/q_label.qss'),
load_stylesheet('views/qss/scrollbar.qss') +
"""
QTextBrowser {
background-color: rgb(21, 28, 52);
color: white;
font: 14px"Inter";
line-height: 1.5;
border: none;
padding: 10px;
}
""",
)
self.tnc_text_desc.setReadOnly(True)
self.tnc_text_desc.verticalScrollBar().valueChanged.connect(
self.check_scroll_completion,
)
self.tnc_text_desc.setOpenExternalLinks(True)

self.grid_layout_10_tnc.addWidget(
self.tnc_text_desc, 2, 0, 1, 1, Qt.AlignHCenter,
Expand Down Expand Up @@ -126,6 +142,7 @@ def __init__(self, view_model):
self.accept_btn = PrimaryButton()
self.accept_btn.setMinimumSize(QSize(318, 40))
self.accept_btn.setMaximumSize(QSize(318, 40))
self.accept_btn.setDisabled(True)

self.tnc_horizontal_layout.addWidget(self.accept_btn)

Expand Down Expand Up @@ -179,13 +196,8 @@ def retranslate_ui(self):
None,
),
)
self.tnc_text_desc.setPlainText(
QCoreApplication.translate(
'iris_wallet_desktop',
'terms_and_conditions_content',
None,
),
)

self.load_terms_conditions()
self.decline_btn.setText(
QCoreApplication.translate(
'iris_wallet_desktop',
Expand All @@ -200,3 +212,53 @@ def retranslate_ui(self):
None,
),
)

def check_scroll_completion(self):
"""Enable the Accept button when the user scrolls to the end."""
scrollbar = self.tnc_text_desc.verticalScrollBar()
if scrollbar.value() == scrollbar.maximum():
self.accept_btn.setEnabled(True)

def load_terms_conditions(self):
"""Load Terms & Conditions text and format 'Privacy Policy' as a hyperlink while preserving formatting."""
get_translated_privacy_policy = QCoreApplication.translate(
'iris_wallet_desktop',
'privacy_policy_tnc',
None,
)
terms_text = QCoreApplication.translate(
'iris_wallet_desktop',
'terms_and_conditions_content',
None,
).format(get_translated_privacy_policy)

terms_text = terms_text.replace(
get_translated_privacy_policy, f'<a href="{
PRIVACY_POLICY_URL
}" style="color:rgb(1, 167, 129); font-weight: 400">{get_translated_privacy_policy}</a>',
)

# Add CSS for line-height
formatted_text = f'''
<html>
<head>
<style>
pre {{
white-space: pre-wrap; /* Enables word wrapping */
word-wrap: break-word; /* Ensures long words break */
line-height: 1.5; /* Adjust line height as needed */
font-family: Inter;
}}
</style>
</head>
<body>
<pre>{terms_text.replace('\n\n', '</p><p>').replace('\n', '<br>')}</pre>
</body>
</html>
'''

self.tnc_text_desc.setHtml(formatted_text)

self.tnc_text_desc.setWordWrapMode(
QTextOption.WrapAtWordBoundaryOrAnywhere,
)
Loading

0 comments on commit f18f91b

Please sign in to comment.