renamed app to anixstream

This commit is contained in:
Benedict Xavier Wanyonyi
2024-05-31 18:12:02 +03:00
parent f24912fd1c
commit 7e9060bb2d
126 changed files with 47 additions and 57 deletions

View File

@@ -0,0 +1,3 @@
from .filters import Filters
from .pagination import SearchResultsPagination
from .trending_sidebar import TrendingAnimeSideBar

View File

@@ -0,0 +1,27 @@
<FilterDropDown>:
MDDropDownItemText:
text: root.text
<FilterLabel@MDLabel>:
adaptive_width:True
<Filters>:
adaptive_height:True
spacing:"10dp"
size_hint_x:.95
pos_hint:{"center_x":.5}
padding:"10dp"
md_bg_color:self.theme_cls.surfaceContainerLowColor
FilterLabel:
text:"Sort By"
FilterDropDown:
id:sort_filter
text:root.filters["sort"]
on_release: root.open_filter_menu(self,"sort")
FilterLabel:
text:"Status"
FilterDropDown:
id:status_filter
text:root.filters["status"]
on_release: root.open_filter_menu(self,"status")

View File

@@ -0,0 +1,83 @@
from kivy.properties import StringProperty, DictProperty
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.dropdownitem import MDDropDownItem
from kivymd.uix.menu import MDDropdownMenu
class FilterDropDown(MDDropDownItem):
text: str = StringProperty()
class Filters(MDBoxLayout):
filters: dict = DictProperty({"sort": "SEARCH_MATCH", "status": "FINISHED"})
def open_filter_menu(self, menu_item, filter_name):
items = []
match filter_name:
case "sort":
items = [
"ID",
"ID_DESC",
"TITLE_ROMANJI",
"TITLE_ROMANJI_DESC",
"TITLE_ENGLISH",
"TITLE_ENGLISH_DESC",
"TITLE_NATIVE",
"TITLE_NATIVE_DESC",
"TYPE",
"TYPE_DESC",
"FORMAT",
"FORMAT_DESC",
"START_DATE",
"START_DATE_DESC",
"END_DATE",
"END_DATE_DESC",
"SCORE",
"SCORE_DESC",
"TRENDING",
"TRENDING_DESC",
"EPISODES",
"EPISODES_DESC",
"DURATION",
"DURATION_DESC",
"STATUS",
"STATUS_DESC",
"UPDATED_AT",
"UPDATED_AT_DESC",
"SEARCH_MATCH",
"POPULARITY",
"POPULARITY_DESC",
"FAVOURITES",
"FAVOURITES_DESC",
]
case "status":
items = [
"FINISHED",
"RELEASING",
"NOT_YET_RELEASED",
"CANCELLED",
"HIATUS",
]
case _:
items = []
if items:
menu_items = [
{
"text": f"{item}",
"on_release": lambda filter_value=f"{item}": self.filter_menu_callback(
filter_name, filter_value
),
}
for item in items
]
MDDropdownMenu(caller=menu_item, items=menu_items).open()
def filter_menu_callback(self, filter_name, filter_value):
match filter_name:
case "sort":
self.ids.sort_filter.text = filter_value
self.filters["sort"] = filter_value
case "status":
self.ids.status_filter.text = filter_value
self.filters["status"] = filter_value

View File

@@ -0,0 +1,21 @@
<PaginationLabel@MDLabel>:
max_lines:0
shorten:False
adaptive_height:True
font_style: "Label"
pos_hint:{"center_y":.5}
halign:"center"
role: "medium"
<SearchResultsPagination>:
md_bg_color:self.theme_cls.surfaceContainerLowColor
radius:8
adaptive_height:True
MDIconButton:
icon:"arrow-left"
on_release:root.search_view.previous_page()
PaginationLabel:
text:"Page {} of {}".format(root.current_page,root.total_pages)
MDIconButton:
icon:"arrow-right"
on_release:root.search_view.next_page()

View File

@@ -0,0 +1,9 @@
from kivy.properties import ObjectProperty, NumericProperty
from kivymd.uix.boxlayout import MDBoxLayout
class SearchResultsPagination(MDBoxLayout):
current_page = NumericProperty()
total_pages = NumericProperty()
search_view = ObjectProperty()

