B4J Question [ABMaterial] Create Toast with no timeout

Harris

Expert
Licensed User
Longtime User
How does one create a toast message where the user must click on it (or a button on the toast) to dismiss it?

I think I recall seeing this in ABM some time ago.

Thanks
 

Harris

Expert
Licensed User
Longtime User
Perhaps... Or on the top menu, a drop down container with new items, along with an icon showing there is new content to read.

I want to show incoming messages from drivers and don't want it to dismiss until the user acknowledges it (as being read), in top right hand corner.

http://codeseven.github.io/toastr/

This JS shows a demo of how this could be done. Could I include this in my project using page.AddExtraJavaScriptFile()?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
why not use a modal sheet? you can "build it" however you want, and it can be dismissable either through a in modal sheet button or a off bounds click
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Or, add a button that would open a form where one could scroll though messages and manage them (respond, delete, etc).

message.jpg
 
Upvote 0

mindful

Active Member
Licensed User
Or, add a button that would open a form where one could scroll though messages and manage them (respond, delete, etc).
or you can use an topbar item with an extrasidebar initialized as a panel where you can display what you want in the extrasidebar and notify the driver by appling a badge over the top item and also displaying a toast ... or something like that ;)
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
or you can use an topbar item with an extrasidebar initialized as a panel where you can display what you want in the extrasidebar and notify the driver by appling a badge over the top item and also displaying a toast ... or something like that ;)

Something like this!
Click on the MAIL (4 NEW) button...

sidebar.jpg


This was the best practical option! Using a sidebar with cards shows nicely. Auto-scroll when cards exceeds page height.
I was considering a table but this works much better!

The title is large, the body will expand the card as required and the action links provide functionality for each message.

Store the primary key of the record in the Tag of each card.
Use AddArrayComponent and then get the link clicked in the messarr_linkclicked() sub.

Thanks everyone for directing me to the RIGHT path.


B4X:
Sub PutNewMail(new As Boolean)
   
    Dim sb As ABMSideBar = page.GetSideBar("SideBar")
    Dim cont As ABMContainer = sb.Content.Component("messcont")
    cont.Cell(2,1).RemoveAllComponents
   
    Dim SQL As SQL = DBM.GetSQL
    If new Then
        Dim SQL_mail As String = "Select * FROM mess_in where readit = 0 AND comp_id = "& Main.comp_id&" ORDER BY time_in DESC"
    Else
        Dim SQL_mail As String = "Select * FROM mess_in where readit >= 0 AND comp_id = "& Main.comp_id&" ORDER BY time_in DESC"
   
    End If   

    Dim newm As List = DBM.SQLSelect(SQL, SQL_mail,Null)   
    If newm.size > 0 Then
       For i = 0 To newm.size-1
          Dim tbl As Map = newm.get(i)
          Dim drv As String = GetDriver(tbl.Get("from_user"),True)
          Dim veh As String = tbl.Get("map_to")
          Dim pk As String = tbl.Get("pk")
          Dim dt As String = DateTime.Time(tbl.Get("time_in"))
          Dim mess As String = tbl.Get("mess_text")
      
          Dim titl As String = drv&"  | "&veh&"  | "&dt
          Dim card As ABMCard
          card.InitializeAsCard(page, "me"&i, titl, mess, ABM.CARD_SMALL,"yeltitle")
          card.AddAction("Reply")
          card.AddAction("Delete")
          card.AddAction("Set As Read")
         
           card.Tag = pk   'the important bit...  all actions require the primary key of the record...

           cont.Cell(2,1).AddArrayComponent(card,"messarr")
       Next
    End If
    DBM.CloseSQL(SQL)
    cont.Refresh
   
End Sub


Sub messarr_linkclicked (target As String, Action As String)
 ' (MyMap) {eventparams=target,action, action=Reply, eventname=messarr_linkclicked, target=messcont-messarrme0}
    Dim sb As ABMSideBar = page.GetSideBar("SideBar")
    Dim cont As ABMContainer = sb.Content.Component("messcont")
    Dim cid As String = target.Replace("messcont-","")
    Dim card As ABMCard = cont.Component(cid)
    Dim tag As String = card.Tag

    Select Action

          Case "Reply"
             ' Bring up reply mesaage form..         
         
          Case "Delete"
             ' Delete message record

          Case "Set As Read"
            ' Mark as read and call button label update method
           
    End Select
   

Log("What id mees arr trget: "&target&"  "&Action&"  tag: "&tag)

End Sub
 
Upvote 0

stanmiller

Active Member
Licensed User
Longtime User
I believe the toast always needs a duration (you could set it very high). However, I think Stanmiller once made kind of a box (using a floating ABMContainer) to show a message about 'this site uses cookies...' and a dismiss button. Maybe it is something similar you could use?

This page has the cookie notification described. Over the weekend I'll post an example using the ABM demo project to show how to integrate into a page.

https://macthomasengineering.com:8443/mte/androidwear/index.html?v=118
 
Last edited:
Upvote 0
Top