mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-17 15:22:36 -08:00
renamed app to anixstream
This commit is contained in:
28
anixstream/View/DownloadsScreen/components/task_card.kv
Normal file
28
anixstream/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:"download"
|
||||
12
anixstream/View/DownloadsScreen/components/task_card.py
Normal file
12
anixstream/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}"
|
||||
58
anixstream/View/DownloadsScreen/download_screen.kv
Normal file
58
anixstream/View/DownloadsScreen/download_screen.kv
Normal file
@@ -0,0 +1,58 @@
|
||||
#:import get_color_from_hex kivy.utils.get_color_from_hex
|
||||
#:import StringProperty kivy.properties.StringProperty
|
||||
|
||||
<DownloadsScreenLabel@MDLabel>:
|
||||
adaptive_height:True
|
||||
max_lines:0
|
||||
shorten:False
|
||||
markup:True
|
||||
font_style: "Label"
|
||||
role: "large"
|
||||
bold:True
|
||||
<DownloadsScreenView>
|
||||
md_bg_color: self.theme_cls.backgroundColor
|
||||
main_container:main_container
|
||||
download_progress_label:download_progress_label
|
||||
progress_bar:progress_bar
|
||||
MDBoxLayout:
|
||||
NavRail:
|
||||
screen:root
|
||||
MDAnchorLayout:
|
||||
anchor_y: 'top'
|
||||
MDBoxLayout:
|
||||
orientation: 'vertical'
|
||||
SearchBar:
|
||||
MDScrollView:
|
||||
size_hint:.95,1
|
||||
MDBoxLayout:
|
||||
id:main_container
|
||||
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"
|
||||
spacing:"10dp"
|
||||
padding:"10dp"
|
||||
md_bg_color:self.theme_cls.secondaryContainerColor
|
||||
DownloadsScreenLabel:
|
||||
id:download_progress_label
|
||||
size_hint_x: .6
|
||||
text:"Try Downloading sth :)"
|
||||
pos_hint: {'center_y': .5}
|
||||
MDLinearProgressIndicator:
|
||||
id: progress_bar
|
||||
size_hint_x: .4
|
||||
size_hint_y:None
|
||||
height:"10dp"
|
||||
type: "determinate"
|
||||
pos_hint: {'center_y': .5}
|
||||
32
anixstream/View/DownloadsScreen/download_screen.py
Normal file
32
anixstream/View/DownloadsScreen/download_screen.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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"
|
||||
Clock.schedule_once(
|
||||
lambda _: self.main_container.add_widget(TaskCard(anime_title, episodes))
|
||||
)
|
||||
|
||||
def on_episode_download_progress(
|
||||
self, current_bytes_downloaded, total_bytes, episode_info
|
||||
):
|
||||
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
|
||||
|
||||
def update_layout(self, widget):
|
||||
self.user_anime_list_container.add_widget(widget)
|
||||
Reference in New Issue
Block a user