From ef19c202d8501d9de1dcb9fbb83dc79352de6aae Mon Sep 17 00:00:00 2001 From: freQniK Date: Mon, 30 Oct 2023 14:58:20 -0400 Subject: [PATCH] Merge Pull Request #56 into fiat-osx --- src/.DS_Store | Bin 14340 -> 14340 bytes src/kv/meile.kv | 5 +++ src/ui/screens.py | 88 +++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 89 insertions(+), 4 deletions(-) diff --git a/src/.DS_Store b/src/.DS_Store index 8202e9409bfbfaf4f40d93ed5af889ec173434f6..9b0e0c32ad01767cb78c067f1ef43dc2af03f42f 100644 GIT binary patch delta 77 zcmZoEXeroWF3x6XZmy$XF!`OP^yCB5YMblC6L B61e~X diff --git a/src/kv/meile.kv b/src/kv/meile.kv index 661232bf..f49e5dd8 100644 --- a/src/kv/meile.kv +++ b/src/kv/meile.kv @@ -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" diff --git a/src/ui/screens.py b/src/ui/screens.py index 7ea80af3..654ba2a1 100644 --- a/src/ui/screens.py +++ b/src/ui/screens.py @@ -44,6 +44,7 @@ import subprocess import copy import re +from shutil import rmtree from unidecode import unidecode from datetime import datetime @@ -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 @@ -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) @@ -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() @@ -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")