Giter VIP home page Giter VIP logo

Comments (20)

lenkaiser avatar lenkaiser commented on June 16, 2024 2

@rnystrom I'll work on that upcoming weekend.

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024 1

Yup makes sense. While you're fixing that, any chance you can decouple the font property from setting the font for text view and all buttons? I'd prefer to set the fonts individually

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024 1

@rnystrom I'm still seeing really strange layout and font issues on 0.2.1.

On load:

screen shot 2018-03-17 at 12 33 04 pm

After typing:

screen shot 2018-03-17 at 12 33 14 pm

And here's my config:

        // Setup the button using text or an icon
        messageView.showLeftButton = false

        // Right button
        messageView.setButton(title: "Send".uppercased(), for: .normal, position: .right)
        messageView.setButton(font: UIFont(barstool: .branding, size: 14), position: .right)
        messageView.addButton(target: self, action: #selector(handleSendButtonTapped), position: .right)
        messageView.rightButtonTint = .barstoolBrightBlue

        // Change the appearance of the text view and its content
        messageView.font = UIFont(barstool: .branding, size: 14)
        messageView.textView.font = UIFont(barstool: .regular, size: 14)
        messageView.textView.placeholderText = "Type comment..."
        messageView.textView.placeholderTextColor = .lightGray
        messageView.textView.tintColor = .barstoolBrightBlue
        messageView.applyBorder(.top, color: .separator, size: 0.5)
        messageView.inset = UIEdgeInsets(top: 20, left: 16, bottom: 20, right: 16)

        // Capsule view
        let containerView = UIView()
        containerView.backgroundColor = UIColor(red: 0.945, green: 0.945, blue: 0.945, alpha: 1)
        containerView.borderColor = .separator
        containerView.borderWidth = 1
        containerView.cornerRadius = 3

        messageView.insertSubview(containerView, at: 0)
        containerView.snp.makeConstraints {
            $0.top.equalToSuperview().inset(8)
            $0.leading.equalToSuperview().inset(8)
            $0.trailing.equalToSuperview().inset(8)
            if #available(iOS 11, *) {
                $0.bottom.equalTo(messageView.safeAreaLayoutGuide.snp.bottom).inset(8)
            } else {
                $0.bottom.equalToSuperview().inset(8)
            }
        }

from messageviewcontroller.

lenkaiser avatar lenkaiser commented on June 16, 2024 1

@AndrewBarba I had the same problem. You can fix this by settings your inset before your settings the left- and right button properties.

// Set messageView inset
messageView.inset = UIEdgeInsets(top: 20, left: 8, bottom: 20, right: 16)
messageView.font = UIFont.preferredFont(forTextStyle: .body)

// Right button
messageView.setButton(title: "Send".uppercased(), for: .normal, position: .right)
messageView.setButton(font: UIFont.systemFont(ofSize: 14), position: .right)
messageView.addButton(target: self, action: #selector(onRightButton), position: .right)
messageView.rightButtonTint = .blue

If you set the inset afterwards you get weird behaviour indeed because the calculation rely on the insets.

from messageviewcontroller.

lenkaiser avatar lenkaiser commented on June 16, 2024 1

@rnystrom Never mind, my bad. I was thinking the same code was used in the example but that works fine.

I did find the problem, the textview uses an attributed string and uses different font sizes. The first character is the correct font but all the other after that use pointSize 17.0. If I input a simple text: Jj and print the attributes we can see the difference between the 2 letters. The reason why is unclear to me yet. Any suggestions?

attributes >> Optional(J{
    NSFont = "<UICTFont: 0x7fa416c1f850> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
}j{
    NSFont = "<UICTFont: 0x7fa416c17de0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 17.00pt";
    "com.messageviewcontroller.autocompletekey" = 0;
})

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

Blame #33 cc @lenkaiser

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

@AndrewBarba does it repro in the example if you just disable the left button?

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

@AndrewBarba I can't seem to repro this in the example. Can you give some more details? Are you also setting the left button inset?

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024

Simply updating the library (no other code changes), went from this:

screen shot 2018-03-16 at 5 39 20 pm

To this:

screen shot 2018-03-16 at 5 41 52 pm

And then typing notice how the first letter is a completely different font than the rest, and the text view just became a larger size (probably due to font change):

screen shot 2018-03-16 at 5 42 09 pm

Adding one line of code to disable the left button (messageView.showLeftButton = false) produced this:

screen shot 2018-03-16 at 5 45 25 pm

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024

Okay this stuff for text view frame based on insets is all just completely wrong:

        // adjust by bottom offset so content is flush w/ text view
        let leftButtonFrame = CGRect(
            x: insetBounds.minX,
            y: (insetBounds.minY + textViewHeight) - leftButtonSize.height + leftButton.bottomHeightOffset,
            width: leftButtonSize.width,
            height: leftButtonSize.height
        )
        leftButton.frame = (showLeftButton) ? leftButtonFrame : .zero
        
        let textViewFrame = CGRect(
            x: ((showLeftButton) ? leftButtonFrame.maxX : 0) + leftButtonInset,
            y: insetBounds.minY,
            width: insetBounds.width - ((showLeftButton) ? leftButtonSize.width : 0) - leftButtonInset - rightButtonSize.width,
            height: textViewHeight
        )
        textView.frame = textViewFrame

        // adjust by bottom offset so content is flush w/ text view
        let rightButtonFrame = CGRect(
            x: textViewFrame.maxX + leftButtonInset,
            y: textViewFrame.maxY - rightButtonSize.height + rightButton.bottomHeightOffset,
            width: rightButtonSize.width,
            height: rightButtonSize.height
        )
        rightButton.frame = rightButtonFrame

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024

Why not just use a stack view for this?

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

Ya fixing the inset stuff now. It's wrong.

Why not just use a stack view for this?

Not going to involve AL layout hooks in this, I want fine control over what layout happens and when so that I can control when the text view resizes.

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

Agree, stripping that part

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

I’ll try to repro the font issue today and send another patch, I actually didn’t see this issue so didn’t make any change for it.

Sent with GitHawk

from messageviewcontroller.

lenkaiser avatar lenkaiser commented on June 16, 2024

@rnystrom Thanks for the initial fix. I do think we can optimise the code a bit. If the left button properties are set but the flag showLeftButton = false, the view still shows the needed insets. I'll try to work on that this asap.

@AndrewBarba You can change your inset to:

messageView.inset = UIEdgeInsets(top: 20, left: 8, bottom: 20, right: 16)

Even when you're enabling the left button there is the correct space between left button and the textview. The original example uses this inset as well. You'll get this:

simulator screen shot - iphone 8 plus - 2018-03-17 at 20 18 50

from messageviewcontroller.

AndrewBarba avatar AndrewBarba commented on June 16, 2024

Okay thanks. Still need to figure out that initial right button position and the font issues. You can see the font issue in the screen you posted above. Is it the order I’m setting the fonts? Really strange

from messageviewcontroller.

lenkaiser avatar lenkaiser commented on June 16, 2024

@rnystrom I’ll have a look at the font issue today. I think we need to update the readme because it uses a 16px inset. What do you think?

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

Seems like we need to lock off the exact same layout mechanisms for any of these property changes.

@lenkaiser not sure I follow about the readme

Sent with GitHawk

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

@lenkaiser what’s the best way to repro the issue? If we can reproduce it in a failing unit test then fix the test that’d be ideal.

Sent with GitHawk

from messageviewcontroller.

rnystrom avatar rnystrom commented on June 16, 2024

Should be fixed in #59

from messageviewcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.