Skip to content

Commit

Permalink
Merge Pull Request #56 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
freQniK committed Nov 2, 2023
1 parent 0baa20d commit 3016fbe
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/kv/meile.kv
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,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
80 changes: 80 additions & 0 deletions src/ui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import sys
import copy
import re
from shutil import rmtree
from time import sleep
from functools import partial
from os import path,geteuid, chdir
Expand Down Expand Up @@ -861,6 +862,9 @@ def __init__(self, ADDRESS, **kwargs):
print("WalletScreen, ADDRESS: %s" % self.ADDRESS)
self.wallet_address = self.ADDRESS

# This variable will be used by: open_wallet_restore_create
self.NewWallet = False

Clock.schedule_once(self.build)


Expand All @@ -870,6 +874,82 @@ 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))
Expand Down

0 comments on commit 3016fbe

Please sign in to comment.