Skip to content

Commit

Permalink
chore(example): improve the demo example
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 31, 2025
1 parent d76d3a3 commit d70c5cb
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 5 deletions.
122 changes: 121 additions & 1 deletion examples/demo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ publish = false
clap = { version = "4.5.23", features = ["derive"] }
rand = { version = "0.8.5", features = ["small_rng"], default-features = false }
ratzilla = { path = "../../" }
tachyonfx = { git = "https://github.com/orhun/tachyonfx", branch = "feat/wasm_support", default-features = false, features = ["web-time"] }
tui-big-text = "0.7.0"
28 changes: 26 additions & 2 deletions examples/demo/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use rand::SeedableRng;
use rand::{
distributions::{Distribution, Uniform},
rngs::SmallRng,
SeedableRng,
};
use ratzilla::ratatui::{style::Color, widgets::ListState};
use tachyonfx::{
fx::{self},
Effect, EffectTimer, Interpolation, Motion,
};
use ratzilla::ratatui::widgets::ListState;

const TASKS: [&str; 24] = [
"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10",
Expand Down Expand Up @@ -233,6 +237,7 @@ pub struct App<'a> {
pub barchart: Vec<(&'a str, u64)>,
pub servers: Vec<Server<'a>>,
pub enhanced_graphics: bool,
pub effect: Effect,
}

impl<'a> App<'a> {
Expand Down Expand Up @@ -297,6 +302,25 @@ impl<'a> App<'a> {
},
],
enhanced_graphics,
effect: fx::sequence(&[
fx::parallel(&[
fx::sweep_in(
Motion::LeftToRight,
10,
0,
Color::Black,
EffectTimer::from_ms(7000, Interpolation::QuadIn),
),
fx::sweep_in(
Motion::UpToDown,
10,
0,
Color::Black,
EffectTimer::from_ms(7000, Interpolation::QuadIn),
),
]),
fx::coalesce((2000, Interpolation::SineOut)),
]),
}
}

Expand Down
18 changes: 16 additions & 2 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ratzilla::ratatui::{
layout::{Constraint, Layout, Rect},
style::{Color, Modifier, Style},
layout::{Constraint, Layout, Margin, Rect},
style::{Color, Modifier, Style, Stylize},
symbols,
text::{self, Span},
widgets::{
Expand All @@ -10,6 +10,8 @@ use ratzilla::ratatui::{
},
Frame,
};
use tachyonfx::{Duration, EffectRenderer};
use tui_big_text::{BigText, PixelSize};

use crate::app::App;

Expand All @@ -31,6 +33,18 @@ pub fn draw(frame: &mut Frame, app: &mut App) {
2 => draw_third_tab(frame, app, chunks[1]),
_ => {}
};
let big_text = BigText::builder()
.pixel_size(PixelSize::Quadrant)
.lines(vec!["RATZILLA".white().into()])
.build();
frame.render_widget(
big_text,
frame.area().inner(Margin {
horizontal: frame.area().width / 2 - 15,
vertical: 0,
}),
);
frame.render_effect(&mut app.effect, frame.area(), Duration::from_millis(40));
}

fn draw_first_tab(frame: &mut Frame, app: &mut App, area: Rect) {
Expand Down

0 comments on commit d70c5cb

Please sign in to comment.