From 995c74daa696b4bafae43e2203ba4146ef386e5a Mon Sep 17 00:00:00 2001 From: Mohammed Imthathullah Date: Fri, 26 Jan 2024 10:54:28 +0530 Subject: [PATCH] Activity Indicator Demo: Update start/stop activity button title based on state --- .../Demos/ActivityIndicatorDemoController.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift index d7e625c36d..e4d3da657d 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/ActivityIndicatorDemoController.swift @@ -52,9 +52,9 @@ class ActivityIndicatorDemoController: DemoTableViewController { return UITableViewCell() } - cell.setup(action1Title: row.title) + cell.setup(action1Title: activityActionButtonTitle) cell.action1Button.addTarget(self, - action: #selector(startStopActivity), + action: #selector(startStopActivity(_:)), for: .touchUpInside) cell.bottomSeparatorType = .full return cell @@ -153,6 +153,8 @@ class ActivityIndicatorDemoController: DemoTableViewController { } } + private var activityActionButtonTitle: String { isAnimating ? "Stop Activity" : "Start Activity" } + private var defaultColorIndicators: [MSFActivityIndicatorSize: MSFActivityIndicator] = { var defaultColorIndicators: [MSFActivityIndicatorSize: MSFActivityIndicator] = [:] @@ -191,7 +193,7 @@ class ActivityIndicatorDemoController: DemoTableViewController { case .hidesWhenStopped: return "Hides when stopped" case .startStopActivity: - return "Start / Stop activity" + return "" case .demoOfSize: return "" } @@ -233,8 +235,9 @@ class ActivityIndicatorDemoController: DemoTableViewController { private let xLargeSize: CGFloat = 36 - @objc private func startStopActivity() { + @objc private func startStopActivity(_ sender: UIButton) { isAnimating.toggle() + sender.setTitle(activityActionButtonTitle, for: .normal) } }