diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95c4320 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..ae3bbce --- /dev/null +++ b/Package.swift @@ -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"]), + ] +) diff --git a/README.md b/README.md index c12b5cf..ab019c3 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# VText \ No newline at end of file +# VText + +A description of this package. diff --git a/Sources/VText/VText.swift b/Sources/VText/VText.swift new file mode 100644 index 0000000..e612b08 --- /dev/null +++ b/Sources/VText/VText.swift @@ -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' +// } + + 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" + +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..73b8923 --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import VTextTests + +var tests = [XCTestCaseEntry]() +tests += VTextTests.allTests() +XCTMain(tests) diff --git a/Tests/VTextTests/VTextTests.swift b/Tests/VTextTests/VTextTests.swift new file mode 100644 index 0000000..fdcb9db --- /dev/null +++ b/Tests/VTextTests/VTextTests.swift @@ -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), +// ] +//} diff --git a/Tests/VTextTests/XCTestManifests.swift b/Tests/VTextTests/XCTestManifests.swift new file mode 100644 index 0000000..d95c621 --- /dev/null +++ b/Tests/VTextTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(VTextTests.allTests), + ] +} +#endif