mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 08:20:39 +08:00
issue: Remove unnecessary generic backend parameter
This commit is contained in:
@@ -15,7 +15,6 @@ use tui::cob::issue;
|
||||
use tui::store::StateValue;
|
||||
use tui::task;
|
||||
use tui::task::Interrupted;
|
||||
use tui::terminal::Backend;
|
||||
use tui::ui::items::{Filter, IssueItem, IssueItemFilter};
|
||||
use tui::ui::widget::{Properties, View, Window, WindowProps};
|
||||
use tui::ui::Frontend;
|
||||
@@ -200,7 +199,7 @@ impl App {
|
||||
let (frontend, action_tx, action_rx) = Frontend::new();
|
||||
let state = State::try_from(&self.context)?;
|
||||
|
||||
let window: Window<Backend, State, Action, Page> = Window::new(&state, action_tx.clone())
|
||||
let window: Window<State, Action, Page> = Window::new(&state, action_tx.clone())
|
||||
.page(
|
||||
Page::Browse,
|
||||
BrowsePage::new(&state, action_tx.clone()).to_boxed(),
|
||||
|
||||
@@ -9,7 +9,6 @@ use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use termion::event::Key;
|
||||
|
||||
use ratatui::backend::Backend;
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::style::Stylize;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
@@ -34,7 +33,7 @@ use crate::tui_issue::common::Mode;
|
||||
|
||||
use super::{Action, State};
|
||||
|
||||
type BoxedWidget<B> = widget::BoxedWidget<B, State, Action>;
|
||||
type BoxedWidget = widget::BoxedWidget<State, Action>;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct BrowsePageProps<'a> {
|
||||
@@ -120,23 +119,20 @@ impl<'a> From<&State> for BrowsePageProps<'a> {
|
||||
|
||||
impl<'a> Properties for BrowsePageProps<'a> {}
|
||||
|
||||
pub struct BrowsePage<'a, B> {
|
||||
pub struct BrowsePage<'a> {
|
||||
/// Internal base
|
||||
base: BaseView<State, Action>,
|
||||
/// Internal props
|
||||
props: BrowsePageProps<'a>,
|
||||
/// Notifications widget
|
||||
issues: BoxedWidget<B>,
|
||||
issues: BoxedWidget,
|
||||
/// Search widget
|
||||
search: BoxedWidget<B>,
|
||||
search: BoxedWidget,
|
||||
/// Shortcut widget
|
||||
shortcuts: BoxedWidget<B>,
|
||||
shortcuts: BoxedWidget,
|
||||
}
|
||||
|
||||
impl<'a: 'static, B> View for BrowsePage<'a, B>
|
||||
where
|
||||
B: Backend + 'a,
|
||||
{
|
||||
impl<'a: 'static> View for BrowsePage<'a> {
|
||||
type Action = Action;
|
||||
type State = State;
|
||||
|
||||
@@ -272,7 +268,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B: Backend> BrowsePage<'a, B> {
|
||||
impl<'a> BrowsePage<'a> {
|
||||
fn build_footer(props: &BrowsePageProps<'a>, selected: Option<usize>) -> Vec<Column<'a>> {
|
||||
let search = Line::from(vec![
|
||||
span::default(" Search ").cyan().dim().reversed(),
|
||||
@@ -349,10 +345,7 @@ impl<'a, B: Backend> BrowsePage<'a, B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a: 'static, B> Widget<B> for BrowsePage<'a, B>
|
||||
where
|
||||
B: Backend + 'a,
|
||||
{
|
||||
impl<'a: 'static> Widget for BrowsePage<'a> {
|
||||
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
|
||||
let props = props
|
||||
.and_then(BrowsePageProps::from_boxed_any)
|
||||
@@ -409,16 +402,16 @@ pub struct SearchProps {}
|
||||
|
||||
impl Properties for SearchProps {}
|
||||
|
||||
pub struct Search<B: Backend> {
|
||||
pub struct Search {
|
||||
/// Internal base
|
||||
base: BaseView<State, Action>,
|
||||
/// Internal props
|
||||
_props: SearchProps,
|
||||
/// Search input field
|
||||
input: BoxedWidget<B>,
|
||||
input: BoxedWidget,
|
||||
}
|
||||
|
||||
impl<B: Backend> View for Search<B> {
|
||||
impl View for Search {
|
||||
type Action = Action;
|
||||
type State = State;
|
||||
|
||||
@@ -478,10 +471,7 @@ impl<B: Backend> View for Search<B> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> Widget<B> for Search<B>
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
impl Widget for Search {
|
||||
fn render(&self, frame: &mut ratatui::Frame, area: Rect, _props: Option<Box<dyn Any>>) {
|
||||
let layout = Layout::horizontal(Constraint::from_mins([0]))
|
||||
.horizontal_margin(1)
|
||||
@@ -512,24 +502,18 @@ impl<'a> From<&State> for HelpPageProps<'a> {
|
||||
|
||||
impl<'a> Properties for HelpPageProps<'a> {}
|
||||
|
||||
pub struct HelpPage<'a, B>
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
pub struct HelpPage<'a> {
|
||||
/// Internal base
|
||||
base: BaseView<State, Action>,
|
||||
/// Internal props
|
||||
props: HelpPageProps<'a>,
|
||||
/// Content widget
|
||||
content: BoxedWidget<B>,
|
||||
content: BoxedWidget,
|
||||
/// Shortcut widget
|
||||
shortcuts: BoxedWidget<B>,
|
||||
shortcuts: BoxedWidget,
|
||||
}
|
||||
|
||||
impl<'a: 'static, B> View for HelpPage<'a, B>
|
||||
where
|
||||
B: Backend + 'a,
|
||||
{
|
||||
impl<'a: 'static> View for HelpPage<'a> {
|
||||
type Action = Action;
|
||||
type State = State;
|
||||
|
||||
@@ -632,10 +616,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a: 'static, B> Widget<B> for HelpPage<'a, B>
|
||||
where
|
||||
B: Backend + 'a,
|
||||
{
|
||||
impl<'a: 'static> Widget for HelpPage<'a> {
|
||||
fn render(&self, frame: &mut ratatui::Frame, area: Rect, props: Option<Box<dyn Any>>) {
|
||||
let props = props
|
||||
.and_then(HelpPageProps::from_boxed_any)
|
||||
|
||||
Reference in New Issue
Block a user