Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 542 forks source link

Extra space before text in RTL Language #257

Open fadiBlessedTree opened 5 years ago

fadiBlessedTree commented 5 years ago

Report

What did you do?

Add RTL Localization to my app "Arabic"

What did you expect to happen?

Work fine without see more spaces before text

What happened instead?

There is extra space before text when I use "SkyFloatingLabelTextFieldWithIcon" with icon Icon type value = 1

Environment

Xcode Version: 10.1 (10B61) SkyFloatingLabelTextField Version: 3.6.0 Deployment Target: 9.4 Base SDK: 11.4 Method of Integration: CocoaPods

Project that demonstrates the issue

fadiBlessedTree commented 5 years ago

I found the problem you have to remove rect.origin.x -= CGFloat(iconWidth + iconMarginLeft) from textRect too like editingRect

Class : (SkyFloatingLabelTextFieldWithIcon)

Function : (textRect(forBounds bounds: CGRect) -> CGRect)

Full function after fix the problem :

override open func textRect(forBounds bounds: CGRect) -> CGRect {
        var rect = super.textRect(forBounds: bounds)
        if isLTRLanguage {
            rect.origin.x += CGFloat(iconWidth + iconMarginLeft)
        } else {
            // don't change the text field X position for RTL languages
        }
        rect.size.width -= CGFloat(iconWidth + iconMarginLeft)
        return rect
    }

hope we get this fix in next release. Thanks 😊

k0nserv commented 5 years ago

Hey @fadiBlessedTree any chance you can send a PR for this? Thanks a bunch

ahmediosDeveloper commented 5 years ago

I found the problem you have to remove rect.origin.x -= CGFloat(iconWidth + iconMarginLeft) from textRect too like editingRect

Class : (SkyFloatingLabelTextFieldWithIcon)

Function : (textRect(forBounds bounds: CGRect) -> CGRect)

Full function after fix the problem :

override open func textRect(forBounds bounds: CGRect) -> CGRect {
        var rect = super.textRect(forBounds: bounds)
        if isLTRLanguage {
            rect.origin.x += CGFloat(iconWidth + iconMarginLeft)
        } else {
            // don't change the text field X position for RTL languages
        }
        rect.size.width -= CGFloat(iconWidth + iconMarginLeft)
        return rect
    }

hope we get this fix in next release. Thanks 😊

i try that but still have same issue

ahmedsafadii commented 2 years ago

same issue