Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pawello2222 committed Jul 23, 2023
1 parent bcab9d6 commit 709a170
Showing 1 changed file with 21 additions and 124 deletions.
145 changes: 21 additions & 124 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,39 @@
<p align="center">
<img src=".resources/Assets/logo.png" alt="PhantomKit logo" height=150>
<img src=".resources/Assets/logo.png" alt="XFormatter logo" height=150>
</p>
<p align="center">
<a href="https://github.com/pawello2222/PhantomKit/actions?query=branch%3Amain">
<img src="https://img.shields.io/github/actions/workflow/status/pawello2222/PhantomKit/ci.yml?logo=github" alt="Build">
<a href="https://github.com/pawello2222/XFormatter/actions?query=branch%3Amain">
<img src="https://img.shields.io/github/actions/workflow/status/pawello2222/XFormatter/ci.yml?logo=github" alt="Build">
</a>
<a href="https://codecov.io/gh/pawello2222/PhantomKit">
<img src="https://codecov.io/gh/pawello2222/PhantomKit/branch/main/graph/badge.svg?token=TFHOHUXCVJ" alt="Code coverage">
<a href="https://codecov.io/gh/pawello2222/XFormatter">
<img src="https://codecov.io/gh/pawello2222/XFormatter/branch/main/graph/badge.svg?token=EYQ7VExCll" alt="Code coverage">
</a>
<a href="https://github.com/pawello2222/PhantomKit">
<a href="https://github.com/pawello2222/XFormatter">
<img src="https://img.shields.io/badge/language-swift-orange.svg" alt="Language">
</a>
<a href="https://github.com/pawello2222/PhantomKit#installation">
<img src="https://img.shields.io/badge/platform-iOS%20%7C%20macOS-lightgrey.svg" alt="Supported platforms">
</a>
</p>
<p align="center">
<a href="https://github.com/pawello2222/PhantomKit#installation">
<a href="https://github.com/pawello2222/XFormatter#installation">
<img src="https://img.shields.io/badge/SPM-compatible-brightgreen.svg" alt="Swift Package Manager">
</a>
<a href="https://github.com/pawello2222/PhantomKit/releases">
<img src="https://img.shields.io/github/v/release/pawello2222/PhantomKit" alt="Release version">
<a href="https://github.com/pawello2222/XFormatter/releases">
<img src="https://img.shields.io/github/v/release/pawello2222/XFormatter" alt="Release version">
</a>
<a href="https://github.com/pawello2222/PhantomKit/blob/main/LICENSE.md">
<img src="https://img.shields.io/github/license/pawello2222/PhantomKit" alt="License">
<a href="https://github.com/pawello2222/XFormatter/blob/main/LICENSE.md">
<img src="https://img.shields.io/github/license/pawello2222/XFormatter" alt="License">
</a>
</p>

# PhantomKit
# XFormatter

PhantomKit is a collection of many useful Swift and SwiftUI extensions and components. It is an _invisible_ layer that supports your application and makes writing Swift code easier.
XFormatter (eXtended Formatter) provides localized strings from numbers, currencies, dates and more.

<details>
<summary>
<b>Table of Contents</b>
</summary>

1. [Installation](#installation)
2. [Swift extensions](#swift)
3. [SwiftUI extensions](#swiftui)
4. [Localized formatters](#formatters)
5. [License](#license)
2. [Highlights](#highlights)
3. [License](#license)

</details>

Expand All @@ -52,111 +45,15 @@ PhantomKit is a collection of many useful Swift and SwiftUI extensions and compo

### Swift Package Manager

PhantomKit is available as a Swift Package.

```swift
.package(url: "https://github.com/pawello2222/PhantomKit.git", .upToNextMajor(from: "1.0.0"))
```

### Tip
XFormatter is available as a Swift Package.

To make PhantomKit _truly invisible_ add the below line in the main file:
```swift
@_exported import PhantomKit
.package(url: "https://github.com/pawello2222/XFormatter.git", .upToNextMajor(from: "1.0.0"))
```

## Highlights <a name="highlights"></a>

### Swift extensions

#### Appliable

```swift
let button = UIButton().apply {
$0.isUserInteractionEnabled = false
}
```

```swift
UserDefaults.standard.apply {
$0.set("Value 1", forKey: "Key 1")
$0.set("Value 2", forKey: "Key 2")
$0.set("Value 3", forKey: "Key 3")
}
```

#### Date

```swift
let date = Date(year: 2023, month: 4, day: 1)

let newDate = date.adjusting(.minute, by: 1)
```

### SwiftUI extensions

#### Convenience methods

```swift
Text("PhantomKit")
.fixedSize(.horizontal)
.frame(max: .infinity)
.onTap {
print("PhantomKit tapped")
}
```

#### Links

```swift
extension URL {
static let home = URL(string: "https://tersacore.com")!
}
```
```swift
Text("Link")
.link(url: .home, openedAs: .fullscreen)
```
```swift
Text("Link")
.link(url: .home, openedAs: .external)
```

#### Presentation

```swift
Text("Open sheet view")
.sheet {
Text("Sheet view")
}
```
```swift
Text("Open fullscreen view")
.fullScreenCover {
Text("Sheet view")
}
```

#### View alignment

```swift
Text("PhantomKit")
.alignment(horizontal: .trailing)
```

instead of:

```swift
HStack {
Spacer()
Text("PhantomKit")
}
```

### Localized formatters


#### Currency
### Currency

```swift
let formatter = XFormatter.currency(
Expand All @@ -173,7 +70,7 @@ XCTAssertEqual(formatter.string(from: -4239.81, abbreviation: .default), "-$4.24
XCTAssertEqual(formatter.string(from: 123.456, sign: .arrow), "▲$123.46")
```

#### Decimal
### Decimal

```swift
let formatter = XFormatter.decimal(
Expand All @@ -189,7 +86,7 @@ XCTAssertEqual(formatter.string(from: 0.123456789, precision: .default), "0.12")
XCTAssertEqual(formatter.string(from: 0.12, precision: .init(3...)), "0.120")
```

#### Date
### Date

```swift
let formatter = XDateFormatter.date(
Expand All @@ -202,7 +99,7 @@ let date = Date(year: 2000, month: 3, day: 24, hour: 16, minute: 14, second: 44)
XCTAssertEqual(formatter.string(from: date), "24.03.2000, 16:14:44")
```

#### Date components
### Date components

```swift
let formatter = XDateFormatter.dateComponents(
Expand Down

0 comments on commit 709a170

Please sign in to comment.