mikaelacaron / brain-marks

[Not Active] Open-source iOS app to save and categorize tweets
MIT License
80 stars 47 forks source link

Add function to highlight hashtags #161

Closed MarshallARoss closed 2 years ago

MarshallARoss commented 2 years ago

Progress / Closed on issue #82 Highlight Hashtags

What it Does

How I Tested

Screenshot

Simulator Screen Shot - iPhone 13 Pro - 2022-10-12 at 17 42 48

MarshallARoss commented 2 years ago

Thanks @mikaelacaron. I kind of got it right after messaging. I reset everything and redid it. If I'm still having trouble in the future I'll hit you up!

mikaelacaron commented 2 years ago

Can you install SwiftLint, it seems you haven't and there are 4 errors related to it when building the project. Please resolve these warnings

Screen Shot 2022-10-14 at 12 38 17 AM
MarshallARoss commented 2 years ago

Hi @mikaelacaron. Any attempt to shorthand these results in an error - "Binary operator '+=' cannot be applied to two 'Text' operands." Do you want to try a different approach or do you prefer I tell lint to ignore that for this function.

mikaelacaron commented 2 years ago

Hi @mikaelacaron. Any attempt to shorthand these results in an error - "Binary operator '+=' cannot be applied to two 'Text' operands." Do you want to try a different approach or do you prefer I tell lint to ignore that for this function.

@MarshallARoss Generally I don't want to comment out SwiftLint rules, but for this I'll allow it. Add // swiftlint:disable shorthand_operator right before the extension.

Also all your comments, fix the SwiftLint warnings for those, and all the if comments, put them inside the if { } or else { }, not before them

// Check if # is at the beginning of a string
if prefixString == "" {            
   output = output + Text(" ") + hashtagText

 } else if prefixString.contains("\n") {
   // Check if # is at the beginning of a word preceded by blank lines
   output = output + Text(" ") + Text(prefixString) + hashtagText

} else {
   // if # is not at the beginning of a word do not highlight
   output = output + Text(" ") + Text(String(word))
}

Also for the comment before the function use Cmd + Shift + / which will give you this, and fill it in appropriately. This will allow your comment to show up when clicking on "quick help"

/// Description
/// - Parameter tweet:
/// - Returns:

On your Tweet+Extension you don't need to put Optional in front of everything, and and use line breaks to fix most of the line length violation warnings

mikaelacaron commented 2 years ago

@MarshallARoss I found an edge case, this tweet: the #help... is highlighted when only the #help should be highlighted

MarshallARoss commented 2 years ago

Updated and resubmitted. #164