Skip to content

Commit

Permalink
feat: add PlantUMLKeyboard local package
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Sep 3, 2022
1 parent 26ca791 commit 0f3a449
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PlantUML.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
A0D3C6C72898770F000838D7 /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
A0D3C6C82898770F000838D7 /* NoLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoLogger.swift; sourceTree = "<group>"; };
A0D3C71D28987D94000838D7 /* SwiftPlantUML.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = SwiftPlantUML.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
A0EF7AF128C40A6300660F09 /* PlantUMLKeyboard */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = PlantUMLKeyboard; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -178,6 +179,7 @@
A0D3C63D28984A0E000838D7 = {
isa = PBXGroup;
children = (
A0EF7AF128C40A6300660F09 /* PlantUMLKeyboard */,
A0C1657C289FD315004EB5C7 /* SwiftPlantUMLView.playground */,
A0A42A7B289AD9FA00E929EB /* README.md */,
A0D3C71D28987D94000838D7 /* SwiftPlantUML.playground */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
<integer>1</integer>
</dict>
<key>SwiftPlantUMLView (Playground) 1.xcscheme</key>
<dict>
Expand All @@ -44,7 +44,7 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
</dict>
</dict>
Expand Down
9 changes: 9 additions & 0 deletions PlantUMLKeyboard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
31 changes: 31 additions & 0 deletions PlantUMLKeyboard/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "PlantUMLKeyboard",
platforms: [
.iOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "PlantUMLKeyboard",
targets: ["PlantUMLKeyboard"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "PlantUMLKeyboard",
dependencies: []),
.testTarget(
name: "PlantUMLKeyboardTests",
dependencies: ["PlantUMLKeyboard"]),
]
)
3 changes: 3 additions & 0 deletions PlantUMLKeyboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PlantUMLKeyboard

A description of this package.
84 changes: 84 additions & 0 deletions PlantUMLKeyboard/Sources/PlantUMLKeyboard/PlantUMLKeyboard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import SwiftUI
import UIKit


struct PlantUMLKeyboardView: View {

@Binding var show : Bool
@Binding var txt : String

var body : some View{

ZStack(alignment: .topLeading) {

ScrollView(.vertical, showsIndicators: false) {

VStack(spacing: 15){

ForEach(self.getEmojiList(),id: \.self){i in

HStack(spacing: 25){

ForEach(i,id: \.self){j in

Button(action: {

self.txt += String(UnicodeScalar(j)!)

}) {

if (UnicodeScalar(j)?.properties.isEmoji)!{

Text(String(UnicodeScalar(j)!)).font(.system(size: 55))
}
else{

Text("")
}
}
}
}
}
}
.padding(.top)

}
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height / 3)
.background(Color.white)
.cornerRadius(25)

Button(action: {
self.show.toggle()
}) {
Image(systemName: "xmark").foregroundColor(.black)
}
.padding()
}
}

func getEmojiList()->[[Int]]{

var emojis : [[Int]] = []

for i in stride(from: 0x1F601, to: 0x1F64F, by: 4){

var temp : [Int] = []

for j in i...i+3{

temp.append(j)
}

emojis.append(temp)
}

return emojis
}
}


struct PlantUMLKeyboardViewPreviews: PreviewProvider {
static var previews: some View {
PlantUMLKeyboardView( show: Binding.constant(true), txt: Binding.constant("TEST"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import XCTest
@testable import PlantUMLKeyboard

final class PlantUMLKeyboardTests: XCTestCase {
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
// XCTAssertEqual(PlantUMLKeyboardView().text, "Hello, World!")
}
}

0 comments on commit 0f3a449

Please sign in to comment.