Coder Social home page Coder Social logo

markbattistella / bezelkit Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 2.0 598 KB

BezelKit is a Swift package designed to simplify the process of accessing device-specific bezel sizes in apps. Knowing the exact bezel size can be crucial for aligning UI elements, creating immersive experiences, or when you need pixel-perfect design layouts.

License: MIT License

Swift 100.00%
corner-radius package-manager swift swift-package-manager swiftui ui-design hacktoberfest open-source ios macos

bezelkit's Introduction

Hi! I'm Mark Battistella

I'm a video editor, cutting and coding through life

Showcase items

A localisation tool made to translate .xcloc files into over 100 languages. Export your localisations from Xcode, Get Local, and re-import

Safely store all your serials, cheat codes, or anything without relying on a subscription service

A public transport app for Victoria, Australia where you can see closest transport, save favourites, and set reminders

An iOS app that shows current COVID-19 exposure sites in Victoria, Australia

Open source projects

BezelKit is a Swift package designed to simplify the process of accessing device-specific bezel sizes in apps. Knowing the exact bezel size can be crucial for aligning UI elements, creating immersive experiences, or when you need pixel-perfect design layouts.

Add some cool ass charts to your documentation system to show off your data

A website that curates all the different proxy settings for application, OS, etc. to get through corporate networks

Search and replace any unsafe urls in your repos using the Google Safe Browsing API. There is also the Github action too!

Easily change between .gitconfig setups without destroying your old settings

ZodiacKit is a Swift package that allows you to fetch Zodiac Sign information based on a given date. It provides a simple, efficient, and easily integrable solution for applications that deal with astrological data.

Books

I have a couple of "books" in the Apple Book Store, which really aren't books but it was a great learning experience on how to properly publish items.

A colour profiles preset book for the Sony NXCam FS100 camera

A collection of images showing you can take decent images without spending a lot on expensive equipment

bezelkit's People

Contributors

markbattistella avatar markbattistella-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bezelkit's Issues

Add iPhone 15 models

Add in new models:

  • iPhone 15,"iPhone15,4"
  • iPhone 15 Plus,"iPhone15,5"
  • iPhone 15 Pro,"iPhone16,1"
  • iPhone 15 Pro Max,"iPhone16,2"

`index.js` script not working

There is some issue with the index.js script where it isn't correctly moving completed identifiers to the correct text file.

Workaround: manually add identifiers into the correct lists.

`setFallbackDeviceBezel()` not working on `0.0` values

When the device is reporting a value of 0.0 from the JSON the fallback doesnt override it.

It should be an optional flag where the user can override the 0.0 value to some sort of curved value.

Why this is good

Currently it's suggested we do this:

extension CGFloat {
  static let deviceRadius = Self.deviceBezel
 }

But in doing so, we will report a 0.0 on older device models.

But if we want to use it as a consistent radius then we could use something like this:

extension CGFloat {
  static let deviceRadius = deviceBezel == .zero ? fallbackValue : deviceBezel
}

But in some better fashion which allows the user to override 0 or not.

Error in logs about Watch

There is an error in logs about Watch not found:

Failed to load device data: keyNotFound(CodingKeys(stringValue: "Watch", 
intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: 
"No value associated with key CodingKeys(stringValue: \"Watch\", intValue: nil) 
(\"Watch\").", underlyingError: nil))

@markbattistella (I) caused this when testing the Github Action for generating the SupportedDeviceList.md file on a CRON.

Cleanup to the folder structure

This is a pending item where I want to clean up the folder structure.

Current local implementation has it listed as:

BezelKit
- README.md
- Package.swift
- LICENCE
- SupportedDeviceList.md
- Data
  - Images for README
- Generator
  - Javascript and worker Xcode project
- Sources
  - BezelKit library

This way the Sources contains only the required package contents, where the Generator will be purely for creating new data.

Extract "Generator" into own repo

Moving the Generator into its own repo might allow Javascript developers worry about that codebase without being worried about Swift code.

It also will hopefully slim down the package to only the Swift codebase

Remove watchOS

watchOS doesn't have any simple way to access the curvature or bezel radius.

To avoid confusion it should be removed unless there is a way to extract the sizes.

๐Ÿ› Fallback bezel size doesn't work on first run

Describe the bug

When setting a fallback size that's not zero with ifZero: true, the fallback size isn't applied when the app loads on iPhone SE / 7. As far as I can tell, it only shows the expected radius after updating it manually.

Reproduction steps

When I run the following code on an iPhone SE in simulator and on a physical iPhone 7, the corners show up completely sharp. The corners then update to the correct cornerRadius only after changing edgeSize. No errors or warnings are shown.

import SwiftUI

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

struct ContentView: View {
	@State private var edgeSize: CGFloat = 10
	
	@State private var showErrorAlert: Bool = false
	@State private var errorMessage: String = ""
	
	var body: some View {
		let outerBezel = CGFloat.deviceBezel
		let innerBezel = outerBezel - edgeSize
		
		VStack {
			Image(systemName: "globe")
				.imageScale(.large)
				.foregroundStyle(.tint)
			Text("Hello, world!")
			Slider(value: $edgeSize, in: 0...55)
			Text("\(edgeSize)")
		}
		.padding()
		.frame(maxWidth: .infinity, maxHeight: .infinity)
		.background(Color.yellow)
		.clipShape(RoundedRectangle(cornerRadius: innerBezel))
		.padding(edgeSize)
		.ignoresSafeArea()
		
		.alert(isPresented: $showErrorAlert) {
			Alert(title: Text("Error"),
				  message: Text(errorMessage),
				  dismissButton: .default(Text("Got it!")))
		}
		.onAppear {
			DeviceBezel.errorCallback = { error in
				errorMessage = error.localizedDescription
				showErrorAlert = true
			}
		}
	}
}

Expected behaviour

View should have rounded corners when app first loads.

Screenshots

bezelkit

Device information

iPhone SE in simulator, physical iPhone 7 running v 15.7.9

Modularise `index.js` file

Though this is a Swift Package, the backbone of the extraction is built on Javascript for the parsing and xcrun simctl commands.

The index.js file is very large and should be extracted into smaller, manageable files - just as we would with Swift code

Re-running `index.js` results in 0.0 bezel data

When re-running simulator data simulators that were not processed results in 0.0 bezel size.

This is a result of merging the new bezel data into the CSV (parsed to JSON) variable, which defaults all values to 0.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.