import { AppWindowModels, TaskData } from "../Models.slint";
import { AppWindowActions } from "../Actions.slint";
import { VButton, ToggleButton, VActionButton, VText, Svg, Palette } from "@selenite";

export component SideBar inherits Rectangle {
	background: Palette.pane;

	VerticalLayout {
		height: parent.height;
		padding: 16px;
		spacing: 16px;
		HorizontalLayout {
			alignment: space-between;
			spacing: 64px;
			VText {
				text: "Sources";
				font-size: 1.5rem;
			}

			VActionButton {
				icon-svg: Svg.plus;
				icon-colorize: Palette.green;
				background: transparent;
				clicked => { AppWindowActions.open-add-source-window() }
			}
		}
		VerticalLayout {
			alignment: space-between;
			vertical-stretch: 1;
			VerticalLayout {
				vertical-stretch: 1;
				spacing: 4px;
				ToggleButton {
					text: "All";
					text-alignment: left;
					active: AppWindowModels.no-source-selected;
					clicked => { AppWindowActions.source-clicked(-1) }

					
				}
				for item[index] in AppWindowModels.sources-selected: ToggleButton {
					text: item.name;
					text-alignment: left;
					active: item.selected;
					clicked => { AppWindowActions.source-clicked(item.id) }
					VActionButton {
						visible: parent.active;
						icon-svg: Svg.cog;
						background: transparent;
						clicked => { AppWindowActions.open-edit-source-window(item.id) }
					}
				}
			}
			VerticalLayout {
				spacing: 4px;
				/*VButton {
					icon-svg: Svg.cog;
					text: "Settings";
					background: transparent;
					clicked => { AppWindowModels.open-settings-window() }
				}*/
			}
		}
	}
}
