B4A Library ColorDialog

A wrapper for this GitHub library https://github.com/andyxialm/ColorDialog

ColorDialog & PromptDialog


Some screenshots from original library author :
Screenshot_type_success.png



Screenshot_type_info.png


ColorDialog
Author:
SMM
Version: 0.01
  • ColorDialog
    Events:
    • _click (result As String)
    Methods:
    • Initialize (EventName As String)
    • Show (ok As String, cancel As String)
    Properties:
    • AnimationEnable As Boolean [write only]
    • Color As Int [write only]
    • ContentImage As Bitmap [write only]
    • ContentText As String [write only]
    • Title As String [write only]
  • PromptDialog
    Events:
    • _promptclick
    Methods:
    • Initialize (EventName As String)
    • Show (ok As String, cancel As String)
    Properties:
    • AnimationEnable As Boolean [write only]
    • ContentText As String [write only]
    • DIALOG_TYPE_HELP As Int [read only]
    • DIALOG_TYPE_INFO As Int [read only]
    • DIALOG_TYPE_SUCCESS As Int [read only]
    • DIALOG_TYPE_WARNING As Int [read only]
    • DIALOG_TYPE_WRONG As Int [read only]
    • DialogType As Int [write only]
    • Title As String [write only]

Sample
B4X:
Sub Activity_click

    Dim colordialog As ColorDialog
    colordialog.Initialize("dialog")
    colordialog.Color=Colors.Red
    colordialog.AnimationEnable=False
    colordialog.ContentText="My own text"
    colordialog.Title="My Own title"
    colordialog.ContentImage=LoadBitmap(File.DirAssets,"ba.png")
    colordialog.Show("Ys","")
End Sub
Sub dialog_click(result As String)
    Log(result)
    If result="Ys" Then
        Dim prompt As PromptDialog
        prompt.Initialize("prompt")
        prompt.DialogType=prompt.DIALOG_TYPE_SUCCESS
        prompt.Title="Good job"
        prompt.AnimationEnable=True
        prompt.ContentText="You have succeeded"
        prompt.Show("Yes","cancel")
    End If
End Sub
Sub prompt_promptclick
    Log("prompt_promptclick")
End Sub

Version 0.02 : Just modified Show method . It requires only one button text.
 

Attachments

  • ColorDialog.zip
    28.3 KB · Views: 382
  • res.zip
    31.1 KB · Views: 382
  • ColorDialog002.zip
    28.3 KB · Views: 429

Daniel-White

Active Member
Licensed User
Hi Somed3v3loper, Thanks you very much, my dialogs boxs are so ugly :confused:, now it will be soooooooo nice with this wrapped lib. Thanks you indeed.:D
 

Daniel-White

Active Member
Licensed User
Hello everybody I have a simple question

I am using the MsgBox2 etc and I would like to remplace it with Dialog of this library. :cool:

The APP show the Dialog Box, not problem, but how to know which button is pressed , I think the Sub dialog_click work asynchronous. :eek:

I had been trying this, and I don't know the clever way to do this

B4X:
Activity_click("INVITACIÓN A UNA RED PENDIENTE","Tiene una Invitación.","Ver la Invitación","Más Tarde")
'       
'        If dialog_click(Respuesta)="Ver la Invitación"  Then
'            StartActivity(AceptarInvitacionRED)
'        End If   
' 


Public Sub Activity_click(Titulo,Mensaje,SI,NO As String)
    Dim colordialog As ColorDialog
    colordialog.Initialize("dialog")
    colordialog.Color=Colors.blue
    colordialog.AnimationEnable=True
    colordialog.ContentText=Mensaje
    colordialog.Title=Titulo
    'colordialog.ContentImage=LoadBitmap(File.DirAssets,"advertencia.png")
    colordialog.Show(SI,NO)   
End Sub


Public Sub dialog_click(result As String)
    Log(result)
    return result           
End Sub
 

somed3v3loper

Well-Known Member
Licensed User
Whats wrong with this snippet ?
result is the text of the pressed button
B4X:
Sub dialog_click(result As String)
if result= SI then
    'SI button was pressed

end if
end sub
 

Daniel-White

Active Member
Licensed User
Whats wrong with this snippet ?
result is the text of the pressed button
B4X:
Sub dialog_click(result As String)
if result= SI then
    'SI button was pressed

end if
end sub

Thanks for you reply

ok, but, that will work, my problem is how to reuse it, I mean, when I have a lot dialog and later if buttonPressed = true then etc, my conditionals (if then), are out of the Sub dialog_click(result As String), can we do something like:

B4X:
Dim respuesta as Int
Respuesta= Msgbox2("Do you like B4A","","YES","","NO",LoadBitmap(File.DirAssets, "logoicon.png"))   
      
    If Respuesta=DialogResponse.POSITIVE Then
        Log("Yes I love it")
    else
        Log("You need to test it :) ")
    endif

I was trying with any clue,

Because for me it will be complex use only one dialog_click with all the possible reply of the end user with a lot dialogs in the same Main activity etc. I would like put the code in a Class module to reuse it :D.

Thx
 

moster67

Expert
Licensed User
Looks nice. One question, using the PromptDialog, can I still get the result when using:
B4X:
prompt.Show("Yes","cancel")
??

I am confused (asking) since you wrote :confused: :
Version 0.02 : Just modified Show method . It requires only one button text.

I would prefer PromptDialog instead of ColorDialog but only if I can get the result of the button the user tapped.

Many thanks for your great work!
 

somed3v3loper

Well-Known Member
Licensed User
Looks nice. One question, using the PromptDialog, can I still get the result when using:
B4X:
prompt.Show("Yes","cancel")
??

I am confused (asking) since you wrote :confused: :


I would prefer PromptDialog instead of ColorDialog but only if I can get the result of the button the user tapped.

Many thanks for your great work!

I went back to source code . It seems that promptdialog does not have a negative button .
I don't remember what was that modification for :D but probably a mistake after copying methods from ColorDialog to PromptDialog which has only one button.
 

Da He

Member
Licensed User
I want to use color dialog to show on Button click
How to i do ?
Please Help me.
 
Top