59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
// src/components/auth/login.rs
|
|
|
|
use ratatui::{
|
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
|
style::Style,
|
|
widgets::{Block, BorderType, Borders, Paragraph},
|
|
Frame,
|
|
};
|
|
use crate::{
|
|
config::colors::themes::Theme,
|
|
state::pages::auth::AuthState
|
|
};
|
|
|
|
pub fn render_login(f: &mut Frame, area: Rect, theme: &Theme, state: &mut AuthState) {
|
|
let block = Block::default()
|
|
.borders(Borders::ALL)
|
|
.border_type(BorderType::Rounded)
|
|
.border_style(Style::default().fg(theme.accent))
|
|
.style(Style::default().bg(theme.bg))
|
|
.title(" Login ");
|
|
|
|
let inner_area = block.inner(area);
|
|
f.render_widget(block, area);
|
|
|
|
let chunks = Layout::default()
|
|
.direction(Direction::Vertical)
|
|
.constraints([
|
|
Constraint::Percentage(40),
|
|
Constraint::Length(3),
|
|
Constraint::Percentage(40),
|
|
])
|
|
.split(inner_area);
|
|
|
|
let button_style = if state.return_selected {
|
|
Style::default()
|
|
.fg(theme.highlight)
|
|
.add_modifier(ratatui::style::Modifier::BOLD)
|
|
} else {
|
|
Style::default().fg(theme.fg)
|
|
};
|
|
|
|
f.render_widget(
|
|
Paragraph::new("Return to Intro")
|
|
.style(button_style)
|
|
.alignment(Alignment::Center)
|
|
.block(
|
|
Block::default()
|
|
.borders(Borders::ALL)
|
|
.border_type(BorderType::Plain)
|
|
.border_style(if state.return_selected {
|
|
Style::default().fg(theme.accent)
|
|
} else {
|
|
Style::default().fg(theme.border)
|
|
}),
|
|
),
|
|
chunks[1]
|
|
);
|
|
}
|