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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow hiding complications when watch is locked #1253
Conversation
Hmm I'm getting:
Pop up. Not sure what I did differently to https://github.com/home-assistant/iOS/blob/master/Sources/Shared/Common/Extensions/Realm%2BInitialization.swift#L89-93 |
Forgot to commit this earlier
Migration should be resolved now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall nice job! just a couple suggestions.
@@ -184,6 +189,11 @@ class ComplicationEditViewController: FormViewController, TypedRowControllerType | |||
cell.detailTextLabel?.text = row.value?.style | |||
} | |||
|
|||
<<< SwitchRow("IsPrivate") { | |||
$0.title = L10n.Watch.Configurator.Rows.IsPrivate.title | |||
$0.value = self.config.IsPrivate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth flipping the way this is presented. "Show When Locked {default on}" is a little easier to mentally discern than the double-negative "Hide when locked {default off}".
|
||
let model: WatchComplication? | ||
|
||
if #available(watchOS 7, *), complication.identifier != CLKDefaultComplicationIdentifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given this is from another method in this class, i think it's worth writing a helper function like func complication(for complication: CLKComplication) -> WatchComplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just minor - let's try and keep to swift-isms for function names here
@@ -16,8 +16,8 @@ class ComplicationController: NSObject, CLKComplicationDataSource { | |||
// https://github.com/LoopKit/Loop/issues/816 | |||
// https://crunchybagel.com/detecting-which-complication-was-tapped/ | |||
|
|||
private func template(for complication: CLKComplication) -> CLKComplicationTemplate? { | |||
Iconic.registerMaterialDesignIcons() | |||
private func getComplicationModel(for complication: CLKComplication) -> WatchComplication? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefixing functions with 'get' is not really a swift-ism that works super well -- apple's been leaning on doing this only for asynchronous returns (e.g. it provides a block)
|
||
let model: WatchComplication? | ||
|
||
model = getComplicationModel(for: complication) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you pull this up into the variable declaration above you can avoid needing to declare the type, too
Given that we essentially let users add anything from Home Assistant that can be represented as text as a complication I thought it would be a good idea to let people choose whether or not to display a complication when the watch is locked.
Tested on my watch and seems to be working 馃槸although I haven't tested the Realm migration yet. Apologies in advance, this is my first time trying something of this complexity (for me, appreciate it's actually pretty simple)