diff --git a/.assets/EmojiPicker-1.png b/.assets/EmojiPicker-1.png new file mode 100644 index 0000000..e0b2436 Binary files /dev/null and b/.assets/EmojiPicker-1.png differ diff --git a/.assets/EmojiPicker-2.png b/.assets/EmojiPicker-2.png new file mode 100644 index 0000000..51978d4 Binary files /dev/null and b/.assets/EmojiPicker-2.png differ diff --git a/.assets/EmojiPicker-Vid.gif b/.assets/EmojiPicker-Vid.gif new file mode 100644 index 0000000..698d663 Binary files /dev/null and b/.assets/EmojiPicker-Vid.gif differ diff --git a/.assets/EmojiPickerFront.png b/.assets/EmojiPickerFront.png new file mode 100644 index 0000000..0af70c3 Binary files /dev/null and b/.assets/EmojiPickerFront.png differ diff --git a/EmojiPicker/.gitignore b/EmojiPicker/.gitignore deleted file mode 100644 index 3b29812..0000000 --- a/EmojiPicker/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/config/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc diff --git a/EmojiPicker/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/EmojiPicker/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/EmojiPicker/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/EmojiPicker/README.md b/EmojiPicker/README.md deleted file mode 100644 index aaf5352..0000000 --- a/EmojiPicker/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# EmojiPicker - -A description of this package. diff --git a/EmojiPicker/Sources/EmojiPicker/EmojiProvider.swift b/EmojiPicker/Sources/EmojiPicker/EmojiProvider.swift deleted file mode 100644 index 2c44ef4..0000000 --- a/EmojiPicker/Sources/EmojiPicker/EmojiProvider.swift +++ /dev/null @@ -1,70 +0,0 @@ -// -// EmojiProvider.swift -// -// -// Created by Kévin Sibué on 11/01/2023. -// - -import Foundation -import Smile - -public final class EmojiProvider { - - func getAll() -> [Emoji] { - return Smile.list().map({ Emoji(value: $0, name: name(emoji: $0).first ?? "") }) - //return emoticons + transportAndMap + regionalCountryFlags + miscItems + miscSymbols + miscSymbolsAndPictographs + supplementalSymbolsAndPictographs + dingbats + variationSelectors + variousAsianCharacters + diacriticalMarksAndSymbols + variationSelector - } - - var emoticons: [String] { - return convert(0x1F601...0x1F64F) - } - - var diacriticalMarksAndSymbols: [String] { - return convert(8400...8447) - } - - var miscItems: [String] { - return convert(9100...9300) - } - - var miscSymbols: [String] { - return convert(0x2600...0x26FF) - } - - var dingbats: [String] { - return convert(0x2700...0x27BF) - } - - var variationSelectors: [String] { - return convert(0xFE00...0xFE0F) - } - - var variousAsianCharacters: [String] { - return convert(0x1F018...0x1F270) - } - - var miscSymbolsAndPictographs: [String] { - return convert(0x1F300...0x1F5FF) - } - - var transportAndMap: [String] { - return convert(0x1F680...0x1F6FF) - } - - var regionalCountryFlags: [String] { - return convert(0x1F1E6...0x1F1FF) - } - - var supplementalSymbolsAndPictographs: [String] { - return convert(0x1F900...0x1F9FF) - } - - var variationSelector: [String] { - return convert(65024...65039) - } - - private func convert(_ range: ClosedRange) -> [String] { - return range.map({ String(UnicodeScalar($0) ?? " ") }).filter({ !$0.isEmpty }) - } - -} diff --git a/EmojiPickerSample/EmojiPickerSample.xcodeproj/project.pbxproj b/EmojiPickerSample/EmojiPickerSample.xcodeproj/project.pbxproj index 260a91b..3a07f8b 100644 --- a/EmojiPickerSample/EmojiPickerSample.xcodeproj/project.pbxproj +++ b/EmojiPickerSample/EmojiPickerSample.xcodeproj/project.pbxproj @@ -7,20 +7,20 @@ objects = { /* Begin PBXBuildFile section */ + B089F70829702B8400F0C479 /* EmojiPicker in Frameworks */ = {isa = PBXBuildFile; productRef = B089F70729702B8400F0C479 /* EmojiPicker */; }; B0DD3892296ED65900DEFE36 /* EmojiPickerSampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0DD3891296ED65900DEFE36 /* EmojiPickerSampleApp.swift */; }; B0DD3894296ED65900DEFE36 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0DD3893296ED65900DEFE36 /* ContentView.swift */; }; B0DD3896296ED65B00DEFE36 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B0DD3895296ED65B00DEFE36 /* Assets.xcassets */; }; B0DD3899296ED65B00DEFE36 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B0DD3898296ED65B00DEFE36 /* Preview Assets.xcassets */; }; - B0DD38A3296ED75900DEFE36 /* EmojiPicker in Frameworks */ = {isa = PBXBuildFile; productRef = B0DD38A2296ED75900DEFE36 /* EmojiPicker */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + B089F70629702B7E00F0C479 /* EmojiPicker */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = EmojiPicker; path = ..; sourceTree = ""; }; B0DD388E296ED65900DEFE36 /* EmojiPickerSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EmojiPickerSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; B0DD3891296ED65900DEFE36 /* EmojiPickerSampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPickerSampleApp.swift; sourceTree = ""; }; B0DD3893296ED65900DEFE36 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; B0DD3895296ED65B00DEFE36 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; B0DD3898296ED65B00DEFE36 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - B0DD38A0296ED67600DEFE36 /* EmojiPicker */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = EmojiPicker; path = ../EmojiPicker; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -28,7 +28,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B0DD38A3296ED75900DEFE36 /* EmojiPicker in Frameworks */, + B089F70829702B8400F0C479 /* EmojiPicker in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -38,6 +38,7 @@ B0DD3885296ED65900DEFE36 = { isa = PBXGroup; children = ( + B089F70629702B7E00F0C479 /* EmojiPicker */, B0DD389F296ED67600DEFE36 /* Packages */, B0DD3890296ED65900DEFE36 /* EmojiPickerSample */, B0DD388F296ED65900DEFE36 /* Products */, @@ -75,7 +76,6 @@ B0DD389F296ED67600DEFE36 /* Packages */ = { isa = PBXGroup; children = ( - B0DD38A0296ED67600DEFE36 /* EmojiPicker */, ); name = Packages; sourceTree = ""; @@ -104,7 +104,7 @@ ); name = EmojiPickerSample; packageProductDependencies = ( - B0DD38A2296ED75900DEFE36 /* EmojiPicker */, + B089F70729702B8400F0C479 /* EmojiPicker */, ); productName = EmojiPickerSample; productReference = B0DD388E296ED65900DEFE36 /* EmojiPickerSample.app */; @@ -364,7 +364,7 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - B0DD38A2296ED75900DEFE36 /* EmojiPicker */ = { + B089F70729702B8400F0C479 /* EmojiPicker */ = { isa = XCSwiftPackageProductDependency; productName = EmojiPicker; }; diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..5179f69 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "smile", + "kind" : "remoteSourceControl", + "location" : "https://github.com/onmyway133/Smile", + "state" : { + "revision" : "40604722a7a56f735124e069fcbb58307637744b", + "version" : "2.1.0" + } + } + ], + "version" : 2 +} diff --git a/EmojiPicker/Package.swift b/Package.swift similarity index 100% rename from EmojiPicker/Package.swift rename to Package.swift diff --git a/README.md b/README.md new file mode 100644 index 0000000..112bd7a --- /dev/null +++ b/README.md @@ -0,0 +1,114 @@ +![EmojiPicker](./.assets/EmojiPickerFront.png) + +## Goal + +In some cases you need to be able to select an emoji and not allow a user to enter anything else (letters, numbers, symbols, ...). + +The EmojiPicker is there for that. + +It is a SwiftUI library that allows you to get a list of all the emojis present on your smartphone but also to create a selector to simplify your life. + +## Screenshots and video + +|Emoji list|Emoji search| +|---|---| +|![Emoji list](./.assets/EmojiPicker-1.png)|![Emoji search](./.assets/EmojiPicker-2.png)| + +![Emoji list](./.assets/EmojiPicker-Vid.gif) + +## Dependencies + +- SwiftUI (iOS >= 15.0) +- [Smile](https://github.com/onmyway133/Smile) (2.1.0) + +## How install it? + +Nowaday we only support Swift Package Manager. You can use build-in UI tool for XCode with this search words: `EmojiPicker` or you can add it directly with this following command : + +```swift +.package(url: "https://github.com/Kelvas09/EmojiPicker.git", from: "1.0.0") +``` + +## How use it? + +First of all you have to import the library `EmojiPicker`: + +```swift +import EmojiPicker +``` + +You then have the option of using the `EmojiPickerView`. This view represents the list of selectable emojis. + +The latter is not embedded in a NavigationView. If you want to display it with a title, you have to do it yourself: + +```swift +... +NavigationView { + EmojiPickerView(selectedEmoji: $selectedEmoji, selectedColor: .orange) + .navigationTitle("Emojis") + .navigationBarTitleDisplayMode(.inline) +} +... +``` + +Here is a complete example: + +```swift +import SwiftUI +import EmojiPicker + +struct ContentView: View { + + @State + var selectedEmoji: Emoji? + + @State + var displayEmojiPicker: Bool = false + + var body: some View { + VStack { + VStack { + Text(selectedEmoji?.value ?? "") + .font(.largeTitle) + Text(selectedEmoji?.name ?? "") + .font(.title3) + } + .padding(8) + Button { + displayEmojiPicker = true + } label: { + Text("Select emoji") + } + } + .padding() + .sheet(isPresented: $displayEmojiPicker) { + NavigationView { + EmojiPickerView(selectedEmoji: $selectedEmoji, selectedColor: .orange) + .navigationTitle("Emojis") + .navigationBarTitleDisplayMode(.inline) + } + } + } + +} +``` + +### Select color + +When a user selects an emoji, it is highlighted. By default the selection color is `blue` but you can change this value when creating the view: + +```swift +EmojiPickerView(selectedEmoji: $selectedEmoji, selectedColor: .orange) +``` + +### Enable search + +By default the search for emoji is allowed in the picker, it is however possible to change this setting when creating the view: + +```swift +EmojiPickerView(selectedEmoji: $selectedEmoji, searchEnabled: false) +``` + +## Samples + +You can access to sample project on folder `EmojiPickerSample` diff --git a/EmojiPicker/Sources/EmojiPicker/Emoji.swift b/Sources/EmojiPicker/Emoji.swift similarity index 100% rename from EmojiPicker/Sources/EmojiPicker/Emoji.swift rename to Sources/EmojiPicker/Emoji.swift diff --git a/EmojiPicker/Sources/EmojiPicker/EmojiPickerView.swift b/Sources/EmojiPicker/EmojiPickerView.swift similarity index 100% rename from EmojiPicker/Sources/EmojiPicker/EmojiPickerView.swift rename to Sources/EmojiPicker/EmojiPickerView.swift diff --git a/Sources/EmojiPicker/EmojiProvider.swift b/Sources/EmojiPicker/EmojiProvider.swift new file mode 100644 index 0000000..f8c5206 --- /dev/null +++ b/Sources/EmojiPicker/EmojiProvider.swift @@ -0,0 +1,17 @@ +// +// EmojiProvider.swift +// +// +// Created by Kévin Sibué on 11/01/2023. +// + +import Foundation +import Smile + +public final class EmojiProvider { + + func getAll() -> [Emoji] { + return Smile.list().map({ Emoji(value: $0, name: name(emoji: $0).first ?? "") }) + } + +} diff --git a/EmojiPicker/Tests/EmojiPickerTests/EmojiPickerTests.swift b/Tests/EmojiPickerTests/EmojiPickerTests.swift similarity index 100% rename from EmojiPicker/Tests/EmojiPickerTests/EmojiPickerTests.swift rename to Tests/EmojiPickerTests/EmojiPickerTests.swift