mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-02 07:50:04 -08:00
feat:added download task card to download screen which marks the end of it
This commit is contained in:
28
app/View/DownloadsScreen/components/task_card.kv
Normal file
28
app/View/DownloadsScreen/components/task_card.kv
Normal file
@@ -0,0 +1,28 @@
|
||||
#:import color_text Utility.kivy_markup_helper.color_text
|
||||
|
||||
<TaskText@MDLabel>:
|
||||
adaptive_height:True
|
||||
max_lines:0
|
||||
shorten:False
|
||||
markup:True
|
||||
font_style: "Label"
|
||||
role: "large"
|
||||
bold:True
|
||||
|
||||
|
||||
<TaskCard>:
|
||||
adaptive_height:True
|
||||
radius:8
|
||||
padding:"20dp"
|
||||
md_bg_color:self.theme_cls.surfaceContainerHighColor
|
||||
|
||||
TaskText:
|
||||
size_hint_x:.8
|
||||
text:color_text(root.anime_task_name,root.theme_cls.primaryColor)
|
||||
TaskText:
|
||||
size_hint_x:.2
|
||||
# color:self.theme_cls.surfaceDimColor
|
||||
theme_text_color:"Secondary"
|
||||
text:color_text(root.episodes_to_download,root.theme_cls.secondaryColor)
|
||||
MDIcon:
|
||||
icon:"check-bold"
|
||||
12
app/View/DownloadsScreen/components/task_card.py
Normal file
12
app/View/DownloadsScreen/components/task_card.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from kivy.properties import StringProperty
|
||||
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
|
||||
# TODO: add a progress bar to show the individual progress of each task
|
||||
class TaskCard(MDBoxLayout):
|
||||
anime_task_name = StringProperty()
|
||||
episodes_to_download = StringProperty()
|
||||
def __init__(self, anime_title:str, episodes:str, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.anime_task_name = f"{anime_title}"
|
||||
self.episodes_to_download = f"Episodes: {episodes}"
|
||||
@@ -24,12 +24,20 @@
|
||||
SearchBar:
|
||||
MDScrollView:
|
||||
size_hint:.95,1
|
||||
MDGridLayout:
|
||||
padding: "75dp","50dp","10dp","100dp"
|
||||
spacing:"40dp"
|
||||
MDBoxLayout:
|
||||
id:main_container
|
||||
cols:5
|
||||
orientation:"vertical"
|
||||
padding:"40dp"
|
||||
pos_hint:{"center_x":.5}
|
||||
spacing:"10dp"
|
||||
adaptive_height:True
|
||||
HeaderLabel:
|
||||
text:"Download Tasks"
|
||||
halign:"left"
|
||||
MDIcon:
|
||||
padding:"10dp"
|
||||
pos_hint:{"center_y":.5}
|
||||
icon:"clock"
|
||||
MDBoxLayout:
|
||||
size_hint_y:None
|
||||
height:"40dp"
|
||||
@@ -39,7 +47,7 @@
|
||||
DownloadsScreenLabel:
|
||||
id:download_progress_label
|
||||
size_hint_x: .6
|
||||
text:"current episode"
|
||||
text:"Try Downloading sth :)"
|
||||
pos_hint: {'center_y': .5}
|
||||
MDLinearProgressIndicator:
|
||||
id: progress_bar
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
from kivy.clock import Clock
|
||||
from kivy.properties import ObjectProperty
|
||||
from kivy.logger import Logger
|
||||
from kivy.utils import format_bytes_to_human
|
||||
|
||||
from View.base_screen import BaseScreenView
|
||||
|
||||
from .components.task_card import TaskCard
|
||||
|
||||
class DownloadsScreenView(BaseScreenView):
|
||||
main_container = ObjectProperty()
|
||||
progress_bar = ObjectProperty()
|
||||
download_progress_label = ObjectProperty()
|
||||
|
||||
def on_new_download_task(self,anime_title:str,episodes:str|None):
|
||||
if not episodes:
|
||||
episodes = "All"
|
||||
self.main_container.add_widget(TaskCard(anime_title,episodes))
|
||||
|
||||
def on_episode_download_progress(self,current_bytes_downloaded,total_bytes,episode_info):
|
||||
percentage_completion = (current_bytes_downloaded/total_bytes)*100
|
||||
self.progress_bar.value= max(min(percentage_completion,100),0)
|
||||
self.download_progress_label.text = f"Downloading: {episode_info['anime_title']} - {episode_info['episode']} ({format_bytes_to_human(current_bytes_downloaded)}/{format_bytes_to_human(total_bytes)})"
|
||||
percentage_completion = round((current_bytes_downloaded/total_bytes)*100)
|
||||
progress_text = f"Downloading: {episode_info['anime_title']} - {episode_info['episode']} ({format_bytes_to_human(current_bytes_downloaded)}/{format_bytes_to_human(total_bytes)})"
|
||||
if (percentage_completion%5)==0:
|
||||
self.progress_bar.value= max(min(percentage_completion,100),0)
|
||||
self.download_progress_label.text = progress_text
|
||||
Logger.info(f"Downloader: {progress_text}")
|
||||
|
||||
|
||||
# def on_enter(self):
|
||||
# Clock.schedule_once(lambda _:self.controller.requested_update_my_list_screen())
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<MDLabel>:
|
||||
allow_copy:True
|
||||
allow_selection:True
|
||||
# <MDLabel>:
|
||||
# allow_copy:True
|
||||
# allow_selection:True
|
||||
Reference in New Issue
Block a user