Skip to content

Commit

Permalink
Extract section header format into helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
geolessel committed Jan 15, 2019
1 parent fe4f96c commit 55f6752
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/details_window.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DetailsWindow < Window

if @card.attachments.size > 0
pad.attron(App::Colors.green)
pad.addstr("\n\n--| Attachments |--\n")
pad.addstr(section_header("Attachments"))
pad.attroff(App::Colors.green)
@card.attachments.each do |attachment|
pad.addstr("#{attachment["name"].to_s}\n")
Expand All @@ -51,7 +51,7 @@ class DetailsWindow < Window

@card.checklists.each do |checklist|
pad.attron(App::Colors.green)
pad.addstr("\n\n--| #{checklist["name"].to_s} |--\n")
pad.addstr(section_header(checklist["name"].to_s))
pad.attroff(App::Colors.green)
checklist["checkItems"].as_a.each do |item|
if item.as_h["state"].to_s == "complete"
Expand All @@ -64,7 +64,7 @@ class DetailsWindow < Window
end

pad.attron(App::Colors.green)
pad.addstr("\n\n--| Activity |--\n")
pad.addstr(section_header("Activity"))
pad.attroff(App::Colors.green)
@card.activities.map { |activity| CardActionBuilder.run(activity) }.each do |activity|
activity.display!(pad, width: @width - 2)
Expand Down Expand Up @@ -163,4 +163,8 @@ class DetailsWindow < Window
def reload_card!
@card.fetch
end

def section_header(text)
"\n\n--| #{text} |--\n"
end
end

0 comments on commit 55f6752

Please sign in to comment.