Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking changes for 2.0 #168

Merged
merged 46 commits into from Apr 10, 2019
Merged

Breaking changes for 2.0 #168

merged 46 commits into from Apr 10, 2019

Conversation

@Zandor300
Copy link
Member

Zandor300 commented Mar 4, 2019

Fixes #149
Closes #130
Fixes #167
Fixes #165
Closes #174 (Both Swift 5 and the @unknown in switch)
Closes #159


Fixes #164 not being defined in the gyb file.
Fixes #166 not being defined in the gyb file.


Changelog

Breaking changes

  • The original Device() constructor has been made private in favour of using Device.current to match UIDevice.current.
  • The enum values for the iPhone Xs, iPhone Xs Max and iPhone Xʀ have been renamed to be .iPhoneXS, .iPhoneXSMax and .iPhoneXR to match proper formatting.
  • .description for the iPhone Xs, iPhone Xs Max and iPhone Xʀ have been changed to contain small caps formatting for the s and the ʀ part.
  • .description for the iPad 5 and iPad 6 have been changed to the proper names; iPad (5th generation) and iPad (6th generation).
  • .name, .systemName, .systemVersion, .model, .localizedModel, .batteryState and .batteryLevel will now all return nil when you try to get its value when the device you are getting it from isn't the current one. (eg. Device.iPad6.name while running on iPad 5)

New features

  • Updated to Swift 5!
  • New .allDevicesWithRoundedDisplayCorners and .hasRoundedDisplayCorners values to check if a device has rounded display corners. (eg. iPhone Xs and iPad Pro (3rd generation))
  • new .allDevicesWithSensorHousing and .hasSensorHousing values to check if a device has a screen cutout for the sensor housing. (eg. iPhone Xs)

Bugfixes

  • .isPad and .isPhone are now giving correct outputs again.
Zandor300 added 16 commits Feb 28, 2019
… hasn't been updated for a new device yet. (Fixes #165)
@dennisweissmann
Copy link
Collaborator

dennisweissmann commented Mar 5, 2019

Wow thank you for that PR :)

Thanks for the fix of #164, that looks awesome, totally missed that yesterday, that’s definitely the way to go!

This is also a todo list for me since I’m mobile only this month and I don’t know off the top of my head:

  • are Device.instance and Device.current the same thing? If so lets either remove .current since init() already does the right thing (right?!) or go 100% your approach and replace .instance with .current
  • thanks for fixing the cases, that’s great! (Should we use the “small capital letters” R and S if at all possible?
  • should those early-return-if’s be guards?

Thank you for working on this!

@Zandor300
Copy link
Member Author

Zandor300 commented Mar 5, 2019

  1. I think .current indicates better that it is the current device the code is running on. .instance is currently private anyway.
  2. I think there might be problems with some peoples applications if we move to using Xʀ and Xs but I might be wrong. I think it is a cool feature but maybe having a separate String variable for getting the small capital name may prevent problems?
  3. That will definitely be cleaner looking 👍
@Zandor300
Copy link
Member Author

Zandor300 commented Mar 5, 2019

Just changed it to using small caps in 3297936.

@Zandor300
Copy link
Member Author

Zandor300 commented Mar 5, 2019

Also slapped in those guards: d8b5102

@Zandor300
Copy link
Member Author

Zandor300 commented Mar 5, 2019

Just changed everything over to solely .current, you may look at it if you like it and if you don't just change my commit: 05cac80

@Zandor300
Copy link
Member Author

Zandor300 commented Mar 5, 2019

Just noticed; Small caps s is just the same as a lowercase s.

@dennisweissmann
Copy link
Collaborator

dennisweissmann commented Mar 5, 2019

You are awesome! 😎 that is super cool Zander! I really like it :)

@@ -617,9 +615,10 @@ public enum Device {
return Device.realDevice(from: self)
}

public var isZoomed: Bool {
public var isZoomed: Bool? {
guard isCurrent else { return nil }
// TODO: Longterm we need a better solution for this!

This comment has been minimized.

@devicekit-danger-bot

devicekit-danger-bot Mar 29, 2019

⚠️ TODOs should be resolved (Longterm we need a better solu…).
@devicekit-danger-bot

This comment was marked as spam.

@devicekit-danger-bot
Copy link

devicekit-danger-bot commented Mar 29, 2019

1 Error
🚫 Please rebase to get rid of the merge commits in this PR
2 Warnings
⚠️ Plist changed, don’t forget to localize your plist values
⚠️ Source/Device.generated.swift#L1172 - Prefer empty collection over optional collection.

SwiftLint found issues

Warnings

File Line Reason
Device.generated.swift 618 Prefer non-optional booleans over optional booleans.
Device.generated.swift 1172 Prefer empty collection over optional collection.
Device.generated.swift 620 TODOs should be resolved (Longterm we need a better solu...).

Generated by 🚫 Danger

Zandor300 added 3 commits Mar 29, 2019
Since this function is generated with a switch for all devices, this needs to be this long.
This is required because Swift 5 isn't supported in Xcode 10.1.
@dennisweissmann
Copy link
Collaborator

dennisweissmann commented Mar 29, 2019

We can set something like this up, sure, but since I won’t have the time to contribute or manage very much going forward, I’d like to leave that up to @denisenepraunig

@denisenepraunig
Copy link
Collaborator

denisenepraunig commented Mar 30, 2019

@Zandor300 I am fine with WhatsApp or Telegram for direct communication - for questions I have to Dennis I will contact him directly. You can drop me a mail with your number to denise dot nepraunig at gmail dot com.

Zandor300 added 10 commits Mar 30, 2019
Copy link
Collaborator

denisenepraunig left a comment

Looks good to me 😊

@robbiet480
Copy link
Contributor

robbiet480 commented Apr 5, 2019

Another warning that needs fixing:

/Users/robbiet480/Repos/HomeAssistant/home-assistant-iOS/Pods/DeviceKit/Source/Device.generated.swift:994:9: Switch covers known cases, but 'WKInterfaceDeviceBatteryState' may have additional unknown values, possibly added in future versions
…faceDeviceBatteryState. (Thanks robbiet480)
@Zandor300
Copy link
Member Author

Zandor300 commented Apr 5, 2019

@robbiet480 Thanks for the catch! Fixed it in 11353eb.

@robbiet480
Copy link
Contributor

robbiet480 commented Apr 8, 2019

@denisenepraunig denisenepraunig merged commit 802e405 into devicekit:master Apr 10, 2019
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.