mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-10-28 23:50:51 +08:00
patch: Remove unnecessary generic backend parameter
This commit is contained in:
@@ -15,7 +15,6 @@ use tui::cob::patch;
|
||||
use tui::store;
|
||||
use tui::task;
|
||||
use tui::task::Interrupted;
|
||||
use tui::terminal::Backend;
|
||||
use tui::ui::items::{Filter, PatchItem, PatchItemFilter};
|
||||
use tui::ui::widget::Properties;
|
||||
use tui::ui::widget::View;
|
||||
@@ -205,7 +204,7 @@ impl App {
|
||||
let (frontend, action_tx, action_rx) = Frontend::<Action>::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(),
|
||||
|
||||
@@ -8,7 +8,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};
|
||||
@@ -36,7 +35,7 @@ use crate::tui_patch::common::PatchOperation;
|
||||
|
||||
use super::{Action, State};
|
||||
|
||||
type BoxedWidget<B> = widget::BoxedWidget<B, State, Action>;
|
||||
type BoxedWidget = widget::BoxedWidget<State, Action>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BrowsePageProps<'a> {
|
||||
@@ -121,23 +120,20 @@ impl<'a> From<&State> for BrowsePageProps<'a> {
|
||||
|
||||
impl<'a: 'static> 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
|
||||
patches: BoxedWidget<B>,
|
||||
patches: 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;
|
||||
|
||||
@@ -290,7 +286,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 filter = PatchItemFilter::from_str(&props.search).unwrap_or_default();
|
||||
|
||||
@@ -377,10 +373,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)
|
||||
@@ -437,16 +430,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;
|
||||
|
||||
@@ -506,10 +499,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)
|
||||
@@ -540,24 +530,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;
|
||||
|
||||
@@ -660,10 +644,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