-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...oppable-ios-app/domains-manager-ios/Modules/Messaging/Entities/MessageMentionString.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// MessageMentionString.swift | ||
// domains-manager-ios | ||
// | ||
// Created by Oleg Kuplin on 26.02.2024. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MessageMentionString { | ||
|
||
static let messageMentionPrefix = "@" | ||
|
||
let mentionWithPrefix: String | ||
let mentionWithoutPrefix: String | ||
|
||
init?(string: String) { | ||
guard string.first == MessageMentionString.messageMentionPrefix.first else { return nil } | ||
|
||
self.mentionWithPrefix = string | ||
self.mentionWithoutPrefix = String(string.dropFirst()) | ||
} | ||
|
||
static func makeMentionFrom(string: String) -> MessageMentionString? { | ||
if let mention = MessageMentionString(string: string) { // Check if already mention first | ||
return mention | ||
} | ||
|
||
let mentionString = messageMentionPrefix + string | ||
return MessageMentionString(string: mentionString) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters