package presentation import ( "fmt" "git.sapphic.engineer/roleypoly/v4/types" "git.sapphic.engineer/roleypoly/v4/utils" ) type InputType string const ( InputCheckbox InputType = "checkbox" InputRadio InputType = "radio" ) type PresentableRole struct { ID string CategoryID string Name string Selected bool InputType InputType Colors PresentableRoleColors } func Role(category *types.Category, role *types.Role, selected bool) PresentableRole { inputType := InputCheckbox if category.Type == types.CategorySingle { inputType = InputRadio } colors := GetColors(role.Color) return PresentableRole{ ID: role.ID, CategoryID: category.ID, Name: role.Name, Selected: selected, InputType: inputType, Colors: colors, } } type PresentableRoleColors struct { Main string IsDark bool } func GetColors(roleColor uint32) PresentableRoleColors { // TODO: no color r, g, b := utils.IntToRgb(roleColor) return PresentableRoleColors{ Main: fmt.Sprintf("#%x", roleColor), IsDark: utils.IsDarkColor(r, g, b), } }