mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
The theme defined in the application is not applied to all UI components (#6532)
* The theme defined in the application is not applied to all UI components
This commit is contained in:
parent
c82ce52a7c
commit
2b4f81fb82
10 changed files with 85 additions and 48 deletions
|
@ -129,33 +129,22 @@ class DarkTheme: NSObject, Theme {
|
|||
if #available(iOS 13.0, *) {
|
||||
let appearance = UINavigationBarAppearance()
|
||||
|
||||
if BuildSettings.newAppLayoutEnabled {
|
||||
appearance.configureWithDefaultBackground()
|
||||
} else {
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
}
|
||||
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
|
||||
if !modernScrollEdgeAppearance {
|
||||
appearance.shadowColor = nil
|
||||
}
|
||||
appearance.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
.foregroundColor: textPrimaryColor
|
||||
]
|
||||
|
||||
appearance.largeTitleTextAttributes = [
|
||||
.foregroundColor: textPrimaryColor
|
||||
]
|
||||
|
||||
navigationBar.standardAppearance = appearance
|
||||
|
||||
if BuildSettings.newAppLayoutEnabled {
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
appearance.shadowColor = nil
|
||||
appearance.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
]
|
||||
}
|
||||
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
|
||||
} else {
|
||||
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
|
||||
} else {
|
||||
navigationBar.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
]
|
||||
|
|
|
@ -134,30 +134,21 @@ class DefaultTheme: NSObject, Theme {
|
|||
if #available(iOS 13.0, *) {
|
||||
let appearance = UINavigationBarAppearance()
|
||||
|
||||
if BuildSettings.newAppLayoutEnabled {
|
||||
appearance.configureWithDefaultBackground()
|
||||
} else {
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
}
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
|
||||
if !modernScrollEdgeAppearance {
|
||||
appearance.shadowColor = nil
|
||||
}
|
||||
appearance.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
.foregroundColor: textPrimaryColor
|
||||
]
|
||||
|
||||
appearance.largeTitleTextAttributes = [
|
||||
.foregroundColor: textPrimaryColor
|
||||
]
|
||||
|
||||
navigationBar.standardAppearance = appearance
|
||||
if BuildSettings.newAppLayoutEnabled {
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = baseColor
|
||||
appearance.shadowColor = nil
|
||||
appearance.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
]
|
||||
}
|
||||
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
|
||||
navigationBar.scrollEdgeAppearance = modernScrollEdgeAppearance ? nil : appearance
|
||||
} else {
|
||||
navigationBar.titleTextAttributes = [
|
||||
NSAttributedString.Key.foregroundColor: textPrimaryColor
|
||||
|
|
|
@ -75,6 +75,7 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
|
|||
super.init()
|
||||
|
||||
setupFlexDebuggerOnWindow(window)
|
||||
update(with: ThemeService.shared().theme)
|
||||
}
|
||||
|
||||
// MARK: - Public methods
|
||||
|
@ -107,6 +108,8 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
|
|||
// NOTE: When split view is shown there can be no Matrix sessions ready. Keep this behavior or use a loading screen before showing the split view.
|
||||
self.showSplitView()
|
||||
MXLog.debug("[AppCoordinator] Showed split view")
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.themeDidChange), name: Notification.Name.themeServiceDidChangeTheme, object: nil)
|
||||
}
|
||||
|
||||
func open(url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
|
||||
|
@ -122,6 +125,18 @@ final class AppCoordinator: NSObject, AppCoordinatorType {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - Theme management
|
||||
|
||||
@objc private func themeDidChange() {
|
||||
update(with: ThemeService.shared().theme)
|
||||
}
|
||||
|
||||
private func update(with theme: Theme) {
|
||||
for window in UIApplication.shared.windows {
|
||||
window.overrideUserInterfaceStyle = ThemeService.shared().theme.userInterfaceStyle
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private methods
|
||||
private func setupLogger() {
|
||||
UILog.configure(logger: MatrixSDKLogger.self)
|
||||
|
|
|
@ -437,6 +437,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
|||
|
||||
// Set up theme
|
||||
ThemeService.shared.themeId = RiotSettings.shared.userInterfaceTheme;
|
||||
|
||||
application.windows.firstObject.overrideUserInterfaceStyle = [ThemeService.shared isCurrentThemeDark] ? UIUserInterfaceStyleDark : UIUserInterfaceStyleLight;
|
||||
|
||||
mxSessionArray = [NSMutableArray array];
|
||||
callEventsListeners = [NSMutableDictionary dictionary];
|
||||
|
|
|
@ -152,6 +152,22 @@ class AllChatsViewController: HomeViewController {
|
|||
lastScrollPosition = scrollPosition
|
||||
}
|
||||
|
||||
// MARK: - Theme management
|
||||
|
||||
override func userInterfaceThemeDidChange() {
|
||||
super.userInterfaceThemeDidChange()
|
||||
|
||||
guard self.tabBarController?.toolbarItems != nil else {
|
||||
return
|
||||
}
|
||||
|
||||
self.update(with: ThemeService.shared().theme)
|
||||
}
|
||||
|
||||
private func update(with theme: Theme) {
|
||||
self.navigationController?.toolbar?.tintColor = theme.colors.accent
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@objc private func setupEditOptions() {
|
||||
|
@ -170,6 +186,7 @@ class AllChatsViewController: HomeViewController {
|
|||
private func updateToolbar(with menu: UIMenu) {
|
||||
let currentSpace = self.dataSource?.currentSpace
|
||||
self.navigationController?.isToolbarHidden = false
|
||||
self.update(with: ThemeService.shared().theme)
|
||||
self.tabBarController?.setToolbarItems([
|
||||
UIBarButtonItem(image: Asset.Images.homeMySpacesAction.image, style: .done, target: self, action: #selector(self.showSpaceSelectorAction(sender: ))),
|
||||
UIBarButtonItem.flexibleSpace(),
|
||||
|
|
|
@ -45,6 +45,7 @@ final class ShowDirectoryCoordinator: ShowDirectoryCoordinatorType {
|
|||
|
||||
let showDirectoryViewModel = ShowDirectoryViewModel(session: self.session, dataSource: dataSource)
|
||||
let showDirectoryViewController = ShowDirectoryViewController.instantiate(with: showDirectoryViewModel)
|
||||
showDirectoryViewController.view.clipsToBounds = false
|
||||
self.showDirectoryViewModel = showDirectoryViewModel
|
||||
self.showDirectoryViewController = showDirectoryViewController
|
||||
}
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="yEe-Sn-mN0">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="yEe-Sn-mN0">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Show Directory View Controller-->
|
||||
<scene sceneID="bXw-aP-pys">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="SearchableDirectoryViewController" id="yEe-Sn-mN0" customClass="ShowDirectoryViewController" customModule="Riot" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<viewController storyboardIdentifier="SearchableDirectoryViewController" id="yEe-Sn-mN0" customClass="ShowDirectoryViewController" customModule="Element" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="ALX-A9-ywk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="hBr-zt-GEh">
|
||||
<tableView contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="hBr-zt-GEh">
|
||||
<rect key="frame" x="0.0" y="44" width="414" height="852"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="yEe-Sn-mN0" id="FHU-nL-H9g"/>
|
||||
<outlet property="delegate" destination="yEe-Sn-mN0" id="V30-de-Prc"/>
|
||||
|
@ -40,10 +41,10 @@
|
|||
<blurEffect style="regular"/>
|
||||
</vibrancyEffect>
|
||||
</visualEffectView>
|
||||
<button contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qGk-Os-0Dj">
|
||||
<rect key="frame" x="140" y="27" width="134" height="30"/>
|
||||
<button contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qGk-Os-0Dj">
|
||||
<rect key="frame" x="139.5" y="27" width="135" height="30"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
|
||||
<color key="tintColor" systemColor="systemGreenColor" red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="tintColor" systemColor="systemGreenColor"/>
|
||||
<state key="normal" title="Create a new room"/>
|
||||
<connections>
|
||||
<action selector="createRoomButtonTapped:" destination="yEe-Sn-mN0" eventType="touchUpInside" id="7TP-Tn-kuq"/>
|
||||
|
@ -65,7 +66,8 @@
|
|||
<blurEffect style="regular"/>
|
||||
</visualEffectView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="PMt-fQ-rFh"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="hBr-zt-GEh" secondAttribute="bottom" id="2m9-dZ-hbT"/>
|
||||
<constraint firstAttribute="trailing" secondItem="hBr-zt-GEh" secondAttribute="trailing" id="9rC-zz-tGb"/>
|
||||
|
@ -75,7 +77,6 @@
|
|||
<constraint firstAttribute="bottom" secondItem="shK-Lq-qu8" secondAttribute="bottom" id="n8O-5X-KlB"/>
|
||||
<constraint firstItem="hBr-zt-GEh" firstAttribute="top" secondItem="PMt-fQ-rFh" secondAttribute="top" id="z0k-qY-JPZ"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="PMt-fQ-rFh"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="blurEffectContentView" destination="4ka-0i-i4y" id="xYO-0s-q7b"/>
|
||||
|
@ -91,4 +92,12 @@
|
|||
<point key="canvasLocation" x="-2479.1999999999998" y="-36.431784107946029"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemGreenColor">
|
||||
<color red="0.20392156862745098" green="0.7803921568627451" blue="0.34901960784313724" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
@ -3920,6 +3920,10 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
|||
// The user wants to select this theme
|
||||
RiotSettings.shared.userInterfaceTheme = newTheme;
|
||||
ThemeService.shared.themeId = newTheme;
|
||||
|
||||
// This is a hack to force the background colour of the container view of the navigation controller
|
||||
// This is needed only for hot theme update as the UIViewControllerWrapperView of the RioNavigationController is not updated
|
||||
self.view.superview.backgroundColor = ThemeService.shared.theme.backgroundColor;
|
||||
|
||||
[self updateSections];
|
||||
}
|
||||
|
|
|
@ -52,11 +52,13 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
|||
self.completions = [:]
|
||||
super.init()
|
||||
self.navigationController.delegate = self
|
||||
|
||||
self.navigationController.overrideUserInterfaceStyle = ThemeService.shared().theme.userInterfaceStyle
|
||||
|
||||
// Post local notification on NavigationRouter creation
|
||||
let userInfo: [String: Any] = [NavigationRouter.NotificationUserInfoKey.navigationRouter: self,
|
||||
NavigationRouter.NotificationUserInfoKey.navigationController: navigationController]
|
||||
NotificationCenter.default.post(name: NavigationRouter.didCreate, object: self, userInfo: userInfo)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.themeDidChange), name: Notification.Name.themeServiceDidChangeTheme, object: nil)
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
@ -291,6 +293,12 @@ final class NavigationRouter: NSObject, NavigationRouterType {
|
|||
return navigationController
|
||||
}
|
||||
|
||||
// MARK: - Theme management
|
||||
|
||||
@objc private func themeDidChange() {
|
||||
self.navigationController.overrideUserInterfaceStyle = ThemeService.shared().theme.userInterfaceStyle
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func module(for viewController: UIViewController) -> Presentable {
|
||||
|
|
1
changelog.d/6526.bugfix
Normal file
1
changelog.d/6526.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Apply current theme to all the UI components
|
Loading…
Reference in a new issue