trying to make config work
This commit is contained in:
parent
2abbacf66e
commit
670f7a5c70
7 changed files with 187 additions and 58 deletions
48
src/main.rs
48
src/main.rs
|
|
@ -1,19 +1,17 @@
|
|||
mod state;
|
||||
mod update;
|
||||
mod view;
|
||||
|
||||
use crate::state::{Message, State};
|
||||
use crate::state::Message;
|
||||
use crate::update::update;
|
||||
use iced::widget::{Column, TextInput, column, container, text, text_input};
|
||||
use iced::{Background, Border, Color, Element, Theme};
|
||||
use crate::view::view;
|
||||
use iced::widget::{container, text_input};
|
||||
use iced::{Background, Border, Color};
|
||||
use iced_layershell::application;
|
||||
use iced_layershell::reexport::Anchor;
|
||||
use iced_layershell::settings::{LayerShellSettings, Settings};
|
||||
|
||||
const BORDER_RADIUS: f32 = 15.;
|
||||
const BORDER_WIDTH: f32 = 2.;
|
||||
const PADDING: f32 = 8.;
|
||||
const WINDOW_SIZE: (u32, u32) = (400, 400);
|
||||
const BG_ALPHA: f32 = 0.75;
|
||||
include!(concat!(env!("OUT_DIR"), "/theme.rs"));
|
||||
|
||||
pub fn main() -> Result<(), iced_layershell::Error> {
|
||||
application(
|
||||
|
|
@ -47,33 +45,6 @@ fn subscription(_state: &State) -> iced::Subscription<Message> {
|
|||
])
|
||||
}
|
||||
|
||||
fn view(state: &State) -> Element<'_, Message> {
|
||||
let input = TextInput::new("Type something here...", &state.current_message)
|
||||
.on_input(Message::TextInput)
|
||||
.on_submit(Message::TextSubmit)
|
||||
.id(state.input_id.clone())
|
||||
.style(input_style);
|
||||
|
||||
let history = state
|
||||
.history
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|msg| column![text!("{}", msg.promt).size(12), text!(" {}", msg.output),].into());
|
||||
|
||||
let content = Column::with_children(
|
||||
std::iter::once(input.into())
|
||||
.chain(history)
|
||||
.collect::<Vec<Element<_>>>(),
|
||||
);
|
||||
|
||||
container(content)
|
||||
.width(iced::Length::Fill)
|
||||
.height(iced::Length::Fill)
|
||||
.padding(PADDING)
|
||||
.style(container_style)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn input_style(theme: &iced::Theme, _status: text_input::Status) -> text_input::Style {
|
||||
let ext = theme.extended_palette();
|
||||
text_input::Style {
|
||||
|
|
@ -102,13 +73,6 @@ fn container_style(theme: &iced::Theme) -> container::Style {
|
|||
}
|
||||
}
|
||||
|
||||
fn theme(_state: &State) -> Theme {
|
||||
match dark_light::detect() {
|
||||
Ok(dark_light::Mode::Light) => Theme::Light,
|
||||
_ => Theme::CatppuccinMocha,
|
||||
}
|
||||
}
|
||||
|
||||
fn style(_state: &State, theme: &iced::Theme) -> iced::theme::Style {
|
||||
iced::theme::Style {
|
||||
background_color: Color::TRANSPARENT,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
fn view(state: &State) -> Element<'_, Message> {
|
||||
use crate::state::{Message, State};
|
||||
use iced::widget::{Column, TextInput, column, container, text, text_input};
|
||||
use iced::{Background, Border, Color, Element, color};
|
||||
|
||||
pub fn view(state: &State) -> Element<'_, Message> {
|
||||
let input: TextInput<'_, Message> =
|
||||
TextInput::new("Type something here...", &state.current_message)
|
||||
.on_input(Message::TextInput)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue