use std::rc::Rc; use gpui::{ AnyElement, App, ElementId, IntoElement, ParentElement, RenderOnce, SharedString, Styled, Window, WindowHandle, div, prelude::*, }; use super::{Hosted, open_hosted}; use crate::{ buttons::{Button, ButtonVariant, IconButton}, layout::ScrollArea, motion::ProgressBar, primitives::{Icon, IconName}, theme::{ActiveTheme, ControlSize, IconSize, Radius, TextSize}, typography::{Caption, Label, Title}, }; /// Where an update stands. #[derive(Clone, Copy, Debug, PartialEq)] pub enum UpdateState { Available, /// 0 to 1. Downloading(f32), Ready, } type Action = Rc; /// Handlers for the update flow. Unset ones hide their button. #[derive(Clone, Default)] struct Actions { download: Option, restart: Option, later: Option, } fn progress_line(state: UpdateState) -> Option { match state { UpdateState::Downloading(value) => { Some(ProgressBar::new("update-progress", value).into_any_element()) } _ => None, } } fn buttons(state: UpdateState, actions: &Actions, size: ControlSize) -> Vec