iOS Question Chat Example

Lucas Eduardo

Active Member
Licensed User
Hello everyone,

I use this code in B4A and works correctly. https://www.b4x.com/android/forum/threads/chat-example-bctextengine.113203/#post-706276

But when i use in B4I the text message it's not showing, just the bubble

my sub BuildMessage it's this one
B4X:
Private Sub BuildMessage (Text As String, Right As Boolean, hora As String) As String
    Dim msg, time As String
    If Right Then time = $"[color=#F1F1F1]${hora}[/color]"$ Else time = $"[color=#808080]${hora}[/color]"$
    msg = $"[Color=#000000][font=fontRegular size=14]${Text}[/font][/Color] [font=fontRegular size=10]${CRLF & time}[/font]"$
    Return msg
End Sub

i can't figure it out why it's not showing the text. What could be?

part of my code to create the message it's this one
B4X:
    Dim p As B4XView = xui.CreatePanel("")
    p.Color = xui.Color_Transparent
'    Dim User As String
'    If Right Then User = "User 2" Else User = "User 1"
    
    If hora.Contains("-") Then
        DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
        Dim time As Long = DateTime.DateParse(hora)
        DateTime.DateFormat = "HH:mm:ss"
        Dim timeParsed As String = DateTime.Date(time)
    Else
        Dim timeParsed As String = hora
    End If
    
'    BBCodeView1.ExternalRuns = BuildMessage(Text, Right, timeParsed)
'    BBCodeView1.ParseAndDraw
    Log("Text: "&Text)
    Log("Right: "&Right)
    Log("timeParsed: "&timeParsed)
    BBCodeView1.Text = BuildMessage(Text, Right, timeParsed)

    Dim ivText As B4XView = CreateImageView
    
    'get the bitmap from BBCodeView1 foreground layer.
    Dim bmpText As B4XBitmap = GetBitmap(BBCodeView1.ForegroundImageView)
    'the image might be scaled by Engine.mScale. The "correct" dimensions are:
    Dim TextWidth As Int = bmpText.Width / Engine.mScale
    Dim TextHeight As Int = bmpText.Height / Engine.mScale
    'bc is not really used here. Only the utility method.
    
    'Now get the whole image
'    BBCodeView1.mBase.Color = Colors.Red
    Dim bmpAll As B4XBitmap = BBCodeView1.mBase.Snapshot
    bmpText = bmpAll.Crop(0, 0, TextWidth, TextHeight)
'    bmpText.TextColor = Colors.Black
    
    bc.SetBitmapToImageView(bmpText, ivText)
    
    Dim ivBG As B4XView = CreateImageView
    
    'Draw the bubble.
    Dim bmpBG As B4XBitmap = DrawBubble(TextWidth, TextHeight, Right)
    bc.SetBitmapToImageView(bmpBG, ivBG)
    p.SetLayoutAnimated(0, 0, 0, CLV.sv.ScrollViewContentWidth - 2dip, TextHeight + 3 * Gap)

Thank you.
 

Lucas Eduardo

Active Member
Licensed User
Yes, it work's, but the example uses external runs and did not show images in the messages. So i use the bbcodeview.text to show images
 
Upvote 0

Lucas Eduardo

Active Member
Licensed User
The problem that it was not showing the text it was fixed, but when i tested with putting images in the message did not work.
 

Attachments

  • chatTest.zip
    221.5 KB · Views: 284
Upvote 0

AlexMaa

Member
Licensed User
Longtime User
I've tried all these messages:


I have the same problem - I can't add pictures to messages in iOS.
What's the solution?
 
Upvote 0
Top