feat: added debug screen

This commit is contained in:
Benedict Xavier Wanyonyi
2024-05-30 17:50:57 +03:00
parent dcc49ff1fa
commit 204690a335
3 changed files with 31 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
from datetime import datetime
import shutil
import os
# TODO: make it use color_text instead of fixed vals
# from .kivy_markup_helper import color_text
@@ -18,6 +18,14 @@ def write_crash(e: Exception):
return index
def read_crash_file():
crash_file_path = "./crashfile.txt"
if not os.path.exists(crash_file_path):
return None
else:
with open(crash_file_path,"r") as file:
return file.read()
def move_file(source_path, dest_path):
try:
path = shutil.move(source_path, dest_path)

View File

@@ -13,6 +13,9 @@
MDBoxLayout:
orientation: 'vertical'
SearchBar:
MDLabel:
text:"Crash Log"
MDScrollView:
MDLabel:
text:root.crash_text
adaptive_height:True
markup:True
padding:"10dp"

View File

@@ -1,13 +1,21 @@
from kivy.properties import ObjectProperty
from kivy.properties import StringProperty
from View.base_screen import BaseScreenView
from Utility.utils import read_crash_file
from Utility.kivy_markup_helper import color_text, bolden
class CrashLogScreenView(BaseScreenView):
"""The crash log screen"""
main_container = ObjectProperty()
def model_is_changed(self) -> None:
"""
Called whenever any change has occurred in the data model.
The view in this method tracks these changes and updates the UI
according to these changes.
"""
crash_text = StringProperty()
def __init__(self, **kw):
super().__init__(**kw)
if crashes := read_crash_file():
self.crash_text = crashes
else:
self.crash_text = color_text(
f"No Crashes so far :) and if there are any in the future {bolden('please report! Okay?')}",
self.theme_cls.primaryColor,
)