From 6acae2f96f89e1602c0178e6959ae42da7b2ad7c Mon Sep 17 00:00:00 2001 From: macsleven Date: Wed, 5 Jan 2022 00:08:52 +0100 Subject: [PATCH 1/6] RTL view support for startup view and authentication view --- Decred Wallet.xcodeproj/project.pbxproj | 11 +- .../FloatingPlaceholderTextField.swift | 17 +- .../StartScreenViewController.swift | 36 ++ .../Features/Security/Security.storyboard | 30 +- .../RestoreExistingWalletViewController.swift | 5 + .../Wallet Setup/WalletSetup.storyboard | 18 +- Decred Wallet/Main.storyboard | 14 +- Decred Wallet/ar.lproj/LaunchScreen.strings | 1 + Decred Wallet/ar.lproj/Localizable.strings | 605 ++++++++++++++++++ 9 files changed, 702 insertions(+), 35 deletions(-) create mode 100644 Decred Wallet/ar.lproj/LaunchScreen.strings create mode 100644 Decred Wallet/ar.lproj/Localizable.strings diff --git a/Decred Wallet.xcodeproj/project.pbxproj b/Decred Wallet.xcodeproj/project.pbxproj index d924e3c9b..48c6b48de 100644 --- a/Decred Wallet.xcodeproj/project.pbxproj +++ b/Decred Wallet.xcodeproj/project.pbxproj @@ -107,7 +107,6 @@ B3B46A15228F0F2700A68EDD /* UIImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469CD228F0F2600A68EDD /* UIImageView.swift */; }; B3B46A17228F0F2700A68EDD /* ContouredButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469CF228F0F2600A68EDD /* ContouredButton.swift */; }; B3B46A18228F0F2700A68EDD /* DropDownSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D0228F0F2600A68EDD /* DropDownSearchField.swift */; }; - B3B46A19228F0F2700A68EDD /* StartScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D3228F0F2600A68EDD /* StartScreenViewController.swift */; }; B3B46A1B228F0F2700A68EDD /* SecurityViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D6228F0F2600A68EDD /* SecurityViewController.swift */; }; B3B46A1D228F0F2700A68EDD /* RequestPasswordViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D8228F0F2600A68EDD /* RequestPasswordViewController.swift */; }; B3B46A1F228F0F2700A68EDD /* RequestPinViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469DA228F0F2600A68EDD /* RequestPinViewController.swift */; }; @@ -197,6 +196,8 @@ DDA8734E245F69C00029A13D /* CIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA8734D245F69C00029A13D /* CIImage.swift */; }; DDAE91042435092200FEC016 /* ErrorMessageForLA.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDAE91032435092200FEC016 /* ErrorMessageForLA.swift */; }; DDB660F52486BABB0060B0C5 /* Decred_WalletUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB660F42486BABB0060B0C5 /* Decred_WalletUITests.swift */; }; + DDB7755C27962DAD00F437E7 /* StartScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D3228F0F2600A68EDD /* StartScreenViewController.swift */; }; + DDB7755D27962DAD00F437E7 /* StartScreenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B469D3228F0F2600A68EDD /* StartScreenViewController.swift */; }; DDCF259A22B8A347005FCBB9 /* Overview.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DDCF259922B8A346005FCBB9 /* Overview.storyboard */; }; DDCF259C22B8A362005FCBB9 /* Send.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DDCF259B22B8A361005FCBB9 /* Send.storyboard */; }; DDCF25A122B8A3D4005FCBB9 /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DDCF25A022B8A3D4005FCBB9 /* Settings.storyboard */; }; @@ -427,6 +428,8 @@ DDB660F22486BABB0060B0C5 /* Decred WalletUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Decred WalletUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; DDB660F42486BABB0060B0C5 /* Decred_WalletUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Decred_WalletUITests.swift; sourceTree = ""; }; DDB660F62486BABB0060B0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DDB775592796192E00F437E7 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = ""; }; + DDB7755A2796192E00F437E7 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = ""; }; DDCF259922B8A346005FCBB9 /* Overview.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Overview.storyboard; sourceTree = ""; }; DDCF259B22B8A361005FCBB9 /* Send.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Send.storyboard; sourceTree = ""; }; DDCF25A022B8A3D4005FCBB9 /* Settings.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = ""; }; @@ -1137,6 +1140,7 @@ "pt-BR", pl, fr, + ar, ); mainGroup = B3B46986228F0C2D00A68EDD; productRefGroup = B3B46990228F0C2D00A68EDD /* Products */; @@ -1273,7 +1277,6 @@ 60DFF5D124F75D4500624161 /* PoliteiaDetailController.swift in Sources */, 1034D5CF24113BF10009576C /* SimpleAlertDialog.swift in Sources */, B3B46A15228F0F2700A68EDD /* UIImageView.swift in Sources */, - B3B46A19228F0F2700A68EDD /* StartScreenViewController.swift in Sources */, B3B46A20228F0F2700A68EDD /* PinPasswordStrength.swift in Sources */, 2557E18B2355C9F000B6A1B7 /* CustomTabMenuView.swift in Sources */, B3D474E423E57DA200B6E305 /* CheckableListOptionTableViewCell.swift in Sources */, @@ -1328,6 +1331,7 @@ DD5AB14C23D36F7E00863362 /* AboutTableViewController.swift in Sources */, B3B46AB3228F0F7D00A68EDD /* ConfirmSeedViewCell.swift in Sources */, DDDF95D723C20AA70057AA7F /* SignMessageViewController.swift in Sources */, + DDB7755D27962DAD00F437E7 /* StartScreenViewController.swift in Sources */, DD81CBC523B39E6A009D3833 /* PaddedLabel.swift in Sources */, 60C7E54724ED88B8009E4569 /* PoliteiaTableViewCell.swift in Sources */, B3B46A88228F0F7D00A68EDD /* UIIMage.swift in Sources */, @@ -1421,6 +1425,7 @@ DD2E176E24A95BAC001AF94D /* RestoreExistingWalletUITest.swift in Sources */, DDB660F52486BABB0060B0C5 /* Decred_WalletUITests.swift in Sources */, DD2E177224A95CA4001AF94D /* SeedBackupUITest.swift in Sources */, + DDB7755C27962DAD00F437E7 /* StartScreenViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1439,6 +1444,7 @@ isa = PBXVariantGroup; children = ( B3B4699C228F0C2E00A68EDD /* Base */, + DDB775592796192E00F437E7 /* ar */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -1454,6 +1460,7 @@ DDFB922722C8FF2D00F46FBE /* pt-BR */, DD36EE33247020C30011C335 /* pl */, 6091E9A8255000CE0028E67F /* fr */, + DDB7755A2796192E00F437E7 /* ar */, ); name = Localizable.strings; sourceTree = ""; diff --git a/Decred Wallet/Custom Views/FloatingPlaceholderInputs/FloatingPlaceholderTextField.swift b/Decred Wallet/Custom Views/FloatingPlaceholderInputs/FloatingPlaceholderTextField.swift index 98b940b58..9519849bc 100644 --- a/Decred Wallet/Custom Views/FloatingPlaceholderInputs/FloatingPlaceholderTextField.swift +++ b/Decred Wallet/Custom Views/FloatingPlaceholderInputs/FloatingPlaceholderTextField.swift @@ -17,7 +17,8 @@ class FloatingPlaceholderTextField: UITextField { return UIButton(type: .custom) }() - let textPadding = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0) + var textPadding = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 0) + override var placeholder: String? { didSet { @@ -40,6 +41,11 @@ class FloatingPlaceholderTextField: UITextField { } private func initView() { + let attribute = self.semanticContentAttribute + let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute) + if layoutDirection == .rightToLeft { + textPadding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16) + } self.layer.addSublayer(borderLayer) self.layer.masksToBounds = false @@ -84,7 +90,14 @@ class FloatingPlaceholderTextField: UITextField { func addTogglePasswordVisibilityButton() { self.pwdVisibilityToggleBtn.setImage(UIImage(named: "ic_reveal"), for: .normal) - self.pwdVisibilityToggleBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: -16, bottom: 0, right: 0) + let attribute = self.semanticContentAttribute + let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute) + if layoutDirection == .rightToLeft { + self.pwdVisibilityToggleBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -16) + } else { + self.pwdVisibilityToggleBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: -16, bottom: 0, right: 0) + } + self.pwdVisibilityToggleBtn.frame = CGRect(x: CGFloat(self.frame.size.width - 22), y: CGFloat(16), width: CGFloat(22), height: CGFloat(16)) self.rightView = self.pwdVisibilityToggleBtn self.rightViewMode = .always diff --git a/Decred Wallet/Features/App Launch/StartScreenViewController.swift b/Decred Wallet/Features/App Launch/StartScreenViewController.swift index 8cc7e39f7..3b6d06116 100644 --- a/Decred Wallet/Features/App Launch/StartScreenViewController.swift +++ b/Decred Wallet/Features/App Launch/StartScreenViewController.swift @@ -62,6 +62,22 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { Utils.showBanner(in: self.view, type: .error, text: "init multiwallet error: \(initError!.localizedDescription)") } } + + let attribute = view.semanticContentAttribute + let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute) + if layoutDirection == .rightToLeft { + createWalletBtn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 32) + restoreWalletBtn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 32) + importWatchWalletBtn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 32) + + createWalletBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16) + restoreWalletBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16) + importWatchWalletBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 16) + + createWalletBtn.contentHorizontalAlignment = .right + importWatchWalletBtn.contentHorizontalAlignment = .right + restoreWalletBtn.contentHorizontalAlignment = .right + } if #available(iOS 13.0, *) { @@ -421,3 +437,23 @@ class StartScreenViewController: UIViewController, CAAnimationDelegate { } } } + +extension UIButton { + func setInsets( + forContentPadding contentPadding: UIEdgeInsets, + imageTitlePadding: CGFloat + ) { + self.contentEdgeInsets = UIEdgeInsets( + top: contentPadding.top, + left: contentPadding.left, + bottom: contentPadding.bottom, + right: contentPadding.right + imageTitlePadding + ) + self.titleEdgeInsets = UIEdgeInsets( + top: 0, + left: imageTitlePadding, + bottom: 0, + right: -imageTitlePadding + ) + } +} diff --git a/Decred Wallet/Features/Security/Security.storyboard b/Decred Wallet/Features/Security/Security.storyboard index 0577dec1b..da57e2ab5 100644 --- a/Decred Wallet/Features/Security/Security.storyboard +++ b/Decred Wallet/Features/Security/Security.storyboard @@ -1,9 +1,9 @@ - + - + @@ -27,16 +27,16 @@ - + - - + @@ -253,7 +253,7 @@ - + diff --git a/Decred Wallet/Main.storyboard b/Decred Wallet/Main.storyboard index f56b309b6..60d0e96a6 100644 --- a/Decred Wallet/Main.storyboard +++ b/Decred Wallet/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -26,7 +26,7 @@ - + @@ -50,13 +50,13 @@ -