Skip to content

Commit

Permalink
2024-01-25 - Updated README (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbattistella authored Jan 25, 2024
1 parent 324180e commit 79a28ce
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 47 deletions.
Binary file modified .github/data/ratio.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 83 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,96 @@

All notable changes to this project will be documented in this file.

## 2.0.2

### What's changed

#### 2024-01-25

- Updated README to detail using `init()` instead of `.onAppear` in SwiftUI
- Fixed the checks for `0` value bezels

## 2.0.1

### What's Changed
<details>
<summary>Expand</summary>

- 2023-10-08 - removed the "Generator" from repo, and moved it into its own repo [#28](https://github.com/markbattistella/BezelKit/issues/28)
### 2023-10-08

- Removed the "Generator" from main repo
- Moved "Generator" into its own repo [#28](https://github.com/markbattistella/BezelKit/issues/28)

</details>

## 2.0.0

### What's Changed
<details>
<summary>Expand</summary>

### 2023-09-23

@corbin-c began working on some of the issues:

- 2023-09-23 - @corbin-c began working on some of the issues:
- This PR starts the refactoring of the huge `index.js`` file, by extracting methods into separate modules.
- 2023-09-25 - Full Updated Package
- This PR addresses a few changes:
1. The `Generator` has been extracted out into the root of the project. This makes it clearer what is Swift Package, and what is NodeJS generation [#20](https://github.com/markbattistella/BezelKit/issues/20)
1. Remove watchOS from the structure since there is no clear and simple way to extract the bezel radius data [#21](https://github.com/markbattistella/BezelKit/issues/21)
1. Removed the use of `txt` files and moved all data into a JSON file. This allows the data to be unique and easier to handle [#24](https://github.com/markbattistella/BezelKit/issues/24)
1. Refactored the way devices are listed in the JSON vs the CSV. JSON using the identifiers as the keys allows there to only be one key at a time - removing conflicts of duplicate identifiers [#24](https://github.com/markbattistella/BezelKit/issues/24)
1. Fixed the way identifiers and data is moved around once the script it run [#19](https://github.com/markbattistella/BezelKit/issues/19)
1. Refactored the modularisation of the Generator scripts [#22](https://github.com/markbattistella/BezelKit/issues/22)
- This PR starts the refactoring of the huge `index.js` file, by extracting methods into separate modules.

### 2023-09-25 - Full Updated Package

This PR addresses a few changes:

1. The `Generator` has been extracted out into the root of the project. This makes it clearer what is Swift Package, and what is NodeJS generation [#20](https://github.com/markbattistella/BezelKit/issues/20)

1. Remove watchOS from the structure since there is no clear and simple way to extract the bezel radius data [#21](https://github.com/markbattistella/BezelKit/issues/21)

1. Removed the use of `txt` files and moved all data into a JSON file. This allows the data to be unique and easier to handle [#24](https://github.com/markbattistella/BezelKit/issues/24)

1. Refactored the way devices are listed in the JSON vs the CSV. JSON using the identifiers as the keys allows there to only be one key at a time - removing conflicts of duplicate identifiers [#24](https://github.com/markbattistella/BezelKit/issues/24)

1. Fixed the way identifiers and data is moved around once the script it run [#19](https://github.com/markbattistella/BezelKit/issues/19)

1. Refactored the modularisation of the Generator scripts [#22](https://github.com/markbattistella/BezelKit/issues/22)

> **Note:** as for the end user / developer there are no breaking changes. There are some error handling additions, and the way the JSON is outputted, but for usage in an Xcode project the API calls are still the same
</details>

## 1.0.4

### What's Changed
<details>
<summary>Expand</summary>

- 2023-09-01 - Auto-update `SupportedDeviceList.md` by @markbattistella-bot in #15
- 2023-09-13 - Added iPhone 15 models by @markbattistella in #17
### 2023-09-01

- Auto-update `SupportedDeviceList.md` by @markbattistella-bot in #15

### 2023-09-13

- Added iPhone 15 models by @markbattistella in #17

</details>

## 1.0.2

<details>
<summary>Expand</summary>

### What's Changed

- 2023-08-26 - Auto-update `SupportedDeviceList.md` by @markbattistella-bot in #10
- 2023-08-27 - fix fallback bezel by @markbattistella in #12
- 2023-08-27 - revert testing of GH action by @markbattistella in #13
#### 2023-08-26

- Auto-update `SupportedDeviceList.md` by @markbattistella-bot in #10

#### 2023-08-27

- Fix fallback bezel by @markbattistella in #12
- Revert testing of GH action by @markbattistella in #13

</details>

## 1.0.1

<details>
<summary>Expand</summary>

### Fixed

- Fixes #4: Now there is a cached version of the JSON next to the `index.js` script. The new data is merged into that instead of the CSV (which was defaulting the bezel to 0.0).
Expand All @@ -57,19 +107,27 @@ All notable changes to this project will be documented in this file.
- README was updated with some images
- Images were compressed for data saving

</details>

## 1.0.0

### Fixed
<details>
<summary>Expand</summary>

- `Package.swift` now imports correct files from the Resources
- `Package.swift` now excludes the Generator correctly
- Codebase now references the JSON file correctly
- Got rid of the expanded JSON file as it wasn't used
- `README` file now has better explanation of `setFallbackDeviceBezel`
- `README` doesn't use US localisation

### Removed
</details>

- Got rid of the expanded JSON file as it wasn't used
## 0.0.1

### Cleanup
<details>
<summary>Expand</summary>

- `README` file now has better explanation of `setFallbackDeviceBezel`
- `README` doesn't use US localisation
- Initial release

</details>
53 changes: 32 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

<img src="https://raw.githubusercontent.com/markbattistella/BezelKit/main/.github/data/kit-icon.png" width="128" height="128"/>
<img alt="Icon of Package" src="https://raw.githubusercontent.com/markbattistella/BezelKit/main/.github/data/kit-icon.png" width="128" height="128"/>

# BezelKit

Expand All @@ -22,12 +22,14 @@ By providing an easy-to-use API, `BezelKit` allows developers to focus more on t

## Rationale

> **Quick Summary**
>
> - No public API from Apple for fetching bezel sizes.
> - Using internal APIs can jeopardise App Store eligibility.
> - Static bezel values can cause UI distortions across devices.
> - `BezelKit` offers an easy-to-use solution for accurate bezel metrics.
### Quick summary

> - There is **no** public API from Apple for fetching device bezel sizes
> - Using the internal API can jeopardise App Store eligibility
> - Static bezel values can cause UI distortions across devices
> - `BezelKit` offers an easy-to-use solution for accurate bezel metrics
### Longer explanation

Apple currently does not offer a public API for fetching the bezel radius of its devices.

Expand Down Expand Up @@ -59,9 +61,15 @@ In terms of the devices supported though, it covers from the initial versions of

The BezelKit package uses Swift Package Manager (SPM) for easy and convenient distribution. Follow these steps to add it to your project:

1. In Xcode, click `File -> Swift Packages -> Add Package Dependency`.
1. In Xcode, click `File -> Swift Packages -> Add Package Dependency`

2. In the search bar, type `https://github.com/markbattistella/BezelKit` and click `Next`.
3. Specify the version you want to use. You can select the exact version, use the latest one, or set a version range, and then click `Next`.

3. Specify the version you want to use. You can select the exact version, use the latest one, or set a version range, and then click `Next`

> [!Tip]
> It's ideal to check the [change log for differences](https://github.com/markbattistella/BezelKit/blob/main/CHANGELOG.md) across versions
4. Finally, select the target in which you want to use `BezelKit` and click `Finish`.

## Usage
Expand Down Expand Up @@ -131,26 +139,28 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

#### SwiftUI: Setting the Fallback on Appear

For SwiftUI applications, you can set this value in the `.onAppear()` modifier for your main content view.
For SwiftUI applications, you can set this value in the `init()` function for your main content view.

```swift
import SwiftUI

@main
struct YourApp: App {
init() {
// Sets a fallback value of 10.0 and enables zero-check
CGFloat.setFallbackDeviceBezel(10.0, ifZero: true)
}
var body: some Scene {
WindowGroup {
ContentView()
.onAppear() {

// Sets a fallback value of 10.0 and enables zero-check
CGFloat.setFallbackDeviceBezel(10.0, ifZero: true)
}
}
}
}
```

> [!Important]
> Previously it was noted to use the `.onAppear` modifier for setting the fallback. This [caused a bug](https://github.com/markbattistella/BezelKit/issues/30) of not updating on launch
#### Note

You only need to call `setFallbackDeviceBezel(_:ifZero:)` **once**. Doing this as early as possible ensures the fallback setting is applied throughout your application.
Expand Down Expand Up @@ -299,12 +309,13 @@ Contributions are more than welcome. If you find a bug or have an idea for an en

Please follow the code style present in the current code base when making contributions.

**Note**: any pull requests need to have the title in the following format, otherwise it will be rejected.

```text
YYYY-mm-dd - {title}
eg. 2023-08-24 - Updated README file
```
> [!Note]
> Any pull requests need to have the title in the following format, otherwise it will be rejected.
>
> ```text
> YYYY-mm-dd - {title}
> eg. 2023-08-24 - Updated README file
> ```
I like to track the day from logged request to completion, allowing sorting, and extraction of data. It helps me know how long things have been pending and provides OCD structure.
Expand Down
5 changes: 4 additions & 1 deletion Sources/BezelKit/CGFloat+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public extension CGFloat {
/// - Returns: A `CGFloat` representing the bezel radius for the current device or the fallback value if necessary.
static var deviceBezel: CGFloat {
if let currentBezel = DeviceBezel.currentBezel,
!(shouldFallbackIfZero && currentBezel == 0.0) {
!(shouldFallbackIfZero &&
(currentBezel == 0.0 ||
currentBezel == 0 ||
currentBezel == .zero)) {
return currentBezel
}
return fallbackBezelValue
Expand Down

0 comments on commit 79a28ce

Please sign in to comment.