Skip to content

Commit 1946257

Browse files
authored
LCP: Dark Mode and localization in the authentication dialog (#50)
1 parent 99d15e3 commit 1946257

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file. Take a look
2323

2424
* Fixed memory leak in the `PublicationServer`.
2525

26+
#### LCP
27+
28+
* The LCP authentication dialog is now fully localized and supports Dark Mode (contributed by [@openm1nd](https://github.com/readium/swift-toolkit/pull/50)).
29+
2630

2731
## [2.3.0]
2832

Sources/LCP/Authentications/Base.lproj/LCPDialogViewController.xib

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait" appearance="light"/>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait" appearance="dark"/>
44
<dependencies>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
67
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
79
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
810
</dependencies>
911
<objects>
1012
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LCPDialogViewController">
1113
<connections>
14+
<outlet property="continueButton" destination="PWg-iR-COW" id="L5i-Au-z2e"/>
15+
<outlet property="forgotPassphraseButton" destination="dJF-9a-QVp" id="XaT-1m-3Do"/>
1216
<outlet property="hintLabel" destination="bM8-E5-8Oh" id="oAd-kM-tLP"/>
1317
<outlet property="messageLabel" destination="OPQ-YI-Mnv" id="qHd-iN-fnX"/>
1418
<outlet property="passphraseField" destination="cyG-aj-Lv1" id="CRB-38-sCX"/>
@@ -40,7 +44,6 @@
4044
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This publication is protected by Readium LCP." textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ahp-0z-soX">
4145
<rect key="frame" x="20" y="20" width="618" height="20.5"/>
4246
<fontDescription key="fontDescription" type="system" pointSize="17"/>
43-
<nil key="textColor"/>
4447
<nil key="highlightedColor"/>
4548
</label>
4649
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OPQ-YI-Mnv">
@@ -49,17 +52,16 @@
4952

5053
To help you remember it, the following hint is available:</string>
5154
<fontDescription key="fontDescription" type="system" pointSize="17"/>
52-
<nil key="textColor"/>
5355
<nil key="highlightedColor"/>
5456
</label>
5557
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Your favorite cake?" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bM8-E5-8Oh">
5658
<rect key="frame" x="20" y="141.5" width="618" height="21.5"/>
5759
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="18"/>
58-
<nil key="textColor"/>
5960
<nil key="highlightedColor"/>
6061
</label>
6162
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Passphrase" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="cyG-aj-Lv1">
6263
<rect key="frame" x="20" y="183" width="618" height="34"/>
64+
<color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
6365
<fontDescription key="fontDescription" type="system" pointSize="14"/>
6466
<textInputTraits key="textInputTraits" returnKeyType="continue" secureTextEntry="YES"/>
6567
<connections>
@@ -68,8 +70,8 @@ To help you remember it, the following hint is available:</string>
6870
</textField>
6971
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PWg-iR-COW">
7072
<rect key="frame" x="20" y="225" width="618" height="30"/>
71-
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
72-
<color key="tintColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
73+
<color key="backgroundColor" systemColor="tintColor"/>
74+
<color key="tintColor" systemColor="tintColor"/>
7375
<state key="normal" title="Continue">
7476
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7577
</state>
@@ -86,7 +88,7 @@ To help you remember it, the following hint is available:</string>
8688
</connections>
8789
</button>
8890
</subviews>
89-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
91+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
9092
<constraints>
9193
<constraint firstItem="cyG-aj-Lv1" firstAttribute="leading" secondItem="Hve-JO-2vR" secondAttribute="leading" constant="20" id="CC2-xC-KWX"/>
9294
<constraint firstItem="OPQ-YI-Mnv" firstAttribute="leading" secondItem="Hve-JO-2vR" secondAttribute="leading" constant="20" id="G37-Cm-3sa"/>
@@ -135,4 +137,15 @@ To help you remember it, the following hint is available:</string>
135137
<point key="canvasLocation" x="302.39999999999998" y="-30.134932533733135"/>
136138
</view>
137139
</objects>
140+
<resources>
141+
<systemColor name="secondarySystemBackgroundColor">
142+
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
143+
</systemColor>
144+
<systemColor name="systemBackgroundColor">
145+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
146+
</systemColor>
147+
<systemColor name="tintColor">
148+
<color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
149+
</systemColor>
150+
</resources>
138151
</document>

Sources/LCP/Authentications/LCPDialogViewController.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ final class LCPDialogViewController: UIViewController {
1515
@IBOutlet weak var messageLabel: UILabel!
1616
@IBOutlet weak var passphraseField: UITextField!
1717
@IBOutlet weak var supportButton: UIButton!
18-
18+
@IBOutlet weak var forgotPassphraseButton: UIButton!
19+
@IBOutlet weak var continueButton: UIButton!
20+
1921
private let license: LCPAuthenticatedLicense
2022
private let reason: LCPAuthenticationReason
2123
private let completion: (String?) -> Void
@@ -74,16 +76,27 @@ final class LCPDialogViewController: UIViewController {
7476
}
7577

7678
label.sizeToFit()
79+
if #available(iOS 13.0, *) {
80+
label.textColor = .label
81+
navigationController?.navigationBar.backgroundColor = .systemBackground
82+
}
83+
7784
let leftItem = UIBarButtonItem(customView: label)
7885
self.navigationItem.leftBarButtonItem = leftItem
7986

8087
promptLabel.text = R2LCPLocalizedString("dialog.prompt.message1")
8188
messageLabel.text = String(format: R2LCPLocalizedString("dialog.prompt.message2"), provider)
89+
forgotPassphraseButton.setTitle(R2LCPLocalizedString("dialog.prompt.forgotPassphrase"), for: .normal)
90+
supportButton.setTitle(R2LCPLocalizedString("dialog.prompt.support"), for: .normal)
91+
continueButton.setTitle(R2LCPLocalizedString("dialog.prompt.continue"), for: .normal)
92+
passphraseField.placeholder = R2LCPLocalizedString("dialog.prompt.passphrase")
8293
hintLabel.text = license.hint
8394

84-
let cancelItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel, target: self, action: #selector(LCPDialogViewController.cancel(_:)));
85-
navigationItem.rightBarButtonItem = cancelItem;
86-
95+
navigationItem.rightBarButtonItem = UIBarButtonItem(
96+
barButtonSystemItem: .cancel,
97+
target: self,
98+
action: #selector(LCPDialogViewController.cancel(_:))
99+
)
87100
}
88101

89102
@IBAction func authenticate(_ sender: Any) {

Sources/LCP/Resources/en.lproj/Localizable.strings

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
"ReadiumLCP.dialog.reason.passphraseNotFound" = "Passphrase Required";
1414
/* Reason to ask for the passphrase when the one entered was incorrect */
1515
"ReadiumLCP.dialog.reason.invalidPassphrase" = "Incorrect Passphrase";
16-
16+
/* Forgot passphrase button */
17+
"ReadiumLCP.dialog.prompt.forgotPassphrase" = "Forgot your passphrase?";
18+
/* Support button */
19+
"ReadiumLCP.dialog.prompt.support" = "Need more help?";
20+
/* Continue button */
21+
"ReadiumLCP.dialog.prompt.continue" = "Continue";
22+
/* Passphrase placeholder */
23+
"ReadiumLCP.dialog.prompt.passphrase" = "Passphrase";
1724
/* Cancel button */
1825
"ReadiumLCP.dialog.cancel" = "Cancel";
1926

0 commit comments

Comments
 (0)