View File

@@ -0,0 +1,6 @@
<TrendingAnimeSideBar>:
orientation: 'vertical'
adaptive_height:True
md_bg_color:self.theme_cls.surfaceContainerLowColor
pos_hint: {'center_x': 0.5}
padding:"25dp","25dp","25dp","200dp"

View File

@@ -0,0 +1,5 @@
from kivymd.uix.boxlayout import MDBoxLayout
class TrendingAnimeSideBar(MDBoxLayout):
pass

View File

@@ -0,0 +1,58 @@
<SearchScreenView>
md_bg_color: self.theme_cls.backgroundColor
search_results_container:search_results_container
trending_anime_sidebar:trending_anime_sidebar
search_results_pagination:search_results_pagination
filters:filters
MDBoxLayout:
size_hint:1,1
NavRail:
screen:root
MDAnchorLayout:
anchor_y: 'top'
padding:"10dp"
size_hint:1,1
MDBoxLayout:
orientation: 'vertical'
size_hint:1,1
SearchBar:
MDBoxLayout:
spacing:"20dp"
padding:"75dp","10dp","100dp","0dp"
MDBoxLayout:
orientation: 'vertical'
size_hint:1,1
Filters:
id:filters
MDBoxLayout:
spacing:"20dp"
MDScrollView:
size_hint:1,1
MDBoxLayout:
orientation: 'vertical'
size_hint_y:None
height:max(self.parent.parent.height,self.minimum_height)
MDGridLayout:
pos_hint: {'center_x': 0.5}
id:search_results_container
spacing: '40dp'
padding: "25dp","50dp","75dp","200dp"
cols:3 if root.width <= 1100 else 5
size_hint_y:None
height:max(self.parent.parent.height,self.minimum_height)
SearchResultsPagination:
id:search_results_pagination
search_view:root
MDBoxLayout:
orientation:"vertical"
size_hint_y:1
size_hint_x:None
width: dp(250)
HeaderLabel:
text:"Trending"
MDScrollView:
TrendingAnimeSideBar:
id:trending_anime_sidebar
height:max(self.parent.parent.height,self.minimum_height)

View File

@@ -0,0 +1,67 @@
from kivy.properties import ObjectProperty, StringProperty
from kivy.clock import Clock
from View.base_screen import BaseScreenView
from .components import TrendingAnimeSideBar, Filters, SearchResultsPagination
class SearchScreenView(BaseScreenView):
trending_anime_sidebar: TrendingAnimeSideBar = ObjectProperty()
search_results_pagination: SearchResultsPagination = ObjectProperty()
filters: Filters = ObjectProperty()
search_results_container = ObjectProperty()
search_term: str = StringProperty()
is_searching = False
has_next_page = False
current_page = 0
total_pages = 0
def handle_search_for_anime(self, search_widget=None, page=None):
if search_widget:
search_term = search_widget.text
elif page:
search_term = self.search_term
else:
return
if search_term and not (self.is_searching):
self.search_term = search_term
self.search_results_container.clear_widgets()
if filters := self.filters.filters:
Clock.schedule_once(
lambda _: self.controller.requested_search_for_anime(
search_term, **filters, page=page
)
)
else:
Clock.schedule_once(
lambda _: self.controller.requested_search_for_anime(
search_term, page=page
)
)
def update_layout(self, widget):
self.search_results_container.add_widget(widget)
def update_pagination(self, pagination_info):
self.search_results_pagination.current_page = self.current_page = (
pagination_info["currentPage"]
)
self.search_results_pagination.total_pages = self.total_pages = max(
int(pagination_info["total"] / 30), 1
)
self.has_next_page = pagination_info["hasNextPage"]
def next_page(self):
if self.has_next_page:
page = self.current_page + 1
self.handle_search_for_anime(page=page)
def previous_page(self):
if self.current_page > 1:
page = self.current_page - 1
self.handle_search_for_anime(page=page)
def update_trending_sidebar(self, trending_anime):
self.trending_anime_sidebar.add_widget(trending_anime)