-
Notifications
You must be signed in to change notification settings - Fork 171
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
Activity Indicator Demo: Dynamic start/stop activity button title #1958
base: main
Are you sure you want to change the base?
Conversation
ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift
Outdated
Show resolved
Hide resolved
995c74d
to
16c3f5b
Compare
16c3f5b
to
bfa9dd9
Compare
@@ -235,6 +235,13 @@ class ActivityIndicatorDemoController: DemoTableViewController { | |||
|
|||
@objc private func startStopActivity() { | |||
isAnimating.toggle() | |||
|
|||
guard let section: Int = ActivityIndicatorDemoSection.allCases.firstIndex(of: .settings), | |||
let row: Int = ActivityIndicatorDemoSection.settings.rows.firstIndex(of: .startStopActivity) else { |
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.
Nit: we avoid declaring types for inline variables unless strictly needed. See the specific reference in our style guide at Type Inference | swift-guide (microsoft.github.io)
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.
Based on the linked guide, it would still make sense to declare types in such cases. Here Int
is not directly used as literal. It is the result of a function firstIndex
on another type. So for quick understanding, I think it is helpful to have the type Int
specified here.
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.
The guide is consistent on this point:
Use type annotation as little as possible when declaring a constant or a variable; instead let the compiler infer the variable type.
Let the compiler infer the type of a constant or variable whenever possible.
The primary exception to this policy is for stored properties; local variables should almost never need a type declared, particularly when they are storing the result of a well-understood method like firstIndex
.
Platforms Impacted
Description of changes
Updated title of action button in the settings of ActivityIndicator demo page. The title is now dynamic and changes based on the state of the activity indicators below.
In the iOS demo app, open ActivityIndicator. The button in the second section (Settings) will now read "Stop Activity". If you tap that, the activity indicators below will stop spinning (and also hide if that is enabled) and the button title will change to "Start Activity".
Previously the button was named "Start/Stop Activity" which did not exactly represent the state of the activity indicators below.
Binary change
No change in binary size as the change is only in the iOS demo app.
Verification
Visual Verification
Before
CleanShot.2024-01-26.at.18.14.22.mp4
After
CleanShot.2024-01-26.at.16.51.59.mp4
Pull request checklist
This PR has considered:
Microsoft Reviewers: Open in CodeFlow