cargo: fmt
This commit is contained in:
parent
05879a8758
commit
09b0e7af9e
12
src/api.rs
12
src/api.rs
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]
|
||||
|
|
16
src/ui.rs
16
src/ui.rs
|
@ -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,
|
||||
);
|
||||
|
||||
|
|
Reference in a new issue