Skip to content

Commit 8e24103

Browse files
committed
Add activity indicator dark mode support
1 parent 410261e commit 8e24103

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

ExampleMVVM.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
1FC2C9632301FEC0001AE47E /* MovieQueryUDS+Mapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC2C9612301FEC0001AE47E /* MovieQueryUDS+Mapping.swift */; };
7373
1FC5B7D0242634EB0086FA8C /* UIImageView+ImageSizeAfterAspectFit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC5B7CF242634EB0086FA8C /* UIImageView+ImageSizeAfterAspectFit.swift */; };
7474
1FC5B7D2242635CC0086FA8C /* CGSize+ScaledSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FC5B7D1242635CB0086FA8C /* CGSize+ScaledSize.swift */; };
75+
1FCBB8CE25237D4C007F23DC /* UIViewController+ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FCBB8CD25237D4C007F23DC /* UIViewController+ActivityIndicator.swift */; };
7576
1FCE68A1222C873A00CC3074 /* MoviesSceneDIContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FCE68A0222C873A00CC3074 /* MoviesSceneDIContainer.swift */; };
7677
1FD03807239098650016D05F /* CoreDataStorage.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 1FD03804239098650016D05F /* CoreDataStorage.xcdatamodeld */; };
7778
1FE49D84230AA7C200D1D42E /* MoviesQueriesItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FE49D69230AA7C200D1D42E /* MoviesQueriesItemCell.swift */; };
@@ -181,6 +182,7 @@
181182
1FC2C9612301FEC0001AE47E /* MovieQueryUDS+Mapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MovieQueryUDS+Mapping.swift"; sourceTree = "<group>"; };
182183
1FC5B7CF242634EB0086FA8C /* UIImageView+ImageSizeAfterAspectFit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+ImageSizeAfterAspectFit.swift"; sourceTree = "<group>"; };
183184
1FC5B7D1242635CB0086FA8C /* CGSize+ScaledSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGSize+ScaledSize.swift"; sourceTree = "<group>"; };
185+
1FCBB8CD25237D4C007F23DC /* UIViewController+ActivityIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+ActivityIndicator.swift"; sourceTree = "<group>"; };
184186
1FCE68A0222C873A00CC3074 /* MoviesSceneDIContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoviesSceneDIContainer.swift; sourceTree = "<group>"; };
185187
1FD03805239098650016D05F /* CoreDataStorage 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "CoreDataStorage 2.xcdatamodel"; sourceTree = "<group>"; };
186188
1FD03806239098650016D05F /* CoreDataStorage.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CoreDataStorage.xcdatamodel; sourceTree = "<group>"; };
@@ -591,6 +593,7 @@
591593
children = (
592594
1FB090392437651700DBE132 /* UIViewController+AddBehaviors.swift */,
593595
1F53E2B523125896008D6A05 /* UIViewController+AddChild.swift */,
596+
1FCBB8CD25237D4C007F23DC /* UIViewController+ActivityIndicator.swift */,
594597
1FC5B7CF242634EB0086FA8C /* UIImageView+ImageSizeAfterAspectFit.swift */,
595598
1FC5B7D1242635CB0086FA8C /* CGSize+ScaledSize.swift */,
596599
1FF53EB323688893008D6CCC /* DataTransferError+ConnectionError.swift */,
@@ -986,6 +989,7 @@
986989
1FEED0F02023576A000F4EAA /* Alertable.swift in Sources */,
987990
1F16031D2426919300C173C6 /* AppFlowCoordinator.swift in Sources */,
988991
1F53E2B823125F71008D6A05 /* MoviesQueryListItemViewModel.swift in Sources */,
992+
1FCBB8CE25237D4C007F23DC /* UIViewController+ActivityIndicator.swift in Sources */,
989993
FC2B715C2156FF93002BD59E /* AppAppearance.swift in Sources */,
990994
1FFF12AA243A022300937EE4 /* MoviesResponseEntity+Mapping.swift in Sources */,
991995
1F1FC48922E3693100BCBA8D /* NetworkService.swift in Sources */,

ExampleMVVM/Presentation/MoviesScene/MoviesList/View/MoviesListTableView/MoviesListTableViewController.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ final class MoviesListTableViewController: UITableViewController {
2929
switch loading {
3030
case .nextPage:
3131
nextPageLoadingSpinner?.removeFromSuperview()
32-
nextPageLoadingSpinner = UIActivityIndicatorView(style: .gray)
33-
nextPageLoadingSpinner?.startAnimating()
34-
nextPageLoadingSpinner?.isHidden = false
35-
nextPageLoadingSpinner?.frame = .init(x: 0, y: 0, width: tableView.frame.width, height: 44)
32+
nextPageLoadingSpinner = makeActivityIndicator(size: .init(width: tableView.frame.width, height: 44))
3633
tableView.tableFooterView = nextPageLoadingSpinner
3734
case .fullScreen, .none:
3835
tableView.tableFooterView = nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// UIViewController+make.swift
3+
// MoviesSearch
4+
//
5+
// Created by Oleh Kudinov on 29/09/2020.
6+
//
7+
8+
import UIKit
9+
10+
extension UITableViewController {
11+
12+
func makeActivityIndicator(size: CGSize) -> UIActivityIndicatorView {
13+
let style: UIActivityIndicatorView.Style
14+
if #available(iOS 12.0, *) {
15+
if self.traitCollection.userInterfaceStyle == .dark {
16+
style = .white
17+
} else {
18+
style = .gray
19+
}
20+
} else {
21+
style = .gray
22+
}
23+
24+
let activityIndicator = UIActivityIndicatorView(style: style)
25+
activityIndicator.startAnimating()
26+
activityIndicator.isHidden = false
27+
activityIndicator.frame = .init(origin: .zero, size: size)
28+
29+
return activityIndicator
30+
}
31+
}

0 commit comments

Comments
 (0)