Skip to content

Commit

Permalink
Make scrollEdgesAppearance singular to match UIKit
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Mar 16, 2022
1 parent 0d5bd23 commit b42c3fa
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Riot/Managers/Theme/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ import DesignKit
/// - Parameter tabBar: The tab bar to customise.
func applyStyle(onTabBar tabBar: UITabBar)

/// Apply the theme on a navigation bar, without enabling the iOS 15's scroll edges appearance.
/// Apply the theme on a navigation bar, without enabling the iOS 15's scroll edge appearance.
///
/// - Parameter navigationBar: the navigation bar to customise.
func applyStyle(onNavigationBar navigationBar: UINavigationBar)

/// Apply the theme on a navigation bar.
///
/// - Parameter navigationBar: the navigation bar to customise.
/// - Parameter modernScrollEdgesAppearance: whether or not to use the iOS 15 style scroll edges appearance
/// - Parameter modernScrollEdgeAppearance: whether or not to use the iOS 15 style scroll edge appearance
func applyStyle(onNavigationBar navigationBar: UINavigationBar,
withModernScrollEdgesAppearance modernScrollEdgesAppearance: Bool)
withModernScrollEdgeAppearance modernScrollEdgeAppearance: Bool)

/// Apply the theme on a search bar.
///
Expand Down
8 changes: 4 additions & 4 deletions Riot/Managers/Theme/Themes/DarkTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ class DarkTheme: NSObject, Theme {

// Protocols don't support default parameter values and a protocol extension won't work for @objc
func applyStyle(onNavigationBar navigationBar: UINavigationBar) {
applyStyle(onNavigationBar: navigationBar, withModernScrollEdgesAppearance: false)
applyStyle(onNavigationBar: navigationBar, withModernScrollEdgeAppearance: false)
}

func applyStyle(onNavigationBar navigationBar: UINavigationBar,
withModernScrollEdgesAppearance modernScrollEdgesAppearance: Bool) {
withModernScrollEdgeAppearance modernScrollEdgeAppearance: Bool) {
navigationBar.tintColor = tintColor

// On iOS 15 use UINavigationBarAppearance to fix visual issues with the scrollEdgeAppearance style.
Expand All @@ -127,15 +127,15 @@ class DarkTheme: NSObject, Theme {

appearance.configureWithOpaqueBackground()
appearance.backgroundColor = baseColor
if !modernScrollEdgesAppearance {
if !modernScrollEdgeAppearance {
appearance.shadowColor = nil
}
appearance.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: textPrimaryColor
]

navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = modernScrollEdgesAppearance ? nil : appearance
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
} else {
navigationBar.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: textPrimaryColor
Expand Down
8 changes: 4 additions & 4 deletions Riot/Managers/Theme/Themes/DefaultTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ class DefaultTheme: NSObject, Theme {

// Protocols don't support default parameter values and a protocol extension doesn't work for @objc
func applyStyle(onNavigationBar navigationBar: UINavigationBar) {
applyStyle(onNavigationBar: navigationBar, withModernScrollEdgesAppearance: false)
applyStyle(onNavigationBar: navigationBar, withModernScrollEdgeAppearance: false)
}

func applyStyle(onNavigationBar navigationBar: UINavigationBar,
withModernScrollEdgesAppearance modernScrollEdgesAppearance: Bool) {
withModernScrollEdgeAppearance modernScrollEdgeAppearance: Bool) {
navigationBar.tintColor = tintColor

// On iOS 15 use UINavigationBarAppearance to fix visual issues with the scrollEdgeAppearance style.
Expand All @@ -133,15 +133,15 @@ class DefaultTheme: NSObject, Theme {

appearance.configureWithOpaqueBackground()
appearance.backgroundColor = baseColor
if !modernScrollEdgesAppearance {
if !modernScrollEdgeAppearance {
appearance.shadowColor = nil
}
appearance.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: textPrimaryColor
]

navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = modernScrollEdgesAppearance ? nil : appearance
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
} else {
navigationBar.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: textPrimaryColor
Expand Down
2 changes: 1 addition & 1 deletion Riot/Modules/Authentication/AuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ - (void)viewDidLoad
- (void)userInterfaceThemeDidChange
{
[ThemeService.shared.theme applyStyleOnNavigationBar:self.navigationController.navigationBar
withModernScrollEdgesAppearance:YES];
withModernScrollEdgeAppearance:YES];

self.view.backgroundColor = ThemeService.shared.theme.backgroundColor;

Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/Common/SwiftUI/VectorHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class VectorHostingController: UIHostingController<AnyView> {

// MARK: Public

var enableNavigationBarScrollEdgesAppearance = false
var enableNavigationBarScrollEdgeAppearance = false

init<Content>(rootView: Content) where Content: View {
self.theme = ThemeService.shared().theme
Expand Down Expand Up @@ -93,7 +93,7 @@ class VectorHostingController: UIHostingController<AnyView> {

private func update(theme: Theme) {
if let navigationBar = self.navigationController?.navigationBar {
theme.applyStyle(onNavigationBar: navigationBar, withModernScrollEdgesAppearance: enableNavigationBarScrollEdgesAppearance)
theme.applyStyle(onNavigationBar: navigationBar, withModernScrollEdgeAppearance: enableNavigationBarScrollEdgeAppearance)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class OnboardingUseCaseSelectionCoordinator: Coordinator, Presentable {

let hostingController = VectorHostingController(rootView: view)
hostingController.vc_removeBackTitle()
hostingController.enableNavigationBarScrollEdgesAppearance = true
hostingController.enableNavigationBarScrollEdgeAppearance = true
onboardingUseCaseHostingController = hostingController
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class SpaceSettingsCoordinator: Coordinator, Presentable {
.addDependency(AvatarService.instantiate(mediaManager: parameters.session.mediaManager))
spaceSettingsViewModel = viewModel
let controller = VectorHostingController(rootView: view)
controller.enableNavigationBarScrollEdgesAppearance = true
controller.enableNavigationBarScrollEdgeAppearance = true
spaceSettingsHostingController = controller
}

Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-5826.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rename scrollEdgesAppearance → scrollEdgeAppearance to match UIKit.

0 comments on commit b42c3fa

Please sign in to comment.