Skip to content

Commit

Permalink
Merge Pull Request #56 into fiat-osx
Browse files Browse the repository at this point in the history
  • Loading branch information
freQniK committed Oct 30, 2023
1 parent 497d6cb commit ef19c20
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
Binary file modified src/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions src/kv/meile.kv
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ WindowManager:
text: "REFRESH"
on_release: root.refresh_wallet()

MDRaisedButton:
pos_hint: {'x' : .1 , 'top': .83 }
text: "NEW WALLET"
on_release: root.open_dialog_new_wallet()

MDRaisedButton:
pos_hint: {'x' : .8 , 'top': .9 }
text: "RE-FUEL"
Expand Down
88 changes: 84 additions & 4 deletions src/ui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import subprocess
import copy
import re
from shutil import rmtree
from unidecode import unidecode
from datetime import datetime

Expand Down Expand Up @@ -330,7 +331,7 @@ class MainWindow(Screen):
Sort = SortOptions[0]
MeileMap = None
MeileMapBuilt = False
NodeSwitch = {"moniker" : None, "node" : None, "switch" : False, 'id' : None, 'consumed' : None, 'og_consumed' : None, 'allocated' : None, 'expirary' : None}}
NodeSwitch = {"moniker" : None, "node" : None, "switch" : False, 'id' : None, 'consumed' : None, 'og_consumed' : None, 'allocated' : None, 'expirary' : None}
NewWallet = False
box_color = ColorProperty('#fcb711')
clock = None
Expand Down Expand Up @@ -367,8 +368,8 @@ def __init__(self, node_tree, **kwargs):

def build(self, dt):
OurWorld.CONTINENTS.remove(OurWorld.CONTINENTS[1])
OurWorld.CONTINENTS.append("Subscriptions")
#OurWorld.CONTINENTS.append("Search")
OurWorld.CONTINENTS.append("Plans")
OurWorld.CONTINENTS.append("Search")

for name_tab in OurWorld.CONTINENTS:
tab = Tab(tab_label_text=name_tab)
Expand Down Expand Up @@ -896,8 +897,10 @@ def __init__(self, ADDRESS, **kwargs):
print("WalletScreen, ADDRESS: %s" % self.ADDRESS)
self.wallet_address = self.ADDRESS

Clock.schedule_once(self.build)
# This variable will be used by: open_wallet_restore_create
self.NewWallet = False

Clock.schedule_once(self.build)

def build(self, dt):
Wallet = HandleWalletFunctions()
Expand All @@ -906,6 +909,83 @@ def build(self, dt):
def refresh_wallet(self):
self.build(None)

def open_dialog_new_wallet(self):
self.dialog = MDDialog(
text="Warning, if you continue your current wallet will be deleted",
md_bg_color=get_color_from_hex(MeileColors.DIALOG_BG_COLOR),
buttons=[
MDFlatButton(
text="CONTINUE",
theme_text_color="Custom",
text_color=(1,1,1,1),
on_release=self.destroy_wallet_open_wallet_dialog
),
MDRaisedButton(
text="CANCEL",
theme_text_color="Custom",
text_color=(1,1,1,1),
on_release=self.closeDialog
),
],
)
self.dialog.open()

def destroy_wallet_open_wallet_dialog(self, _):
keyring_fpath = path.join(MeileGuiConfig.BASEDIR, "keyring-file")
img_fpath = path.join(MeileGuiConfig.BASEDIR, "img")

for folder_path in [keyring_fpath, img_fpath]:
if path.exists(folder_path):
rmtree(folder_path)

# Remove also the [wallet] section in config.ini
# So, if the keyring-file is deleted and the use close accidentaly the application
# We can bypass the case with a wallet reference (in config) without a keyring
if path.exists(keyring_fpath) is False:
MeileConfig = MeileGuiConfig()
CONFIG = MeileConfig.read_configuration(MeileGuiConfig.CONFFILE)
# CONFIG.remove_section('wallet')
# We had to clear all the data as defaultconf file (can't remove)
for k in CONFIG["wallet"]:
if k != "uuid":
CONFIG.set("wallet", k, "")
FILE = open(MeileConfig.CONFFILE, 'w')
CONFIG.write(FILE)

self.closeDialog(None) # arg is required (?)

self.dialog = MDDialog(
text="Wallet Restore/Create",
md_bg_color=get_color_from_hex(MeileColors.DIALOG_BG_COLOR),
buttons=[
MDFlatButton(
text="CREATE",
theme_text_color="Custom",
text_color=(1,1,1,1),
on_release=partial(self.wallet_restore, True)
),

MDRaisedButton(
text="RESTORE",
theme_text_color="Custom",
text_color=(1,1,1,1),
on_release=partial(self.wallet_restore, False)
),
],
)
self.dialog.open()

# duplicate of MainWindow.wallet_restore
def wallet_restore(self, new_wallet = False, _ = None):
# self.NewWallet will be read by WalletRestore in order to determine ui login
self.NewWallet = new_wallet
self.closeDialog(None) # arg is required (?)

Meile.app.manager.add_widget(WalletRestore(name=WindowNames.WALLET_RESTORE))
Meile.app.root.transition = SlideTransition(direction = "right")
Meile.app.root.current = WindowNames.WALLET_RESTORE


def open_fiat_interface(self):
Meile.app.root.add_widget(fiat_interface.FiatInterface(name=WindowNames.FIAT))
Meile.app.root.transistion = SlideTransition(direction="right")
Expand Down

0 comments on commit ef19c20

Please sign in to comment.