-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename several files and update location (#62)
* fix: fine-tune landscape view sizes * refactor: rename Cell prefix to MessageView for message kinds * refactor: update location of several files * Update ChatView.swift * Update ChatView.swift * chore: remove ViewBuilder [skip ci]
- Loading branch information
1 parent
ccff273
commit c5b3abc
Showing
51 changed files
with
194 additions
and
181 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 was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...es/SwiftyChat/Model/ChatMessageKind.swift → ...ces/SwiftyChat/Core/ChatMessageKind.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// String++.swift | ||
// | ||
// Created by Enes Karaosman on 19.05.2020. | ||
// Copyright © 2020 All rights reserved. | ||
// | ||
|
||
/// Emoji helper | ||
extension Character { | ||
/// A simple emoji is one scalar and presented to the user as an Emoji | ||
private var isSimpleEmoji: Bool { | ||
guard let firstScalar = unicodeScalars.first else { return false } | ||
return firstScalar.properties.isEmoji && firstScalar.value > 0x238C | ||
} | ||
|
||
/// Checks if the scalars will be merged into an emoji | ||
private var isCombinedIntoEmoji: Bool { | ||
unicodeScalars.count > 1 && unicodeScalars.first?.properties.isEmoji ?? false | ||
} | ||
|
||
fileprivate var isEmoji: Bool { isSimpleEmoji || isCombinedIntoEmoji } | ||
} | ||
|
||
extension String { | ||
var containsOnlyEmoji: Bool { !isEmpty && !contains { !$0.isEmoji } } | ||
|
||
private var isSingleEmoji: Bool { count == 1 && containsEmoji } | ||
|
||
private var containsEmoji: Bool { contains { $0.isEmoji } } | ||
|
||
private var emojiString: String { emojis.map { String($0) }.reduce("", +) } | ||
|
||
private var emojis: [Character] { filter { $0.isEmoji } } | ||
|
||
private var emojiScalars: [UnicodeScalar] { filter { $0.isEmoji }.flatMap { $0.unicodeScalars } } | ||
} |
1 change: 0 additions & 1 deletion
1
...ces/SwiftyChat/Extension/UIDevice++.swift → ...wiftyChat/Core/Extension/UIDevice++.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
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
File renamed without changes.
File renamed without changes.
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
3 changes: 1 addition & 2 deletions
3
Sources/SwiftyChat/Protocols/ChatUser.swift → .../SwiftyChat/Core/Protocols/ChatUser.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// EmojiModifier.swift | ||
// | ||
// Created by Enes Karaosman on 22.05.2020. | ||
// Copyright © 2020 All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Modifies text font if contains emoji | ||
struct EmojiModifier: ViewModifier { | ||
|
||
let text: String | ||
let defaultFont: Font | ||
|
||
private var font: Font { | ||
if text.containsOnlyEmoji { | ||
switch text.count { | ||
case 1: return .system(size: 50) | ||
case 2: return .system(size: 38) | ||
case 3: return .system(size: 25) | ||
default: return defaultFont | ||
} | ||
} | ||
|
||
return defaultFont | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content.font(font) | ||
} | ||
} |
Oops, something went wrong.