Skip to content

Commit 4a710f5

Browse files
author
cht
committed
添加颜色
1 parent fcc50c8 commit 4a710f5

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ tui界面的v2ray
1010
* 按h出设置界面,设置界面里面有两个设置
1111
* v2raycore
1212
* 订阅,当在第二个设置里面添加了订阅后按下键可以选中订阅,d键删除
13-
* s 回到popup的只读界面后按下s进行设置更新和订阅同步,同步失败后不会回退,应该需要做个提示
13+
* s 回到popup的只读界面后按下s进行设置更新
14+
* r 进行订阅同步,同步失败后不会回退,应该需要做个提示
1415
* e
1516
* TODO, 计划作为设置
1617
* s

src/subscribe/appsub.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::spider;
55
use crate::state::{MyBackend, IFEXIT};
66
use std::io;
77
use tokio::sync::mpsc::Receiver;
8+
use tui::style::Color;
89
use tui::widgets::ListState;
910
use tui::Terminal;
1011
pub(super) enum InputMode {
@@ -38,6 +39,7 @@ pub struct AppSub {
3839
pub subscription: Vec<String>,
3940
pub receiver: Option<Receiver<reqwest::Result<Vec<Vec<String>>>>>,
4041
pub popinfomation: String,
42+
pub(super) popupcolor: Color,
4143
}
4244
impl AppSub {
4345
pub fn next(&mut self) {
@@ -143,6 +145,7 @@ impl Default for AppSub {
143145
subscription: Vec::new(),
144146
receiver: None,
145147
popinfomation: "Settings, e to edit, s to save".to_string(),
148+
popupcolor: Color::LightBlue,
146149
}
147150
}
148151
}

src/subscribe/render.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ pub(super) fn ui<B: Backend>(f: &mut Frame<B>, app: &mut AppSub) {
149149
.as_ref(),
150150
)
151151
.split(area);
152+
let block = Block::default().style(Style::default().bg(app.popupcolor).fg(Color::Black));
152153

153154
f.render_widget(Clear, area); //this clears out the background
155+
f.render_widget(block, area); //this clears out the background
154156
let (msg, style) = (vec![Span::raw(app.popinfomation.clone())], Style::default());
155157
let mut text = Text::from(Spans::from(msg));
156158
text.patch_style(style);
@@ -183,7 +185,7 @@ pub(super) fn ui<B: Backend>(f: &mut Frame<B>, app: &mut AppSub) {
183185
.block(Block::default().borders(Borders::ALL).title("List"))
184186
.highlight_style(
185187
Style::default()
186-
.bg(Color::LightBlue)
188+
.bg(Color::LightGreen)
187189
.add_modifier(Modifier::BOLD),
188190
)
189191
.highlight_symbol(">> ");

src/subscribe/state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::{Page, IFEXIT};
55
use crossterm::event::{self, Event, KeyCode};
66
use serde_json::json;
77
use std::{env, io, process::Command};
8+
use tui::style::Color;
89
use tui::widgets::ListState;
910
pub(super) async fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
1011
if app.receiver.is_some() {
@@ -50,6 +51,7 @@ pub(super) async fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
5051
app.receiver = None;
5152
app.popinfomation = "Settings, e to edit, s to save".to_string();
5253
app.input_mode = InputMode::Popup;
54+
app.popupcolor = Color::LightBlue;
5355
}
5456
} else if let Event::Key(key) = event::read()? {
5557
match app.input_mode {
@@ -165,12 +167,16 @@ pub(super) async fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
165167
subscribe_json.push_str("\n]");
166168
utils::create_json_file(utils::Save::Subscribes, subscribe_json)
167169
.unwrap_or_else(|err| panic!("{}", err));
170+
app.popinfomation = "Have saved".to_string();
168171
// .collect();
172+
}
173+
KeyCode::Char('r') => {
169174
let (sync_io_tx, sync_io_rx) =
170175
tokio::sync::mpsc::channel::<reqwest::Result<Vec<Vec<String>>>>(100);
171176
app.receiver = Some(sync_io_rx);
172177
let input = app.subscription.clone();
173178
app.popinfomation = "Waiting for a moment".to_string();
179+
app.popupcolor = Color::LightYellow;
174180
tokio::spawn(async move {
175181
let get_list = spider::get_the_key(input).await;
176182
sync_io_tx.send(get_list).await.unwrap();

0 commit comments

Comments
 (0)