mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 00:10:38 +08:00
bin: Use new imUI messaging
This commit is contained in:
@@ -49,7 +49,7 @@ const HELP: &str = r#"# Generic keybindings
|
||||
Pattern: is:<state> | is:authored | authors:[<did>, <did>] | <search>
|
||||
Example: is:open is:authored improve"#;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
Quit,
|
||||
Exit {
|
||||
@@ -243,7 +243,7 @@ impl App {
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn show_patches(&self, frame: &mut Frame, ui: &mut im::Ui, state: &State) {
|
||||
pub fn show_patches(&self, frame: &mut Frame, ui: &mut im::Ui<Message>, state: &State) {
|
||||
let patches = state
|
||||
.storage
|
||||
.patches
|
||||
@@ -278,7 +278,12 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show_search_text_edit(&self, frame: &mut Frame, ui: &mut im::Ui, state: &State) {
|
||||
pub fn show_search_text_edit(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
ui: &mut im::Ui<Message>,
|
||||
state: &State,
|
||||
) {
|
||||
let (mut search_text, mut search_cursor) = (
|
||||
state.search.clone().read().text,
|
||||
state.search.clone().read().cursor,
|
||||
@@ -314,7 +319,7 @@ impl im::App for App {
|
||||
type State = State;
|
||||
type Message = Message;
|
||||
|
||||
fn update(&self, ctx: &im::Context, frame: &mut Frame, state: &Self::State) -> Result<()> {
|
||||
fn update(&self, ctx: &im::Context<Message>, frame: &mut Frame, state: &State) -> Result<()> {
|
||||
Window::default().show(ctx, |ui| {
|
||||
match state.page {
|
||||
Page::Main => {
|
||||
@@ -481,7 +486,7 @@ impl im::App for App {
|
||||
}
|
||||
}
|
||||
|
||||
fn browser_context<'a>(ui: &im::Ui, state: &'a State) -> Vec<Column<'a>> {
|
||||
fn browser_context<'a>(ui: &im::Ui<Message>, state: &'a State) -> Vec<Column<'a>> {
|
||||
let search = state.search.read().text;
|
||||
let total_count = state.storage.patches.len();
|
||||
let filtered_count = state
|
||||
@@ -644,7 +649,7 @@ fn browser_context<'a>(ui: &im::Ui, state: &'a State) -> Vec<Column<'a>> {
|
||||
}
|
||||
}
|
||||
|
||||
fn default_context<'a>(ui: &im::Ui) -> Vec<Column<'a>> {
|
||||
fn default_context<'a>(ui: &im::Ui<Message>) -> Vec<Column<'a>> {
|
||||
[
|
||||
Column::new(
|
||||
Span::raw(" ".to_string())
|
||||
|
||||
+13
-7
@@ -9,22 +9,25 @@ use tui::ui::im::widget::{TableState, TextEditState, Widget};
|
||||
use tui::ui::im::{Borders, BufferedValue, Response, Ui};
|
||||
use tui::ui::{Column, ToRow};
|
||||
|
||||
pub struct UiExt<'a>(&'a mut Ui);
|
||||
pub struct UiExt<'a, M>(&'a mut Ui<M>);
|
||||
|
||||
impl<'a> UiExt<'a> {
|
||||
pub fn new(ui: &'a mut Ui) -> Self {
|
||||
impl<'a, M> UiExt<'a, M> {
|
||||
pub fn new(ui: &'a mut Ui<M>) -> Self {
|
||||
Self(ui)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a mut Ui> for UiExt<'a> {
|
||||
fn from(ui: &'a mut Ui) -> Self {
|
||||
impl<'a, M> From<&'a mut Ui<M>> for UiExt<'a, M> {
|
||||
fn from(ui: &'a mut Ui<M>) -> Self {
|
||||
Self::new(ui)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<'a> UiExt<'a> {
|
||||
impl<'a, M> UiExt<'a, M>
|
||||
where
|
||||
M: Clone,
|
||||
{
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn browser<R, const W: usize>(
|
||||
&mut self,
|
||||
@@ -106,7 +109,10 @@ impl<'a, R, const W: usize> Widget for Browser<'a, R, W>
|
||||
where
|
||||
R: ToRow<W> + Clone,
|
||||
{
|
||||
fn ui(self, ui: &mut Ui, frame: &mut Frame) -> Response {
|
||||
fn ui<M>(self, ui: &mut Ui<M>, frame: &mut Frame) -> Response
|
||||
where
|
||||
M: Clone,
|
||||
{
|
||||
let mut response = Response::default();
|
||||
|
||||
let (_, has_focus) = ui.current_area().unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user