Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/pulls: draw pull status in a rounded rect

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by tangled.org d3ed18b4 8be62f1f

+27 -19
+27 -19
appview/pulls/opengraph.go
··· 128 128 } 129 129 130 130 // Split stats area: left side for status/stats (80%), right side for dolly (20%) 131 - statusStatsArea, dollyArea := statsArea.Split(true, 80) 131 + statusArea, dollyArea := statsArea.Split(true, 80) 132 132 133 133 // Draw status and stats 134 - statsBounds := statusStatsArea.Img.Bounds() 134 + statsBounds := statusArea.Img.Bounds() 135 135 statsX := statsBounds.Min.X + 60 // left padding 136 136 statsY := statsBounds.Min.Y 137 137 ··· 157 157 } else { 158 158 statusIcon = "git-pull-request-closed" 159 159 statusText = "closed" 160 - statusColor = color.RGBA{128, 128, 128, 255} // gray 160 + statusColor = color.RGBA{52, 58, 64, 255} // dark gray 161 161 } 162 162 163 - statusIconSize := 36 163 + statusTextWidth := statusArea.TextWidth(statusText, textSize) 164 + badgePadding := 12 165 + badgeHeight := int(textSize) + (badgePadding * 2) 166 + badgeWidth := iconSize + badgePadding + statusTextWidth + (badgePadding * 2) 167 + cornerRadius := 8 168 + badgeX := 60 169 + badgeY := 0 164 170 165 - // Draw icon with status color 166 - err = statusStatsArea.DrawLucideIcon(statusIcon, statsX, statsY+iconBaselineOffset-statusIconSize/2+5, statusIconSize, statusColor) 171 + statusArea.DrawRoundedRect(badgeX, badgeY, badgeWidth, badgeHeight, cornerRadius, statusColor) 172 + 173 + whiteColor := color.RGBA{255, 255, 255, 255} 174 + iconX := statsX + badgePadding 175 + iconY := statsY + (badgeHeight-iconSize)/2 176 + err = statusArea.DrawLucideIcon(statusIcon, iconX, iconY, iconSize, whiteColor) 167 177 if err != nil { 168 178 log.Printf("failed to draw status icon: %v", err) 169 179 } 170 180 171 - // Draw text with status color 172 - textX := statsX + statusIconSize + 12 173 - statusTextSize := 32.0 174 - err = statusStatsArea.DrawTextAt(statusText, textX, statsY+iconBaselineOffset, statusColor, statusTextSize, ogcard.Middle, ogcard.Left) 181 + textX := statsX + badgePadding + iconSize + badgePadding 182 + textY := statsY + (badgeHeight-int(textSize))/2 - 5 183 + err = statusArea.DrawTextAt(statusText, textX, textY, whiteColor, textSize, ogcard.Top, ogcard.Left) 175 184 if err != nil { 176 185 log.Printf("failed to draw status text: %v", err) 177 186 } 178 187 179 - statusTextWidth := len(statusText) * 20 180 - currentX := statsX + statusIconSize + 12 + statusTextWidth + 40 188 + currentX := statsX + badgeWidth + 50 181 189 182 190 // Draw comment count 183 - err = statusStatsArea.DrawLucideIcon("message-square", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 191 + err = statusArea.DrawLucideIcon("message-square", currentX, iconY, iconSize, iconColor) 184 192 if err != nil { 185 193 log.Printf("failed to draw comment icon: %v", err) 186 194 } ··· 198 190 if commentCount == 1 { 199 191 commentText = "1 comment" 200 192 } 201 - err = statusStatsArea.DrawTextAt(commentText, currentX, statsY+iconBaselineOffset, iconColor, textSize, ogcard.Middle, ogcard.Left) 193 + err = statusArea.DrawTextAt(commentText, currentX, textY, iconColor, textSize, ogcard.Top, ogcard.Left) 202 194 if err != nil { 203 195 log.Printf("failed to draw comment text: %v", err) 204 196 } ··· 207 199 currentX += commentTextWidth + 40 208 200 209 201 // Draw files changed 210 - err = statusStatsArea.DrawLucideIcon("file-diff", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 202 + err = statusArea.DrawLucideIcon("file-diff", currentX, iconY, iconSize, iconColor) 211 203 if err != nil { 212 204 log.Printf("failed to draw file diff icon: %v", err) 213 205 } ··· 217 209 if filesChanged == 1 { 218 210 filesText = "1 file" 219 211 } 220 - err = statusStatsArea.DrawTextAt(filesText, currentX, statsY+iconBaselineOffset, iconColor, textSize, ogcard.Middle, ogcard.Left) 212 + err = statusArea.DrawTextAt(filesText, currentX, textY, iconColor, textSize, ogcard.Top, ogcard.Left) 221 213 if err != nil { 222 214 log.Printf("failed to draw files text: %v", err) 223 215 } ··· 228 220 // Draw additions (green +) 229 221 greenColor := color.RGBA{34, 139, 34, 255} 230 222 additionsText := fmt.Sprintf("+%d", diffStats.Insertions) 231 - err = statusStatsArea.DrawTextAt(additionsText, currentX, statsY+iconBaselineOffset, greenColor, textSize, ogcard.Middle, ogcard.Left) 223 + err = statusArea.DrawTextAt(additionsText, currentX, textY, greenColor, textSize, ogcard.Top, ogcard.Left) 232 224 if err != nil { 233 225 log.Printf("failed to draw additions text: %v", err) 234 226 } ··· 239 231 // Draw deletions (red -) right next to additions 240 232 redColor := color.RGBA{220, 20, 60, 255} 241 233 deletionsText := fmt.Sprintf("-%d", diffStats.Deletions) 242 - err = statusStatsArea.DrawTextAt(deletionsText, currentX, statsY+iconBaselineOffset, redColor, textSize, ogcard.Middle, ogcard.Left) 234 + err = statusArea.DrawTextAt(deletionsText, currentX, textY, redColor, textSize, ogcard.Top, ogcard.Left) 243 235 if err != nil { 244 236 log.Printf("failed to draw deletions text: %v", err) 245 237 } ··· 262 254 openedDate := pull.Created.Format("Jan 2, 2006") 263 255 metaText := fmt.Sprintf("opened by %s · %s", authorHandle, openedDate) 264 256 265 - err = statusStatsArea.DrawTextAt(metaText, statsX, labelY, iconColor, labelSize, ogcard.Top, ogcard.Left) 257 + err = statusArea.DrawTextAt(metaText, statsX, labelY, iconColor, labelSize, ogcard.Top, ogcard.Left) 266 258 if err != nil { 267 259 log.Printf("failed to draw metadata: %v", err) 268 260 }