package gio import ( "image" "image/color" "gioui.org/layout" "gioui.org/op/clip" "gioui.org/op/paint" "gioui.org/unit" "gioui.org/widget/material" "softbox.local/core/application" "softbox.local/core/domain" ) var shellColors = struct { background color.NRGBA surface color.NRGBA muted color.NRGBA foreground color.NRGBA secondary color.NRGBA primary color.NRGBA onPrimary color.NRGBA border color.NRGBA success color.NRGBA warning color.NRGBA destructive color.NRGBA }{ background: color.NRGBA{R: 248, G: 250, B: 252, A: 255}, surface: color.NRGBA{R: 255, G: 255, B: 255, A: 255}, muted: color.NRGBA{R: 240, G: 248, B: 246, A: 255}, foreground: color.NRGBA{R: 15, G: 23, B: 42, A: 255}, secondary: color.NRGBA{R: 71, G: 85, B: 105, A: 255}, primary: color.NRGBA{R: 5, G: 150, B: 105, A: 255}, onPrimary: color.NRGBA{R: 255, G: 255, B: 255, A: 255}, border: color.NRGBA{R: 209, G: 229, B: 223, A: 255}, success: color.NRGBA{R: 4, G: 120, B: 87, A: 255}, warning: color.NRGBA{R: 180, G: 83, B: 9, A: 255}, destructive: color.NRGBA{R: 185, G: 28, B: 28, A: 255}, } // NewTheme creates the accessible palette shared by the Legacy shell. func NewTheme() *material.Theme { theme := material.NewTheme() theme.Palette = material.Palette{ Bg: shellColors.background, Fg: shellColors.foreground, ContrastBg: shellColors.primary, ContrastFg: shellColors.onPrimary, } theme.FingerSize = unit.Dp(44) return theme } func panel( gtx layout.Context, background color.NRGBA, radius unit.Dp, inset layout.Inset, content layout.Widget, ) layout.Dimensions { return layout.Background{}.Layout( gtx, func(gtx layout.Context) layout.Dimensions { paint.FillShape( gtx.Ops, background, clip.UniformRRect( image.Rectangle{Max: gtx.Constraints.Min}, gtx.Dp(radius), ).Op(gtx.Ops), ) return layout.Dimensions{Size: gtx.Constraints.Min} }, func(gtx layout.Context) layout.Dimensions { return inset.Layout(gtx, content) }, ) } func outlinedPanel( gtx layout.Context, border color.NRGBA, background color.NRGBA, radius unit.Dp, inset layout.Inset, content layout.Widget, ) layout.Dimensions { return panel( gtx, border, radius, layout.UniformInset(unit.Dp(1)), func(gtx layout.Context) layout.Dimensions { return panel(gtx, background, radius-unit.Dp(1), inset, content) }, ) } func viewTitle(view application.CatalogView) string { switch view { case application.CatalogViewInstalled: return "已安装软件" case application.CatalogViewUpdates: return "可更新软件" default: return "全部软件" } } func statusLabel(status domain.AppStatus) string { switch status { case domain.StatusQueued: return "排队中" case domain.StatusDownloading: return "下载中" case domain.StatusVerifying: return "校验中" case domain.StatusExtracting: return "解压中" case domain.StatusInstalling: return "安装中" case domain.StatusInstalled: return "已安装" case domain.StatusUpdateAvailable: return "可更新" case domain.StatusRunning: return "运行中" case domain.StatusFailed: return "失败" case domain.StatusRollbackPending: return "待恢复" case domain.StatusIncompatible: return "不兼容" default: return "未安装" } } func statusColor(status domain.AppStatus) color.NRGBA { switch status { case domain.StatusFailed, domain.StatusRollbackPending: return shellColors.destructive case domain.StatusUpdateAvailable: return shellColors.warning case domain.StatusInstalled, domain.StatusRunning: return shellColors.success case domain.StatusIncompatible: return shellColors.secondary default: return shellColors.primary } }