modde_ui/views/
overwrite.rs1use std::path::PathBuf;
2
3use crate::views::selectable_text::text;
4use iced::widget::{button, column, row, scrollable};
5use iced::{Element, Length};
6
7use crate::action_button::{ButtonAction, DescribedButtonExt};
8use crate::app::Message;
9
10#[derive(Debug, Clone, Default)]
12pub struct OverwriteState {
13 pub files: Vec<String>, pub overrides_dir: PathBuf,
15}
16
17pub fn view(state: &OverwriteState) -> Element<'_, Message> {
18 let title = text("Overwrite / Profile Overrides").size(20);
19
20 let count_text = text(format!("{} file(s) in overrides", state.files.len())).size(14);
21
22 if state.files.is_empty() {
23 return column![
24 title,
25 count_text,
26 text("No override files. Files placed here will win over all mods during deploy.")
27 .size(12),
28 ]
29 .spacing(12)
30 .padding(16)
31 .into();
32 }
33
34 let file_list: Vec<Element<Message>> = state
35 .files
36 .iter()
37 .map(|f| {
38 row![text(f).size(12).width(Length::Fill),]
39 .padding(4)
40 .into()
41 })
42 .collect();
43
44 let actions = row![
45 button(text("Clear All").size(12))
46 .style(button::danger)
47 .padding([4, 12])
48 .on_action(ButtonAction::ClearOverwrite),
49 button(text("Create Mod from Overrides").size(12))
50 .padding([4, 12])
51 .on_action(ButtonAction::MoveOverwriteToMod(
52 "__from_overrides__".to_string(),
53 )),
54 ]
55 .spacing(8);
56
57 column![
58 title,
59 count_text,
60 actions,
61 scrollable(column(file_list).spacing(2)).height(Length::Fill),
62 ]
63 .spacing(12)
64 .padding(16)
65 .into()
66}