Skip to content

Commit

Permalink
first Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
NuPlay committed Apr 17, 2021
1 parent 44759e0 commit 40f0db9
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "VText",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "VText",
targets: ["VText"]),
],
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: "VText",
dependencies: []),
.testTarget(
name: "VTextTests",
dependencies: ["VText"]),
]
)
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# VText
# VText

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

public struct VText : View {
var text : String

var fontWeight : FontWeight = FontWeight(rawValue: "") ?? .medium
var fontSize : CGFloat = 17
var spacing : CGFloat = 6
var alignment : HorizontalAlignment = .leading

// init(text: String) {
// self.text = text // Error: Cannot assign value of type 'String' to type 'State<String>'
// }

public init(text : String ,fontWeight: FontWeight = FontWeight(rawValue: "") ?? .medium, fontSize: CGFloat = 17, spacing: CGFloat = 6, alignment: HorizontalAlignment = .leading) {
self.text = text
self.fontWeight = fontWeight
self.fontSize = fontSize
self.spacing = spacing
self.alignment = alignment
}


public var body: some View{
VStack(alignment: alignment, spacing: spacing){
ForEach(0 ..< text.count) { textIndex in
switch fontWeight.rawValue{
case "light" :
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.light)

case "regular":
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.regular)

case "medium":
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.medium)

case "bold":
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.bold)

case "heavy":
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.heavy)

case "black":
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.black)

default:
Text(String(text[text.index(text.startIndex, offsetBy: textIndex)]))
.font(.system(size: fontSize))
.fontWeight(.regular)
}
}
}
}
}

public enum FontWeight: String {
case light = "light"
case regular = "regular"
case medium = "medium"
case bold = "bold"
case heavy = "heavy"
case black = "black"

}
7 changes: 7 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import XCTest

import VTextTests

var tests = [XCTestCaseEntry]()
tests += VTextTests.allTests()
XCTMain(tests)
15 changes: 15 additions & 0 deletions Tests/VTextTests/VTextTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//import XCTest
//@testable import VText
//
//final class VTextTests: XCTestCase {
// func testExample() {
// // This is an example of a functional test case.
// // Use XCTAssert and related functions to verify your tests produce the correct
// // results.
// XCTAssertEqual(VText().text, "Hello, World!")
// }
//
// static var allTests = [
// ("testExample", testExample),
// ]
//}
9 changes: 9 additions & 0 deletions Tests/VTextTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import XCTest

#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(VTextTests.allTests),
]
}
#endif

0 comments on commit 40f0db9

Please # to comment.