Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right Language views support #885

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Decred Wallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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 */; };
Expand Down Expand Up @@ -198,6 +197,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 */; };
Expand Down Expand Up @@ -429,6 +430,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 = "<group>"; };
DDB660F62486BABB0060B0C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DDB775592796192E00F437E7 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
DDB7755A2796192E00F437E7 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
DDCF259922B8A346005FCBB9 /* Overview.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Overview.storyboard; sourceTree = "<group>"; };
DDCF259B22B8A361005FCBB9 /* Send.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Send.storyboard; sourceTree = "<group>"; };
DDCF25A022B8A3D4005FCBB9 /* Settings.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1140,6 +1143,7 @@
"pt-BR",
pl,
fr,
ar,
);
mainGroup = B3B46986228F0C2D00A68EDD;
productRefGroup = B3B46990228F0C2D00A68EDD /* Products */;
Expand Down Expand Up @@ -1277,7 +1281,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 */,
Expand Down Expand Up @@ -1332,6 +1335,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 */,
Expand Down Expand Up @@ -1425,6 +1429,7 @@
DD2E176E24A95BAC001AF94D /* RestoreExistingWalletUITest.swift in Sources */,
DDB660F52486BABB0060B0C5 /* Decred_WalletUITests.swift in Sources */,
DD2E177224A95CA4001AF94D /* SeedBackupUITest.swift in Sources */,
DDB7755C27962DAD00F437E7 /* StartScreenViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -1443,6 +1448,7 @@
isa = PBXVariantGroup;
children = (
B3B4699C228F0C2E00A68EDD /* Base */,
DDB775592796192E00F437E7 /* ar */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -1458,6 +1464,7 @@
DDFB922722C8FF2D00F46FBE /* pt-BR */,
DD36EE33247020C30011C335 /* pl */,
6091E9A8255000CE0028E67F /* fr */,
DDB7755A2796192E00F437E7 /* ar */,
);
name = Localizable.strings;
sourceTree = "<group>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line


override var placeholder: String? {
didSet {
Expand All @@ -40,6 +41,12 @@ 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.textAlignment = .right
}
self.layer.addSublayer(borderLayer)
self.layer.masksToBounds = false

Expand Down Expand Up @@ -84,7 +91,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class FloatingPlaceholderTextView: UITextView {
self.layer.addSublayer(borderLayer)
self.layer.masksToBounds = false
self.textContainerInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
let attribute = self.semanticContentAttribute
let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute)
if layoutDirection == .leftToRight {
self.textAlignment = .left

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

} else {
self.textAlignment = .right
}

self.addSubview(self.floatingPlaceholderLabel)
}
Expand All @@ -62,6 +70,15 @@ class FloatingPlaceholderTextView: UITextView {
if let lastButton = self.subviews.last(where: { $0 is UIButton }) {
trailingAnchor = lastButton.leadingAnchor
trailingConstant = -16

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

}

let attribute = self.semanticContentAttribute
let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute)
if layoutDirection == .leftToRight {
self.textContainerInset.right += button.frame.width + abs(trailingConstant)
} else {
self.textContainerInset.right += abs(trailingConstant)
}

self.addSubview(button)
Expand All @@ -71,7 +88,6 @@ class FloatingPlaceholderTextView: UITextView {

self.layoutIfNeeded()

self.textContainerInset.right += button.frame.width + abs(trailingConstant)
}

public func toggleButtonVisibility(_ button: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ import Dcrlibwallet
])

self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.showAccountSelectorDialog)))

let attribute = self.semanticContentAttribute
let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute)
if layoutDirection == .rightToLeft {
self.accountBalanceLabel.textAlignment = .left
}
}

@objc func showAccountSelectorDialog(_ sender: Any) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -36,7 +36,7 @@
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" axis="vertical" distribution="equalSpacing" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="Y4s-88-qVp">
<rect key="frame" x="48" y="16" width="176" height="45"/>
<rect key="frame" x="48" y="16" width="190" height="45"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Default" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f5d-hq-a48">
<rect key="frame" x="8" y="0.0" width="54.5" height="23"/>
Expand Down Expand Up @@ -75,13 +75,13 @@
<edgeInsets key="layoutMargins" top="0.0" left="8" bottom="0.0" right="0.0"/>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="7.51464806 DCR" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EhC-c0-yiY">
<rect key="frame" x="232" y="26" width="134" height="25.5"/>
<rect key="frame" x="246" y="26" width="134" height="25.5"/>
<fontDescription key="fontDescription" name="SourceSansPro-Regular" family="Source Sans Pro" pointSize="20"/>
<color key="textColor" name="text1"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_dropdown" translatesAutoresizingMaskIntoConstraints="NO" id="qlt-Ng-9uf">
<rect key="frame" x="374" y="26.5" width="24" height="24"/>
<rect key="frame" x="388" y="35.5" width="10" height="6"/>
</imageView>
</subviews>
<edgeInsets key="layoutMargins" top="16" left="16" bottom="16" right="16"/>
Expand All @@ -104,7 +104,7 @@
</designables>
<resources>
<image name="ic_account" width="24" height="24"/>
<image name="ic_dropdown" width="24" height="24"/>
<image name="ic_dropdown" width="10" height="6"/>
<namedColor name="surface">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Expand Down
36 changes: 36 additions & 0 deletions Decred Wallet/Features/App Launch/StartScreenViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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, *) {
Expand Down Expand Up @@ -422,3 +438,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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ class AccountSelectorTableViewCell: UITableViewCell {
self.totalAccountBalanceLabel.attributedText = Utils.getAttributedString(str: "\(totalBalanceRoundedOff)", siz: 15.0, TexthexColor: UIColor.appColors.text1)
}
}

override func awakeFromNib() {
super.awakeFromNib()
let attribute = self.semanticContentAttribute
let layoutDirection = UIView.userInterfaceLayoutDirection(for: attribute)
if layoutDirection == .rightToLeft {
self.totalAccountBalanceLabel.textAlignment = .left
self.spendableAccountBalanceLabel.textAlignment = .left
}
}
}
Loading