Skip to content

Commit

Permalink
refactor: move bar to api component
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Sep 30, 2024
1 parent acc826c commit 32c874a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dooit/ui/api/api_components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .vars import VarManager
from .formatters import Formatter
from .dashboard import DashboardManager
from .bar import BarManager

__all__ = [
"KeyManager",
Expand All @@ -11,4 +12,5 @@
"VarManager",
"Formatter",
"DashboardManager",
"BarManager",
]
14 changes: 14 additions & 0 deletions dooit/ui/api/api_components/bar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from typing import TYPE_CHECKING, List
from dooit.ui.widgets.bars import StatusBarWidget
from ._base import ApiComponent

if TYPE_CHECKING: # pragma: no cover
from dooit.ui.tui import Dooit

class BarManager(ApiComponent):
def __init__(self, app: "Dooit") -> None:
super().__init__()
self.app = app

def set(self, widgets: List[StatusBarWidget]):
self.app.bar.set_widgets(widgets)
6 changes: 2 additions & 4 deletions dooit/ui/api/dooit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dooit.ui.widgets.bars import StatusBarWidget
from dooit.utils import CssManager

from .api_components import KeyManager, LayoutManager, Formatter
from .api_components import KeyManager, LayoutManager, Formatter, BarManager

if TYPE_CHECKING: # pragma: no cover
from ..tui import Dooit
Expand All @@ -21,6 +21,7 @@ def __init__(self, app: "Dooit") -> None:
self.keys = KeyManager(self.app.get_mode)
self.layouts = LayoutManager(self.app)
self.formatter = Formatter(self.app)
self.bar = BarManager(self.app)

self.css_manager.refresh_css()

Expand Down Expand Up @@ -109,6 +110,3 @@ def start_search(self):

def start_sort(self):
self.focused.start_sort()

def set_bar(self, widgets: List[StatusBarWidget]):
self.app.bar.set_widgets(widgets)
2 changes: 1 addition & 1 deletion dooit/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def key_setup(api: DooitAPI):
api.formatter.todos.description.add(todo_desc_formatter)
api.formatter.todos.due.add(due_formatter)

api.set_bar(bar_widgets)
api.bar.set(bar_widgets)

0 comments on commit 32c874a

Please sign in to comment.