Skip to content

Commit

Permalink
Add Solana & ZCash payment options. Add USD value to Plan Subscriptio…
Browse files Browse the repository at this point in the history
…n UI. Format btc. Add Coin options in BTCPay. v2.1.0-rc1
  • Loading branch information
freQniK committed Jan 16, 2025
1 parent 2a01028 commit f14b41a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/kv/meile.kv
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,15 @@ WindowManager:
pos_hint: {'center_x': .5, 'center_y': .5}
text: "dvpn"
on_release: root.menu.open()

MDLabel:
id: usd_price
text: "$0.00"
theme_text_color: "Custom"
font_style: "Subtitle2"
font_size: "14sp"
font_name: root.get_font()
text_color: get_color_from_hex(MeileColors.MEILE)

<ProcessingSubDialog>
orientation: "vertical"
Expand Down
15 changes: 11 additions & 4 deletions src/typedef/konstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,21 @@ class IBCTokens():
'dvpn' : 'sentinel',
'beam' : 'beam',
'firo' : 'zcoin',
'pivx' : 'pivx'}
'pivx' : 'pivx',
'zec' : 'zcash',
'sol' : 'solana',
'btc' : 'bitcoin',
'xmr' : 'monero',
'ltc' : 'litecoin',
'doge' : 'dogecoin'}

NOWCOINS = ["firo", "beam", "pivx"]
NOWCOINS = ["firo", "beam", "pivx", "zec", "sol"]
BTCPAYCOINS = ["xmr", "btc", "ltc", "doge"]
#mu_coins = ["tsent", "udvpn", "uscrt", "uosmo", "uatom", "udec"]
class TextStrings():
dash = "-"
VERSION = "v2.0.7"
BUILD = "17354365963"
VERSION = "v2.1.0"
BUILD = "17370138213"
RootTag = "SENTINEL"
PassedHealthCheck = "Passed Sentinel Health Check"
FailedHealthCheck = "Failed Sentinel Health Check"
Expand Down
8 changes: 4 additions & 4 deletions src/ui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,16 +799,16 @@ def build_meile_map(self):
#self.MeileMap.map_source = "osm"
self.MeileMap.map_source = source

layout = FloatLayout(size_hint=(1,1))
layout = FloatLayout(size_hint=(1,1))
bw_label = BandwidthLabel()
self.quota = BandwidthBar()
self.quota_pct = QuotaPct()
self.map_widget_1 = IPAddressTextField()
self.map_widget_2 = ConnectedNode()
self.map_widget_3 = ProtectedLabel()
self.recenter = MapCenterButton()
recenter = MapCenterButton()

self.recenter.on_release = self.recenter_map
recenter.on_release = self.recenter_map

self.MeileMap.bind(lat=self.check_boundaries)
self.MeileMap.bind(lon=self.check_boundaries)
Expand All @@ -820,7 +820,7 @@ def build_meile_map(self):
layout.add_widget(bw_label)
layout.add_widget(self.quota)
layout.add_widget(self.quota_pct)
layout.add_widget(self.recenter)
layout.add_widget(recenter)


self.quota.value = 0
Expand Down
40 changes: 37 additions & 3 deletions src/ui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ def refresh_price(self, mu_coin: str = "dvpn", cache: int = 30):
def set_item(self, text_item):
self.ids.drop_item.set_item(text_item)
self.ids.deposit.text = self.parse_coin_deposit(text_item)
self.get_usd(text_item)
try:
self.menu.dismiss()
except TypeError as e:
print(str(e))

def parse_coin_deposit(self, mu_coin):

# Save a copy, so we can edit the value without update the ui
price_text = self.price_text
# Parse all the coins without u-unit
Expand All @@ -410,11 +412,12 @@ def parse_coin_deposit(self, mu_coin):
if mu_coin == "dvpn":
value = float(price_text.rstrip(mu_coin).strip())
else:
value = round(float(price_text.rstrip("dvpn").strip()) * self.price_cache["dvpn"]["price"] / self.price_cache[mu_coin]["price"], 5)
value = round(float(price_text.rstrip("dvpn").strip()) * self.price_cache["dvpn"]["price"] / self.price_cache[mu_coin]["price"], 8)

print(f"mu_coin={mu_coin}, month={month}, value={value}, price_cache={self.price_cache}")

self.ids.deposit.text = str(round(month * value, 5))
# display satoshis for BTC
self.ids.deposit.text = str(format(round(month * value, 8),'8f'))
return self.ids.deposit.text


Expand All @@ -437,7 +440,21 @@ def on_checkbox_active(self, pay_with: str, checkbox, value):
]
self.menu.items = menu_items
self.set_item(IBCTokens.NOWCOINS[0])
#self.menu.bind()

elif pay_with == "btcpay":
self.ids.drop_item.text = "xmr"
menu_items = [
{
"viewclass": "IconListItem",
"icon": "circle-multiple",
"text": f"{i}",
"height": dp(56),
"on_release": lambda x=f"{i}": self.set_item(x),
} for i in IBCTokens.BTCPAYCOINS
]
self.menu.items = menu_items
self.set_item(IBCTokens.BTCPAYCOINS[0])

else:
self.ids.drop_item.text = "dvpn"
menu_items = [
Expand All @@ -451,6 +468,23 @@ def on_checkbox_active(self, pay_with: str, checkbox, value):
]
self.menu.items = menu_items
self.set_item("dvpn")


def get_usd(self, coin):
deposit_ret = self.return_deposit_text()
match = re.match(r"([0-9]+.[0-9]+)", deposit_ret[0], re.I)
if match:
amt = match.groups()[0]
else:
amt = 0.0
coin = "dvpn"

self.refresh_price(coin, cache=30)
self.ids.usd_price.text = '$' + str(round(float(self.price_cache[coin]["price"]) * float(amt),3))

def get_font(self):
Config = MeileGuiConfig()
return Config.resource_path(MeileColors.FONT_FACE)

class ProcessingSubDialog(BoxLayout):
moniker = StringProperty()
Expand Down

0 comments on commit f14b41a

Please sign in to comment.