cargo: fmt

This commit is contained in:
Muhammad Nauman Raza 2024-05-28 15:51:15 +01:00
parent 05879a8758
commit 09b0e7af9e
Signed by: devraza
GPG key ID: 91EAD6081011574B
4 changed files with 29 additions and 28 deletions

View file

@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
#[allow(non_snake_case)]
@ -15,12 +15,16 @@ pub struct SearchResults {
pub struct Search {
pub currentPage: String,
pub hasNextPage: bool,
pub results: Vec<SearchResults>
pub results: Vec<SearchResults>,
}
pub async fn query_anime(query: String) -> Result<Search, reqwest::Error> {
reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query))
.await.expect("Failed to get from API")
reqwest::get(format!(
"https://altoku-api.vercel.app/anime/gogoanime/{}?page=1",
query
))
.await
.expect("Failed to get from API")
.json::<Search>()
.await
}

View file

@ -1,5 +1,5 @@
use crate::app::{App, AppResult};
use crate::api::query_anime;
use crate::app::{App, AppResult};
use crossterm::event::*;
use tui_input::backend::crossterm::EventHandler;

View file

@ -1,15 +1,12 @@
use std::io;
use ratatui::{
prelude::*,
backend::CrosstermBackend,
};
use ratatui::{backend::CrosstermBackend, prelude::*};
use altoku::{
app::{App, AppResult},
tui::Tui,
event::{Event, EventHandler},
handler::handle_key_events,
tui::Tui,
};
#[tokio::main]

View file

@ -22,8 +22,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
)
.split(frame.size());
let text: Vec<Line> = vec![
Line::from(vec![
let text: Vec<Line> = vec![Line::from(vec![
"Press ".into(),
"Esc".bold(),
" or ".into(),
@ -31,8 +30,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
" to quit, and ".into(),
"Enter".bold(),
" to submit your query.".into(),
]),
];
])];
let help_message = Paragraph::new(text);
frame.render_widget(help_message, chunks[0]);
@ -42,12 +40,14 @@ pub fn render(app: &mut App, frame: &mut Frame) {
let input = Paragraph::new(app.input.value())
.style(Style::default().fg(Color::Yellow))
.scroll((0, scroll as u16))
.block(Block::default().borders(Borders::ALL).title("Search (Anime)"));
.block(
Block::default()
.borders(Borders::ALL)
.title("Search (Anime)"),
);
frame.render_widget(input, chunks[1]);
frame.set_cursor(
chunks[1].x
+ ((app.input.visual_cursor()).max(scroll) - scroll) as u16
+ 1,
chunks[1].x + ((app.input.visual_cursor()).max(scroll) - scroll) as u16 + 1,
chunks[1].y + 1,
);