Skip to content

Commit

Permalink
Activity Indicator Demo: Update start/stop activity button title base…
Browse files Browse the repository at this point in the history
…d on state
  • Loading branch information
imthath-m committed Feb 2, 2024
1 parent 4669412 commit 995c74d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] = [:]

Expand Down Expand Up @@ -191,7 +193,7 @@ class ActivityIndicatorDemoController: DemoTableViewController {
case .hidesWhenStopped:
return "Hides when stopped"
case .startStopActivity:
return "Start / Stop activity"
return ""
case .demoOfSize:
return ""
}
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 995c74d

Please sign in to comment.